Class: Fog::Hyperv::Compute::DvdDrive
- Defined in:
- lib/fog/hyperv/compute/models/dvd_drive.rb
Overview
A virtual DVD drive attached to a VM
Instance Attribute Summary collapse
-
#allow_unverified_paths ⇒ Object
Should non-verifiable paths be allowed to be set.
-
#computer_name ⇒ String
readonly
The name of the computer running the VM that this DVD drive is attached to.
-
#controller_location ⇒ String
The controller location this DVD drive is attached to.
-
#controller_number ⇒ Integer
The controller number this DVD drive is attached to.
-
#controller_type ⇒ :IDE, :SCSI
readonly
The controller type this DVD drive is attached to.
-
#dvd_media_type ⇒ :None, ...
readonly
The current type of media in the DVD drive.
-
#id ⇒ String
readonly
The GUID of this DVD drive.
-
#name ⇒ String
readonly
The name of this DVD drive.
-
#path ⇒ String
The path of the underlying image inserted into this DVD drive.
-
#pool_name ⇒ String
The pool storing this DVD drive’s image.
-
#vm_id ⇒ String
readonly
The GUID of the VM this DVD drive is attached to.
Instance Method Summary collapse
-
#create ⇒ Object
Create a new instance of a DVD drive.
-
#destroy ⇒ Object
Remove the DVD drive from Hyper-V.
-
#reload ⇒ Object
Reload attributes from Hyper-V.
-
#update ⇒ Object
Save any modifications to Hyper-V.
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_unverified_paths ⇒ Object
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_name ⇒ String (readonly)
Returns 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_location ⇒ String
Returns 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_number ⇒ Integer
Returns 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.
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.
39 |
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 39 attribute :dvd_media_type, type: :hypervenum, values: %i[None ISO Passthrough] |
#id ⇒ String (readonly)
Returns the GUID of this DVD drive.
10 |
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 10 identity :id |
#name ⇒ String (readonly)
Returns the name of this DVD drive.
21 |
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 21 attribute :name |
#path ⇒ String
Returns 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_name ⇒ String
Returns the pool storing this DVD drive’s image.
27 |
# File 'lib/fog/hyperv/compute/models/dvd_drive.rb', line 27 attribute :pool_name |
#vm_id ⇒ String (readonly)
Returns 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
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#reload ⇒ Object
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 |
#update ⇒ Object
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 |