Class: Fog::Hyperv::Compute::NetworkAdapterVlan
- Defined in:
- lib/fog/hyperv/compute/models/network_adapter_vlan.rb
Constant Summary collapse
- VLAN_OPERATION_MODE =
Note:
Defined by Microsoft.HyperV.PowerShell.VMNetworkAdapterVlanMode
VLAN mode
%i[ Untagged Access Trunk Private ].freeze
- PRIVATE_VLAN_MODE =
Note:
Defined by Microsoft.HyperV.PowerShell.VMNetworkAdapterPrivateVlanMode
Extended mode for Private VLANs
%i[ Unknown Isolated Community Promiscuous ].freeze
Instance Attribute Summary collapse
-
#access_vlan_id ⇒ Integer
The VLAN ID to use for operation_mode
:Access. -
#allowed_vlan_id_list ⇒ Array<Integer>
The list of allowed VLAN IDs to use for operation_mode
:Trunk. -
#native_vlan_id ⇒ Integer
The native VLAN ID to use for operation_mode
:Trunk. -
#operation_mode ⇒ :Untagged, ...
The active VLAN mode.
-
#parent_adapter ⇒ NetworkAdapter
(also: #identity)
The network adapter this VLAN configuration applies to.
-
#primary_vlan_id ⇒ Integer
The primary VLAN ID to use for operation_mode
:Private. -
#private_vlan_mode ⇒ :Isolated, ...
The type of private VLAN mode to use.
-
#secondary_vlan_id ⇒ Integer
The secondary VLAN ID to use for private_vlan_mode
:Isolatedor:Community. -
#secondary_vlan_id_list ⇒ Array<Integer>
The list of secondary VLAN IDs to use for private_vlan_mode
:Promiscuous.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Model
Methods included from ModelExtends
Methods included from ModelIncludes
#cluster, #computer, #dirty, #dirty?, #vm
Constructor Details
This class inherits a constructor from Fog::Hyperv::Model
Instance Attribute Details
#access_vlan_id ⇒ Integer
Returns the VLAN ID to use for operation_mode :Access.
25 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 25 attribute :access_vlan_id, type: :integer |
#allowed_vlan_id_list ⇒ Array<Integer>
Returns the list of allowed VLAN IDs to use for operation_mode :Trunk.
28 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 28 attribute :allowed_vlan_id_list |
#native_vlan_id ⇒ Integer
Returns the native VLAN ID to use for operation_mode :Trunk.
31 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 31 attribute :native_vlan_id, type: :integer |
#operation_mode ⇒ :Untagged, ...
Returns the active VLAN mode.
19 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 19 attribute :operation_mode, type: :hypervenum, default: :Untagged, values: VLAN_OPERATION_MODE |
#parent_adapter ⇒ NetworkAdapter Also known as: identity
Returns the network adapter this VLAN configuration applies to.
44 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 44 has_one :parent_adapter, :network_adapters |
#primary_vlan_id ⇒ Integer
Returns the primary VLAN ID to use for operation_mode :Private.
34 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 34 attribute :primary_vlan_id, type: :integer |
#private_vlan_mode ⇒ :Isolated, ...
Returns the type of private VLAN mode to use.
22 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 22 attribute :private_vlan_mode, type: :hypervenum, default: :Isolated, values: PRIVATE_VLAN_MODE |
#secondary_vlan_id ⇒ Integer
Returns the secondary VLAN ID to use for private_vlan_mode :Isolated or :Community.
37 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 37 attribute :secondary_vlan_id, type: :integer |
#secondary_vlan_id_list ⇒ Array<Integer>
Returns the list of secondary VLAN IDs to use for private_vlan_mode :Promiscuous.
40 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 40 attribute :secondary_vlan_id_list |
Class Method Details
.render_vlan_list(list) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 83 def self.render_vlan_list(list) ret = [] list = list.map(&:to_i).reject(&:zero?).sort.uniq render_tuple = proc do |from, to| next from if from == to "#{from}-#{to}" end rangeend = rangestart = list.first list.each do |vlan| if vlan > rangeend + 1 ret << render_tuple.call(rangestart, rangeend) rangestart = rangeend = vlan else rangeend = vlan end end ret << render_tuple.call(rangestart, rangeend) ret.join ',' end |
Instance Method Details
#reload ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 68 def reload requires :parent_adapter data = service.get_vm_network_adapter_vlan( computer_name: parent_adapter.computer_name, vm_id: parent_adapter.vm_id, id: parent_adapter.id, _return_fields: self.class.attributes ) return unless data merge_attributes(data) end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fog/hyperv/compute/models/network_adapter_vlan.rb', line 48 def update requires :parent_adapter changes = build_changelist return self unless changes.any? merge_attributes( service.set_vm_network_adapter_vlan( computer_name: parent_adapter.computer_name, vm_id: parent_adapter.vm_id, id: parent_adapter.id, **changes, _always_include: changes.keys, _return_fields: self.class.attributes ) || {} # Unmodified object returns nothing ) end |