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

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

Overview

A virtual DVD drive attached to a VM

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#initialize, #merge_attributes

Methods included from ModelExtends

#collection

Methods included from ModelIncludes

#cluster, #computer, #dirty, #dirty?, #vm

Constructor Details

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

Instance Attribute Details

#allow_unverified_pathsObject

Should non-verifiable paths be allowed to be set



44
45
46
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 44

def allow_unverified_paths
  @allow_unverified_paths
end

#computer_nameString (readonly)

Returns the name of the computer running the VM that this DVD drive is attached to.

Returns:

  • (String)

    the name of the computer running the VM that this DVD drive is attached to



14
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 14

attribute :computer_name

#controller_locationString

Returns the controller location this DVD drive is attached to.

Returns:

  • (String)

    the controller location this DVD drive is attached to



30
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 30

attribute :controller_location

#controller_numberInteger

Returns the controller number this DVD drive is attached to.

Returns:

  • (Integer)

    the controller number this DVD drive is attached to



33
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 33

attribute :controller_number, type: :integer

#controller_type:IDE, :SCSI (readonly)

Returns the controller type this DVD drive is attached to.

Returns:

  • (:IDE, :SCSI)

    the controller type this DVD drive is attached to



36
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 36

attribute :controller_type, type: :hypervenum, values: %i[IDE SCSI]

#dvd_media_type:None, ... (readonly)

Returns the current type of media in the DVD drive.

Returns:

  • (:None, :ISO, :Passthrough)

    the current type of media in the DVD drive



39
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 39

attribute :dvd_media_type, type: :hypervenum, values: %i[None ISO Passthrough]

#idString (readonly)

Returns the GUID of this DVD drive.

Returns:

  • (String)

    the GUID of this DVD drive



10
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 10

identity :id

#nameString (readonly)

Returns the name of this DVD drive.

Returns:

  • (String)

    the name of this DVD drive



21
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 21

attribute :name

#pathString

Returns the path of the underlying image inserted into this DVD drive.

Returns:

  • (String)

    the path of the underlying image inserted into this DVD drive



24
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 24

attribute :path

#pool_nameString

Returns the pool storing this DVD drive’s image.

Returns:

  • (String)

    the pool storing this DVD drive’s image



27
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 27

attribute :pool_name

#vm_idString (readonly)

Returns the GUID of the VM this DVD drive is attached to.

Returns:

  • (String)

    the GUID of the VM this DVD drive is attached to



17
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 17

attribute :vm_id

Instance Method Details

#createObject

Note:

Requires vm_id, as well as either controller settings or a path

Create a new instance of a DVD drive



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 50

def create
  requires :vm_id
  requires_one :controller_location, :controller_number, :controller_type, :path

  merge_attributes(
    service.add_vm_dvd_drive(
      computer_name:,
      vm_id:,

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

      _return_fields: self.class.attributes
    )
  )
end

#destroyObject

Remove the DVD drive from Hyper-V



99
100
101
102
103
104
105
106
107
108
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 99

def destroy
  requires :id, :vm_id

  service.remove_vm_dvd_drive(
    computer_name:,
    vm_id:,
    id:
  )
  true
end

#reloadObject

Reload attributes from Hyper-V



111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 111

def reload
  requires :id, :vm_id

  data = service.get_vm_dvd_drive(
    computer_name:,
    vm_id:,
    id:,

    _return_fields: self.class.attributes
  )
  return unless data

  merge_attributes(data)
end

#updateObject

Save any modifications to Hyper-V



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 71

def update
  requires :id, :vm_id

  changes = {
    resource_pool_name: changed!(:pool_name),
    to_controller_number: changed!(:controller_number),
    to_controller_location: changed!(:controller_location)
  }.compact
  # Ensure path: nil is sent
  changes[:path] = path if changed? :path
  return self unless changes.any?

  merge_attributes(
    service.set_vm_dvd_drive(
      computer_name: old.computer_name,
      vm_id: old.vm_id,
      id: old.id,

      allow_unverified_paths:,
      **changes,

      _always_include: changes.keys,
      _return_fields: self.class.attributes
    )
  )
end