fog-hyperv 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/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 +60 -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 +187 -0
- data/lib/fog/hyperv/compute/models/hard_drives.rb +28 -0
- data/lib/fog/hyperv/compute/models/host.rb +66 -0
- data/lib/fog/hyperv/compute/models/hosts.rb +13 -0
- data/lib/fog/hyperv/compute/models/network_adapter.rb +362 -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 +9 -0
- data/lib/fog/hyperv/compute/requests/resize_vhd.rb +9 -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 +51 -44
- metadata +198 -110
- data/.gitignore +0 -10
- data/.travis.yml +0 -11
- data/CHANGELOG.md +0 -48
- data/Gemfile +0 -4
- data/Rakefile +0 -10
- data/fog-hyperv.gemspec +0 -29
- 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
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Vhd < Fog::Hyperv::Model
|
|
5
|
-
identity :disk_identifier
|
|
6
|
-
|
|
7
|
-
attribute :attached
|
|
8
|
-
attribute :block_size
|
|
9
|
-
attribute :computer_name
|
|
10
|
-
attribute :disk
|
|
11
|
-
attribute :file_size
|
|
12
|
-
attribute :is_deleted
|
|
13
|
-
attribute :minimum_size
|
|
14
|
-
attribute :path, type: :string, default: 'New Disk'
|
|
15
|
-
attribute :pool_name
|
|
16
|
-
attribute :size, type: :integer, default: 343_597_383_68
|
|
17
|
-
attribute :vhd_format, type: :enum, values: [:Unknown, nil, :VHD, :VHDX, :VHDSet]
|
|
18
|
-
attribute :vhd_type, type: :enum, values: [:Unknown, nil, :Fixed, :Dynamic, :Differencing]
|
|
19
|
-
# TODO? VM Snapshots?
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
# def identity_name
|
|
23
|
-
# :disk_identifier unless disk_identifier
|
|
24
|
-
# :disk_number if disk
|
|
25
|
-
# :path
|
|
26
|
-
# end
|
|
27
|
-
|
|
28
|
-
def real_path
|
|
29
|
-
requires :path, :computer_name
|
|
30
|
-
|
|
31
|
-
ret = path
|
|
32
|
-
ret += '.vhdx' unless ret.downcase.end_with? '.vhdx'
|
|
33
|
-
ret = host.virtual_hard_disk_path + '\\' + ret unless ret.downcase.start_with? host.virtual_hard_disk_path.downcase
|
|
34
|
-
ret
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def unc_path
|
|
38
|
-
"\\\\#{computer_name || '.'}\\#{real_path.tr ':', '$'}"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def host
|
|
42
|
-
requires :computer_name
|
|
43
|
-
|
|
44
|
-
@host ||= begin
|
|
45
|
-
ret = parent
|
|
46
|
-
ret = service.hosts.get computer_name unless ret
|
|
47
|
-
ret = ret.parent unless ret.is_a?(Host)
|
|
48
|
-
ret
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def save
|
|
53
|
-
requires :path, :computer_name, :size
|
|
54
|
-
|
|
55
|
-
data = \
|
|
56
|
-
if persisted?
|
|
57
|
-
# Can't change much of a VHD
|
|
58
|
-
attributes
|
|
59
|
-
else
|
|
60
|
-
service.new_vhd(
|
|
61
|
-
computer_name: computer_name,
|
|
62
|
-
path: real_path,
|
|
63
|
-
|
|
64
|
-
block_size_bytes: block_size,
|
|
65
|
-
size_bytes: size,
|
|
66
|
-
|
|
67
|
-
_return_fields: self.class.attributes,
|
|
68
|
-
_json_depth: 1
|
|
69
|
-
)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
merge_attributes(data)
|
|
73
|
-
@old = dup
|
|
74
|
-
self
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def reload
|
|
78
|
-
requires :computer_name
|
|
79
|
-
requires_one :path, :disk
|
|
80
|
-
|
|
81
|
-
data = service.get_vhd(
|
|
82
|
-
computer_name: computer_name,
|
|
83
|
-
path: path,
|
|
84
|
-
disk_number: disk
|
|
85
|
-
)
|
|
86
|
-
merge_attributes(data.attributes)
|
|
87
|
-
@old = data
|
|
88
|
-
self
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def destroy
|
|
92
|
-
requires :path, :disk_identifier
|
|
93
|
-
|
|
94
|
-
service.remove_item(
|
|
95
|
-
path: unc_path
|
|
96
|
-
)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Vhds < Fog::Hyperv::VMCollection
|
|
5
|
-
model Fog::Compute::Hyperv::Vhd
|
|
6
|
-
match_on :vm_id
|
|
7
|
-
|
|
8
|
-
get_method :get_vhd
|
|
9
|
-
|
|
10
|
-
def get(path, filters = {})
|
|
11
|
-
super search_attributes.merge(filters.merge(path: path))
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def add_vm_network_adapter(options = {})
|
|
6
|
-
requires_one options, :vm_name, :management_os
|
|
7
|
-
run_shell('Add-VMNetworkAdapter', options.merge(_always_include: [:is_legacy]))
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def connect_vm_network_adapter(options = {})
|
|
6
|
-
requires options, :vm_name, :switch_name
|
|
7
|
-
run_shell('Connect-VMNetworkAdapter', options.merge(_skip_json: true)).exitcode.zero?
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_cluster_node(options = {})
|
|
6
|
-
run_shell('Get-ClusterNode', options)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class Mock
|
|
11
|
-
def get_cluster_node(args = {})
|
|
12
|
-
data = handle_mock_response args
|
|
13
|
-
data = data.find { |n| n[:name] == args[:name] } if args[:name]
|
|
14
|
-
data
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vhd(options = {})
|
|
6
|
-
requires_one options, :vm_id, :path, :disk_number
|
|
7
|
-
run_shell('Get-VHD', options)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Mock
|
|
12
|
-
def get_vhd(args = {})
|
|
13
|
-
requires_one args, :vm_id, :path, :disk_number
|
|
14
|
-
data = handle_mock_response args
|
|
15
|
-
|
|
16
|
-
if args[:vm_id]
|
|
17
|
-
data = case args[:vm_id].downcase
|
|
18
|
-
when '20ff7fe3-fd54-425c-aa97-fbf3c2e7a868'
|
|
19
|
-
data[1..-1]
|
|
20
|
-
when '416e49fd-28dd-413c-9743-aa3e69e4807d'
|
|
21
|
-
data[0]
|
|
22
|
-
end
|
|
23
|
-
elsif args[:path]
|
|
24
|
-
data = data.find { |d| d[:path].casecmp(args[:path]).zero? }
|
|
25
|
-
elsif args[:disk_number]
|
|
26
|
-
Fog::Mock.not_implemented
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
data
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm(options = {})
|
|
6
|
-
run_shell('Get-VM', options)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class Mock
|
|
11
|
-
def get_vm(args = {})
|
|
12
|
-
data = handle_mock_response args
|
|
13
|
-
data = data.find { |v| v[:name].casecmp(args[:name]).zero? } if args[:name]
|
|
14
|
-
data = data.find { |v| v[:id].casecmp(args[:id]).zero? } if args[:id]
|
|
15
|
-
data
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_bios(options = {})
|
|
6
|
-
requires options, :vm_name
|
|
7
|
-
run_shell('Get-VMBios', options)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Mock
|
|
12
|
-
def get_vm_bios(args = {})
|
|
13
|
-
requires args, :vm_name
|
|
14
|
-
|
|
15
|
-
handle_mock_response(args).find { |b| b[:vm_name].casecmp(args[:vm_name]).zero? }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_dvd_drive(options = {})
|
|
6
|
-
requires options, :vm_name
|
|
7
|
-
run_shell('Get-VMDvdDrive', options)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Mock
|
|
12
|
-
def get_vm_dvd_drive(options = {})
|
|
13
|
-
requires options, :vm_name
|
|
14
|
-
|
|
15
|
-
handle_mock_response(args).find { |b| b[:vm_name].casecmp(args[:vm_name]).zero? }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_firmware(options = {})
|
|
6
|
-
requires options, :vm_name
|
|
7
|
-
run_shell('Get-VMFirmware', options)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Mock
|
|
12
|
-
def get_vm_firmware(args = {})
|
|
13
|
-
handle_mock_response(args).find { |b| b[:vm_name].casecmp(args[:vm_name]).zero? }
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_floppy_disk_drive(options = {})
|
|
6
|
-
requires options, :vm_name
|
|
7
|
-
run_shell('Get-VMFloppyDiskDrive', options)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Mock
|
|
12
|
-
def get_vm_floppy_disk_drive(options = {})
|
|
13
|
-
requires options, :vm_name
|
|
14
|
-
|
|
15
|
-
handle_mock_response(args).find { |b| b[:vm_name].casecmp(args[:vm_name]).zero? }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_group(options = {})
|
|
6
|
-
requires_version '10.0'
|
|
7
|
-
|
|
8
|
-
run_shell('Get-VMGroup', options)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class Mock
|
|
13
|
-
def get_vm_group(options = {})
|
|
14
|
-
requires_version '10.0'
|
|
15
|
-
|
|
16
|
-
# TODO
|
|
17
|
-
Fog::Mock.not_implemented
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_hard_disk_drive(options = {})
|
|
6
|
-
requires options, :vm_name
|
|
7
|
-
run_shell('Get-VMHardDiskDrive', options)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class Mock
|
|
12
|
-
def get_vm_hard_disk_drive(args = {})
|
|
13
|
-
requires args, :vm_name
|
|
14
|
-
|
|
15
|
-
handle_mock_response(args).find { |b| b[:vm_name].casecmp(args[:vm_name]).zero? }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def get_vm_host_cluster(options = {})
|
|
6
|
-
requires_version '10.0'
|
|
7
|
-
requires options, :cluster_name
|
|
8
|
-
|
|
9
|
-
run_shell('Get-VMHostCluster', options)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class Mock
|
|
14
|
-
def get_vm_host_cluster(options = {})
|
|
15
|
-
requires_version '10.0'
|
|
16
|
-
requires options, :cluster_name
|
|
17
|
-
|
|
18
|
-
# TODO
|
|
19
|
-
Fog::Mock.not_implemented
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1 +0,0 @@
|
|
|
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"}]
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Real
|
|
5
|
-
def remove_vm_dvd_drive(options = {})
|
|
6
|
-
requires options, :vm_name, :controller_number, :controller_location
|
|
7
|
-
run_shell('Remove-VMDvdDrive', options.merge(_skip_json: true)).exitcode.zero?
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|