Class: Squall::IpAddressJoin

Inherits:
Base
  • Object
show all
Defined in:
lib/squall/ip_address_join.rb

Overview

Handles IP assignments for virtual machines

Instance Attribute Summary

Attributes inherited from Base

#result, #success

Instance Method Summary (collapse)

Methods inherited from Base

#check_config, #default_params, #key_for_class, #request

Instance Method Details

- (Object) assign(virtual_machine_id, options = {})

Assigns an IP address to a VM.

Parameters:

  • virtual_machine_id

    Virtual machine ID to assign IP to

  • options (defaults to: {})

    Params for IP assignment:

Options Hash (options):

  • :ip_address_id (Object)

    ID of the IP address

  • :network_interface_id (Object)

    ID of the network interface

Returns:

  • a Hash.



22
23
24
25
# File 'lib/squall/ip_address_join.rb', line 22

def assign(virtual_machine_id, options = {})
  response = request(:post, "/virtual_machines/#{virtual_machine_id}/ip_addresses.json", default_params(options))
  response['ip_address_join']
end

- (Object) delete(virtual_machine_id, ip_address_id)

Deletes an IP address assignment from a VM

Parameters:

  • virtual_machine_id

    Virtual machine ID to remove IP join from

  • ip_address_id

    IP Address ID to remove, see `#assign`.

Returns:

  • a Hash.



33
34
35
# File 'lib/squall/ip_address_join.rb', line 33

def delete(virtual_machine_id, ip_address_id)
  request(:delete, "/virtual_machines/#{virtual_machine_id}/ip_addresses/#{ip_address_id}.json")
end

- (Object) list(virtual_machine_id)

List IP address assignments for a virtual machine.

Parameters:

  • virtual_machine_id

    Virtual machine ID to lookup

Returns:

  • an Array.



9
10
11
12
# File 'lib/squall/ip_address_join.rb', line 9

def list(virtual_machine_id)
  response = request(:get, "/virtual_machines/#{virtual_machine_id}/ip_addresses.json")
  response.collect { |ip| ip['ip_address_join'] }
end