Class: Fog::Compute::Hyperv::DvdDrive

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

Instance Method Summary collapse

Methods inherited from Hyperv::Model

#initialize

Methods included from Hyperv::ModelExtends

#lazy_attributes

Methods included from Hyperv::ModelIncludes

#cluster, #computer, #dirty?, #lazy_attributes, #parent, #vm

Constructor Details

This class inherits a constructor from Fog::Hyperv::Model

Instance Method Details

#destroyObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/fog/hyperv/models/compute/dvd_drive.rb', line 62

def destroy
  requires :computer_name, :vm_name, :controller_number, :controller_location

  service.remove_vm_dvd_drive(
    computer_name: computer_name,
    vm_name: vm_name,
    controller_number: controller_number,
    controller_location: controller_location
  )
end

#reloadObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fog/hyperv/models/compute/dvd_drive.rb', line 73

def reload
  requires :computer_name, :vm_name

  data = collection.get(
    computer_name: computer_name,
    vm_name: vm_name,
    controller_location: controller_location,
    controller_number: controller_number,

    _return_fields: self.class.attributes,
    _json_depth: 1
  )
  merge_attributes(data.attributes)
  @old = data
  self
end

#saveObject

TODO? VM Snapshots?



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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/hyperv/models/compute/dvd_drive.rb', line 21

def save
  requires :computer_name, :vm_name

  data = \
    if persisted?
      service.set_vm_dvd_drive(
        computer_name: old.computer_name,
        vm_name: old.vm_name,
        controller_number: old.controller_number,
        controller_location: old.controller_location,
        passthru: true,

        resource_pool_name: changed!(:pool_name),
        path: changed?(:path) && (path || '$null'),
        to_controller_number: changed!(:controller_number),
        to_controller_location: changed!(:controller_location),

        _return_fields: self.class.attributes,
        _json_depth: 1
      )
    else
      service.add_vm_dvd_drive(
        computer_name: computer_name,
        vm_name: vm_name,
        passthru: true,

        controller_number: controller_number,
        controller_location: controller_location,
        path: path,
        resource_pool_name: pool_name,

        _return_fields: self.class.attributes,
        _json_depth: 1
      )
    end

  merge_attributes(data)
  @old = dup
  self
end