fog-hyperv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +4 -0
  5. data/README.md +53 -0
  6. data/Rakefile +10 -0
  7. data/fog-hyperv.gemspec +28 -0
  8. data/lib/fog/bin/hyperv.rb +28 -0
  9. data/lib/fog/collection.rb +114 -0
  10. data/lib/fog/hyperv.rb +123 -0
  11. data/lib/fog/hyperv/compute.rb +327 -0
  12. data/lib/fog/hyperv/fog_extensions/enum.rb +51 -0
  13. data/lib/fog/hyperv/models/compute/bios.rb +52 -0
  14. data/lib/fog/hyperv/models/compute/cluster.rb +37 -0
  15. data/lib/fog/hyperv/models/compute/clusters.rb +11 -0
  16. data/lib/fog/hyperv/models/compute/com_port.rb +22 -0
  17. data/lib/fog/hyperv/models/compute/dvd_drive.rb +62 -0
  18. data/lib/fog/hyperv/models/compute/dvd_drives.rb +11 -0
  19. data/lib/fog/hyperv/models/compute/firmware.rb +52 -0
  20. data/lib/fog/hyperv/models/compute/floppy_drive.rb +48 -0
  21. data/lib/fog/hyperv/models/compute/floppy_drives.rb +11 -0
  22. data/lib/fog/hyperv/models/compute/hard_drive.rb +110 -0
  23. data/lib/fog/hyperv/models/compute/hard_drives.rb +11 -0
  24. data/lib/fog/hyperv/models/compute/host.rb +20 -0
  25. data/lib/fog/hyperv/models/compute/hosts.rb +15 -0
  26. data/lib/fog/hyperv/models/compute/network_adapter.rb +142 -0
  27. data/lib/fog/hyperv/models/compute/network_adapters.rb +19 -0
  28. data/lib/fog/hyperv/models/compute/server.rb +192 -0
  29. data/lib/fog/hyperv/models/compute/servers.rb +30 -0
  30. data/lib/fog/hyperv/models/compute/switch.rb +58 -0
  31. data/lib/fog/hyperv/models/compute/switches.rb +15 -0
  32. data/lib/fog/hyperv/models/compute/vhd.rb +100 -0
  33. data/lib/fog/hyperv/models/compute/vhds.rb +16 -0
  34. data/lib/fog/hyperv/requests/compute/add_vm_hard_disk_drive.rb +12 -0
  35. data/lib/fog/hyperv/requests/compute/add_vm_network_adapter.rb +12 -0
  36. data/lib/fog/hyperv/requests/compute/connect_vm_network_adapter.rb +12 -0
  37. data/lib/fog/hyperv/requests/compute/disconnect_vm_network_adapter.rb +12 -0
  38. data/lib/fog/hyperv/requests/compute/get_cluster.rb +11 -0
  39. data/lib/fog/hyperv/requests/compute/get_cluster_node.rb +19 -0
  40. data/lib/fog/hyperv/requests/compute/get_vhd.rb +34 -0
  41. data/lib/fog/hyperv/requests/compute/get_vm.rb +20 -0
  42. data/lib/fog/hyperv/requests/compute/get_vm_bios.rb +21 -0
  43. data/lib/fog/hyperv/requests/compute/get_vm_dvd_drive.rb +20 -0
  44. data/lib/fog/hyperv/requests/compute/get_vm_firmware.rb +21 -0
  45. data/lib/fog/hyperv/requests/compute/get_vm_floppy_disk_drive.rb +20 -0
  46. data/lib/fog/hyperv/requests/compute/get_vm_group.rb +23 -0
  47. data/lib/fog/hyperv/requests/compute/get_vm_hard_disk_drive.rb +20 -0
  48. data/lib/fog/hyperv/requests/compute/get_vm_host.rb +12 -0
  49. data/lib/fog/hyperv/requests/compute/get_vm_host_cluster.rb +25 -0
  50. data/lib/fog/hyperv/requests/compute/get_vm_network_adapter.rb +27 -0
  51. data/lib/fog/hyperv/requests/compute/get_vm_switch.rb +27 -0
  52. data/lib/fog/hyperv/requests/compute/mock_files/get_cluster.json +1 -0
  53. data/lib/fog/hyperv/requests/compute/mock_files/get_cluster_node.json +1 -0
  54. data/lib/fog/hyperv/requests/compute/mock_files/get_vhd.json +1 -0
  55. data/lib/fog/hyperv/requests/compute/mock_files/get_vm.json +1 -0
  56. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_bios.json +1 -0
  57. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_dvd_drive.json +1 -0
  58. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_firmware.json +1 -0
  59. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_floppy_disk_drive.json +1 -0
  60. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_hard_disk_drive.json +1 -0
  61. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_host.json +1 -0
  62. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_network_adapter.json +1 -0
  63. data/lib/fog/hyperv/requests/compute/mock_files/get_vm_switch.json +1 -0
  64. data/lib/fog/hyperv/requests/compute/new_vhd.rb +12 -0
  65. data/lib/fog/hyperv/requests/compute/new_vm.rb +15 -0
  66. data/lib/fog/hyperv/requests/compute/new_vm_switch.rb +13 -0
  67. data/lib/fog/hyperv/requests/compute/remove_item.rb +13 -0
  68. data/lib/fog/hyperv/requests/compute/remove_vm.rb +15 -0
  69. data/lib/fog/hyperv/requests/compute/remove_vm_hard_disk_drive.rb +12 -0
  70. data/lib/fog/hyperv/requests/compute/remove_vm_network_adapter.rb +12 -0
  71. data/lib/fog/hyperv/requests/compute/restart_vm.rb +15 -0
  72. data/lib/fog/hyperv/requests/compute/set_vm.rb +12 -0
  73. data/lib/fog/hyperv/requests/compute/set_vm_bios.rb +13 -0
  74. data/lib/fog/hyperv/requests/compute/set_vm_dvd_drive.rb +12 -0
  75. data/lib/fog/hyperv/requests/compute/set_vm_firmware.rb +13 -0
  76. data/lib/fog/hyperv/requests/compute/set_vm_hard_disk_drive.rb +12 -0
  77. data/lib/fog/hyperv/requests/compute/set_vm_network_adapter.rb +12 -0
  78. data/lib/fog/hyperv/requests/compute/set_vm_switch.rb +13 -0
  79. data/lib/fog/hyperv/requests/compute/start_vm.rb +15 -0
  80. data/lib/fog/hyperv/requests/compute/stop_vm.rb +15 -0
  81. data/lib/fog/hyperv/version.rb +5 -0
  82. data/lib/fog/model.rb +64 -0
  83. data/test/fog/hyperv_test.rb +7 -0
  84. data/test/test_helper.rb +4 -0
  85. metadata +199 -0
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def get_vm_network_adapter(options = {})
6
+ requires_one options, :vm_name, :all, :management_os
7
+ run_shell('Get-VMNetworkAdapter', options)
8
+ end
9
+ end
10
+
11
+ class Mock
12
+ def get_vm_network_adapter(args = {})
13
+ requires_one args, :vm_name, :all, :management_os
14
+
15
+ data = handle_mock_response(args)
16
+ if args[:all]
17
+ data
18
+ elsif args[:vm_name]
19
+ data.find { |i| i[:vm_name].casecmp(args[:vm_name]).zero? }
20
+ elsif args[:management_os]
21
+ data.find { |i| i[:is_management_os] }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def get_vm_switch(options = {})
6
+ if options[:_quick_query]
7
+ search = {}
8
+ search[:element_name] = options[:name] if options[:name]
9
+ search[:name] = options[:id].upcase if options[:id]
10
+ data = run_wql('SELECT ElementName,Name FROM Msvm_VirtualEthernetSwitch', search)
11
+ nil if data.empty?
12
+ data[:xml_fragment].map do |sw|
13
+ {
14
+ id: sw[:name].downcase,
15
+ computer_name: options[:computer_name],
16
+ name: sw[:element_name],
17
+ }
18
+ end
19
+ else
20
+ run_shell('Get-VMSwitch', options)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1 @@
1
+ [{"Domain":"example.com","Name":"mock-cluster","AddEvictDelay":60,"AdministrativeAccessPoint":1,"BackupInProgress":0,"ClusSvcHangTimeout":60,"ClusSvcRegroupOpeningTimeout":5,"ClusSvcRegroupPruningTimeout":5,"ClusSvcRegroupStageTimeout":5,"ClusSvcRegroupTickInMilliseconds":300,"ClusterGroupWaitDelay":120,"MinimumNeverPreemptPriority":3000,"MinimumPreemptorPriority":1,"ClusterEnforcedAntiAffinity":0,"ClusterLogLevel":3,"ClusterLogSize":300,"CrossSubnetDelay":1000,"CrossSubnetThreshold":20,"DefaultNetworkRole":2,"Description":"","FixQuorum":0,"WitnessDynamicWeight":0,"HangRecoveryAction":3,"IgnorePersistentStateOnStartup":0,"LogResourceControls":0,"PlumbAllCrossSubnetRoutes":0,"PreventQuorum":0,"QuorumArbitrationTimeMax":20,"RequestReplyTimeout":60,"RootMemoryReserved":4294967295,"RouteHistoryLength":20,"SameSubnetDelay":1000,"SameSubnetThreshold":10,"SecurityLevel":1,"SharedVolumeCompatibleFilters":[],"SharedVolumeIncompatibleFilters":[],"SharedVolumesRoot":"C:\\ClusterStorage","SharedVolumeSecurityDescriptor":[1,0,4,128,12,1,0,0,0,0,0,0,0,0,0,0,20,0,0,0,2,0,248,0,6,0,0,0,0,0,40,0,0,0,0,16,1,6,0,0,0,0,0,5,80,0,0,0,96,132,185,219,221,88,255,167,246,160,14,87,200,249,220,152,6,236,243,20,0,0,40,0,0,0,0,16,1,6,0,0,0,0,0,5,80,0,0,0,7,46,57,96,160,220,227,206,31,177,65,64,23,113,246,220,2,41,59,99,0,0,40,0,0,0,0,16,1,6,0,0,0,0,0,5,80,0,0,0,76,88,234,130,181,132,86,86,40,110,37,12,112,9,199,231,65,245,217,225,0,0,40,0,0,0,0,16,1,6,0,0,0,0,0,5,87,0,0,0,59,59,160,247,244,100,154,233,3,206,113,65,228,113,244,133,145,209,169,79,0,0,40,0,0,0,0,16,1,6,0,0,0,0,0,5,80,0,0,0,199,91,10,148,110,213,255,197,33,177,250,32,99,169,103,35,121,179,213,26,0,0,40,0,0,0,0,16,1,6,0,0,0,0,0,5,87,0,0,0,172,7,79,174,144,249,162,18,42,223,80,216,223,55,255,107,27,43,112,9,1,1,0,0,0,0,0,5,18,0,0,0],"ShutdownTimeoutInMinutes":56,"DrainOnShutdown":1,"SharedVolumeVssWriterOperationTimeout":1800,"NetftIPSecEnabled":1,"LowerQuorumPriorityNodeId":0,"UseClientAccessNetworksForSharedVolumes":0,"BlockCacheSize":0,"WitnessDatabaseWriteTimeout":300,"WitnessRestartInterval":15,"RecentEventsResetTime":"\/Date(1502720094894)\/","EnableSharedVolumes":"Enabled","DynamicQuorum":1,"CsvBalancer":1,"DatabaseReadWriteMode":0,"MessageBufferLength":50,"Id":"becc0c8a-6444-4df5-bcd8-585ebab46518"}]
@@ -0,0 +1 @@
1
+ [{"Cluster":{"Domain":"example.com","Name":"mock-cluster","AddEvictDelay":60,"AdministrativeAccessPoint":1,"BackupInProgress":0,"ClusSvcHangTimeout":60,"ClusSvcRegroupOpeningTimeout":5,"ClusSvcRegroupPruningTimeout":5,"ClusSvcRegroupStageTimeout":5,"ClusSvcRegroupTickInMilliseconds":300,"ClusterGroupWaitDelay":120,"MinimumNeverPreemptPriority":3000,"MinimumPreemptorPriority":1,"ClusterEnforcedAntiAffinity":0,"ClusterLogLevel":3,"ClusterLogSize":300,"CrossSubnetDelay":1000,"CrossSubnetThreshold":20,"DefaultNetworkRole":2,"Description":"","FixQuorum":0,"WitnessDynamicWeight":0,"HangRecoveryAction":3,"IgnorePersistentStateOnStartup":0,"LogResourceControls":0,"PlumbAllCrossSubnetRoutes":0,"PreventQuorum":0,"QuorumArbitrationTimeMax":20,"RequestReplyTimeout":60,"RootMemoryReserved":4294967295,"RouteHistoryLength":20,"SameSubnetDelay":1000,"SameSubnetThreshold":10,"SecurityLevel":1,"SharedVolumeCompatibleFilters":"","SharedVolumeIncompatibleFilters":"","SharedVolumesRoot":"C:\\ClusterStorage","SharedVolumeSecurityDescriptor":"1 0 4 128 12 1 0 0 0 0 0 0 0 0 0 0 20 0 0 0 2 0248 0 6 0 0 0 0 0 40 0 0 0 0 16 1 6 0 0 0 0 0 5 80 0 0 0 96 132 185 219 221 88 255 167 246 160 14 87 200 249 220 152 6 236 243 20 0 0 40 0 0 0 0 16 1 6 0 0 0 0 0 5 80 0 0 0 7 46 57 96 160 220 227 206 31 177 65 64 23 113 246 220 2 41 59 99 0 0 40 0 0 0 0 16 1 6 0 0 0 0 0 5 80 0 0 0 76 88 234 130 181 132 86 86 40 110 37 12 112 9 199 231 65 245 217 225 0 0 40 0 0 0 0 16 1 6 0 0 0 0 0 5 87 0 0 0 59 59 160 247 244 100 154 233 3 206 113 65 228 113 244 133 145 209 169 79 0 0 40 0 00 0 16 1 6 0 0 0 0 0 5 80 0 0 0 199 91 10 148 110 213 255 197 33 177 250 32 99 169 103 35 121 179 213 26 0 0 40 0 0 0 016 1 6 0 0 0 0 0 5 87 0 0 0 172 7 79 174 144 249 162 18 42 223 80 216 223 55 255 107 27 43 112 9 1 1 0 0 0 0 0 5 18 0 00","ShutdownTimeoutInMinutes":56,"DrainOnShutdown":1,"SharedVolumeVssWriterOperationTimeout":1800,"NetftIPSecEnabled":1,"LowerQuorumPriorityNodeId":0,"UseClientAccessNetworksForSharedVolumes":0,"BlockCacheSize":0,"WitnessDatabaseWriteTimeout":300,"WitnessRestartInterval":15,"RecentEventsResetTime":"\/Date(1502720094894)\/","EnableSharedVolumes":"Enabled","DynamicQuorum":1,"CsvBalancer":1,"DatabaseReadWriteMode":0,"MessageBufferLength":50,"Id":"becc0c8a-6444-4df5-bcd8-585ebab46518"},"State":0,"Id":"1","Name":"mock-host","NodeName":"mock-host","NodeHighestVersion":533888,"NodeLowestVersion":533888,"MajorVersion":6,"MinorVersion":3,"BuildNumber":9600,"CSDVersion":"","NodeInstanceID":"00000000-0000-0000-0000-000000000001","Description":"","DrainStatus":0,"DrainTarget":4294967295,"DynamicWeight":1,"NodeWeight":1,"NeedsPreventQuorum":0}]
@@ -0,0 +1 @@
1
+ [{"ComputerName":"MOCK-HOST","Path":"C:\\Hyper-V\\VirtualHardDisks\\mockvm1.vhdx","VhdFormat":3,"VhdType":3,"FileSize":4194304,"Size":136365211648,"MinimumSize":null,"LogicalSectorSize":512,"PhysicalSectorSize":4096,"BlockSize":33554432,"ParentPath":null,"DiskIdentifier":"e07370bc-7885-4308-a1f7-e538897a834d","FragmentationPercentage":0,"Alignment":1,"Attached":false,"DiskNumber":null,"Key":null,"IsDeleted":false,"Number":null},{"ComputerName":"MOCK-HOST","Path":"C:\\Hyper-V\\VirtualHardDisks\\mockvm21.vhdx","VhdFormat":3,"VhdType":3,"FileSize":4194304,"Size":128849018880,"MinimumSize":null,"LogicalSectorSize":512,"PhysicalSectorSize":4096,"BlockSize":33554432,"ParentPath":null,"DiskIdentifier":"36ded7e9-cd56-4cf0-8482-a72f27af2396","FragmentationPercentage":0,"Alignment":1,"Attached":true,"DiskNumber":null,"Key":null,"IsDeleted":false,"Number":null},{"ComputerName":"MOCK-HOST","Path":"C:\\Hyper-V\\VirtualHardDisks\\mockvm22.vhdx","VhdFormat":3,"VhdType":3,"FileSize":4194304,"Size":32212254720,"MinimumSize":null,"LogicalSectorSize":512,"PhysicalSectorSize":4096,"BlockSize":33554432,"ParentPath":null,"DiskIdentifier":"75cbe2f3-7e33-49a2-8bce-79acd962b1a4","FragmentationPercentage":0,"Alignment":1,"Attached":true,"DiskNumber":null,"Key":null,"IsDeleted":false,"Number":null}]
@@ -0,0 +1 @@
1
+ [{"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":"Operating normally","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"},{"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":"Operating normally","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"}]
@@ -0,0 +1 @@
1
+ [{"ComputerName":"mock-host","NumLockEnabled":false,"StartupOrder":[3,2,1,0],"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null,"IsDeleted":false}]
@@ -0,0 +1 @@
1
+ [{"DvdMediaType":0,"Path":null,"ControllerType":1,"ControllerNumber":0,"ControllerLocation":1,"Name":"DVD Drive on SCSI controller number 0 at location 1","PoolName":null,"ComputerName":"MOCK-HOST","Id":"Microsoft:416E49FD-28DD-413C-9743-AA3E69E4807D\\33972D26-7EE4-49E8-8C11-C5F761133946\\0\\1\\D","IsDeleted":false,"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null}]
@@ -0,0 +1 @@
1
+ [{"ComputerName":"mock-host","SecureBoot":1,"PreferredNetworkBootProtocol":0,"BootOrder":[{"BootType":2,"Description":"EFINetwork","FirmwarePath":"\\AcpiEx(VMBus,0,0)\\VenHw(9B17E5A2-0891-42DD-B653-80B5C22809BA,635161F83EDFC546913FF2D2F965ED0E2356A9EBD9A09343962409B8D67728CF)\\MAC(000000000000)","Device":"Microsoft.HyperV.PowerShell.VMNetworkAdapter","VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null,"IsDeleted":false,"ComputerName":"mock-host"},{"BootType":1,"Description":"EFISCSIDevice","FirmwarePath":"\\AcpiEx(VMBus,0,0)\\VenHw(9B17E5A2-0891-42DD-B653-80B5C22809BA,D96361BAA104294DB60572E2FFB1DC7FD7A3B955CDA66848ACAF773B75A1804B)\\Scsi(0,0)","Device":"Microsoft.HyperV.PowerShell.HardDiskDrive","VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null,"IsDeleted":false,"ComputerName":"mock-host"},{"BootType":1,"Description":"EFISCSIDevice","FirmwarePath":"\\AcpiEx(VMBus,0,0)\\VenHw(9B17E5A2-0891-42DD-B653-80B5C22809BA,D96361BAA104294DB60572E2FFB1DC7FD7A3B955CDA66848ACAF773B75A1804B)\\Scsi(0,1)","Device":"Microsoft.HyperV.PowerShell.HardDiskDrive","VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null,"IsDeleted":false,"ComputerName":"mock-host"}],"VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null,"IsDeleted":false}]
@@ -0,0 +1 @@
1
+ [{"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}]
@@ -0,0 +1 @@
1
+ [{"DiskNumber":null,"SupportPersistentReservations":false,"MaximumIOPS":0,"MinimumIOPS":0,"ControllerType":1,"ControllerNumber":0,"ControllerLocation":0,"Name":"Hard Drive on SCSI controller number 0 at location 0","PoolName":"Primordial","Path":"C:\\Hyper-V\\VirtualHardDisks\\mockvm1.vhdx","Disk":null,"ComputerName":"MOCK-HOST","Id":"Microsoft:416E49FD-28DD-413C-9743-AA3E69E4807D\\33972D26-7EE4-49E8-8C11-C5F761133946\\0\\0\\D","IsDeleted":false,"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},[{"DiskNumber":null,"SupportPersistentReservations":false,"MaximumIOPS":0,"MinimumIOPS":0,"ControllerType":1,"ControllerNumber":0,"ControllerLocation":0,"Name":"Hard Drive on SCSI controller number 0 at location 0","PoolName":"Primordial","Path":"C:\\Hyper-V\\VirtualHardDisks\\mockvm21.vhdx","Disk":null,"ComputerName":"mock-host","Id":"Microsoft:20FF7FE3-FD54-425C-AA97-FBF3C2E7A868\\D3533C44-6C1E-4901-A747-81CE148A3C0C\\0\\0\\D","IsDeleted":false,"VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},{"DiskNumber":null,"SupportPersistentReservations":false,"MaximumIOPS":0,"MinimumIOPS":0,"ControllerType":1,"ControllerNumber":0,"ControllerLocation":1,"Name":"Hard Drive on SCSI controller number 0 at location 1","PoolName":"Primordial","Path":"C:\\Hyper-V\\VirtualHardDisks\\mockvm22.vhdx","Disk":null,"ComputerName":"mock-host","Id":"Microsoft:20FF7FE3-FD54-425C-AA97-FBF3C2E7A868\\D3533C44-6C1E-4901-A747-81CE148A3C0C\\0\\1\\D","IsDeleted":false,"VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null}]]
@@ -0,0 +1 @@
1
+ [{"VirtualHardDiskPath":"C:\\Hyper-V\\VirtualHardDisks","VirtualMachinePath":"C:\\Hyper-V","FullyQualifiedDomainName":"example.com","Name":"MOCK-HOST","MacAddressMinimum":"00155D1FD200","MacAddressMaximum":"00155D1FD2FF","MaximumStorageMigrations":2,"MaximumVirtualMachineMigrations":2,"VirtualMachineMigrationEnabled":true,"VirtualMachineMigrationAuthenticationType":1,"VirtualMachineMigrationPerformanceOption":0,"UseAnyNetworkForMigration":true,"FibreChannelWwnn":"C003FF0000FFFF00","FibreChannelWwpnMaximum":"C003FF01051CFFFF","FibreChannelWwpnMinimum":"C003FF01051C0000","LogicalProcessorCount":24,"MemoryCapacity":38644006912,"ResourceMeteringSaveInterval":{"Ticks":36000000000,"Days":0,"Hours":1,"Milliseconds":0,"Minutes":0,"Seconds":0,"TotalDays":0.041666666666666664,"TotalHours":1,"TotalMilliseconds":3600000,"TotalMinutes":60,"TotalSeconds":3600},"NumaSpanningEnabled":true,"EnableEnhancedSessionMode":true,"HostNumaStatus":["Microsoft.HyperV.PowerShell.VMHostNumaNode","Microsoft.HyperV.PowerShell.VMHostNumaNode"],"NumaStatus":null,"InternalNetworkAdapters":["Microsoft.HyperV.PowerShell.VMInternalNetworkAdapter"],"ExternalNetworkAdapters":["Microsoft.HyperV.PowerShell.VMExternalNetworkAdapter"],"IovSupport":false,"IovSupportReasons":["The chipset on the system does not do interrupt remapping, without which SR-IOV cannot be supported.","To use SR-IOV on this system, the system BIOS must be updated to allow Windows to control PCI Express. Contact your system manufacturer for an update.","SR-IOV cannot be used on this system as the PCI Express hardware does not support Access Control Services (ACS) at any root port. Contact your system vendor for further information.","This system has a security vulnerability in the system I/O remapping hardware. As a precaution, the ability to use SR-IOV has been disabled. You should contact your system manufacturer for an updated BIOS which enables Root Port Alternate Error Delivery mechanism. If all Virtual Machines intended to use SR-IOV run trusted workloads, SR-IOV may be enabled by adding a registry key of type DWORD with value 1 named IOVEnableOverride under HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Virtualization and changing state of the trusted virtual machines. If the system exhibits reduced performance or instability after SR-IOV devices are assigned to Virtual Machines, consider disabling the use of SR-IOV."],"ComputerName":"MOCK-HOST"}]
@@ -0,0 +1 @@
1
+ [{"IsManagementOs":true,"DeviceId":"{C161B9F5-A0A5-426A-B61A-3E2C7631AE91}","Name":"mock-switch","MandatoryFeatureId":null,"IsLegacy":false,"IsExternalAdapter":false,"Id":"Microsoft:DFF9D5BD-A474-4C3A-A00C-1F4DEB9E63A7\\CB570AC9-96FF-45B2-99CF-B89420EBC1B9","AdapterId":"9747F448-B573-4E19-BD26-B7F12860815A","DynamicMacAddressEnabled":false,"MacAddress":"3CD92BEB39F0","MacAddressSpoofing":1,"SwitchId":"dff9d5bd-a474-4c3a-a00c-1f4deb9e63a7","Connected":true,"PoolName":null,"SwitchName":"mock-switch","AclList":"","ExtendedAclList":"","IsolationSetting":"Microsoft.HyperV.PowerShell.VMNetworkAdapterIsolationSetting","CurrentIsolationMode":3,"RoutingDomainList":"","DhcpGuard":1,"RouterGuard":1,"PortMirroringMode":0,"IeeePriorityTag":1,"VirtualSubnetId":0,"DynamicIPAddressLimit":0,"StormLimit":0,"AllowTeaming":1,"VMQWeight":100,"IPsecOffloadMaxSA":512,"VmqUsage":0,"IPsecOffloadSAUsage":0,"VFDataPathActive":false,"VMQueue":null,"MandatoryFeatureName":null,"VlanSetting":"Microsoft.HyperV.PowerShell.VMNetworkAdapterVlanSetting","BandwidthSetting":null,"BandwidthPercentage":0,"TestReplicaPoolName":null,"TestReplicaSwitchName":null,"StatusDescription":"OK","Status":"Ok","IPAddresses":null,"ComputerName":"MOCK-HOST","IsDeleted":false,"VMId":"00000000-0000-0000-0000-000000000000","VMName":null,"VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},{"IovWeight":0,"IovQueuePairsRequested":1,"IovQueuePairsAssigned":null,"IovInterruptModeration":0,"IovUsage":null,"ClusterMonitored":true,"VirtualFunction":null,"IsLegacy":false,"IsManagementOs":false,"IsExternalAdapter":false,"Id":"Microsoft:416E49FD-28DD-413C-9743-AA3E69E4807D\\6FDBD090-5B0C-47AE-872C-A5BD622E807D","AdapterId":null,"DynamicMacAddressEnabled":true,"MacAddress":"00155D1FD216","MacAddressSpoofing":1,"SwitchId":"dff9d5bd-a474-4c3a-a00c-1f4deb9e63a7","Connected":true,"PoolName":"","SwitchName":"mock-switch","AclList":"","ExtendedAclList":"","IsolationSetting":"Microsoft.HyperV.PowerShell.VMNetworkAdapterIsolationSetting","CurrentIsolationMode":3,"RoutingDomainList":"","DhcpGuard":1,"RouterGuard":1,"PortMirroringMode":0,"IeeePriorityTag":1,"VirtualSubnetId":0,"DynamicIPAddressLimit":0,"StormLimit":0,"AllowTeaming":1,"VMQWeight":100,"IPsecOffloadMaxSA":512,"VmqUsage":null,"IPsecOffloadSAUsage":null,"VFDataPathActive":false,"VMQueue":null,"MandatoryFeatureId":"","MandatoryFeatureName":"","VlanSetting":"Microsoft.HyperV.PowerShell.VMNetworkAdapterVlanSetting","BandwidthSetting":null,"BandwidthPercentage":0,"TestReplicaPoolName":"","TestReplicaSwitchName":"","StatusDescription":null,"Status":null,"IPAddresses":"","ComputerName":"MOCK-HOST","Name":"NetworkAdapter","IsDeleted":false,"VMId":"416e49fd-28dd-413c-9743-aa3e69e4807d","VMName":"mockvm1","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null},{"IovWeight":0,"IovQueuePairsRequested":1,"IovQueuePairsAssigned":0,"IovInterruptModeration":0,"IovUsage":0,"ClusterMonitored":true,"VirtualFunction":null,"IsLegacy":false,"IsManagementOs":false,"IsExternalAdapter":false,"Id":"Microsoft:20FF7FE3-FD54-425C-AA97-FBF3C2E7A868\\81653A64-643D-4CC2-B53B-EB9EA72667E8","AdapterId":"81653a64-643d-4cc2-b53b-eb9ea72667e8","DynamicMacAddressEnabled":true,"MacAddress":"00155D1FD215","MacAddressSpoofing":1,"SwitchId":"dff9d5bd-a474-4c3a-a00c-1f4deb9e63a7","Connected":true,"PoolName":"","SwitchName":"mock-switch","AclList":"","ExtendedAclList":"","IsolationSetting":"Microsoft.HyperV.PowerShell.VMNetworkAdapterIsolationSetting","CurrentIsolationMode":3,"RoutingDomainList":"","DhcpGuard":1,"RouterGuard":1,"PortMirroringMode":0,"IeeePriorityTag":1,"VirtualSubnetId":0,"DynamicIPAddressLimit":0,"StormLimit":0,"AllowTeaming":1,"VMQWeight":100,"IPsecOffloadMaxSA":512,"VmqUsage":0,"IPsecOffloadSAUsage":0,"VFDataPathActive":false,"VMQueue":null,"MandatoryFeatureId":"","MandatoryFeatureName":"","VlanSetting":"Microsoft.HyperV.PowerShell.VMNetworkAdapterVlanSetting","BandwidthSetting":null,"BandwidthPercentage":0,"TestReplicaPoolName":"","TestReplicaSwitchName":"","StatusDescription":"OK","Status":"Ok","IPAddresses":"","ComputerName":"mock-host","Name":"NetworkAdapter","IsDeleted":false,"VMId":"20ff7fe3-fd54-425c-aa97-fbf3c2e7a868","VMName":"mockvm2","VMSnapshotId":"00000000-0000-0000-0000-000000000000","VMSnapshotName":null,"Key":null}]
@@ -0,0 +1 @@
1
+ [{"ComputerName":"MOCK-HOST","Name":"mock-switch","Id":"dff9d5bd-a474-4c3a-a00c-1f4deb9e63a7","Notes":"","SwitchType":2,"AllowManagementOS":true,"NetAdapterInterfaceDescription":"Microsoft Network Adapter Multiplexor Driver","AvailableVMQueues":0,"NumberVmqAllocated":0,"IovEnabled":false,"IovVirtualFunctionCount":0,"IovVirtualFunctionsInUse":0,"IovQueuePairCount":0,"IovQueuePairsInUse":0,"AvailableIPSecSA":0,"NumberIPSecSAAllocated":0,"BandwidthPercentage":10,"BandwidthReservationMode":2,"DefaultFlowMinimumBandwidthAbsolute":100000000,"DefaultFlowMinimumBandwidthWeight":0,"Extensions":["Microsoft.HyperV.PowerShell.VMSwitchExtension","Microsoft.HyperV.PowerShell.VMSwitchExtension","Microsoft.HyperV.PowerShell.VMSwitchExtension"],"IovSupport":false,"IovSupportReasons":["The chipset on the system does not do interrupt remapping, without which SR-IOV cannot be supported.","To use SR-IOV on this system, the system BIOS must be updated to allow Windows to control PCI Express. Contact your system manufacturer for an update.","SR-IOV cannot be used on this system as the PCI Express hardware does not support Access Control Services (ACS) at any root port. Contact your system vendor for further information.","This system has a security vulnerability in the system I/O remapping hardware. As a precaution, the ability to use SR-IOV has been disabled. You should contact your system manufacturer for an updated BIOS which enables Root Port Alternate Error Delivery mechanism. If all Virtual Machines intended to use SR-IOV run trusted workloads, SR-IOV may be enabled by adding a registry key of type DWORD with value 1 named IOVEnableOverride under HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Virtualization and changing state of the trusted virtual machines. If the system exhibits reduced performance or instability after SR-IOV devices are assigned to Virtual Machines, consider disabling the use of SR-IOV.","This network adapter does not support SR-IOV."],"IsDeleted":false,"Key":null}]
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def new_vhd(options = {})
6
+ requires options, :path, :size_bytes
7
+ run_shell('New-VHD', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def new_vm(options = {})
6
+ options[:memory_startup_bytes] = options.delete :memory_startup if options.key? :memory_startup
7
+
8
+ requires options, :new_vhd_path, :new_vhd_size_bytes \
9
+ if options[:new_whd_path] || options[:new_vhd_size_bytes]
10
+ run_shell('New-VM', options)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def new_vm_switch(options = {})
6
+ requires options, :name
7
+ requires_one options, :net_adapter_name, :net_adapter_interface_description
8
+ run_shell('New-VMSwitch', options)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def remove_item(options = {})
6
+ # TODO: Really lock this method down, validation is good.
7
+ requires options, :path
8
+ run_shell('Remove-Item', options.merge(force: true, _skip_json: true)).exitcode.zero?
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def remove_vm(options = {})
6
+ # TODO: Handle -VMId/-Id too;
7
+ #
8
+ # Get-VM -Id <guid> | Remove-VM
9
+ requires options, :name
10
+ run_shell('Remove-VM', options.merge(force: true, _skip_json: true)).exitcode.zero?
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def remove_vm_hard_disk_drive(options = {})
6
+ requires options, :vm_name, :controller_type, :controller_number, :controller_location
7
+ run_shell('Remove-VMHardDiskDrive', options.merge(_skip_json: true)).exitcode.zero?
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def remove_vm_network_adapter(options = {})
6
+ requires_one options, :vm_name, :management_os
7
+ run_shell('Remove-VMNetworkAdapter', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def restart_vm(options = {})
6
+ # TODO: Handle -VMId/-Id too;
7
+ #
8
+ # Get-VM -Id <guid> | Start-VM
9
+ requires options, :name
10
+ run_shell('Restart-VM', options.merge(_skip_json: true)).exitcode.zero?
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm(options = {})
6
+ requires options, :name
7
+ run_shell('Set-VM', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm_bios(options = {})
6
+ requires options, :vm_name
7
+ run_shell('Set-VMBios', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm_dvd_drive(options = {})
6
+ requires options, :vm_name
7
+ run_shell('Set-VMDvdDrive', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm_firmware(options = {})
6
+ requires options, :vm_name
7
+ run_shell('Set-VMFirmware', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm_hard_disk_drive(options = {})
6
+ requires options, :vm_name
7
+ run_shell('Set-VMHardDiskDrive', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm_network_adapter(options = {})
6
+ requires_one options, :vm_name, :management_os
7
+ run_shell('Set-VMNetworkAdapter', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def set_vm_switch(options = {})
6
+ requires options, :name
7
+ run_shell('Set-VMSwitch', options)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def start_vm(options = {})
6
+ # TODO: Handle -VMId/-Id too;
7
+ #
8
+ # Get-VM -Id <guid> | Start-VM
9
+ requires options, :name
10
+ run_shell('Start-VM', options.merge(_skip_json: true)).exitcode.zero?
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Hyperv
4
+ class Real
5
+ def stop_vm(options = {})
6
+ # TODO: Handle -VMId/-Id too;
7
+ #
8
+ # Get-VM -Id <guid> | Stop-VM
9
+ requires options, :name
10
+ run_shell('Stop-VM', options.merge(_skip_json: true)).exitcode.zero?
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Fog
2
+ module Hyperv
3
+ VERSION = '0.0.1'.freeze
4
+ end
5
+ end
data/lib/fog/model.rb ADDED
@@ -0,0 +1,64 @@
1
+ module Fog
2
+ module Hyperv
3
+ module ModelExtends
4
+ def lazy_attributes(*attrs)
5
+ @lazy_attributes ||= []
6
+ @lazy_attributes += attrs.map(&:to_s).map(&:to_sym)
7
+ end
8
+ end
9
+
10
+ module ModelIncludes
11
+ def lazy_attributes
12
+ self.class.respond_to?(:lazy_attributes) ? self.class.lazy_attributes : []
13
+ end
14
+
15
+ def dirty?
16
+ attributes.reject do |k, v|
17
+ !self.class.attributes.include?(k) || lazy_attributes.include?(k) || (old ? old.attributes[k] == v : false)
18
+ end.any?
19
+ end
20
+
21
+ def parent
22
+ return nil unless collection
23
+ return collection.vm if collection.attributes.include? :vm
24
+ return collection.computer if collection.attributes.include? :computer
25
+ @parent ||= begin
26
+ r = service.servers.get vm_name if attributes.include? :vm_name
27
+ r = service.hosts.get computer_name if attributes.include? :computer_name
28
+ r
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def logger
35
+ service.logger
36
+ end
37
+
38
+ def clear_lazy
39
+ lazy_attributes.each do |attr|
40
+ attributes[attr] = nil
41
+ end
42
+ end
43
+
44
+ def changed?(attr)
45
+ attributes.reject do |k, v|
46
+ !self.class.attributes.include?(k) || lazy_attributes.include?(k) || (old ? old.attributes[k] == v : true)
47
+ end.key?(attr)
48
+ end
49
+
50
+ def changed!(attr)
51
+ changed?(attr) ? attributes[attr] : nil
52
+ end
53
+
54
+ def old
55
+ @old ||= (persisted? ? dup.reload : nil)
56
+ end
57
+ end
58
+
59
+ class Model < Fog::Model
60
+ extend Fog::Hyperv::ModelExtends
61
+ include Fog::Hyperv::ModelIncludes
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class Fog::HypervTest < Minitest::Test
4
+ def test_that_it_has_a_version_number
5
+ refute_nil ::Fog::Hyperv::VERSION
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'fog/hyperv'
3
+
4
+ require 'minitest/autorun'