Class: VagrantPlugins::Openstack::NeutronClient

Inherits:
Object
  • Object
show all
Includes:
Singleton, Domain, HttpUtils
Defined in:
lib/vagrant-openstack-provider/client/neutron.rb

Instance Method Summary collapse

Methods included from HttpUtils

#delete, #get, #get_api_version_list, #post

Methods included from HttpUtils::RequestLogger

#log_request, #log_response

Constructor Details

#initializeNeutronClient

Returns a new instance of NeutronClient.



14
15
16
17
# File 'lib/vagrant-openstack-provider/client/neutron.rb', line 14

def initialize
  @logger = Log4r::Logger.new('vagrant_openstack::neutron')
  @session = VagrantPlugins::Openstack.session
end

Instance Method Details

#get_all_networks(env) ⇒ Object



23
24
25
# File 'lib/vagrant-openstack-provider/client/neutron.rb', line 23

def get_all_networks(env)
  get_networks(env, true)
end

#get_private_networks(env) ⇒ Object



19
20
21
# File 'lib/vagrant-openstack-provider/client/neutron.rb', line 19

def get_private_networks(env)
  get_networks(env, false)
end

#get_subnets(env) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/vagrant-openstack-provider/client/neutron.rb', line 27

def get_subnets(env)
  subnets_json = get(env, "#{@session.endpoints[:network]}/subnets")
  subnets = []
  JSON.parse(subnets_json)['subnets'].each do |n|
    subnets << Subnet.new(n['id'], n['name'], n['cidr'], n['enable_dhcp'], n['network_id'])
  end
  subnets
end