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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

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 Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

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

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



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

def destroy
  service.destroy_vif reference
end

#networkObject



40
41
42
# File 'lib/fog/xenserver/models/compute/vif.rb', line 40

def network
  service.networks.get __network
end

#saveObject

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
# File 'lib/fog/xenserver/models/compute/vif.rb', line 48

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

#serverObject



44
45
46
# File 'lib/fog/xenserver/models/compute/vif.rb', line 44

def server
  service.servers.get __vm
end