Class: Fog::Compute::XenServer::VLAN

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/xenserver/models/compute/vlan.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

Destroys a VLAN.

service = Fog::Compute[:xenserver]

# Find VLAN 123 and destroy it
(service.vlans.find { |v| v.tag == 123 }).destroy


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

#saveObject

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_pifFog::Compute::XenServer::PIF

Returns interface on which traffic is untagged.

Returns:

See Also:



30
31
32
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 30

def tagged_pif
  service.pifs.get __tagged_pif
end

#untagged_pifFog::Compute::XenServer::PIF

Returns interface on which traffic is tagged.

Returns:

See Also:



22
23
24
# File 'lib/fog/xenserver/models/compute/vlan.rb', line 22

def untagged_pif
  service.pifs.get __untagged_pif
end