Class: VagrantPlugins::Openstack::Catalog::OpenstackCatalog

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-openstack-provider/catalog/openstack_catalog.rb

Instance Method Summary collapse

Constructor Details

#initializeOpenstackCatalog

Returns a new instance of OpenstackCatalog.



5
6
7
# File 'lib/vagrant-openstack-provider/catalog/openstack_catalog.rb', line 5

def initialize
  @logger = Log4r::Logger.new('vagrant_openstack::action::openstack_reader')
end

Instance Method Details

#read(env, catalog) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vagrant-openstack-provider/catalog/openstack_catalog.rb', line 9

def read(env, catalog)
  config = env[:machine].provider_config
  client = env[:openstack_client]
  endpoints = client.session.endpoints
  @logger.info(I18n.t('vagrant_openstack.client.looking_for_available_endpoints'))
  @logger.info("Selecting endpoints matching region '#{config.region}'") unless config.region.nil?

  catalog.each do |service|
    se = service['endpoints']
    if config.identity_api_version == '2'
      get_endpoints_2(env, se, service, config, endpoints)
    elsif config.identity_api_version == '3'
      get_interfaces_3(se, service, config, endpoints)
    end
  end

  endpoints[:network] = choose_api_version('Neutron', 'openstack_network_url', 'v2') do
    client.neutron.get_api_version_list(env, :network)
  end if config.openstack_network_url.nil? && !endpoints[:network].nil?

  endpoints[:image] = choose_api_version('Glance', 'openstack_image_url', nil, false) do
    client.glance.get_api_version_list(env)
  end if config.openstack_image_url.nil? && !endpoints[:image].nil?
end