Sha256: 82a581cf6a38b1110c679f5faa490892978afe86181a9e4faff792ba92180704

Contents?: true

Size: 996 Bytes

Versions: 7

Compression:

Stored size: 996 Bytes

Contents

class IpAddress < CloudstackCli::Base

  desc "release ID", "release public IP address"
  def release(id)
    say("OK", :green) if client.disassociate_ip_address(id)
  end

  desc "ip_address assign NETWORK", "assign a public IP address"
  option :project
  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

  desc "list", "list public IP address"
  option :project
  option :account
  option :listall
  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

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cloudstack-cli-0.5.8 lib/cloudstack-cli/commands/ip_address.rb
cloudstack-cli-0.5.5 lib/cloudstack-cli/commands/ip_address.rb
cloudstack-cli-0.5.4 lib/cloudstack-cli/commands/ip_address.rb
cloudstack-cli-0.5.3 lib/cloudstack-cli/commands/ip_address.rb
cloudstack-cli-0.5.2 lib/cloudstack-cli/commands/ip_address.rb
cloudstack-cli-0.5.1 lib/cloudstack-cli/commands/ip_address.rb
cloudstack-cli-0.5.0 lib/cloudstack-cli/commands/ip_address.rb