Class: Fog::Compute::Hyperv::Switch

Inherits:
Hyperv::Model show all
Defined in:
lib/fog/hyperv/models/compute/switch.rb

Instance Method Summary collapse

Methods included from Hyperv::ModelExtends

#lazy_attributes

Methods included from Hyperv::ModelIncludes

#dirty?, #lazy_attributes, #parent

Instance Method Details

#reloadObject



47
48
49
50
51
52
53
54
# File 'lib/fog/hyperv/models/compute/switch.rb', line 47

def reload
  data = collection.get(
    name,
    computer_name: computer_name
  )
  merge_attributes(data.attributes)
  self
end

#saveObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/hyperv/models/compute/switch.rb', line 16

def save
  requires :name

  data = if persisted?
           service.set_vm_switch(
             computer_name: computer_name,
             default_flow_minimum_bandwidth_absolute: default_flow_minimum_bandwidth_absolute,
             default_flow_minimum_bandwidth_weight: default_flow_minimum_bandwidth_weight,
             name: name,
             net_adapter_interface_description: net_adapter_interface_description,
             notes: notes,
             switch_type: !net_adapter_interface_description && switch_type,
             passthru: true,
             _return_fields: self.class.attributes,
             _json_depth: 1
           )
         else
           service.new_vm_switch(
             computer_name: computer_name,
             name: name,
             net_adapter_interface_description: net_adapter_interface_description,
             notes: notes,
             switch_type: !net_adapter_interface_description && switch_type,
             _return_fields: self.class.attributes,
             _json_depth: 1
           )
         end
  merge_attributes(data)
  self
end