Method: CloudstackClient::Network#get_network

Defined in:
lib/cloudstack_client/commands/network.rb

#get_network(name, project_id = nil) ⇒ Object

Finds the network with the specified name.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cloudstack_client/commands/network.rb', line 22

def get_network(name, project_id = nil)
  params = {
      'command' => 'listNetworks',
      'listall' => true
  }
  params['projectid'] = project_id if project_id
  json = send_request(params)

  networks = json['network']
  return nil unless networks

  networks.each { |n|
    if n['name'] == name then
      return n
    end
  }
  nil
end