Class: IpAddress

Inherits:
CloudstackCli::Base show all
Defined in:
lib/cloudstack-cli/commands/ip_address.rb

Constant Summary

Constants included from CloudstackCli::Helper

CloudstackCli::Helper::ASYNC_STATES

Instance Attribute Summary

Attributes inherited from CloudstackCli::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackCli::Base

exit_on_failure?

Methods included from CloudstackCli::Helper

#ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #print_job_status, #print_options, #update_job_status, #watch_jobs

Instance Method Details

#assign(network) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/cloudstack-cli/commands/ip_address.rb', line 10

def assign(network)
  project = find_project if options[:project]
  unless network = client.get_network(network, project ? project["id"] : nil)
    error "Network #{network} not found."
    exit 1
  end
  ip = client.associate_ip_address(network["id"])
  puts
  say ip['ipaddress']
end

#listObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cloudstack-cli/commands/ip_address.rb', line 25

def list
  table = [["Address", "Account", "Zone"]]
  addresses = client.list_public_ip_addresses(options)
  if addresses.size < 1
    say "No ip addresses found."
  else
    addresses.each do |address|
      table << [address["ipaddress"], address["account"], address["zonename"]]
    end
    print_table table
  end
end

#release(id) ⇒ Object



4
5
6
# File 'lib/cloudstack-cli/commands/ip_address.rb', line 4

def release(id)
  say("OK", :green) if client.disassociate_ip_address(id)
end