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
70 71 72 73 74 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 70 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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 48 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.
30 31 32 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 30 def tagged_pif service.pifs.get __tagged_pif end |
#untagged_pif ⇒ Fog::Compute::XenServer::PIF
Returns interface on which traffic is tagged.
22 23 24 |
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 22 def untagged_pif service.pifs.get __untagged_pif end |