Sha256: 6bde5c1c19ea5d4ab056442a5a302d76adfb703d3ad2f8bd6d6be1436c2af982

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

module VagrantPlugins
  module Openstack
    class Utils
      def initialize
        @logger = Log4r::Logger.new('vagrant_openstack::action::config_resolver')
      end

      def get_ip_address(env)
        return env[:machine].provider_config.floating_ip unless env[:machine].provider_config.floating_ip.nil?
        details = env[:openstack_client].nova.get_server_details(env, env[:machine].id)
        details['addresses'].each do |network|
          network[1].each do |network_detail|
            return network_detail['addr'] if network_detail['OS-EXT-IPS:type'] == 'floating'
          end
        end
        return details['addresses'].first[1][0]['addr'] if details['addresses'].size == 1 && details['addresses'].first[1].size == 1
        fail Errors::UnableToResolveIP
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.5.1 lib/vagrant-openstack-provider/utils.rb
vagrant-openstack-provider-0.5.0 lib/vagrant-openstack-provider/utils.rb