Class: Fog::Compute::RackspaceV2::VirtualInterface

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/compute_v2/virtual_interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idString (readonly)

Returns The virtual interface id.

Returns:

  • (String)

    The virtual interface id



10
# File 'lib/fog/rackspace/models/compute_v2/virtual_interface.rb', line 10

identity :id

#ip_addressesArray<Hash> (readonly)

[

{
    "address": "2001:4800:7810:0512:d87b:9cbc:ff04:850c",
    "network_id": "ba122b32-dbcc-4c21-836e-b701996baeb3",
    "network_label": "public"
},
{
    "address": "64.49.226.149",
    "network_id": "ba122b32-dbcc-4c21-836e-b701996baeb3",
    "network_label": "public"
}

]

Returns:

  • (Array<Hash>)

    returns an array of hashes containing information about allocated ip addresses and their associated networks



32
# File 'lib/fog/rackspace/models/compute_v2/virtual_interface.rb', line 32

attribute :ip_addresses

#mac_addressString (readonly)

Returns The Media Access Control (MAC) address for the virtual interface. A MAC address is a unique identifier assigned to network interfaces for communications on the physical network segment.

Returns:

  • (String)

    The Media Access Control (MAC) address for the virtual interface. A MAC address is a unique identifier assigned to network interfaces for communications on the physical network segment.



15
# File 'lib/fog/rackspace/models/compute_v2/virtual_interface.rb', line 15

attribute :mac_address

Instance Method Details

#createBoolean

Creates Virtual interface for server

  • requires attributes: :network

my_server.virtual_interfaces.create :network => my_network

Examples:

To create a virtual interface;

Returns:

  • (Boolean)

    returns true if virtual network interface is being created

Raises:

See Also:



56
57
58
59
# File 'lib/fog/rackspace/models/compute_v2/virtual_interface.rb', line 56

def create
  data = service.create_virtual_interface(server_id, network_id)
  merge_attributes(data.body['virtual_interfaces'].first)
end

#destroyBoolean

Destroy the virtual interface

Returns:

  • (Boolean)

    returns true if virtual interface has been destroyed

Raises:

See Also:



68
69
70
71
# File 'lib/fog/rackspace/models/compute_v2/virtual_interface.rb', line 68

def destroy
  service.delete_virtual_interface(server_id, id)
  true
end

#save(attributes = {}) ⇒ Boolean

Saves the virtual interface. This method can only create a virtual interface. Attempting to update interface will result an exception

Returns:

  • (Boolean)

    true if virtual interface has been saved



37
38
39
40
41
42
43
44
# File 'lib/fog/rackspace/models/compute_v2/virtual_interface.rb', line 37

def save(attributes = {})
  if persisted?
    raise Fog::Errors::Error.new("This virtual interface has already been created and it cannot be updated")
  else
    create
  end
  true
end