fog-hyperv 0.0.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -2
  3. data/lib/fog/bin/hyperv.rb +6 -4
  4. data/lib/fog/hyperv/collection.rb +89 -0
  5. data/lib/fog/hyperv/compute/models/bios.rb +70 -0
  6. data/lib/fog/hyperv/compute/models/cluster.rb +50 -0
  7. data/lib/fog/hyperv/compute/models/clusters.rb +21 -0
  8. data/lib/fog/hyperv/compute/models/com_port.rb +78 -0
  9. data/lib/fog/hyperv/compute/models/com_ports.rb +29 -0
  10. data/lib/fog/hyperv/compute/models/dvd_drive.rb +126 -0
  11. data/lib/fog/hyperv/compute/models/dvd_drives.rb +29 -0
  12. data/lib/fog/hyperv/compute/models/firmware.rb +78 -0
  13. data/lib/fog/hyperv/compute/models/floppy_drive.rb +64 -0
  14. data/lib/fog/hyperv/compute/models/floppy_drives.rb +18 -0
  15. data/lib/fog/hyperv/compute/models/hard_drive.rb +183 -0
  16. data/lib/fog/hyperv/compute/models/hard_drives.rb +28 -0
  17. data/lib/fog/hyperv/compute/models/host.rb +63 -0
  18. data/lib/fog/hyperv/compute/models/hosts.rb +13 -0
  19. data/lib/fog/hyperv/compute/models/network_adapter.rb +368 -0
  20. data/lib/fog/hyperv/compute/models/network_adapter_vlan.rb +172 -0
  21. data/lib/fog/hyperv/compute/models/network_adapters.rb +32 -0
  22. data/lib/fog/hyperv/compute/models/security.rb +121 -0
  23. data/lib/fog/hyperv/compute/models/server.rb +466 -0
  24. data/lib/fog/hyperv/compute/models/servers.rb +18 -0
  25. data/lib/fog/hyperv/compute/models/switch.rb +117 -0
  26. data/lib/fog/hyperv/compute/models/switches.rb +20 -0
  27. data/lib/fog/hyperv/compute/models/vhd.rb +210 -0
  28. data/lib/fog/hyperv/compute/models/vhds.rb +28 -0
  29. data/lib/fog/hyperv/compute/requests/add_vm_dvd_drive.rb +15 -0
  30. data/lib/fog/hyperv/compute/requests/add_vm_hard_disk_drive.rb +15 -0
  31. data/lib/fog/hyperv/compute/requests/add_vm_network_adapter.rb +24 -0
  32. data/lib/fog/hyperv/compute/requests/connect_vm_network_adapter.rb +41 -0
  33. data/lib/fog/hyperv/compute/requests/disable_vm_tpm.rb +16 -0
  34. data/lib/fog/hyperv/compute/requests/disconnect_vm_network_adapter.rb +29 -0
  35. data/lib/fog/hyperv/compute/requests/enable_vm_tpm.rb +16 -0
  36. data/lib/fog/hyperv/compute/requests/get_cluster.rb +11 -0
  37. data/lib/fog/hyperv/compute/requests/get_cluster_node.rb +22 -0
  38. data/lib/fog/hyperv/compute/requests/get_vhd.rb +32 -0
  39. data/lib/fog/hyperv/compute/requests/get_vm.rb +18 -0
  40. data/lib/fog/hyperv/compute/requests/get_vm_bios.rb +21 -0
  41. data/lib/fog/hyperv/compute/requests/get_vm_com_port.rb +17 -0
  42. data/lib/fog/hyperv/compute/requests/get_vm_dvd_drive.rb +25 -0
  43. data/lib/fog/hyperv/compute/requests/get_vm_firmware.rb +21 -0
  44. data/lib/fog/hyperv/compute/requests/get_vm_floppy_disk_drive.rb +16 -0
  45. data/lib/fog/hyperv/compute/requests/get_vm_group.rb +20 -0
  46. data/lib/fog/hyperv/compute/requests/get_vm_hard_disk_drive.rb +24 -0
  47. data/lib/fog/hyperv/compute/requests/get_vm_host.rb +9 -0
  48. data/lib/fog/hyperv/compute/requests/get_vm_host_cluster.rb +21 -0
  49. data/lib/fog/hyperv/compute/requests/get_vm_host_sbt.rb +10 -0
  50. data/lib/fog/hyperv/compute/requests/get_vm_key_protector.rb +16 -0
  51. data/lib/fog/hyperv/compute/requests/get_vm_network_adapter.rb +41 -0
  52. data/lib/fog/hyperv/compute/requests/get_vm_network_adapter_vlan.rb +41 -0
  53. data/lib/fog/hyperv/compute/requests/get_vm_security.rb +15 -0
  54. data/lib/fog/hyperv/compute/requests/get_vm_switch.rb +10 -0
  55. data/lib/fog/hyperv/compute/requests/mock_files/get_vm.json +4 -0
  56. data/lib/fog/hyperv/compute/requests/new_vhd.rb +9 -0
  57. data/lib/fog/hyperv/compute/requests/new_vm.rb +12 -0
  58. data/lib/fog/hyperv/compute/requests/new_vm_switch.rb +11 -0
  59. data/lib/fog/hyperv/compute/requests/optimize_vhd.rb +9 -0
  60. data/lib/fog/hyperv/compute/requests/remove_item.rb +10 -0
  61. data/lib/fog/hyperv/compute/requests/remove_vm.rb +16 -0
  62. data/lib/fog/hyperv/compute/requests/remove_vm_dvd_drive.rb +17 -0
  63. data/lib/fog/hyperv/compute/requests/remove_vm_hard_disk_drive.rb +17 -0
  64. data/lib/fog/hyperv/compute/requests/remove_vm_network_adapter.rb +29 -0
  65. data/lib/fog/hyperv/compute/requests/remove_vm_switch.rb +9 -0
  66. data/lib/fog/hyperv/compute/requests/rename_vm.rb +16 -0
  67. data/lib/fog/hyperv/compute/requests/rename_vm_network_adapter.rb +25 -0
  68. data/lib/fog/hyperv/compute/requests/rename_vm_switch.rb +16 -0
  69. data/lib/fog/hyperv/compute/requests/resize_vhd.rb +16 -0
  70. data/lib/fog/hyperv/compute/requests/restart_vm.rb +22 -0
  71. data/lib/fog/hyperv/compute/requests/resume_vm.rb +22 -0
  72. data/lib/fog/hyperv/compute/requests/save_vm.rb +22 -0
  73. data/lib/fog/hyperv/compute/requests/set_vm.rb +15 -0
  74. data/lib/fog/hyperv/compute/requests/set_vm_bios.rb +15 -0
  75. data/lib/fog/hyperv/compute/requests/set_vm_com_port.rb +16 -0
  76. data/lib/fog/hyperv/compute/requests/set_vm_dvd_drive.rb +16 -0
  77. data/lib/fog/hyperv/compute/requests/set_vm_firmware.rb +15 -0
  78. data/lib/fog/hyperv/compute/requests/set_vm_floppy_disk_drive.rb +16 -0
  79. data/lib/fog/hyperv/compute/requests/set_vm_hard_disk_drive.rb +16 -0
  80. data/lib/fog/hyperv/compute/requests/set_vm_key_protector.rb +15 -0
  81. data/lib/fog/hyperv/compute/requests/set_vm_network_adapter.rb +25 -0
  82. data/lib/fog/hyperv/compute/requests/set_vm_network_adapter_vlan.rb +25 -0
  83. data/lib/fog/hyperv/compute/requests/set_vm_security.rb +17 -0
  84. data/lib/fog/hyperv/compute/requests/set_vm_switch.rb +9 -0
  85. data/lib/fog/hyperv/compute/requests/start_vm.rb +22 -0
  86. data/lib/fog/hyperv/compute/requests/stop_vm.rb +22 -0
  87. data/lib/fog/hyperv/compute/requests/suspend_vm.rb +22 -0
  88. data/lib/fog/hyperv/compute/requests/update_vm.rb +22 -0
  89. data/lib/fog/hyperv/compute.rb +206 -387
  90. data/lib/fog/hyperv/constants.rb +24 -0
  91. data/lib/fog/hyperv/fog_extensions/associations/collection.rb +11 -0
  92. data/lib/fog/hyperv/fog_extensions/attributes/datetime.rb +28 -0
  93. data/lib/fog/hyperv/fog_extensions/attributes/enum.rb +139 -0
  94. data/lib/fog/hyperv/fog_extensions/attributes/enumarray.rb +149 -0
  95. data/lib/fog/hyperv/fog_extensions/attributes/timespan.rb +27 -0
  96. data/lib/fog/hyperv/model.rb +142 -0
  97. data/lib/fog/hyperv/utils/powershell.rb +88 -0
  98. data/lib/fog/hyperv/utils/winrm.rb +233 -0
  99. data/lib/fog/hyperv/version.rb +4 -1
  100. data/lib/fog/hyperv.rb +53 -44
  101. metadata +187 -105
  102. data/.gitignore +0 -10
  103. data/.travis.yml +0 -11
  104. data/CHANGELOG.md +0 -52
  105. data/Gemfile +0 -4
  106. data/Rakefile +0 -10
  107. data/fog-hyperv.gemspec +0 -25
  108. data/lib/fog/collection.rb +0 -152
  109. data/lib/fog/hyperv/fog_extensions/enum.rb +0 -85
  110. data/lib/fog/hyperv/models/compute/bios.rb +0 -61
  111. data/lib/fog/hyperv/models/compute/cluster.rb +0 -64
  112. data/lib/fog/hyperv/models/compute/clusters.rb +0 -15
  113. data/lib/fog/hyperv/models/compute/com_port.rb +0 -22
  114. data/lib/fog/hyperv/models/compute/dvd_drive.rb +0 -92
  115. data/lib/fog/hyperv/models/compute/dvd_drives.rb +0 -12
  116. data/lib/fog/hyperv/models/compute/firmware.rb +0 -53
  117. data/lib/fog/hyperv/models/compute/floppy_drive.rb +0 -53
  118. data/lib/fog/hyperv/models/compute/floppy_drives.rb +0 -12
  119. data/lib/fog/hyperv/models/compute/hard_drive.rb +0 -110
  120. data/lib/fog/hyperv/models/compute/hard_drives.rb +0 -11
  121. data/lib/fog/hyperv/models/compute/host.rb +0 -45
  122. data/lib/fog/hyperv/models/compute/hosts.rb +0 -15
  123. data/lib/fog/hyperv/models/compute/network_adapter.rb +0 -145
  124. data/lib/fog/hyperv/models/compute/network_adapters.rb +0 -19
  125. data/lib/fog/hyperv/models/compute/server.rb +0 -220
  126. data/lib/fog/hyperv/models/compute/servers.rb +0 -21
  127. data/lib/fog/hyperv/models/compute/switch.rb +0 -65
  128. data/lib/fog/hyperv/models/compute/switches.rb +0 -15
  129. data/lib/fog/hyperv/models/compute/vhd.rb +0 -101
  130. data/lib/fog/hyperv/models/compute/vhds.rb +0 -16
  131. data/lib/fog/hyperv/requests/compute/add_vm_dvd_drive.rb +0 -12
  132. data/lib/fog/hyperv/requests/compute/add_vm_hard_disk_drive.rb +0 -12
  133. data/lib/fog/hyperv/requests/compute/add_vm_network_adapter.rb +0 -12
  134. data/lib/fog/hyperv/requests/compute/connect_vm_network_adapter.rb +0 -12
  135. data/lib/fog/hyperv/requests/compute/disconnect_vm_network_adapter.rb +0 -12
  136. data/lib/fog/hyperv/requests/compute/get_cluster.rb +0 -11
  137. data/lib/fog/hyperv/requests/compute/get_cluster_node.rb +0 -19
  138. data/lib/fog/hyperv/requests/compute/get_vhd.rb +0 -34
  139. data/lib/fog/hyperv/requests/compute/get_vm.rb +0 -20
  140. data/lib/fog/hyperv/requests/compute/get_vm_bios.rb +0 -21
  141. data/lib/fog/hyperv/requests/compute/get_vm_dvd_drive.rb +0 -20
  142. data/lib/fog/hyperv/requests/compute/get_vm_firmware.rb +0 -19
  143. data/lib/fog/hyperv/requests/compute/get_vm_floppy_disk_drive.rb +0 -20
  144. data/lib/fog/hyperv/requests/compute/get_vm_group.rb +0 -23
  145. data/lib/fog/hyperv/requests/compute/get_vm_hard_disk_drive.rb +0 -20
  146. data/lib/fog/hyperv/requests/compute/get_vm_host.rb +0 -12
  147. data/lib/fog/hyperv/requests/compute/get_vm_host_cluster.rb +0 -25
  148. data/lib/fog/hyperv/requests/compute/get_vm_network_adapter.rb +0 -27
  149. data/lib/fog/hyperv/requests/compute/get_vm_switch.rb +0 -27
  150. data/lib/fog/hyperv/requests/compute/mock_files/get_vm.json +0 -1
  151. data/lib/fog/hyperv/requests/compute/new_vhd.rb +0 -12
  152. data/lib/fog/hyperv/requests/compute/new_vm.rb +0 -15
  153. data/lib/fog/hyperv/requests/compute/new_vm_switch.rb +0 -13
  154. data/lib/fog/hyperv/requests/compute/remove_item.rb +0 -13
  155. data/lib/fog/hyperv/requests/compute/remove_vm.rb +0 -15
  156. data/lib/fog/hyperv/requests/compute/remove_vm_dvd_drive.rb +0 -12
  157. data/lib/fog/hyperv/requests/compute/remove_vm_hard_disk_drive.rb +0 -12
  158. data/lib/fog/hyperv/requests/compute/remove_vm_network_adapter.rb +0 -12
  159. data/lib/fog/hyperv/requests/compute/restart_vm.rb +0 -15
  160. data/lib/fog/hyperv/requests/compute/set_vm.rb +0 -12
  161. data/lib/fog/hyperv/requests/compute/set_vm_bios.rb +0 -13
  162. data/lib/fog/hyperv/requests/compute/set_vm_dvd_drive.rb +0 -12
  163. data/lib/fog/hyperv/requests/compute/set_vm_firmware.rb +0 -13
  164. data/lib/fog/hyperv/requests/compute/set_vm_hard_disk_drive.rb +0 -12
  165. data/lib/fog/hyperv/requests/compute/set_vm_network_adapter.rb +0 -12
  166. data/lib/fog/hyperv/requests/compute/set_vm_network_adapter_vlan.rb +0 -12
  167. data/lib/fog/hyperv/requests/compute/set_vm_switch.rb +0 -13
  168. data/lib/fog/hyperv/requests/compute/start_vm.rb +0 -15
  169. data/lib/fog/hyperv/requests/compute/stop_vm.rb +0 -15
  170. data/lib/fog/model.rb +0 -91
  171. data/test/fog/hyperv_test.rb +0 -7
  172. data/test/test_helper.rb +0 -4
  173. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_cluster.json +0 -0
  174. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_cluster_node.json +0 -0
  175. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vhd.json +0 -0
  176. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_bios.json +0 -0
  177. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_dvd_drive.json +0 -0
  178. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_firmware.json +0 -0
  179. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_floppy_disk_drive.json +0 -0
  180. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_hard_disk_drive.json +0 -0
  181. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_host.json +0 -0
  182. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_network_adapter.json +0 -0
  183. /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_switch.json +0 -0
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Fog::Hyperv::Compute
4
+ class FloppyDrive < Fog::Hyperv::Model
5
+ # @!attribute [r] id
6
+ # @return [String] the combined GUID of this floppy drive
7
+ identity :id, type: :string
8
+
9
+ # @!attribute [r] vm_id
10
+ # @return [String] the GUID of the VM this BIOS configuration is attached to
11
+ attribute :vm_id, type: :string
12
+ # @!attribute [r] computer_name
13
+ # @return [String] the name of the computer running the VM that this BIOS configuration is attached to
14
+ attribute :computer_name, type: :string
15
+
16
+ # @!attribute [r] name
17
+ # @return [String] the name of this floppy drive
18
+ attribute :name, type: :string
19
+ # @!attribute path
20
+ # @return [String] the path this floppy drive is serving
21
+ attribute :path
22
+ # @!attribute pool_name
23
+ # @return [String] the pool storing this floppy drive's image
24
+ attribute :pool_name
25
+
26
+ def update
27
+ requires :vm_id, :id
28
+
29
+ changes = {
30
+ resource_pool_name: changed!(:pool_name)
31
+ }.compact
32
+ changes[:path] = path if changed? :path
33
+ return self unless changes.any?
34
+
35
+ merge_attributes(
36
+ service.set_vm_floppy_disk_drive(
37
+ computer_name: computer_name,
38
+ vm_id: vm_id,
39
+ id: id,
40
+
41
+ **changes,
42
+
43
+ _always_include: changes.keys,
44
+ _return_fields: self.class.attributes
45
+ )
46
+ )
47
+ end
48
+
49
+ def reload
50
+ requires :vm_id, :id
51
+
52
+ data = service.get_vm_floppy_disk_drive(
53
+ computer_name: computer_name,
54
+ vm_id: vm_id,
55
+ id: id,
56
+
57
+ _return_fields: self.class.attributes
58
+ )
59
+ return unless data
60
+
61
+ merge_attributes(data)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Fog::Hyperv::Compute
4
+ class FloppyDrives < Fog::Hyperv::Collection
5
+ model Fog::Hyperv::Compute::FloppyDrive
6
+
7
+ get_method :get_vm_floppy_disk_drive
8
+
9
+ attribute :computer_name
10
+ attribute :vm_id
11
+
12
+ requires :vm_id
13
+
14
+ def get(id, **filters)
15
+ super(_by_id: id, **filters)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,183 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fog/hyperv/model'
4
+
5
+ class Fog::Hyperv::Compute
6
+ # A hard drive attached to a VM
7
+ class HardDrive < Fog::Hyperv::Model
8
+ # @!attribute [r] id
9
+ # @return [String] the GUID of this hard drive
10
+ identity :id
11
+
12
+ # @!attribute [r] computer_name
13
+ # @return [String] the name of the computer running the VM that this hard drive is attached to
14
+ attribute :computer_name
15
+ # @!attribute [r] vm_id
16
+ # @return [String] the GUID of the VM this hard drive is attached to
17
+ attribute :vm_id
18
+
19
+ # @!attribute controller_location
20
+ # @return [String] the controller location this hard drive is attached to
21
+ attribute :controller_location
22
+ # @!attribute controller_number
23
+ # @return [Integer] the controller number this hard drive is attached to
24
+ attribute :controller_number, type: :integer
25
+ # @!attribute [r] controller_type
26
+ # @return [:IDE, :SCSI] the controller type this hard drive is attached to
27
+ attribute :controller_type, type: :hypervenum, values: %i[IDE SCSI]
28
+ # @!attribute disk
29
+ # @return [Object] the attached physical disk
30
+ attribute :disk
31
+ # attribute :is_deleted
32
+ # @!attribute maximum_iops
33
+ # @return [Integer] the maximum number of IOPS allocated for this hard drive
34
+ attribute :maximum_iops, type: :integer
35
+ # @!attribute minimum_iops
36
+ # @return [Integer] the minimum number of IOPS allocated for this hard drive
37
+ attribute :minimum_iops, type: :integer
38
+ # @!attribute [r] name
39
+ # @return [String] the name of this hard drive
40
+ attribute :name
41
+ # @!attribute path
42
+ # @return [String] the path to the VHD file for this hard drive
43
+ attribute :path
44
+ # @!attribute pool_name
45
+ # @return [String] the name of the pool storing this hard drive's image
46
+ attribute :pool_name
47
+ # @!attribute support_persistent_reservations
48
+ # @return [Boolean] if the underlying hard drive supports SCSI persistent reservations.
49
+ # This should be set when multiple VMs share the same underlying disk.
50
+ attribute :support_persistent_reservations
51
+ # TODO? VM Snapshots?
52
+
53
+ attribute :allow_unverified_paths, type: :boolean
54
+
55
+ has_one :vhd, :vhds
56
+
57
+ def initialize(attributes = {})
58
+ vhd = attributes[:vhd]
59
+ attributes[:path] ||= vhd&.path
60
+
61
+ super
62
+ end
63
+
64
+ # @!attribute vhd
65
+ # @return [Vhd,nil] the VHD that is attached to this hard drive
66
+ def vhd
67
+ return associations[:vhd] if associations[:vhd]
68
+ return unless path
69
+
70
+ associations[:vhd] = service.vhds.get(path, computer_name: computer_name)
71
+ end
72
+
73
+ def vhd=(new_vhd)
74
+ raise ArgumentError, 'Must be a VHD' unless new_vhd.nil? || new_vhd.is_a?(Vhd)
75
+
76
+ attributes[:path] = new_vhd&.path
77
+ associations[:vhd] = new_vhd
78
+ end
79
+
80
+ # @return [Boolean] does the hard drive have a VHD attached?
81
+ def vhd?
82
+ !vhd.nil?
83
+ end
84
+
85
+ # @!attribute [r] size_bytes
86
+ # @return [Integer,nil] the size of the underlying VHD if any
87
+ def size_bytes
88
+ vhd&.size
89
+ end
90
+
91
+ def create
92
+ requires :vm_id
93
+ requires_one :controller_location, :controller_number, :controller_type, :path
94
+
95
+ if associations[:vhd]
96
+ vhd.save if !vhd.persisted? || vhd.dirty?
97
+ attributes[:path] ||= vhd.path
98
+ end
99
+
100
+ merge_attributes(
101
+ service.add_vm_hard_disk_drive(
102
+ **attributes.slice(
103
+ :computer_name,
104
+ :vm_id,
105
+ :allow_unverified_paths,
106
+ :controller_location,
107
+ :controller_number,
108
+ :controller_type,
109
+ :maximum_iops,
110
+ :minimum_iops,
111
+ :path
112
+ ),
113
+ resource_pool_name: pool_name,
114
+
115
+ _return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
116
+ )
117
+ )
118
+ end
119
+
120
+ def update
121
+ requires :id, :vm_id
122
+
123
+ changes = {
124
+ maximum_iops: changed!(:maximum_iops),
125
+ minimum_iops: changed!(:minimum_iops),
126
+ resource_pool_name: changed!(:pool_name),
127
+ support_persistent_reservations: changed!(:support_persistent_reservations),
128
+ to_controller_location: changed!(:controller_location),
129
+ to_controller_number: changed!(:controller_number),
130
+ to_controller_type: changed!(:controller_type)
131
+ }.compact
132
+ changes[:path] = path if changed?(:path)
133
+
134
+ if changes.any?
135
+ merge_attributes(
136
+ service.set_vm_hard_disk_drive(
137
+ computer_name: old.computer_name,
138
+ vm_id: old.vm_id,
139
+ id: old.id,
140
+
141
+ **changes,
142
+ allow_unverified_paths: allow_unverified_paths,
143
+
144
+ _always_include: changes.keys,
145
+ _return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
146
+ )
147
+ )
148
+ end
149
+
150
+ if associations[:vhd]
151
+ vhd.save if !vhd.persisted? || vhd.dirty?
152
+ associations[:vhd] = nil if changed?(:path)
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ def reload
159
+ requires :id, :vm_id
160
+
161
+ data = service.get_vm_hard_disk_drive(
162
+ computer_name: computer_name,
163
+ vm_id: vm_id,
164
+ id: id,
165
+
166
+ _return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
167
+ )
168
+ return unless data
169
+
170
+ merge_attributes(data)
171
+ end
172
+
173
+ def destroy(underlying: false)
174
+ return unless persisted?
175
+
176
+ requires :id, :vm_id
177
+
178
+ service.remove_vm_hard_disk_drive computer_name: computer_name, vm_id: vm_id, id: id
179
+ vhd.destroy if underlying && vhd?
180
+ true
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Fog::Hyperv::Compute
4
+ class HardDrives < Fog::Hyperv::Collection
5
+ model Fog::Hyperv::Compute::HardDrive
6
+
7
+ get_method :get_vm_hard_disk_drive
8
+
9
+ attribute :computer_name
10
+ attribute :vm_id
11
+
12
+ requires :vm_id
13
+
14
+ def get(id, **filters)
15
+ raise ArgumentError, 'Must provide a GUID' if id.nil? || id.empty?
16
+
17
+ super(_by_id: id, **filters)
18
+ end
19
+
20
+ protected
21
+
22
+ def search_attributes
23
+ super.merge(
24
+ _return_fields: model.attributes - %i[allow_unverified_paths vhd]
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Fog::Hyperv::Compute
4
+ class Host < Fog::Hyperv::Model
5
+ # @!attribute [r] name
6
+ # @return [String] the name of the host
7
+ identity :name
8
+ alias computer_name :name
9
+
10
+ # @!attribute [r] fully_qualified_domain_name
11
+ # @return [String] the FQDN of this host
12
+ attribute :fully_qualified_domain_name
13
+ # @!attribute [r] logical_processor_count
14
+ # @return [Integer] the number of logical CPUs on this host
15
+ attribute :logical_processor_count, type: :integer
16
+ # @!attribute [r] memory_capacity
17
+ # @return [Integer] the amount of memory on this host
18
+ attribute :memory_capacity, type: :integer
19
+ # @!attribute [r] mac_address_minimum
20
+ # @return [String] the lowest possible MAC address for VMs on this host
21
+ attribute :mac_address_minimum
22
+ # @!attribute [r] mac_address_maximum
23
+ # @return [String] the highest possible MAC address for VMs on this host
24
+ attribute :mac_address_maximum
25
+ # @!attribute [r] maximum_storage_migrations
26
+ # @return [String] the maximum number of simulatenous storage migrations on this host
27
+ attribute :maximum_storage_migrations, type: :integer
28
+ # @!attribute [r] maximum_virtual_machine_migrations
29
+ # @return [String] the maximum number of simulatenous VMM migrations on this host
30
+ attribute :maximum_virtual_machine_migrations, type: :integer
31
+ # @!attribute [r] virtual_hard_disk_path
32
+ # @return [String] the path where VHDs will be stored on this host
33
+ attribute :virtual_hard_disk_path
34
+ # @!attribute [r] virtual_machine_path
35
+ # @return [String] the path where VMs will be stored on this host
36
+ attribute :virtual_machine_path
37
+
38
+ # @!attribute [r] network_adapters
39
+ # @return [Array<NetworkAdapter>] the network adapters on this host
40
+ collection :network_adapters
41
+ # @!attribute [r] servers
42
+ # @return [Array<Server>] the VMs running on this host
43
+ collection :servers
44
+ # @!attribute [r] switches
45
+ # @return [Array<Switch>] the network switches available on this host
46
+ collection :switches
47
+
48
+ # @!attribute [r] secure_boot_templates
49
+ # @return [Array<String>] the available secure boot templates on this host
50
+ def secure_boot_templates
51
+ service.get_vm_host_sbt(computer_name: name)
52
+ end
53
+
54
+ def reload
55
+ requires :name
56
+
57
+ data = service.get_vm_host computer_name: computer_name, name: name
58
+ return unless data
59
+
60
+ merge_attributes(data)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Fog::Hyperv::Compute
4
+ class Hosts < Fog::Hyperv::Collection
5
+ model Fog::Hyperv::Compute::Host
6
+
7
+ get_method :get_vm_host
8
+
9
+ def get(name, **filters)
10
+ super(computer_name: name, **filters)
11
+ end
12
+ end
13
+ end