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.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/lib/fog/bin/hyperv.rb +6 -4
- data/lib/fog/hyperv/collection.rb +89 -0
- data/lib/fog/hyperv/compute/models/bios.rb +70 -0
- data/lib/fog/hyperv/compute/models/cluster.rb +50 -0
- data/lib/fog/hyperv/compute/models/clusters.rb +21 -0
- data/lib/fog/hyperv/compute/models/com_port.rb +78 -0
- data/lib/fog/hyperv/compute/models/com_ports.rb +29 -0
- data/lib/fog/hyperv/compute/models/dvd_drive.rb +126 -0
- data/lib/fog/hyperv/compute/models/dvd_drives.rb +29 -0
- data/lib/fog/hyperv/compute/models/firmware.rb +78 -0
- data/lib/fog/hyperv/compute/models/floppy_drive.rb +64 -0
- data/lib/fog/hyperv/compute/models/floppy_drives.rb +18 -0
- data/lib/fog/hyperv/compute/models/hard_drive.rb +183 -0
- data/lib/fog/hyperv/compute/models/hard_drives.rb +28 -0
- data/lib/fog/hyperv/compute/models/host.rb +63 -0
- data/lib/fog/hyperv/compute/models/hosts.rb +13 -0
- data/lib/fog/hyperv/compute/models/network_adapter.rb +368 -0
- data/lib/fog/hyperv/compute/models/network_adapter_vlan.rb +172 -0
- data/lib/fog/hyperv/compute/models/network_adapters.rb +32 -0
- data/lib/fog/hyperv/compute/models/security.rb +121 -0
- data/lib/fog/hyperv/compute/models/server.rb +466 -0
- data/lib/fog/hyperv/compute/models/servers.rb +18 -0
- data/lib/fog/hyperv/compute/models/switch.rb +117 -0
- data/lib/fog/hyperv/compute/models/switches.rb +20 -0
- data/lib/fog/hyperv/compute/models/vhd.rb +210 -0
- data/lib/fog/hyperv/compute/models/vhds.rb +28 -0
- data/lib/fog/hyperv/compute/requests/add_vm_dvd_drive.rb +15 -0
- data/lib/fog/hyperv/compute/requests/add_vm_hard_disk_drive.rb +15 -0
- data/lib/fog/hyperv/compute/requests/add_vm_network_adapter.rb +24 -0
- data/lib/fog/hyperv/compute/requests/connect_vm_network_adapter.rb +41 -0
- data/lib/fog/hyperv/compute/requests/disable_vm_tpm.rb +16 -0
- data/lib/fog/hyperv/compute/requests/disconnect_vm_network_adapter.rb +29 -0
- data/lib/fog/hyperv/compute/requests/enable_vm_tpm.rb +16 -0
- data/lib/fog/hyperv/compute/requests/get_cluster.rb +11 -0
- data/lib/fog/hyperv/compute/requests/get_cluster_node.rb +22 -0
- data/lib/fog/hyperv/compute/requests/get_vhd.rb +32 -0
- data/lib/fog/hyperv/compute/requests/get_vm.rb +18 -0
- data/lib/fog/hyperv/compute/requests/get_vm_bios.rb +21 -0
- data/lib/fog/hyperv/compute/requests/get_vm_com_port.rb +17 -0
- data/lib/fog/hyperv/compute/requests/get_vm_dvd_drive.rb +25 -0
- data/lib/fog/hyperv/compute/requests/get_vm_firmware.rb +21 -0
- data/lib/fog/hyperv/compute/requests/get_vm_floppy_disk_drive.rb +16 -0
- data/lib/fog/hyperv/compute/requests/get_vm_group.rb +20 -0
- data/lib/fog/hyperv/compute/requests/get_vm_hard_disk_drive.rb +24 -0
- data/lib/fog/hyperv/compute/requests/get_vm_host.rb +9 -0
- data/lib/fog/hyperv/compute/requests/get_vm_host_cluster.rb +21 -0
- data/lib/fog/hyperv/compute/requests/get_vm_host_sbt.rb +10 -0
- data/lib/fog/hyperv/compute/requests/get_vm_key_protector.rb +16 -0
- data/lib/fog/hyperv/compute/requests/get_vm_network_adapter.rb +41 -0
- data/lib/fog/hyperv/compute/requests/get_vm_network_adapter_vlan.rb +41 -0
- data/lib/fog/hyperv/compute/requests/get_vm_security.rb +15 -0
- data/lib/fog/hyperv/compute/requests/get_vm_switch.rb +10 -0
- data/lib/fog/hyperv/compute/requests/mock_files/get_vm.json +4 -0
- data/lib/fog/hyperv/compute/requests/new_vhd.rb +9 -0
- data/lib/fog/hyperv/compute/requests/new_vm.rb +12 -0
- data/lib/fog/hyperv/compute/requests/new_vm_switch.rb +11 -0
- data/lib/fog/hyperv/compute/requests/optimize_vhd.rb +9 -0
- data/lib/fog/hyperv/compute/requests/remove_item.rb +10 -0
- data/lib/fog/hyperv/compute/requests/remove_vm.rb +16 -0
- data/lib/fog/hyperv/compute/requests/remove_vm_dvd_drive.rb +17 -0
- data/lib/fog/hyperv/compute/requests/remove_vm_hard_disk_drive.rb +17 -0
- data/lib/fog/hyperv/compute/requests/remove_vm_network_adapter.rb +29 -0
- data/lib/fog/hyperv/compute/requests/remove_vm_switch.rb +9 -0
- data/lib/fog/hyperv/compute/requests/rename_vm.rb +16 -0
- data/lib/fog/hyperv/compute/requests/rename_vm_network_adapter.rb +25 -0
- data/lib/fog/hyperv/compute/requests/rename_vm_switch.rb +16 -0
- data/lib/fog/hyperv/compute/requests/resize_vhd.rb +16 -0
- data/lib/fog/hyperv/compute/requests/restart_vm.rb +22 -0
- data/lib/fog/hyperv/compute/requests/resume_vm.rb +22 -0
- data/lib/fog/hyperv/compute/requests/save_vm.rb +22 -0
- data/lib/fog/hyperv/compute/requests/set_vm.rb +15 -0
- data/lib/fog/hyperv/compute/requests/set_vm_bios.rb +15 -0
- data/lib/fog/hyperv/compute/requests/set_vm_com_port.rb +16 -0
- data/lib/fog/hyperv/compute/requests/set_vm_dvd_drive.rb +16 -0
- data/lib/fog/hyperv/compute/requests/set_vm_firmware.rb +15 -0
- data/lib/fog/hyperv/compute/requests/set_vm_floppy_disk_drive.rb +16 -0
- data/lib/fog/hyperv/compute/requests/set_vm_hard_disk_drive.rb +16 -0
- data/lib/fog/hyperv/compute/requests/set_vm_key_protector.rb +15 -0
- data/lib/fog/hyperv/compute/requests/set_vm_network_adapter.rb +25 -0
- data/lib/fog/hyperv/compute/requests/set_vm_network_adapter_vlan.rb +25 -0
- data/lib/fog/hyperv/compute/requests/set_vm_security.rb +17 -0
- data/lib/fog/hyperv/compute/requests/set_vm_switch.rb +9 -0
- data/lib/fog/hyperv/compute/requests/start_vm.rb +22 -0
- data/lib/fog/hyperv/compute/requests/stop_vm.rb +22 -0
- data/lib/fog/hyperv/compute/requests/suspend_vm.rb +22 -0
- data/lib/fog/hyperv/compute/requests/update_vm.rb +22 -0
- data/lib/fog/hyperv/compute.rb +206 -387
- data/lib/fog/hyperv/constants.rb +24 -0
- data/lib/fog/hyperv/fog_extensions/associations/collection.rb +11 -0
- data/lib/fog/hyperv/fog_extensions/attributes/datetime.rb +28 -0
- data/lib/fog/hyperv/fog_extensions/attributes/enum.rb +139 -0
- data/lib/fog/hyperv/fog_extensions/attributes/enumarray.rb +149 -0
- data/lib/fog/hyperv/fog_extensions/attributes/timespan.rb +27 -0
- data/lib/fog/hyperv/model.rb +142 -0
- data/lib/fog/hyperv/utils/powershell.rb +88 -0
- data/lib/fog/hyperv/utils/winrm.rb +233 -0
- data/lib/fog/hyperv/version.rb +4 -1
- data/lib/fog/hyperv.rb +53 -44
- metadata +187 -105
- data/.gitignore +0 -10
- data/.travis.yml +0 -11
- data/CHANGELOG.md +0 -52
- data/Gemfile +0 -4
- data/Rakefile +0 -10
- data/fog-hyperv.gemspec +0 -25
- data/lib/fog/collection.rb +0 -152
- data/lib/fog/hyperv/fog_extensions/enum.rb +0 -85
- data/lib/fog/hyperv/models/compute/bios.rb +0 -61
- data/lib/fog/hyperv/models/compute/cluster.rb +0 -64
- data/lib/fog/hyperv/models/compute/clusters.rb +0 -15
- data/lib/fog/hyperv/models/compute/com_port.rb +0 -22
- data/lib/fog/hyperv/models/compute/dvd_drive.rb +0 -92
- data/lib/fog/hyperv/models/compute/dvd_drives.rb +0 -12
- data/lib/fog/hyperv/models/compute/firmware.rb +0 -53
- data/lib/fog/hyperv/models/compute/floppy_drive.rb +0 -53
- data/lib/fog/hyperv/models/compute/floppy_drives.rb +0 -12
- data/lib/fog/hyperv/models/compute/hard_drive.rb +0 -110
- data/lib/fog/hyperv/models/compute/hard_drives.rb +0 -11
- data/lib/fog/hyperv/models/compute/host.rb +0 -45
- data/lib/fog/hyperv/models/compute/hosts.rb +0 -15
- data/lib/fog/hyperv/models/compute/network_adapter.rb +0 -145
- data/lib/fog/hyperv/models/compute/network_adapters.rb +0 -19
- data/lib/fog/hyperv/models/compute/server.rb +0 -220
- data/lib/fog/hyperv/models/compute/servers.rb +0 -21
- data/lib/fog/hyperv/models/compute/switch.rb +0 -65
- data/lib/fog/hyperv/models/compute/switches.rb +0 -15
- data/lib/fog/hyperv/models/compute/vhd.rb +0 -101
- data/lib/fog/hyperv/models/compute/vhds.rb +0 -16
- data/lib/fog/hyperv/requests/compute/add_vm_dvd_drive.rb +0 -12
- data/lib/fog/hyperv/requests/compute/add_vm_hard_disk_drive.rb +0 -12
- data/lib/fog/hyperv/requests/compute/add_vm_network_adapter.rb +0 -12
- data/lib/fog/hyperv/requests/compute/connect_vm_network_adapter.rb +0 -12
- data/lib/fog/hyperv/requests/compute/disconnect_vm_network_adapter.rb +0 -12
- data/lib/fog/hyperv/requests/compute/get_cluster.rb +0 -11
- data/lib/fog/hyperv/requests/compute/get_cluster_node.rb +0 -19
- data/lib/fog/hyperv/requests/compute/get_vhd.rb +0 -34
- data/lib/fog/hyperv/requests/compute/get_vm.rb +0 -20
- data/lib/fog/hyperv/requests/compute/get_vm_bios.rb +0 -21
- data/lib/fog/hyperv/requests/compute/get_vm_dvd_drive.rb +0 -20
- data/lib/fog/hyperv/requests/compute/get_vm_firmware.rb +0 -19
- data/lib/fog/hyperv/requests/compute/get_vm_floppy_disk_drive.rb +0 -20
- data/lib/fog/hyperv/requests/compute/get_vm_group.rb +0 -23
- data/lib/fog/hyperv/requests/compute/get_vm_hard_disk_drive.rb +0 -20
- data/lib/fog/hyperv/requests/compute/get_vm_host.rb +0 -12
- data/lib/fog/hyperv/requests/compute/get_vm_host_cluster.rb +0 -25
- data/lib/fog/hyperv/requests/compute/get_vm_network_adapter.rb +0 -27
- data/lib/fog/hyperv/requests/compute/get_vm_switch.rb +0 -27
- data/lib/fog/hyperv/requests/compute/mock_files/get_vm.json +0 -1
- data/lib/fog/hyperv/requests/compute/new_vhd.rb +0 -12
- data/lib/fog/hyperv/requests/compute/new_vm.rb +0 -15
- data/lib/fog/hyperv/requests/compute/new_vm_switch.rb +0 -13
- data/lib/fog/hyperv/requests/compute/remove_item.rb +0 -13
- data/lib/fog/hyperv/requests/compute/remove_vm.rb +0 -15
- data/lib/fog/hyperv/requests/compute/remove_vm_dvd_drive.rb +0 -12
- data/lib/fog/hyperv/requests/compute/remove_vm_hard_disk_drive.rb +0 -12
- data/lib/fog/hyperv/requests/compute/remove_vm_network_adapter.rb +0 -12
- data/lib/fog/hyperv/requests/compute/restart_vm.rb +0 -15
- data/lib/fog/hyperv/requests/compute/set_vm.rb +0 -12
- data/lib/fog/hyperv/requests/compute/set_vm_bios.rb +0 -13
- data/lib/fog/hyperv/requests/compute/set_vm_dvd_drive.rb +0 -12
- data/lib/fog/hyperv/requests/compute/set_vm_firmware.rb +0 -13
- data/lib/fog/hyperv/requests/compute/set_vm_hard_disk_drive.rb +0 -12
- data/lib/fog/hyperv/requests/compute/set_vm_network_adapter.rb +0 -12
- data/lib/fog/hyperv/requests/compute/set_vm_network_adapter_vlan.rb +0 -12
- data/lib/fog/hyperv/requests/compute/set_vm_switch.rb +0 -13
- data/lib/fog/hyperv/requests/compute/start_vm.rb +0 -15
- data/lib/fog/hyperv/requests/compute/stop_vm.rb +0 -15
- data/lib/fog/model.rb +0 -91
- data/test/fog/hyperv_test.rb +0 -7
- data/test/test_helper.rb +0 -4
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_cluster.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_cluster_node.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vhd.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_bios.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_dvd_drive.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_firmware.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_floppy_disk_drive.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_hard_disk_drive.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_host.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_network_adapter.json +0 -0
- /data/lib/fog/hyperv/{requests/compute → compute/requests}/mock_files/get_vm_switch.json +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
# Retrieve SecureBoot Templates for a VM Host
|
|
6
|
+
def get_vm_key_protector(vm_id:, computer_name: nil, **options)
|
|
7
|
+
run_cmdlist(
|
|
8
|
+
[
|
|
9
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
10
|
+
['$VM | Get-VMKeyProtector', options]
|
|
11
|
+
],
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def get_vm_network_adapter(computer_name: nil, **options)
|
|
6
|
+
requires_one options, :vm_id, :all, :management_os
|
|
7
|
+
|
|
8
|
+
id = options.delete :id
|
|
9
|
+
if options[:vm_id]
|
|
10
|
+
vm_id = options.delete :vm_id
|
|
11
|
+
options.delete :management_os
|
|
12
|
+
options.delete :all
|
|
13
|
+
run_cmdlist(
|
|
14
|
+
[
|
|
15
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
16
|
+
['$VM | Get-VMNetworkAdapter', { _by_id: id, **options }]
|
|
17
|
+
],
|
|
18
|
+
target_computer: computer_name
|
|
19
|
+
)
|
|
20
|
+
else
|
|
21
|
+
options.delete :management_os if options[:all]
|
|
22
|
+
run_cmd 'Get-VMNetworkAdapter', _by_id: id, _target_computer: computer_name, **options
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Mock
|
|
28
|
+
def get_vm_network_adapter(**args)
|
|
29
|
+
requires_one args, :vm_name, :all, :management_os
|
|
30
|
+
|
|
31
|
+
data = handle_mock_response(args)
|
|
32
|
+
if args[:all]
|
|
33
|
+
data
|
|
34
|
+
elsif args[:vm_name]
|
|
35
|
+
data.find { |i| i[:vm_name].casecmp(args[:vm_name]).zero? }
|
|
36
|
+
elsif args[:management_os]
|
|
37
|
+
data.find { |i| i[:is_management_os] }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def get_vm_network_adapter_vlan(id:, computer_name: nil, **options)
|
|
6
|
+
requires_one options, :vm_id, :management_os
|
|
7
|
+
|
|
8
|
+
commands = []
|
|
9
|
+
if options.key? :vm_id
|
|
10
|
+
vm_id = options.delete :vm_id
|
|
11
|
+
options.delete :management_os
|
|
12
|
+
commands += [
|
|
13
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
14
|
+
['$NIC = $VM | Get-VMNetworkAdapter', { _by_id: id }]
|
|
15
|
+
]
|
|
16
|
+
else
|
|
17
|
+
options.delete :management_os
|
|
18
|
+
commands << ['$NIC = Get-VMNetworkAdapter', { management_os: true, _by_id: id }]
|
|
19
|
+
end
|
|
20
|
+
commands << ['$NIC | Get-VMNetworkAdapterVlan', options]
|
|
21
|
+
|
|
22
|
+
run_cmdlist(
|
|
23
|
+
commands,
|
|
24
|
+
target_computer: computer_name
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class Mock
|
|
30
|
+
def get_vm_network_adapter_vlan(**args)
|
|
31
|
+
data = handle_mock_response(args)
|
|
32
|
+
if args[:vm_id]
|
|
33
|
+
data.find { |i| i[:vm_id].casecmp(args[:vm_id]).zero? }
|
|
34
|
+
elsif args[:management_os]
|
|
35
|
+
data.find { |i| i[:is_management_os] }
|
|
36
|
+
else
|
|
37
|
+
data
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def get_vm_security(vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Get-VMSecurity', options]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"Id":"416e49fd-28dd-413c-9743-aa3e69e4807d","Name":"mockvm1","State":3,"IntegrationServicesState":"","OperationalStatus":[2],"PrimaryOperationalStatus":2,"SecondaryOperationalStatus":null,"StatusDescriptions":["Operating normally"],"PrimaryStatusDescription":"Operating normally","SecondaryStatusDescription":null,"Status":"Ok","Heartbeat":null,"ReplicationState":0,"ReplicationHealth":0,"ReplicationMode":0,"CPUUsage":0,"MemoryAssigned":0,"MemoryDemand":0,"MemoryStatus":"","SmartPagingFileInUse":false,"Uptime":{"Ticks":0,"Days":0,"Hours":0,"Milliseconds":0,"Minutes":0,"Seconds":0,"TotalDays":0,"TotalHours":0,"TotalMilliseconds":0,"TotalMinutes":0,"TotalSeconds":0},"IntegrationServicesVersion":null,"ResourceMeteringEnabled":false,"ConfigurationLocation":"C:\\Hyper-V","SnapshotFileLocation":"C:\\Hyper-V","AutomaticStartAction":4,"AutomaticStopAction":3,"AutomaticStartDelay":0,"SmartPagingFilePath":"C:\\Hyper-V","NumaAligned":null,"NumaNodesCount":1,"NumaSocketCount":1,"Key":{"Id":"416e49fd-28dd-413c-9743-aa3e69e4807d"},"IsDeleted":false,"ComputerName":"MOCK-HOST","Version":"5.0","Notes":"","Generation":1,"Path":"C:\\Hyper-V","CreationTime":"\/Date(1488869314761)\/","IsClustered":false,"SizeOfSystemFiles":46832,"ParentSnapshotId":null,"ParentSnapshotName":null,"MemoryStartup":4294967296,"DynamicMemoryEnabled":true,"MemoryMinimum":536870912,"MemoryMaximum":1099511627776,"ProcessorCount":4,"RemoteFxAdapter":null,"NetworkAdapters":["Microsoft.HyperV.PowerShell.VMNetworkAdapter"],"FibreChannelHostBusAdapters":"","ComPort1":{"Path":"","ComputerName":"MOCK-HOST","Name":"COM1","Id":"Microsoft:416E49FD-28DD-413C-9743-AA3E69E4807D\\8E3A359F-559A-4B6A-98A9-1690A6100ED7\\0","IsDeleted":false,"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},"ComPort2":{"Path":"","ComputerName":"MOCK-HOST","Name":"COM2","Id":"Microsoft:416E49FD-28DD-413C-9743-AA3E69E4807D\\8E3A359F-559A-4B6A-98A9-1690A6100ED7\\1","IsDeleted":false,"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},"FloppyDrive":{"PoolName":null,"Path":null,"Disk":null,"ComputerName":"mock-host","Name":"DisketteDrive","Id":"Microsoft:416E49FD-28DD-413C-9743-AA3E69E4807D\\8F0D2762-0B00-4E04-AF4F-19010527CB93\\0\\0\\D","IsDeleted":false,"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},"DVDDrives":["Microsoft.HyperV.PowerShell.DvdDrive"],"HardDrives":["Microsoft.HyperV.PowerShell.HardDiskDrive"],"VMIntegrationService":["Microsoft.HyperV.PowerShell.VMIntegrationComponent","Microsoft.HyperV.PowerShell.VMIntegrationComponent","Microsoft.HyperV.PowerShell.DataExchangeComponent","Microsoft.HyperV.PowerShell.ShutdownComponent","Microsoft.HyperV.PowerShell.VMIntegrationComponent","Microsoft.HyperV.PowerShell.GuestServiceInterfaceComponent"],"VMName":"mockvm1","VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d"},
|
|
3
|
+
{"Id":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","Name":"mockvm2","State":2,"IntegrationServicesState":"","OperationalStatus":"Ok","PrimaryOperationalStatus":2,"SecondaryOperationalStatus":null,"StatusDescriptions":"Operating normally","PrimaryStatusDescription":"Operating normally","SecondaryStatusDescription":null,"Status":"Ok","Heartbeat":1,"ReplicationState":0,"ReplicationHealth":0,"ReplicationMode":0,"CPUUsage":0,"MemoryAssigned":4294967296,"MemoryDemand":0,"MemoryStatus":"","SmartPagingFileInUse":false,"Uptime":"6.02:21:14","IntegrationServicesVersion":null,"ResourceMeteringEnabled":false,"ConfigurationLocation":"C:\\Hyper-V","SnapshotFileLocation":"C:\\Hyper-V","AutomaticStartAction":4,"AutomaticStopAction":3,"AutomaticStartDelay":0,"SmartPagingFilePath":"C:\\Hyper-V","NumaAligned":false,"NumaNodesCount":1,"NumaSocketCount":1,"Key":"Microsoft.HyperV.PowerShell.VirtualMachineObjectKey","IsDeleted":false,"ComputerName":"mock-host","Version":"5.0","Notes":"","Generation":2,"Path":"C:\\Hyper-V","CreationTime":"\/Date(1488869316886)\/","IsClustered":false,"SizeOfSystemFiles":56228,"ParentSnapshotId":null,"ParentSnapshotName":null,"MemoryStartup":4294967296,"DynamicMemoryEnabled":true,"MemoryMinimum":536870912,"MemoryMaximum":1099511627776,"ProcessorCount":4,"RemoteFxAdapter":null,"NetworkAdapters":"Microsoft.HyperV.PowerShell.VMNetworkAdapter","FibreChannelHostBusAdapters":"","ComPort1":"Microsoft.HyperV.PowerShell.VMComPort","ComPort2":"Microsoft.HyperV.PowerShell.VMComPort","FloppyDrive":null,"DVDDrives":"","HardDrives":"Microsoft.HyperV.PowerShell.HardDiskDrive Microsoft.HyperV.PowerShell.HardDiskDrive","VMIntegrationService":"Microsoft.HyperV.PowerShell.VMIntegrationComponent Microsoft.HyperV.PowerShell.VMIntegrationComponent Microsoft.HyperV.PowerShell.DataExchangeComponent Microsoft.HyperV.PowerShell.ShutdownComponent Microsoft.HyperV.PowerShell.VMIntegrationComponent Microsoft.HyperV.PowerShell.GuestServiceInterfaceComponent","VMName":"mockvm2","VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868"}
|
|
4
|
+
]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def new_vm(computer_name: nil, **options)
|
|
6
|
+
requires options, :new_vhd_path, :new_vhd_size_bytes \
|
|
7
|
+
if options[:new_whd_path] || options[:new_vhd_size_bytes]
|
|
8
|
+
|
|
9
|
+
run_cmd 'New-VM', _target_computer: computer_name, **options
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def new_vm_switch(name:, computer_name: nil, **options)
|
|
6
|
+
requires_one options, :net_adapter_name, :net_adapter_interface_description
|
|
7
|
+
|
|
8
|
+
run_cmd 'New-VMSwitch', _target_computer: computer_name, name: name, **options
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def remove_item(path:, computer_name: nil, **options)
|
|
6
|
+
# TODO: Really lock this method down, validation is good.
|
|
7
|
+
run_cmd 'Remove-Item', _target_computer: computer_name, _skip_json: true, path: path, force: true, **options
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def remove_vm(id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Remove-VM', { force: true, **options }]
|
|
10
|
+
],
|
|
11
|
+
skip_json: true,
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def remove_vm_dvd_drive(id:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$DVD = $VM | Get-VMDvdDrive', { _by_id: id }],
|
|
10
|
+
['$DVD | Remove-VMDvdDrive', options]
|
|
11
|
+
],
|
|
12
|
+
skip_json: true,
|
|
13
|
+
target_computer: computer_name
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def remove_vm_hard_disk_drive(vm_id:, id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$HDD = $VM | Get-VMHardDiskDrive', { _by_id: id }],
|
|
10
|
+
['$HDD | Remove-VMHardDiskDrive', options]
|
|
11
|
+
],
|
|
12
|
+
skip_json: true,
|
|
13
|
+
target_computer: computer_name
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def remove_vm_network_adapter(id:, computer_name: nil, **options)
|
|
6
|
+
requires_one options, :vm_id, :management_os
|
|
7
|
+
options.delete :management_os
|
|
8
|
+
|
|
9
|
+
cmdlist = []
|
|
10
|
+
if options[:vm_id]
|
|
11
|
+
vm_id = options.delete :vm_id
|
|
12
|
+
cmdlist += [
|
|
13
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
14
|
+
['$NIC = $VM | Get-VMNetworkAdapter', { _by_id: id }]
|
|
15
|
+
]
|
|
16
|
+
else
|
|
17
|
+
options.delete :vm_id
|
|
18
|
+
cmdlist << ['$NIC = Get-VMNetworkAdapter', { _by_id: id, management_os: true }]
|
|
19
|
+
end
|
|
20
|
+
cmdlist << ['$NIC | Remove-VMNetworkAdapter', options]
|
|
21
|
+
|
|
22
|
+
run_cmdlist(
|
|
23
|
+
cmdlist,
|
|
24
|
+
skip_json: true,
|
|
25
|
+
target_computer: computer_name
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def remove_vm_switch(id:, computer_name: nil, **options)
|
|
6
|
+
run_cmd 'Remove-VMSwitch', _target_computer: computer_name, _by_id: id, _skip_json: true, force: true, **options
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def rename_vm(id:, new_name:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Rename-VM', { new_name: new_name, **options }]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name,
|
|
12
|
+
skip_json: true
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def rename_vm_network_adapter(id:, new_name:, computer_name: nil, **options)
|
|
6
|
+
requires_one options, :vm_id, :management_os
|
|
7
|
+
options.delete :management_os
|
|
8
|
+
|
|
9
|
+
cmdlist = []
|
|
10
|
+
if options[:vm_id]
|
|
11
|
+
vm_id = options.delete :vm_id
|
|
12
|
+
cmdlist += [
|
|
13
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
14
|
+
['$NIC = $VM | Get-VMNetworkAdapter', { _by_id: id }]
|
|
15
|
+
]
|
|
16
|
+
else
|
|
17
|
+
options.delete :vm_id
|
|
18
|
+
cmdlist << ['$NIC = Get-VMNetworkAdapter', { _by_id: id, management_os: true }]
|
|
19
|
+
end
|
|
20
|
+
cmdlist << ['$NIC | Rename-VMNetworkAdapter', { new_name: new_name, **options }]
|
|
21
|
+
|
|
22
|
+
run_cmdlist(cmdlist, target_computer: computer_name, skip_json: true)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def rename_vm_switch(id:, new_name:, computer_name: nil, **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
|
+
)
|
|
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 resize_vhd(path:, size_bytes:, computer_name: nil, **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
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def restart_vm(id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Restart-VM', { force: true, **options }]
|
|
10
|
+
],
|
|
11
|
+
skip_json: true,
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Mock
|
|
18
|
+
def restart_vm(**_)
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def resume_vm(id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Resume-VM', options]
|
|
10
|
+
],
|
|
11
|
+
skip_json: true,
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Mock
|
|
18
|
+
def resume_vm(**_)
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def save_vm(id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Save-VM', options]
|
|
10
|
+
],
|
|
11
|
+
skip_json: true,
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Mock
|
|
18
|
+
def save_vm(**_)
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm(id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: id }],
|
|
9
|
+
['$VM | Set-VM', { passthru: true, **options }]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_bios(vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Set-VMBios', { passthru: true, **options }]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_com_port(id:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$COM = $VM | Get-VMComPort', { _by_id: id }],
|
|
10
|
+
['$COM | Set-VMComPort', { passthru: true, **options }]
|
|
11
|
+
],
|
|
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 set_vm_dvd_drive(id:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$DVD = $VM | Get-VMDvdDrive', { _by_id: id }],
|
|
10
|
+
['$DVD | Set-VMDvdDrive', { passthru: true, **options }]
|
|
11
|
+
],
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_firmware(vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Set-VMFirmware', { passthru: true, **options }]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_floppy_disk_drive(id:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$Floppy = $VM | Get-VMFloppyDiskDrive', { _by_id: id }],
|
|
10
|
+
['$Floppy | Set-VMFloppyDiskDrive', { passthru: true, **options }]
|
|
11
|
+
],
|
|
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 set_vm_hard_disk_drive(id:, vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$HDD = $VM | Get-VMHardDiskDrive', { _by_id: id }],
|
|
10
|
+
['$HDD | Set-VMHardDiskDrive', { passthru: true, **options }]
|
|
11
|
+
],
|
|
12
|
+
target_computer: computer_name
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_key_protector(vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Set-VMKeyProtector', options]
|
|
10
|
+
],
|
|
11
|
+
target_computer: computer_name
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_network_adapter(id:, computer_name: nil, **options)
|
|
6
|
+
requires_one options, :vm_id, :management_os
|
|
7
|
+
options.delete :management_os
|
|
8
|
+
|
|
9
|
+
cmdlist = []
|
|
10
|
+
if options[:vm_id]
|
|
11
|
+
vm_id = options.delete :vm_id
|
|
12
|
+
cmdlist += [
|
|
13
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
14
|
+
['$NIC = $VM | Get-VMNetworkAdapter', { _by_id: id }]
|
|
15
|
+
]
|
|
16
|
+
else
|
|
17
|
+
options.delete :vm_id
|
|
18
|
+
cmdlist << ['$NIC = Get-VMNetworkAdapter', { _by_id: id, management_os: true }]
|
|
19
|
+
end
|
|
20
|
+
cmdlist << ['$NIC | Set-VMNetworkAdapter', { passthru: true, **options }]
|
|
21
|
+
|
|
22
|
+
run_cmdlist(cmdlist, target_computer: computer_name)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_network_adapter_vlan(id:, computer_name: nil, **options)
|
|
6
|
+
requires_one options, :vm_id, :management_os
|
|
7
|
+
options.delete :management_os
|
|
8
|
+
|
|
9
|
+
cmdlist = []
|
|
10
|
+
if options[:vm_id]
|
|
11
|
+
vm_id = options.delete :vm_id
|
|
12
|
+
cmdlist += [
|
|
13
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
14
|
+
['$NIC = $VM | Get-VMNetworkAdapter', { _by_id: id }]
|
|
15
|
+
]
|
|
16
|
+
else
|
|
17
|
+
options.delete :vm_id
|
|
18
|
+
cmdlist << ['$NIC = Get-VMNetworkAdapter', { _by_id: id, management_os: true }]
|
|
19
|
+
end
|
|
20
|
+
cmdlist << ['$NIC | Set-VMNetworkAdapterVlan', { passthru: true, **options }]
|
|
21
|
+
|
|
22
|
+
run_cmdlist(cmdlist, target_computer: computer_name)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Real
|
|
5
|
+
def set_vm_security(vm_id:, computer_name: nil, **options)
|
|
6
|
+
run_cmdlist(
|
|
7
|
+
[
|
|
8
|
+
['$VM = Get-VM', { id: vm_id }],
|
|
9
|
+
['$VM | Set-VMSecurity', {
|
|
10
|
+
_always_include: %i[encrypt_state_and_vm_migration_traffic virtualization_based_security_opt_out], passthru: true, **options
|
|
11
|
+
}]
|
|
12
|
+
],
|
|
13
|
+
target_computer: computer_name
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|