Class: Fog::Compute::XenServer::VIF

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/xenserver/models/compute/vif.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



27
28
29
# File 'lib/rackspace-fog/xenserver/models/compute/vif.rb', line 27

def destroy
  connection.destroy_vif reference
end

#networkObject



31
32
33
# File 'lib/rackspace-fog/xenserver/models/compute/vif.rb', line 31

def network
  connection.networks.get __network
end

#saveObject

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
# File 'lib/rackspace-fog/xenserver/models/compute/vif.rb', line 39

def save
  requires :server
  raise ArgumentError.new('network is required for this operation') \
    unless attributes[:__network]
  ref = connection.create_vif attributes[:server], attributes[:__network]
  merge_attributes connection.vifs.get(ref).attributes
end

#serverObject



35
36
37
# File 'lib/rackspace-fog/xenserver/models/compute/vif.rb', line 35

def server
  connection.servers.get __vm
end