Class: Fog::Hyperv::Compute::Switch
- Defined in:
- lib/fog/hyperv/compute/models/switch.rb
Instance Attribute Summary collapse
-
#allow_management_os ⇒ Boolean
Is the management OS allowed to use this switch.
-
#computer_name ⇒ String
readonly
The name of the computer hosting this network switch.
-
#default_flow_minimum_bandwidth_absolute ⇒ Integer
The default minimum bandwidth allocation for VMs without specific allocations.
-
#default_flow_minimum_bandwidth_weight ⇒ Integer
The default minimum bandwidth allocation for VMs without specific allocations, as a relative weight.
-
#id ⇒ String
readonly
The GUID of the network switch.
-
#name ⇒ String
The name of the network switch.
-
#net_adapter_interface_description ⇒ String
readonly
The network interface description this switch is attached to.
-
#net_adapter_name ⇒ String
readonly
The network interface name this switch is attached to.
-
#notes ⇒ String
The user-specified notes for the network switch.
-
#resource_pool_name ⇒ String
The resource pool the switch is part of.
-
#switch_type ⇒ :Private, ...
readonly
The type of network switch.
Instance Method Summary collapse
Methods inherited from Model
#initialize, #merge_attributes
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
#allow_management_os ⇒ Boolean
Returns is the management OS allowed to use this switch.
15 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 15 attribute :allow_management_os, type: :boolean |
#computer_name ⇒ String (readonly)
Returns the name of the computer hosting this network switch.
11 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 11 attribute :computer_name |
#default_flow_minimum_bandwidth_absolute ⇒ Integer
Returns the default minimum bandwidth allocation for VMs without specific allocations.
18 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 18 attribute :default_flow_minimum_bandwidth_absolute, type: :integer |
#default_flow_minimum_bandwidth_weight ⇒ Integer
Returns the default minimum bandwidth allocation for VMs without specific allocations, as a relative weight.
21 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 21 attribute :default_flow_minimum_bandwidth_weight, type: :integer |
#id ⇒ String (readonly)
Returns the GUID of the network switch.
7 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 7 identity :id |
#name ⇒ String
Returns the name of the network switch.
24 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 24 attribute :name |
#net_adapter_interface_description ⇒ String (readonly)
Returns the network interface description this switch is attached to.
27 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 27 attribute :net_adapter_interface_description |
#net_adapter_name ⇒ String (readonly)
Returns the network interface name this switch is attached to.
30 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 30 attribute :net_adapter_name |
#notes ⇒ String
Returns the user-specified notes for the network switch.
33 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 33 attribute :notes |
#resource_pool_name ⇒ String
Returns the resource pool the switch is part of.
36 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 36 attribute :resource_pool_name |
#switch_type ⇒ :Private, ... (readonly)
Returns the type of network switch.
39 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 39 attribute :switch_type, type: :hypervenum, values: %i[Private Internal External] |
Instance Method Details
#create ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 41 def create requires :name requires_one :net_adapter_name, :net_adapter_interface_description, :switch_type merge_attributes( service.new_vm_switch( computer_name:, name:, allow_management_os:, net_adapter_interface_description:, net_adapter_name:, notes:, switch_type: !net_adapter_interface_description && switch_type, _return_fields: self.class.attributes ) ) end |
#destroy ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 95 def destroy requires :id service.remove_vm_switch( computer_name:, id: ) true end |
#reload ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 105 def reload requires :id data = service.get_vm_switch( computer_name:, id: ) return unless data merge_attributes(data) end |
#update ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fog/hyperv/compute/models/switch.rb', line 61 def update requires :id if changed?(:name) service.rename_vm_switch( computer_name: old.computer_name, id: old.id, new_name: name ) @old.name = name end changes = { allow_management_os: changed!(:allow_management_os), default_flow_minimum_bandwidth_absolute: changed!(:default_flow_minimum_bandwidth_absolute), default_flow_minimum_bandwidth_weight: changed!(:default_flow_minimum_bandwidth_weight) }.compact changes[:notes] = notes || '' if changed? :notes return self unless changes.any? merge_attributes( service.set_vm_switch( computer_name: old.computer_name, id: old.id, **changes, _always_include: changes.keys, _return_fields: self.class.attributes ) ) end |