fog-hyperv 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/fog/hyperv/compute/models/bios.rb +4 -4
- data/lib/fog/hyperv/compute/models/cluster.rb +2 -12
- data/lib/fog/hyperv/compute/models/clusters.rb +1 -1
- data/lib/fog/hyperv/compute/models/com_port.rb +6 -6
- data/lib/fog/hyperv/compute/models/dvd_drive.rb +13 -13
- data/lib/fog/hyperv/compute/models/firmware.rb +6 -4
- data/lib/fog/hyperv/compute/models/floppy_drive.rb +6 -6
- data/lib/fog/hyperv/compute/models/hard_drive.rb +17 -21
- data/lib/fog/hyperv/compute/models/host.rb +1 -4
- data/lib/fog/hyperv/compute/models/integration_service.rb +72 -0
- data/lib/fog/hyperv/compute/models/integration_services.rb +29 -0
- data/lib/fog/hyperv/compute/models/network_adapter.rb +26 -20
- data/lib/fog/hyperv/compute/models/network_adapters.rb +1 -1
- data/lib/fog/hyperv/compute/models/security.rb +8 -4
- data/lib/fog/hyperv/compute/models/server.rb +55 -26
- data/lib/fog/hyperv/compute/models/servers.rb +1 -1
- data/lib/fog/hyperv/compute/models/switch.rb +10 -10
- data/lib/fog/hyperv/compute/models/switches.rb +1 -1
- data/lib/fog/hyperv/compute/models/vhd.rb +23 -10
- data/lib/fog/hyperv/compute/models/vhds.rb +1 -1
- data/lib/fog/hyperv/compute/requests/connect_vm_network_adapter.rb +1 -1
- data/lib/fog/hyperv/compute/requests/disable_vm_integration_service.rb +16 -0
- data/lib/fog/hyperv/compute/requests/enable_vm_integration_service.rb +16 -0
- data/lib/fog/hyperv/compute/requests/get_cluster.rb +2 -2
- data/lib/fog/hyperv/compute/requests/get_vhd.rb +2 -0
- data/lib/fog/hyperv/compute/requests/get_vm_com_port.rb +2 -2
- data/lib/fog/hyperv/compute/requests/get_vm_dvd_drive.rb +2 -2
- data/lib/fog/hyperv/compute/requests/get_vm_floppy_disk_drive.rb +2 -2
- data/lib/fog/hyperv/compute/requests/get_vm_hard_disk_drive.rb +2 -2
- data/lib/fog/hyperv/compute/requests/get_vm_host_cluster.rb +1 -1
- data/lib/fog/hyperv/compute/requests/get_vm_integration_service.rb +15 -0
- data/lib/fog/hyperv/compute/requests/new_vhd.rb +1 -1
- data/lib/fog/hyperv/compute/requests/new_vm_switch.rb +1 -1
- data/lib/fog/hyperv/compute/requests/optimize_vhd.rb +1 -1
- data/lib/fog/hyperv/compute/requests/remove_item.rb +1 -1
- data/lib/fog/hyperv/compute/requests/remove_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/rename_vm.rb +2 -2
- data/lib/fog/hyperv/compute/requests/rename_vm_network_adapter.rb +1 -1
- data/lib/fog/hyperv/compute/requests/rename_vm_switch.rb +8 -1
- data/lib/fog/hyperv/compute/requests/resize_vhd.rb +8 -1
- data/lib/fog/hyperv/compute/requests/restart_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/resume_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/save_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/set_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/start_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/stop_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/suspend_vm.rb +1 -1
- data/lib/fog/hyperv/compute/requests/update_vm.rb +1 -1
- data/lib/fog/hyperv/compute.rb +5 -0
- data/lib/fog/hyperv/model.rb +2 -2
- data/lib/fog/hyperv/utils/powershell.rb +1 -1
- data/lib/fog/hyperv/utils/winrm.rb +1 -1
- data/lib/fog/hyperv/version.rb +1 -1
- data/lib/fog/hyperv.rb +3 -1
- metadata +6 -1
|
@@ -141,6 +141,9 @@ class Fog::Hyperv::Compute
|
|
|
141
141
|
# @!attribute notes
|
|
142
142
|
# @return [String] user-specified notes for the VM
|
|
143
143
|
attribute :notes, type: :string
|
|
144
|
+
# @!attribute path
|
|
145
|
+
# @return [String] the path on disk where the VM configuration is stored
|
|
146
|
+
attribute :path, type: :string
|
|
144
147
|
# @!attribute processor_count
|
|
145
148
|
# @return [Integer] the number of processors in the VM
|
|
146
149
|
attribute :processor_count, type: :integer, default: 1
|
|
@@ -161,6 +164,9 @@ class Fog::Hyperv::Compute
|
|
|
161
164
|
# @!attribute hard_drives
|
|
162
165
|
# @return [Array<HardDrive>] the hard drives on the VM
|
|
163
166
|
collection :hard_drives
|
|
167
|
+
# @!attribute integration_services
|
|
168
|
+
# @return [Array<IntegrationService>] the integration services on the VM
|
|
169
|
+
collection :integration_services
|
|
164
170
|
# @!attribute network_adapters
|
|
165
171
|
# @return [Array<NetworkAdapter>] the network adapters on the VM
|
|
166
172
|
collection :network_adapters
|
|
@@ -194,8 +200,8 @@ class Fog::Hyperv::Compute
|
|
|
194
200
|
klass.new(
|
|
195
201
|
**service.public_send(
|
|
196
202
|
method,
|
|
197
|
-
computer_name
|
|
198
|
-
vm_id
|
|
203
|
+
computer_name: computer_name,
|
|
204
|
+
vm_id: vm_id,
|
|
199
205
|
|
|
200
206
|
_return_fields: klass.attributes
|
|
201
207
|
),
|
|
@@ -212,16 +218,21 @@ class Fog::Hyperv::Compute
|
|
|
212
218
|
# @!attribute [r] security
|
|
213
219
|
# @return [Security] UEFI security configuration, if #generation is +:UEFI+
|
|
214
220
|
def security
|
|
215
|
-
|
|
216
|
-
return nil unless generation == :UEFI
|
|
221
|
+
return unless persisted?
|
|
217
222
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
requires :generation
|
|
224
|
+
return unless generation == :UEFI
|
|
225
|
+
|
|
226
|
+
security = service.get_vm_security(
|
|
227
|
+
computer_name: computer_name,
|
|
228
|
+
vm_id: vm_id,
|
|
222
229
|
|
|
223
|
-
|
|
224
|
-
|
|
230
|
+
_return_fields: Fog::Hyperv::Compute::Security.attributes
|
|
231
|
+
)
|
|
232
|
+
return unless security.is_a? Hash
|
|
233
|
+
|
|
234
|
+
associations[:security] ||= Fog::Hyperv::Compute::Security.new(
|
|
235
|
+
**security,
|
|
225
236
|
|
|
226
237
|
vm: self,
|
|
227
238
|
service: @service,
|
|
@@ -249,7 +260,7 @@ class Fog::Hyperv::Compute
|
|
|
249
260
|
def start
|
|
250
261
|
requires :id
|
|
251
262
|
|
|
252
|
-
service.start_vm(computer_name
|
|
263
|
+
service.start_vm(computer_name: computer_name, id: id)
|
|
253
264
|
true
|
|
254
265
|
end
|
|
255
266
|
|
|
@@ -258,7 +269,7 @@ class Fog::Hyperv::Compute
|
|
|
258
269
|
def stop(turn_off: false)
|
|
259
270
|
requires :id
|
|
260
271
|
|
|
261
|
-
service.stop_vm(computer_name
|
|
272
|
+
service.stop_vm(computer_name: computer_name, id: id, turn_off: turn_off)
|
|
262
273
|
true
|
|
263
274
|
end
|
|
264
275
|
|
|
@@ -266,7 +277,7 @@ class Fog::Hyperv::Compute
|
|
|
266
277
|
def suspend
|
|
267
278
|
requires :id
|
|
268
279
|
|
|
269
|
-
service.suspend_vm(computer_name
|
|
280
|
+
service.suspend_vm(computer_name: computer_name, id: id)
|
|
270
281
|
true
|
|
271
282
|
end
|
|
272
283
|
|
|
@@ -274,7 +285,7 @@ class Fog::Hyperv::Compute
|
|
|
274
285
|
def resume
|
|
275
286
|
requires :id
|
|
276
287
|
|
|
277
|
-
service.resume_vm(computer_name
|
|
288
|
+
service.resume_vm(computer_name: computer_name, id: id)
|
|
278
289
|
true
|
|
279
290
|
end
|
|
280
291
|
|
|
@@ -282,7 +293,7 @@ class Fog::Hyperv::Compute
|
|
|
282
293
|
def hibernate
|
|
283
294
|
requires :id
|
|
284
295
|
|
|
285
|
-
service.save_vm(computer_name
|
|
296
|
+
service.save_vm(computer_name: computer_name, id: id)
|
|
286
297
|
true
|
|
287
298
|
end
|
|
288
299
|
|
|
@@ -291,7 +302,7 @@ class Fog::Hyperv::Compute
|
|
|
291
302
|
def restart
|
|
292
303
|
requires :id
|
|
293
304
|
|
|
294
|
-
service.restart_vm(computer_name
|
|
305
|
+
service.restart_vm(computer_name: computer_name, id: id)
|
|
295
306
|
true
|
|
296
307
|
end
|
|
297
308
|
alias reboot :restart
|
|
@@ -300,26 +311,36 @@ class Fog::Hyperv::Compute
|
|
|
300
311
|
def update_version
|
|
301
312
|
requires :id
|
|
302
313
|
|
|
303
|
-
service.update_vm(computer_name
|
|
314
|
+
service.update_vm(computer_name: computer_name, id: id)
|
|
304
315
|
true
|
|
305
316
|
end
|
|
306
317
|
|
|
307
318
|
# Remove the VM object from Hyper-V
|
|
319
|
+
# @param [Boolean] underlying remove the underlying configuration directory from disk on the Hyper-V host
|
|
308
320
|
#
|
|
309
321
|
# @note if the VM has VHDs, make sure to remove them first to not leave the VM data remaining on disk
|
|
310
|
-
|
|
322
|
+
# @note underlying will remove the +full+ path of the VM, make sure this is what you want before using it
|
|
323
|
+
def destroy(underlying = nil)
|
|
324
|
+
underlying = true if underlying.nil? && attributes[:path]&.end_with?(attributes[:name])
|
|
325
|
+
|
|
311
326
|
requires :id
|
|
327
|
+
requires :path if underlying
|
|
312
328
|
stop turn_off: true if ready?
|
|
313
329
|
|
|
314
|
-
service.remove_vm(computer_name
|
|
330
|
+
service.remove_vm(computer_name: computer_name, id: id)
|
|
331
|
+
service.remove_item(path: path, computer_name: computer_name, recurse: true) if underlying
|
|
315
332
|
true
|
|
316
333
|
end
|
|
317
334
|
|
|
318
335
|
# Create the VM object if it doesn't exist
|
|
319
336
|
# @param [Symbol] boot_device the default boot device to configure the VM with, one of BOOT_DEVICE
|
|
320
337
|
# @param [String] switch_name the name of a Switch to connect the VM to on creation
|
|
338
|
+
# @option attrs [String] :path
|
|
339
|
+
# a custom path to store the VM configuration under - will use a subdir under the default config path if relative
|
|
321
340
|
def create(boot_device: nil, switch_name: nil, **attrs)
|
|
322
341
|
attrs[:no_vhd] = true unless attrs[:new_vhd_path]
|
|
342
|
+
attrs[:path] = [computer.virtual_machine_path, attrs[:path]].join('\\') \
|
|
343
|
+
if attrs[:path] && attrs[:path] !~ %r{^(\w:[\\/]|[\\/]{2}\w+[\\/])}i
|
|
323
344
|
|
|
324
345
|
# Attributes that can't be set as part of the New-VM call
|
|
325
346
|
post_create_attributes = {
|
|
@@ -337,13 +358,13 @@ class Fog::Hyperv::Compute
|
|
|
337
358
|
|
|
338
359
|
merge_attributes(
|
|
339
360
|
service.new_vm(
|
|
340
|
-
computer_name
|
|
341
|
-
name
|
|
361
|
+
computer_name: computer_name,
|
|
362
|
+
name: name,
|
|
342
363
|
|
|
343
364
|
generation: generation_num,
|
|
344
365
|
memory_startup_bytes: memory_startup,
|
|
345
|
-
boot_device
|
|
346
|
-
switch_name
|
|
366
|
+
boot_device: boot_device,
|
|
367
|
+
switch_name: switch_name,
|
|
347
368
|
|
|
348
369
|
**attrs,
|
|
349
370
|
|
|
@@ -411,7 +432,7 @@ class Fog::Hyperv::Compute
|
|
|
411
432
|
def reload
|
|
412
433
|
requires :id
|
|
413
434
|
|
|
414
|
-
data = service.get_vm computer_name
|
|
435
|
+
data = service.get_vm computer_name: computer_name, id: id, _return_fields: self.class.attributes
|
|
415
436
|
return unless data
|
|
416
437
|
|
|
417
438
|
merge_attributes(data)
|
|
@@ -422,10 +443,18 @@ class Fog::Hyperv::Compute
|
|
|
422
443
|
|
|
423
444
|
# Build a path for where to store a VHD of a given name
|
|
424
445
|
# @return [String] the absolute path for the VHD
|
|
425
|
-
def build_vhd_path(filename)
|
|
446
|
+
def build_vhd_path(filename = nil)
|
|
447
|
+
requires :name
|
|
448
|
+
|
|
449
|
+
[computer.virtual_hard_disk_path, name, filename].compact.join('\\')
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
# Build a path for where to store configuration files
|
|
453
|
+
# @return [String] the absolute path for the configuration store
|
|
454
|
+
def build_config_path(subdir = nil)
|
|
426
455
|
requires :name
|
|
427
456
|
|
|
428
|
-
[computer.
|
|
457
|
+
[computer.virtual_machine_path, name, subdir].compact.join('\\')
|
|
429
458
|
end
|
|
430
459
|
|
|
431
460
|
# Get the username of the main system account
|
|
@@ -44,13 +44,13 @@ class Fog::Hyperv::Compute
|
|
|
44
44
|
|
|
45
45
|
merge_attributes(
|
|
46
46
|
service.new_vm_switch(
|
|
47
|
-
computer_name
|
|
48
|
-
name
|
|
47
|
+
computer_name: computer_name,
|
|
48
|
+
name: name,
|
|
49
49
|
|
|
50
|
-
allow_management_os
|
|
51
|
-
net_adapter_interface_description
|
|
52
|
-
net_adapter_name
|
|
53
|
-
notes
|
|
50
|
+
allow_management_os: allow_management_os,
|
|
51
|
+
net_adapter_interface_description: net_adapter_interface_description,
|
|
52
|
+
net_adapter_name: net_adapter_name,
|
|
53
|
+
notes: notes,
|
|
54
54
|
switch_type: !net_adapter_interface_description && switch_type,
|
|
55
55
|
|
|
56
56
|
_return_fields: self.class.attributes
|
|
@@ -96,8 +96,8 @@ class Fog::Hyperv::Compute
|
|
|
96
96
|
requires :id
|
|
97
97
|
|
|
98
98
|
service.remove_vm_switch(
|
|
99
|
-
computer_name
|
|
100
|
-
id:
|
|
99
|
+
computer_name: computer_name,
|
|
100
|
+
id: id
|
|
101
101
|
)
|
|
102
102
|
true
|
|
103
103
|
end
|
|
@@ -106,8 +106,8 @@ class Fog::Hyperv::Compute
|
|
|
106
106
|
requires :id
|
|
107
107
|
|
|
108
108
|
data = service.get_vm_switch(
|
|
109
|
-
computer_name
|
|
110
|
-
id:
|
|
109
|
+
computer_name: computer_name,
|
|
110
|
+
id: id
|
|
111
111
|
)
|
|
112
112
|
return unless data
|
|
113
113
|
|
|
@@ -121,9 +121,9 @@ class Fog::Hyperv::Compute
|
|
|
121
121
|
|
|
122
122
|
merge_attributes(
|
|
123
123
|
service.new_vhd(
|
|
124
|
-
computer_name
|
|
124
|
+
computer_name: computer_name,
|
|
125
125
|
|
|
126
|
-
path
|
|
126
|
+
path: path,
|
|
127
127
|
block_size_bytes: block_size,
|
|
128
128
|
size_bytes: size,
|
|
129
129
|
**attrs,
|
|
@@ -154,9 +154,9 @@ class Fog::Hyperv::Compute
|
|
|
154
154
|
requires_one :path, :disk_number
|
|
155
155
|
|
|
156
156
|
data = service.get_vhd(
|
|
157
|
-
computer_name
|
|
158
|
-
path
|
|
159
|
-
disk_number
|
|
157
|
+
computer_name: computer_name,
|
|
158
|
+
path: path,
|
|
159
|
+
disk_number: disk_number,
|
|
160
160
|
|
|
161
161
|
_return_fields: self.class.attributes - %i[basename]
|
|
162
162
|
)
|
|
@@ -170,9 +170,22 @@ class Fog::Hyperv::Compute
|
|
|
170
170
|
requires :path
|
|
171
171
|
|
|
172
172
|
service.remove_item(
|
|
173
|
-
computer_name
|
|
174
|
-
path:
|
|
173
|
+
computer_name: computer_name,
|
|
174
|
+
path: [path, "#{path}.*"],
|
|
175
175
|
)
|
|
176
|
+
components = path.split('\\')
|
|
177
|
+
if components[-2] == vm.name
|
|
178
|
+
# if (!Test-Path -Path ...\*) { Remove-Item -Path ... -Recurse -Force }
|
|
179
|
+
vmpath = components[0..-2].join '\\'
|
|
180
|
+
service.run_cmdlist(
|
|
181
|
+
[
|
|
182
|
+
["$anyFiles = Test-Path", { path: [vmpath, '*'].join('\\') }],
|
|
183
|
+
['if (-not $anyFiles) { Remove-Item @Args }', { path: vmpath, recurse: true, force: true }]
|
|
184
|
+
],
|
|
185
|
+
skip_json: true,
|
|
186
|
+
target_computer: computer_name,
|
|
187
|
+
)
|
|
188
|
+
end
|
|
176
189
|
true
|
|
177
190
|
end
|
|
178
191
|
|
|
@@ -184,9 +197,9 @@ class Fog::Hyperv::Compute
|
|
|
184
197
|
requires :path
|
|
185
198
|
|
|
186
199
|
service.optimize_vhd(
|
|
187
|
-
computer_name
|
|
188
|
-
path
|
|
189
|
-
mode:
|
|
200
|
+
computer_name: computer_name,
|
|
201
|
+
path: path,
|
|
202
|
+
mode: mode
|
|
190
203
|
)
|
|
191
204
|
true
|
|
192
205
|
end
|
|
@@ -14,7 +14,7 @@ class Fog::Hyperv::Compute
|
|
|
14
14
|
|
|
15
15
|
raise ArgumentError, 'Must provide a path or GUID' if (id.nil? || id.empty?) && (path.nil? || path.empty?)
|
|
16
16
|
|
|
17
|
-
super(disk_identifier: id, path
|
|
17
|
+
super(disk_identifier: id, path: path, **filters)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
protected
|
|
@@ -28,7 +28,7 @@ class Fog::Hyperv::Compute
|
|
|
28
28
|
else
|
|
29
29
|
switch_name = options.delete :switch_name
|
|
30
30
|
options.delete :switch_id
|
|
31
|
-
cmdlist << ['$NIC | Connect-VMNetworkAdapter', { switch_name
|
|
31
|
+
cmdlist << ['$NIC | Connect-VMNetworkAdapter', { switch_name: switch_name, **options }]
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
run_cmdlist(cmdlist, skip_json: true, target_computer: computer_name)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def disable_vm_integration_service(name:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Disable-VMIntegrationService', { name: name, **options }]
|
|
10
|
+
],
|
|
11
|
+
skip_json: true,
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def enable_vm_integration_service(name:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Enable-VMIntegrationService', { name: name, **options }]
|
|
10
|
+
],
|
|
11
|
+
skip_json: true,
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -4,6 +4,8 @@ class Fog::Hyperv::Compute
|
|
|
4
4
|
class Real
|
|
5
5
|
def get_vhd(computer_name: nil, **options)
|
|
6
6
|
requires_one options, :path, :disk_number unless options[:vm_id]
|
|
7
|
+
options.delete :vm_id if options[:path] || options[:disk_number]
|
|
8
|
+
|
|
7
9
|
run_cmd 'Get-VHD', _target_computer: computer_name, **options
|
|
8
10
|
end
|
|
9
11
|
end
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def get_vm_com_port(vm_id:, computer_name: nil, **options)
|
|
6
|
-
|
|
6
|
+
by_id = options.delete :id
|
|
7
7
|
|
|
8
8
|
run_cmdlist(
|
|
9
9
|
[
|
|
10
10
|
['$VM = Get-VM', { id: vm_id }],
|
|
11
|
-
['$VM | Get-VMComPort', { _by_id
|
|
11
|
+
['$VM | Get-VMComPort', { _by_id: by_id, **options }]
|
|
12
12
|
],
|
|
13
13
|
target_computer: computer_name
|
|
14
14
|
)
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def get_vm_dvd_drive(vm_id:, computer_name: nil, **options)
|
|
6
|
-
|
|
6
|
+
by_id = options.delete :id
|
|
7
7
|
|
|
8
8
|
run_cmdlist(
|
|
9
9
|
[
|
|
10
10
|
['$VM = Get-VM', { id: vm_id }],
|
|
11
|
-
['$VM | Get-VMDvdDrive', { _by_id
|
|
11
|
+
['$VM | Get-VMDvdDrive', { _by_id: by_id, **options }]
|
|
12
12
|
],
|
|
13
13
|
target_computer: computer_name
|
|
14
14
|
)
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def get_vm_floppy_disk_drive(vm_id:, computer_name: nil, **options)
|
|
6
|
-
|
|
6
|
+
by_id = options.delete :id
|
|
7
7
|
run_cmdlist(
|
|
8
8
|
[
|
|
9
9
|
['$VM = Get-VM', { id: vm_id }],
|
|
10
|
-
['$VM | Get-VMFloppyDiskDrive', { _by_id
|
|
10
|
+
['$VM | Get-VMFloppyDiskDrive', { _by_id: by_id, **options }]
|
|
11
11
|
],
|
|
12
12
|
target_computer: computer_name
|
|
13
13
|
)
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def get_vm_hard_disk_drive(vm_id:, computer_name: nil, **options)
|
|
6
|
-
|
|
6
|
+
by_id = options.delete :id
|
|
7
7
|
run_cmdlist(
|
|
8
8
|
[
|
|
9
9
|
['$VM = Get-VM', { id: vm_id }],
|
|
10
|
-
['$VM | Get-VMHardDiskDrive', { _by_id
|
|
10
|
+
['$VM | Get-VMHardDiskDrive', { _by_id: by_id, **options }]
|
|
11
11
|
],
|
|
12
12
|
target_computer: computer_name
|
|
13
13
|
)
|
|
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
|
|
|
5
5
|
def get_vm_host_cluster(cluster_name:, computer_name: nil, **options)
|
|
6
6
|
requires_version '10.0'
|
|
7
7
|
|
|
8
|
-
run_cmd 'Get-VMHostCluster', _target_computer: computer_name, cluster_name
|
|
8
|
+
run_cmd 'Get-VMHostCluster', _target_computer: computer_name, cluster_name: cluster_name, **options
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def get_vm_integration_service(vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Get-VMIntegrationService', options]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def new_vhd(path:, size_bytes:, computer_name: nil, **options)
|
|
6
|
-
run_cmd 'New-VHD', _target_computer: computer_name, path
|
|
6
|
+
run_cmd 'New-VHD', _target_computer: computer_name, path: path, size_bytes: size_bytes, **options
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
|
|
|
5
5
|
def new_vm_switch(name:, computer_name: nil, **options)
|
|
6
6
|
requires_one options, :net_adapter_name, :net_adapter_interface_description
|
|
7
7
|
|
|
8
|
-
run_cmd 'New-VMSwitch', _target_computer: computer_name, name
|
|
8
|
+
run_cmd 'New-VMSwitch', _target_computer: computer_name, name: name, **options
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def optimize_vhd(path:, computer_name: nil, **options)
|
|
6
|
-
run_cmd 'Optimize-VHD', _target_computer: computer_name, _skip_json: true, path
|
|
6
|
+
run_cmd 'Optimize-VHD', _target_computer: computer_name, _skip_json: true, path: path, **options
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -4,7 +4,7 @@ class Fog::Hyperv::Compute
|
|
|
4
4
|
class Real
|
|
5
5
|
def remove_item(path:, computer_name: nil, **options)
|
|
6
6
|
# TODO: Really lock this method down, validation is good.
|
|
7
|
-
run_cmd 'Remove-Item', _target_computer: computer_name, _skip_json: true, path
|
|
7
|
+
run_cmd 'Remove-Item', _target_computer: computer_name, _skip_json: true, path: path, force: true, **options
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -5,8 +5,8 @@ class Fog::Hyperv::Compute
|
|
|
5
5
|
def rename_vm(id:, new_name:, computer_name: nil, **options)
|
|
6
6
|
run_cmdlist(
|
|
7
7
|
[
|
|
8
|
-
['$VM = Get-VM', { id: }],
|
|
9
|
-
['$VM | Rename-VM', { new_name
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Rename-VM', { new_name: new_name, **options }]
|
|
10
10
|
],
|
|
11
11
|
target_computer: computer_name,
|
|
12
12
|
skip_json: true
|
|
@@ -17,7 +17,7 @@ class Fog::Hyperv::Compute
|
|
|
17
17
|
options.delete :vm_id
|
|
18
18
|
cmdlist << ['$NIC = Get-VMNetworkAdapter', { _by_id: id, management_os: true }]
|
|
19
19
|
end
|
|
20
|
-
cmdlist << ['$NIC | Rename-VMNetworkAdapter', { new_name
|
|
20
|
+
cmdlist << ['$NIC | Rename-VMNetworkAdapter', { new_name: new_name, **options }]
|
|
21
21
|
|
|
22
22
|
run_cmdlist(cmdlist, target_computer: computer_name, skip_json: true)
|
|
23
23
|
end
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def rename_vm_switch(id:, new_name:, computer_name: nil, **options)
|
|
6
|
-
run_cmd
|
|
6
|
+
run_cmd(
|
|
7
|
+
'Rename-VMSwitch',
|
|
8
|
+
new_name: new_name,
|
|
9
|
+
_target_computer: computer_name,
|
|
10
|
+
_by_id: id,
|
|
11
|
+
_skip_json: true,
|
|
12
|
+
**options
|
|
13
|
+
)
|
|
7
14
|
end
|
|
8
15
|
end
|
|
9
16
|
end
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
class Fog::Hyperv::Compute
|
|
4
4
|
class Real
|
|
5
5
|
def resize_vhd(path:, size_bytes:, computer_name: nil, **options)
|
|
6
|
-
run_cmd
|
|
6
|
+
run_cmd(
|
|
7
|
+
'Resize-VHD',
|
|
8
|
+
_target_computer: computer_name,
|
|
9
|
+
_skip_json: true,
|
|
10
|
+
path: path,
|
|
11
|
+
size_bytes: size_bytes,
|
|
12
|
+
**options
|
|
13
|
+
)
|
|
7
14
|
end
|
|
8
15
|
end
|
|
9
16
|
end
|