Class: Fog::Compute::XenServer::VLAN
- Defined in:
- lib/fog/xenserver/models/compute/vlan.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroys a VLAN.
-
#save ⇒ Object
Creates a new VLAN.
-
#tagged_pif ⇒ Fog::Compute::XenServer::PIF
Interface on which traffic is untagged.
-
#untagged_pif ⇒ Fog::Compute::XenServer::PIF
Interface on which traffic is tagged.
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
#destroy ⇒ Object
71 72 73 74 75 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 71 def destroy requires :reference service.destroy_vlan reference true end |
#save ⇒ Object
Creates a new VLAN.
service = Fog::Compute[:xenserver]
# create a network 'foo-net'
net = service.networks.create :name => 'foo-net'
# get the eth0 physical interface where the
# VLAN subinterface will be added
pif = service.pifs.find { |p| p.device == 'eth0' and p.physical }
Fog::Compute[:xenserver].vlans.create :tag => 123,
:network => net,
:pif => pif
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 49 def save requires :tag pif = attributes[:pif] net = attributes[:network] unless pif and net raise Fog::Error.new 'save requires :pif and :network attributes' end ref = service.create_vlan attributes[:pif].reference, tag, attributes[:network].reference data = service.get_record ref, 'VLAN' merge_attributes data true end |
#tagged_pif ⇒ Fog::Compute::XenServer::PIF
Returns interface on which traffic is untagged.
31 32 33 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 31 def tagged_pif service.pifs.get __tagged_pif end |
#untagged_pif ⇒ Fog::Compute::XenServer::PIF
Returns interface on which traffic is tagged.
23 24 25 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 23 def untagged_pif service.pifs.get __untagged_pif end |