Module: CloudstackClient::IpAddress
- Defined in:
- lib/cloudstack_client/commands/ip_address.rb
Instance Method Summary collapse
-
#associate_ip_address(network_id, project_id = nil) ⇒ Object
Acquires and associates a public IP to an account.
-
#disassociate_ip_address(id) ⇒ Object
Disassociates an ip address from the account.
-
#get_public_ip_address(ip_address, project_id = nil) ⇒ Object
Finds the public ip address for a given ip address string.
-
#list_public_ip_addresses(args = {}) ⇒ Object
Lists the public ip addresses.
Instance Method Details
#associate_ip_address(network_id, project_id = nil) ⇒ Object
Acquires and associates a public IP to an account.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cloudstack_client/commands/ip_address.rb', line 56 def associate_ip_address(network_id, project_id = nil) params = { 'command' => 'associateIpAddress', 'networkid' => network_id } params['projectid'] = project_id if project_id json = send_async_request(params) json['ipaddress'] end |
#disassociate_ip_address(id) ⇒ Object
Disassociates an ip address from the account.
Returns true if successful, false otherwise.
72 73 74 75 76 77 78 79 |
# File 'lib/cloudstack_client/commands/ip_address.rb', line 72 def disassociate_ip_address(id) params = { 'command' => 'disassociateIpAddress', 'id' => id } json = send_async_request(params) json['success'] end |
#get_public_ip_address(ip_address, project_id = nil) ⇒ Object
Finds the public ip address for a given ip address string.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cloudstack_client/commands/ip_address.rb', line 39 def get_public_ip_address(ip_address, project_id = nil) params = { 'command' => 'listPublicIpAddresses', 'ipaddress' => ip_address } params['projectid'] = project_id if project_id json = send_request(params) ip_address = json['publicipaddress'] return nil unless ip_address ip_address.first end |
#list_public_ip_addresses(args = {}) ⇒ Object
Lists the public ip addresses.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cloudstack_client/commands/ip_address.rb', line 8 def list_public_ip_addresses(args = {}) params = { 'command' => 'listPublicIpAddresses', 'isrecursive' => true } if args[:project] project = get_project(args[:project]) unless project puts "Error: project #{args[:project]} not found." exit 1 end params['projectid'] = project['id'] end if args[:account] account = list_accounts({name: args[:account]}).first unless account puts "Error: Account #{args[:account]} not found." exit 1 end params['domainid'] = account["domainid"] params['account'] = args[:account] end params['listall'] = args[:listall] if args[:listall] json = send_request(params) json['publicipaddress'] || [] end |