Class: VagrantPlugins::Openstack::Catalog::OpenstackCatalog
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::Catalog::OpenstackCatalog
- Defined in:
- lib/vagrant-openstack-provider/catalog/openstack_catalog.rb
Instance Method Summary collapse
-
#initialize ⇒ OpenstackCatalog
constructor
A new instance of OpenstackCatalog.
- #read(env, catalog) ⇒ Object
Constructor Details
#initialize ⇒ OpenstackCatalog
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 33 34 35 36 37 38 39 40 |
# 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 endpoint_type = config.endpoint_type @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.region.nil? if se.size > 1 env[:ui].warn I18n.t('vagrant_openstack.client.multiple_endpoint', size: se.size, type: service['type']) env[:ui].warn " => #{service['endpoints'][0][endpoint_type]}" end url = se[0][endpoint_type].strip else se.each do |endpoint| url = endpoint[endpoint_type].strip if endpoint['region'].eql? config.region end end endpoints[service['type'].to_sym] = url unless url.nil? || url.empty? 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 |