fog-hyperv 0.1.0 → 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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fog/hyperv/compute/models/bios.rb +4 -4
  3. data/lib/fog/hyperv/compute/models/cluster.rb +2 -12
  4. data/lib/fog/hyperv/compute/models/clusters.rb +1 -1
  5. data/lib/fog/hyperv/compute/models/com_port.rb +6 -6
  6. data/lib/fog/hyperv/compute/models/dvd_drive.rb +13 -13
  7. data/lib/fog/hyperv/compute/models/firmware.rb +4 -4
  8. data/lib/fog/hyperv/compute/models/floppy_drive.rb +6 -6
  9. data/lib/fog/hyperv/compute/models/hard_drive.rb +17 -21
  10. data/lib/fog/hyperv/compute/models/host.rb +1 -4
  11. data/lib/fog/hyperv/compute/models/network_adapter.rb +26 -20
  12. data/lib/fog/hyperv/compute/models/network_adapters.rb +1 -1
  13. data/lib/fog/hyperv/compute/models/server.rb +17 -17
  14. data/lib/fog/hyperv/compute/models/servers.rb +1 -1
  15. data/lib/fog/hyperv/compute/models/switch.rb +10 -10
  16. data/lib/fog/hyperv/compute/models/switches.rb +1 -1
  17. data/lib/fog/hyperv/compute/models/vhd.rb +10 -10
  18. data/lib/fog/hyperv/compute/models/vhds.rb +1 -1
  19. data/lib/fog/hyperv/compute/requests/connect_vm_network_adapter.rb +1 -1
  20. data/lib/fog/hyperv/compute/requests/get_cluster.rb +2 -2
  21. data/lib/fog/hyperv/compute/requests/get_vm_com_port.rb +2 -2
  22. data/lib/fog/hyperv/compute/requests/get_vm_dvd_drive.rb +2 -2
  23. data/lib/fog/hyperv/compute/requests/get_vm_floppy_disk_drive.rb +2 -2
  24. data/lib/fog/hyperv/compute/requests/get_vm_hard_disk_drive.rb +2 -2
  25. data/lib/fog/hyperv/compute/requests/get_vm_host_cluster.rb +1 -1
  26. data/lib/fog/hyperv/compute/requests/new_vhd.rb +1 -1
  27. data/lib/fog/hyperv/compute/requests/new_vm_switch.rb +1 -1
  28. data/lib/fog/hyperv/compute/requests/optimize_vhd.rb +1 -1
  29. data/lib/fog/hyperv/compute/requests/remove_item.rb +1 -1
  30. data/lib/fog/hyperv/compute/requests/remove_vm.rb +1 -1
  31. data/lib/fog/hyperv/compute/requests/rename_vm.rb +2 -2
  32. data/lib/fog/hyperv/compute/requests/rename_vm_network_adapter.rb +1 -1
  33. data/lib/fog/hyperv/compute/requests/rename_vm_switch.rb +8 -1
  34. data/lib/fog/hyperv/compute/requests/resize_vhd.rb +8 -1
  35. data/lib/fog/hyperv/compute/requests/restart_vm.rb +1 -1
  36. data/lib/fog/hyperv/compute/requests/resume_vm.rb +1 -1
  37. data/lib/fog/hyperv/compute/requests/save_vm.rb +1 -1
  38. data/lib/fog/hyperv/compute/requests/set_vm.rb +1 -1
  39. data/lib/fog/hyperv/compute/requests/start_vm.rb +1 -1
  40. data/lib/fog/hyperv/compute/requests/stop_vm.rb +1 -1
  41. data/lib/fog/hyperv/compute/requests/suspend_vm.rb +1 -1
  42. data/lib/fog/hyperv/compute/requests/update_vm.rb +1 -1
  43. data/lib/fog/hyperv/model.rb +2 -2
  44. data/lib/fog/hyperv/utils/powershell.rb +1 -1
  45. data/lib/fog/hyperv/utils/winrm.rb +1 -1
  46. data/lib/fog/hyperv/version.rb +1 -1
  47. data/lib/fog/hyperv.rb +3 -1
  48. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af18f5580ade8fe5abf47b387585468f91015c27629395924701e00b93d91c63
4
- data.tar.gz: ed2a99e90fe6f3352900348c58a35a49a4c958faaa1171e14eba8f7bc2bfe266
3
+ metadata.gz: ccbf3e9eda759ea102435d2964c19386543882388faf665cef30f1799ec53ae1
4
+ data.tar.gz: 45decf89ada52daa7b99e4fbba5f638c115835f03c6cc298a812c4028f7057d0
5
5
  SHA512:
6
- metadata.gz: 6b68ca5623d9bf6cac41b8c1225bb42d7cb64243914bc99b438dc0f77c39379eba129461161bdca8f31d5afd5338092210bcfa275e2eea238116576707b8f205
7
- data.tar.gz: 30719e7bd1f874b8ce11ea283682af5f676d014a742ac04e5ea86c5ab68c01633e615db8a6fdb7b52be75ae0629d79408b9e24bd7c515bdf9ab0584041dd057f
6
+ metadata.gz: 5f5840914ddd70af716c7695a65afe481315b9fee527106b08dd0ac3668b1ec6303a4bddbc30eae15be77c7d77e0f75cb2f0594abd55e65caa84381a0cf504b3
7
+ data.tar.gz: 07cddab77c89dd6ead6c54b168eed4ea74a56f96070b9d8305811083cc410d940bdc47783576df1100ba6cf72c9a24599a98a46882eaac5744ab10e59f3eaab5
@@ -41,8 +41,8 @@ class Fog::Hyperv::Compute
41
41
  return self unless changes.any?
42
42
 
43
43
  data = service.set_vm_bios(
44
- computer_name:,
45
- vm_id:,
44
+ computer_name: computer_name,
45
+ vm_id: vm_id,
46
46
 
47
47
  **changes,
48
48
 
@@ -57,8 +57,8 @@ class Fog::Hyperv::Compute
57
57
  requires :vm_id
58
58
 
59
59
  data = service.get_vm_bios(
60
- computer_name:,
61
- vm_id:,
60
+ computer_name: computer_name,
61
+ vm_id: vm_id,
62
62
 
63
63
  _return_fields: self.class.attributes
64
64
  )
@@ -31,11 +31,7 @@ class Fog::Hyperv::Compute
31
31
  def reload
32
32
  requires :id
33
33
 
34
- data = service.get_cluster(
35
- id:,
36
-
37
- _return_fields: self.class.attributes
38
- )
34
+ data = service.get_cluster id: id, _return_fields: self.class.attributes
39
35
  return unless data
40
36
 
41
37
  merge_attributes(data.attributes)
@@ -48,13 +44,7 @@ class Fog::Hyperv::Compute
48
44
 
49
45
  requires :id
50
46
 
51
- [
52
- service.get_cluster_node(
53
- id:,
54
-
55
- _return_fields: %i[name]
56
- )
57
- ].flatten
47
+ [service.get_cluster_node(id: id, _return_fields: %i[name])].flatten
58
48
  end
59
49
  end
60
50
  end
@@ -15,7 +15,7 @@ class Fog::Hyperv::Compute
15
15
 
16
16
  raise ArgumentError, 'Must provide a name or GUID' if (id.nil? || id.empty?) && (name.nil? || name.empty?)
17
17
 
18
- super(name:, _by_id: id, **filters)
18
+ super(name: name, _by_id: id, **filters)
19
19
  end
20
20
  end
21
21
  end
@@ -39,9 +39,9 @@ class Fog::Hyperv::Compute
39
39
 
40
40
  merge_attributes(
41
41
  service.set_vm_com_port(
42
- computer_name:,
43
- vm_id:,
44
- id:,
42
+ computer_name: computer_name,
43
+ vm_id: vm_id,
44
+ id: id,
45
45
 
46
46
  **changes,
47
47
 
@@ -56,9 +56,9 @@ class Fog::Hyperv::Compute
56
56
  requires :vm_id, :id
57
57
 
58
58
  data = service.get_vm_com_port(
59
- computer_name:,
60
- vm_id:,
61
- id:,
59
+ computer_name: computer_name,
60
+ vm_id: vm_id,
61
+ id: id,
62
62
 
63
63
  _return_fields: self.class.attributes
64
64
  )
@@ -53,13 +53,13 @@ class Fog::Hyperv::Compute
53
53
 
54
54
  merge_attributes(
55
55
  service.add_vm_dvd_drive(
56
- computer_name:,
57
- vm_id:,
56
+ computer_name: computer_name,
57
+ vm_id: vm_id,
58
58
 
59
- allow_unverified_paths:,
60
- controller_number:,
61
- controller_location:,
62
- path:,
59
+ allow_unverified_paths: allow_unverified_paths,
60
+ controller_number: controller_numbere,
61
+ controller_location: controller_location,
62
+ path: path,
63
63
  resource_pool_name: pool_name,
64
64
 
65
65
  _return_fields: self.class.attributes
@@ -86,7 +86,7 @@ class Fog::Hyperv::Compute
86
86
  vm_id: old.vm_id,
87
87
  id: old.id,
88
88
 
89
- allow_unverified_paths:,
89
+ allow_unverified_paths: allow_unverified_paths,
90
90
  **changes,
91
91
 
92
92
  _always_include: changes.keys,
@@ -100,9 +100,9 @@ class Fog::Hyperv::Compute
100
100
  requires :id, :vm_id
101
101
 
102
102
  service.remove_vm_dvd_drive(
103
- computer_name:,
104
- vm_id:,
105
- id:
103
+ computer_name: computer_name,
104
+ vm_id: vm_id,
105
+ id: id
106
106
  )
107
107
  true
108
108
  end
@@ -112,9 +112,9 @@ class Fog::Hyperv::Compute
112
112
  requires :id, :vm_id
113
113
 
114
114
  data = service.get_vm_dvd_drive(
115
- computer_name:,
116
- vm_id:,
117
- id:,
115
+ computer_name: computer_name,
116
+ vm_id: vm_id,
117
+ id: id,
118
118
 
119
119
  _return_fields: self.class.attributes
120
120
  )
@@ -52,8 +52,8 @@ class Fog::Hyperv::Compute
52
52
 
53
53
  merge_attributes(
54
54
  service.set_vm_firmware(
55
- computer_name:,
56
- vm_id:,
55
+ computer_name: computer_name,
56
+ vm_id: vm_id,
57
57
 
58
58
  _return_fields: self.class.attributes
59
59
  )
@@ -65,8 +65,8 @@ class Fog::Hyperv::Compute
65
65
  requires :vm_id
66
66
 
67
67
  data = service.get_vm_firmware(
68
- computer_name:,
69
- vm_id:,
68
+ computer_name: computer_name,
69
+ vm_id: vm_id,
70
70
 
71
71
  _return_fields: self.class.attributes
72
72
  )
@@ -34,9 +34,9 @@ class Fog::Hyperv::Compute
34
34
 
35
35
  merge_attributes(
36
36
  service.set_vm_floppy_disk_drive(
37
- computer_name:,
38
- vm_id:,
39
- id:,
37
+ computer_name: computer_name,
38
+ vm_id: vm_id,
39
+ id: id,
40
40
 
41
41
  **changes,
42
42
 
@@ -50,9 +50,9 @@ class Fog::Hyperv::Compute
50
50
  requires :vm_id, :id
51
51
 
52
52
  data = service.get_vm_floppy_disk_drive(
53
- computer_name:,
54
- vm_id:,
55
- id:,
53
+ computer_name: computer_name,
54
+ vm_id: vm_id,
55
+ id: id,
56
56
 
57
57
  _return_fields: self.class.attributes
58
58
  )
@@ -67,7 +67,7 @@ class Fog::Hyperv::Compute
67
67
  return associations[:vhd] if associations[:vhd]
68
68
  return unless path
69
69
 
70
- associations[:vhd] = service.vhds.get(path, computer_name:)
70
+ associations[:vhd] = service.vhds.get(path, computer_name: computer_name)
71
71
  end
72
72
 
73
73
  def vhd=(new_vhd)
@@ -99,17 +99,17 @@ class Fog::Hyperv::Compute
99
99
 
100
100
  merge_attributes(
101
101
  service.add_vm_hard_disk_drive(
102
- computer_name:,
103
- vm_id:,
104
-
105
- allow_unverified_paths:,
106
- controller_location:,
107
- controller_number:,
108
- controller_type:,
109
- # disk_number: disk&.number,
110
- maximum_iops:,
111
- minimum_iops:,
112
- path:,
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
113
  resource_pool_name: pool_name,
114
114
 
115
115
  _return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
@@ -139,7 +139,7 @@ class Fog::Hyperv::Compute
139
139
  id: old.id,
140
140
 
141
141
  **changes,
142
- allow_unverified_paths:,
142
+ allow_unverified_paths: allow_unverified_paths,
143
143
 
144
144
  _always_include: changes.keys,
145
145
  _return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
@@ -159,9 +159,9 @@ class Fog::Hyperv::Compute
159
159
  requires :id, :vm_id
160
160
 
161
161
  data = service.get_vm_hard_disk_drive(
162
- computer_name:,
163
- vm_id:,
164
- id:,
162
+ computer_name: computer_name,
163
+ vm_id: vm_id,
164
+ id: id,
165
165
 
166
166
  _return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
167
167
  )
@@ -175,11 +175,7 @@ class Fog::Hyperv::Compute
175
175
 
176
176
  requires :id, :vm_id
177
177
 
178
- service.remove_vm_hard_disk_drive(
179
- computer_name:,
180
- vm_id:,
181
- id:
182
- )
178
+ service.remove_vm_hard_disk_drive computer_name: computer_name, vm_id: vm_id, id: id
183
179
  vhd.destroy if underlying && vhd?
184
180
  true
185
181
  end
@@ -54,10 +54,7 @@ class Fog::Hyperv::Compute
54
54
  def reload
55
55
  requires :name
56
56
 
57
- data = service.get_vm_host(
58
- computer_name:,
59
- name:
60
- )
57
+ data = service.get_vm_host computer_name: computer_name, name: name
61
58
  return unless data
62
59
 
63
60
  merge_attributes(data)
@@ -118,10 +118,10 @@ class Fog::Hyperv::Compute
118
118
 
119
119
  associations[:vlan_setting] = Fog::Hyperv::Compute::NetworkAdapterVlan.new(
120
120
  **service.get_vm_network_adapter_vlan(
121
- computer_name:,
121
+ computer_name: computer_name,
122
122
  management_os: is_management_os,
123
- vm_id:,
124
- id:,
123
+ vm_id: vm_id,
124
+ id: id,
125
125
 
126
126
  _return_fields: Fog::Hyperv::Compute::NetworkAdapterVlan.attributes
127
127
  ),
@@ -147,9 +147,9 @@ class Fog::Hyperv::Compute
147
147
  options[:management_os] = true if is_management_os
148
148
 
149
149
  service.connect_vm_network_adapter(
150
- computer_name:,
151
- vm_id:,
152
- id:,
150
+ computer_name: computer_name,
151
+ vm_id: vm_id,
152
+ id: id,
153
153
 
154
154
  switch_id: new_switch_id,
155
155
  switch_name: new_switch_name,
@@ -168,9 +168,9 @@ class Fog::Hyperv::Compute
168
168
 
169
169
  options[:management_os] = true if is_management_os
170
170
  service.disconnect_vm_network_adapter(
171
- computer_name:,
172
- vm_id:,
173
- id:,
171
+ computer_name: computer_name,
172
+ vm_id: vm_id,
173
+ id: id,
174
174
 
175
175
  **options
176
176
  )
@@ -185,7 +185,13 @@ class Fog::Hyperv::Compute
185
185
  # @see connect
186
186
  # @see disconnect
187
187
  def switch
188
- service.switches.get(switch_id:, switch_name:, computer_name:) if switch_name.any? || switch_id.any?
188
+ return unless switch_name.any? || switch_id.any?
189
+
190
+ service.switches.get(
191
+ switch_id: switch_id,
192
+ switch_name: switch_name,
193
+ computer_name: computer_name
194
+ )
189
195
  end
190
196
 
191
197
  def switch=(new_switch)
@@ -212,7 +218,7 @@ class Fog::Hyperv::Compute
212
218
  selector[:vm_id] = vm_id
213
219
  end
214
220
 
215
- args = { name:, switch_name: }
221
+ args = attributes.slice(:name, :switch_name)
216
222
  args[:is_legacy] = true if is_legacy
217
223
  if !dynamic_mac_address_enabled && mac_address != NIC_FALLBACK_MAC
218
224
  args[:static_mac_address] = mac_address
@@ -221,7 +227,7 @@ class Fog::Hyperv::Compute
221
227
  end
222
228
  data = service.add_vm_network_adapter(
223
229
  **selector,
224
- computer_name:,
230
+ computer_name: computer_name,
225
231
 
226
232
  **args,
227
233
 
@@ -293,9 +299,9 @@ class Fog::Hyperv::Compute
293
299
  requires :vm_id unless is_management_os
294
300
 
295
301
  service.remove_vm_network_adapter(
296
- computer_name:,
297
- vm_id:,
298
- id:,
302
+ computer_name: computer_name,
303
+ vm_id: vm_id,
304
+ id: id,
299
305
  management_os: is_management_os
300
306
  )
301
307
  true
@@ -306,9 +312,9 @@ class Fog::Hyperv::Compute
306
312
  requires :vm_id unless is_management_os
307
313
 
308
314
  data = service.get_vm_network_adapter(
309
- computer_name:,
310
- vm_id:,
311
- id:,
315
+ computer_name: computer_name,
316
+ vm_id: vm_id,
317
+ id: id,
312
318
  management_os: is_management_os,
313
319
 
314
320
  _return_fields: self.class.attributes
@@ -348,11 +354,11 @@ class Fog::Hyperv::Compute
348
354
  end
349
355
 
350
356
  def save_switch
351
- selector = { computer_name:, vm_id:, id: }.compact
357
+ selector = attributes.slice(:computer_name, :vm_id, :id).compact
352
358
  selector[:management_os] = true if is_management_os
353
359
 
354
360
  if switch_name || switch_id
355
- service.connect_vm_network_adapter(**selector, switch_name:, switch_id:)
361
+ service.connect_vm_network_adapter(**selector, switch_name: switch_name, switch_id: switch_id)
356
362
  else
357
363
  service.disconnect_vm_network_adapter(**selector)
358
364
  end
@@ -18,7 +18,7 @@ class Fog::Hyperv::Compute
18
18
 
19
19
  raise ArgumentError, 'Must provide a name or combined GUID' if id.nil? && name.nil?
20
20
 
21
- super(name:, _by_id: id, **filters)
21
+ super(name: name, _by_id: id, **filters)
22
22
  end
23
23
 
24
24
  protected
@@ -194,8 +194,8 @@ class Fog::Hyperv::Compute
194
194
  klass.new(
195
195
  **service.public_send(
196
196
  method,
197
- computer_name:,
198
- vm_id:,
197
+ computer_name: computer_name,
198
+ vm_id: vm_id,
199
199
 
200
200
  _return_fields: klass.attributes
201
201
  ),
@@ -217,8 +217,8 @@ class Fog::Hyperv::Compute
217
217
 
218
218
  associations[:security] ||= Fog::Hyperv::Compute::Security.new(
219
219
  **service.get_vm_security(
220
- computer_name:,
221
- vm_id:,
220
+ computer_name: computer_name,
221
+ vm_id: vm_id,
222
222
 
223
223
  _return_fields: Fog::Hyperv::Compute::Security.attributes
224
224
  ),
@@ -249,7 +249,7 @@ class Fog::Hyperv::Compute
249
249
  def start
250
250
  requires :id
251
251
 
252
- service.start_vm(computer_name:, id:)
252
+ service.start_vm(computer_name: computer_name, id: id)
253
253
  true
254
254
  end
255
255
 
@@ -258,7 +258,7 @@ class Fog::Hyperv::Compute
258
258
  def stop(turn_off: false)
259
259
  requires :id
260
260
 
261
- service.stop_vm(computer_name:, id:, turn_off:)
261
+ service.stop_vm(computer_name: computer_name, id: id, turn_off: turn_off)
262
262
  true
263
263
  end
264
264
 
@@ -266,7 +266,7 @@ class Fog::Hyperv::Compute
266
266
  def suspend
267
267
  requires :id
268
268
 
269
- service.suspend_vm(computer_name:, id:)
269
+ service.suspend_vm(computer_name: computer_name, id: id)
270
270
  true
271
271
  end
272
272
 
@@ -274,7 +274,7 @@ class Fog::Hyperv::Compute
274
274
  def resume
275
275
  requires :id
276
276
 
277
- service.resume_vm(computer_name:, id:)
277
+ service.resume_vm(computer_name: computer_name, id: id)
278
278
  true
279
279
  end
280
280
 
@@ -282,7 +282,7 @@ class Fog::Hyperv::Compute
282
282
  def hibernate
283
283
  requires :id
284
284
 
285
- service.save_vm(computer_name:, id:)
285
+ service.save_vm(computer_name: computer_name, id: id)
286
286
  true
287
287
  end
288
288
 
@@ -291,7 +291,7 @@ class Fog::Hyperv::Compute
291
291
  def restart
292
292
  requires :id
293
293
 
294
- service.restart_vm(computer_name:, id:, force:)
294
+ service.restart_vm(computer_name: computer_name, id: id)
295
295
  true
296
296
  end
297
297
  alias reboot :restart
@@ -300,7 +300,7 @@ class Fog::Hyperv::Compute
300
300
  def update_version
301
301
  requires :id
302
302
 
303
- service.update_vm(computer_name:, id:)
303
+ service.update_vm(computer_name: computer_name, id: id)
304
304
  true
305
305
  end
306
306
 
@@ -311,7 +311,7 @@ class Fog::Hyperv::Compute
311
311
  requires :id
312
312
  stop turn_off: true if ready?
313
313
 
314
- service.remove_vm(computer_name:, id:)
314
+ service.remove_vm(computer_name: computer_name, id: id)
315
315
  true
316
316
  end
317
317
 
@@ -337,13 +337,13 @@ class Fog::Hyperv::Compute
337
337
 
338
338
  merge_attributes(
339
339
  service.new_vm(
340
- computer_name:,
341
- name:,
340
+ computer_name: computer_name,
341
+ name: name,
342
342
 
343
343
  generation: generation_num,
344
344
  memory_startup_bytes: memory_startup,
345
- boot_device:,
346
- switch_name:,
345
+ boot_device: boot_device,
346
+ switch_name: switch_name,
347
347
 
348
348
  **attrs,
349
349
 
@@ -411,7 +411,7 @@ class Fog::Hyperv::Compute
411
411
  def reload
412
412
  requires :id
413
413
 
414
- data = service.get_vm computer_name:, id:, _return_fields: self.class.attributes
414
+ data = service.get_vm computer_name: computer_name, id: id, _return_fields: self.class.attributes
415
415
  return unless data
416
416
 
417
417
  merge_attributes(data)
@@ -12,7 +12,7 @@ class Fog::Hyperv::Compute
12
12
 
13
13
  raise ArgumentError, 'Must provide a name or GUID' if (id.nil? || id.empty?) && (name.nil? || name.empty?)
14
14
 
15
- super(name:, id:, **filters)
15
+ super(name: name, id: id, **filters)
16
16
  end
17
17
  end
18
18
  end
@@ -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
 
@@ -14,7 +14,7 @@ class Fog::Hyperv::Compute
14
14
 
15
15
  raise ArgumentError, 'Must provide a name or GUID' if (id.nil? || id.empty?) && (name.nil? || name.empty?)
16
16
 
17
- super(name:, id:, **filter)
17
+ super(name: name, id: id, **filter)
18
18
  end
19
19
  end
20
20
  end
@@ -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,8 +170,8 @@ 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
175
175
  )
176
176
  true
177
177
  end
@@ -184,9 +184,9 @@ class Fog::Hyperv::Compute
184
184
  requires :path
185
185
 
186
186
  service.optimize_vhd(
187
- computer_name:,
188
- path:,
189
- mode:
187
+ computer_name: computer_name,
188
+ path: path,
189
+ mode: mode
190
190
  )
191
191
  true
192
192
  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:, **filters)
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:, **options }]
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)
@@ -3,9 +3,9 @@
3
3
  class Fog::Hyperv::Compute
4
4
  class Real
5
5
  def get_cluster(**options)
6
- _by_id = options.delete(:id)
6
+ by_id = options.delete(:id)
7
7
 
8
- run_cmd 'Get-Cluster', _by_id:, **options
8
+ run_cmd 'Get-Cluster', _by_id: by_id, **options
9
9
  end
10
10
  end
11
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
- _by_id = options.delete :id
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:, **options }]
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
- _by_id = options.delete :id
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:, **options }]
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
- _by_id = options.delete :id
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:, **options }]
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
- _by_id = options.delete :id
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:, **options }]
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:, **options
8
+ run_cmd 'Get-VMHostCluster', _target_computer: computer_name, cluster_name: cluster_name, **options
9
9
  end
10
10
  end
11
11
 
@@ -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:, size_bytes:, **options
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:, **options
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:, **options
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:, force: true, **options
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,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def remove_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Remove-VM', { force: true, **options }]
10
10
  ],
11
11
  skip_json: true,
@@ -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:, **options }]
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:, **options }]
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 'Rename-VMSwitch', new_name:, _target_computer: computer_name, _by_id: id, _skip_json: true, **options
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 'Resize-VHD', _target_computer: computer_name, _skip_json: true, path:, size_bytes:, **options
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
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def restart_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Restart-VM', { force: true, **options }]
10
10
  ],
11
11
  skip_json: true,
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def resume_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Resume-VM', options]
10
10
  ],
11
11
  skip_json: true,
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def save_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Save-VM', options]
10
10
  ],
11
11
  skip_json: true,
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def set_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Set-VM', { passthru: true, **options }]
10
10
  ],
11
11
  target_computer: computer_name
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def start_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Start-VM', options]
10
10
  ],
11
11
  skip_json: true,
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def stop_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Stop-VM', { force: true, **options }]
10
10
  ],
11
11
  skip_json: true,
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def suspend_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Suspend-VM', options]
10
10
  ],
11
11
  skip_json: true,
@@ -5,7 +5,7 @@ class Fog::Hyperv::Compute
5
5
  def update_vm(id:, computer_name: nil, **options)
6
6
  run_cmdlist(
7
7
  [
8
- ['$VM = Get-VM', { id: }],
8
+ ['$VM = Get-VM', { id: id }],
9
9
  ['$VM | Update-VM', options]
10
10
  ],
11
11
  skip_json: true,
@@ -14,11 +14,11 @@ module Fog::Hyperv
14
14
  case to_s
15
15
  when 'Fog::Hyperv::Compute::Server'
16
16
  define_method name do
17
- associations[name] ||= service.send(collection_name, vm: self, computer_name:, vm_id: id)
17
+ associations[name] ||= service.send(collection_name, vm: self, computer_name: computer_name, vm_id: id)
18
18
  end
19
19
  when 'Fog::Hyperv::Compute::Host'
20
20
  define_method name do
21
- associations[name] ||= service.send(collection_name, computer: self, computer_name:)
21
+ associations[name] ||= service.send(collection_name, computer: self, computer_name: computer_name)
22
22
  end
23
23
  else
24
24
  raise "Unknown class #{self}"
@@ -45,7 +45,7 @@ module Fog::Hyperv::Utils::Powershell
45
45
  optmap = "Fog#{id}"
46
46
 
47
47
  commands = []
48
- commands += build_optmap(_optmap_name: optmap, _ps_version:, **args)
48
+ commands += build_optmap(_optmap_name: optmap, _ps_version: _ps_version, **args)
49
49
  commands << if cmdlet.include? '@Args'
50
50
  cmdlet.gsub('@Args', "@#{optmap}")
51
51
  else
@@ -151,7 +151,7 @@ module Fog::Hyperv::Utils::Winrm
151
151
 
152
152
  command += ' @Args' unless command.include? '@Args'
153
153
  pipeline = [command] + pipeline
154
- Fog::Hyperv::Utils::Powershell.build_call(pipeline.join(' | '), options, _ps_version:)
154
+ Fog::Hyperv::Utils::Powershell.build_call(pipeline.join(' | '), options, _ps_version: _ps_version)
155
155
  end
156
156
 
157
157
  def connection(host)
@@ -3,6 +3,6 @@
3
3
  module Fog
4
4
  module Hyperv
5
5
  # The Fog Hyper-V version
6
- VERSION = '0.1.0'
6
+ VERSION = '0.1.1'
7
7
  end
8
8
  end
data/lib/fog/hyperv.rb CHANGED
@@ -56,14 +56,16 @@ module Fog
56
56
 
57
57
  private
58
58
 
59
+ # rubocop:disable Naming/MemoizedInstanceVariableName -- Extracting message, not reading it
59
60
  def extract_message
60
61
  stderr = @stderr.split("\n").map(&:strip)
61
62
 
62
63
  # Find a line ending in an error ID
63
- @message = stderr.find { |line| line =~ /\(0x[0-9a-f]+\)\.?$/}
64
+ @message = stderr.find { |line| line =~ /\(0x[0-9a-f]+\)\.?$/ }
64
65
  # Find the last line that isn't include error class information
65
66
  @message ||= stderr.take_while { |line| !line.start_with? '+' }.last
66
67
  end
68
+ # rubocop:enable Naming/MemoizedInstanceVariableName
67
69
  end
68
70
  end
69
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-hyperv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson