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
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class NetworkAdapter < Fog::Hyperv::Model
|
|
5
|
-
identity :id
|
|
6
|
-
|
|
7
|
-
# attribute :acl_list
|
|
8
|
-
attribute :computer_name
|
|
9
|
-
attribute :connected
|
|
10
|
-
attribute :dynamic_mac_address_enabled, type: :boolean, default: true
|
|
11
|
-
attribute :ip_addresses
|
|
12
|
-
# attribute :is_deleted
|
|
13
|
-
attribute :is_external_adapter
|
|
14
|
-
attribute :is_legacy
|
|
15
|
-
attribute :is_management_os
|
|
16
|
-
# attribute :isolation_setting # Might need lazy loading
|
|
17
|
-
attribute :mac_address
|
|
18
|
-
attribute :name, type: :string, default: 'Network Adapter'
|
|
19
|
-
# attribute :router_guard, type: :enum, values: [ :On, :Off ]
|
|
20
|
-
# attribute :status, type: :enum, values: STATUS_ENUM_VALUES
|
|
21
|
-
attribute :switch_id
|
|
22
|
-
attribute :switch_name, type: :string
|
|
23
|
-
attribute :vm_id
|
|
24
|
-
attribute :vm_name
|
|
25
|
-
# attribute :vlan_setting # Might need lazy loading
|
|
26
|
-
|
|
27
|
-
def connect(switch, options = {})
|
|
28
|
-
requires :name, :computer_name, :vm_name
|
|
29
|
-
|
|
30
|
-
switch = switch.name if switch.is_a? Fog::Compute::Hyperv::Switch
|
|
31
|
-
|
|
32
|
-
service.connect_vm_network_adapter options.merge(
|
|
33
|
-
computer_name: computer_name,
|
|
34
|
-
name: name,
|
|
35
|
-
switch_name: switch,
|
|
36
|
-
vm_name: vm_name
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def disconnect(options = {})
|
|
41
|
-
requires :name, :computer_name, :vm_name
|
|
42
|
-
|
|
43
|
-
service.disconnect_vm_network_adapter options.merge(
|
|
44
|
-
computer_name: computer_name,
|
|
45
|
-
name: name,
|
|
46
|
-
vm_name: vm_name
|
|
47
|
-
)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def switch
|
|
51
|
-
service.switches.get switch_name, computer_name: computer_name if switch_name
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def ip_addresses
|
|
55
|
-
attributes[:ip_addresses] = [] \
|
|
56
|
-
if attributes[:ip_addresses] == ''
|
|
57
|
-
attributes[:ip_addresses]
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def save
|
|
61
|
-
requires :name, :computer_name, :vm_name
|
|
62
|
-
|
|
63
|
-
data = \
|
|
64
|
-
if !persisted?
|
|
65
|
-
service.add_vm_network_adapter(
|
|
66
|
-
computer_name: computer_name,
|
|
67
|
-
name: name,
|
|
68
|
-
vm_name: vm_name,
|
|
69
|
-
passthru: true,
|
|
70
|
-
|
|
71
|
-
dynamic_mac_address: dynamic_mac_address_enabled,
|
|
72
|
-
is_legacy: !!is_legacy,
|
|
73
|
-
static_mac_address: !dynamic_mac_address_enabled && mac_address,
|
|
74
|
-
switch_name: switch_name,
|
|
75
|
-
|
|
76
|
-
_return_fields: self.class.attributes,
|
|
77
|
-
_json_depth: 1
|
|
78
|
-
)
|
|
79
|
-
else
|
|
80
|
-
ret = service.set_vm_network_adapter(
|
|
81
|
-
computer_name: old.computer_name,
|
|
82
|
-
name: old.name,
|
|
83
|
-
vm_name: old.vm_name,
|
|
84
|
-
passthru: true,
|
|
85
|
-
|
|
86
|
-
dynamic_mac_address: changed?(:dynamic_mac_address_enabled) && dynamic_mac_address_enabled,
|
|
87
|
-
static_mac_address: changed!(:mac_address) || ((changed!(:dynamic_mac_address_enabled) == false) && mac_address),
|
|
88
|
-
|
|
89
|
-
_return_fields: self.class.attributes,
|
|
90
|
-
_json_depth: 1
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
if changed?(:switch_name)
|
|
94
|
-
service.disconnect_vm_network_adapter(
|
|
95
|
-
computer_name: ret.computer_name,
|
|
96
|
-
name: ret.name,
|
|
97
|
-
vm_name: ret.vm_name
|
|
98
|
-
) unless switch_name
|
|
99
|
-
|
|
100
|
-
service.connect_vm_network_adapter(
|
|
101
|
-
computer_name: ret.computer_name,
|
|
102
|
-
name: ret.name,
|
|
103
|
-
vm_name: ret.vm_name,
|
|
104
|
-
switch_name: switch_name
|
|
105
|
-
) if switch_name
|
|
106
|
-
end
|
|
107
|
-
ret[:switch_name] = switch_name
|
|
108
|
-
ret
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
if data.is_a? Array
|
|
112
|
-
data = data.find { |e| e[:id] == id } if id
|
|
113
|
-
data = data.last unless id
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
merge_attributes(data)
|
|
117
|
-
@old = dup
|
|
118
|
-
self
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def destroy
|
|
122
|
-
requires :vm_name, :name, :computer_name, :id
|
|
123
|
-
|
|
124
|
-
service.remove_vm_network_adapter(
|
|
125
|
-
name: name,
|
|
126
|
-
computer_name: computer_name,
|
|
127
|
-
vm_name: vm_name
|
|
128
|
-
)
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def reload
|
|
132
|
-
data = collection.get(
|
|
133
|
-
name,
|
|
134
|
-
computer_name: computer_name,
|
|
135
|
-
vm_name: vm_name,
|
|
136
|
-
_suffix: "| Where Id -Eq '#{id}'"
|
|
137
|
-
)
|
|
138
|
-
merge_attributes(data.attributes)
|
|
139
|
-
@old = data
|
|
140
|
-
self
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class NetworkAdapters < Fog::Hyperv::VMCollection
|
|
5
|
-
model Fog::Compute::Hyperv::NetworkAdapter
|
|
6
|
-
|
|
7
|
-
get_method :get_vm_network_adapter
|
|
8
|
-
|
|
9
|
-
def all(filters = {})
|
|
10
|
-
super filters.merge(all: !vm)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def get(name, filters = {})
|
|
14
|
-
super filters.merge(name: name, all: !vm)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
require 'fog/compute/models/server'
|
|
2
|
-
|
|
3
|
-
module Fog
|
|
4
|
-
module Compute
|
|
5
|
-
class Hyperv
|
|
6
|
-
class Server < Fog::Compute::Server
|
|
7
|
-
extend Fog::Hyperv::ModelExtends
|
|
8
|
-
include Fog::Hyperv::ModelIncludes
|
|
9
|
-
|
|
10
|
-
VM_STATUS_ENUM_VALUES = {
|
|
11
|
-
Unknown: 1,
|
|
12
|
-
Running: 2,
|
|
13
|
-
Off: 3,
|
|
14
|
-
Stopping: 4,
|
|
15
|
-
Saved: 6,
|
|
16
|
-
Paused: 9,
|
|
17
|
-
Starting: 10,
|
|
18
|
-
Reset: 11,
|
|
19
|
-
Saving: 32773,
|
|
20
|
-
Pausing: 32776,
|
|
21
|
-
Resuming: 32777,
|
|
22
|
-
FastSaved: 32779,
|
|
23
|
-
FastSaving: 32780,
|
|
24
|
-
ForceShutdown: 32781,
|
|
25
|
-
ForceReboot: 32782,
|
|
26
|
-
RunningCritical: 32783,
|
|
27
|
-
OffCritical: 32784,
|
|
28
|
-
StoppingCritical: 32785,
|
|
29
|
-
SavedCritical: 32786,
|
|
30
|
-
PausedCritical: 32787,
|
|
31
|
-
StartingCritical: 32788,
|
|
32
|
-
ResetCritical: 32789,
|
|
33
|
-
SavingCritical: 32790,
|
|
34
|
-
PausingCritical: 32791,
|
|
35
|
-
ResumingCritical: 32792,
|
|
36
|
-
FastSavedCritical: 32793,
|
|
37
|
-
FastSavingCritical: 32794,
|
|
38
|
-
}.freeze
|
|
39
|
-
|
|
40
|
-
identity :id, type: :string
|
|
41
|
-
|
|
42
|
-
attribute :name, type: :string
|
|
43
|
-
attribute :computer_name, type: :string
|
|
44
|
-
attribute :com_port1
|
|
45
|
-
attribute :com_port2
|
|
46
|
-
attribute :dynamic_memory_enabled, type: :boolean, default: false
|
|
47
|
-
attribute :generation, type: :integer, default: 1 # 1 => bios, 2 => uefi
|
|
48
|
-
attribute :is_clustered, type: :boolean, default: false
|
|
49
|
-
attribute :state, type: :enum, values: VM_STATUS_ENUM_VALUES
|
|
50
|
-
attribute :status, type: :string
|
|
51
|
-
attribute :memory_assigned, type: :integer
|
|
52
|
-
attribute :memory_maximum, type: :integer, default: 17_179_869_184
|
|
53
|
-
attribute :memory_minimum, type: :integer, default: 536_870_912
|
|
54
|
-
attribute :memory_startup, type: :integer, default: 536_870_912
|
|
55
|
-
attribute :notes, type: :string
|
|
56
|
-
attribute :processor_count, type: :integer, default: 1
|
|
57
|
-
|
|
58
|
-
lazy_attributes :network_adapters,
|
|
59
|
-
:dvd_drives,
|
|
60
|
-
:hard_drives,
|
|
61
|
-
:floppy_drive
|
|
62
|
-
|
|
63
|
-
attr_accessor :cluster_name
|
|
64
|
-
|
|
65
|
-
%i(network_adapters dvd_drives floppy_drives hard_drives vhds).each do |attr|
|
|
66
|
-
define_method attr do
|
|
67
|
-
if persisted?
|
|
68
|
-
attributes[attr] ||= service.send(attr, vm: self)
|
|
69
|
-
else
|
|
70
|
-
attributes[attr] ||= [] unless persisted?
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
%i(com_port1 com_port2).each do |attr|
|
|
76
|
-
define_method "#{attr}=".to_sym do |data|
|
|
77
|
-
attributes[attr] = Fog::Compute::Hyperv::ComPort.new(data) if data.is_a?(Hash)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def initialize(attrs = {})
|
|
82
|
-
super
|
|
83
|
-
|
|
84
|
-
@cluster = attrs.delete :cluster
|
|
85
|
-
@computer = attrs.delete :computer
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def bios
|
|
89
|
-
@bios ||= begin
|
|
90
|
-
if generation == 1
|
|
91
|
-
Fog::Compute::Hyperv::Bios.new(service.get_vm_bios(computer_name: computer_name, vm_name: name).merge service: service)
|
|
92
|
-
elsif generation == 2
|
|
93
|
-
Fog::Compute::Hyperv::Firmware.new(service.get_vm_firmware(computer_name: computer_name, vm_name: name).merge service: service)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
alias firmware :bios
|
|
98
|
-
|
|
99
|
-
alias vm_id :id
|
|
100
|
-
alias vm_name :name
|
|
101
|
-
|
|
102
|
-
# TODO: Do this properly
|
|
103
|
-
def set_vlan(vlan_id, options = {})
|
|
104
|
-
requires :name, :computer_name
|
|
105
|
-
if vlan_id
|
|
106
|
-
options[:access] = true
|
|
107
|
-
options[:vlan_id] = vlan_id
|
|
108
|
-
else
|
|
109
|
-
options[:untagged] = true
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
service.set_vm_network_adapter_vlan options.merge(
|
|
113
|
-
vm_name: name,
|
|
114
|
-
computer_name: computer_name
|
|
115
|
-
)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def start(options = {})
|
|
119
|
-
requires :name, :computer_name
|
|
120
|
-
service.start_vm options.merge(
|
|
121
|
-
name: name,
|
|
122
|
-
computer_name: computer_name
|
|
123
|
-
)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def stop(options = {})
|
|
127
|
-
requires :name, :computer_name
|
|
128
|
-
service.stop_vm options.merge(
|
|
129
|
-
name: name,
|
|
130
|
-
computer_name: computer_name
|
|
131
|
-
)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def restart(options = {})
|
|
135
|
-
requires :name, :computer_name
|
|
136
|
-
service.restart_vm options.merge(
|
|
137
|
-
name: name,
|
|
138
|
-
computer_name: computer_name
|
|
139
|
-
)
|
|
140
|
-
end
|
|
141
|
-
alias reboot :restart
|
|
142
|
-
|
|
143
|
-
def destroy(options = {})
|
|
144
|
-
requires :name, :computer_name
|
|
145
|
-
stop turn_off: true if ready?
|
|
146
|
-
service.remove_vm options.merge(
|
|
147
|
-
name: name,
|
|
148
|
-
computer_name: computer_name
|
|
149
|
-
)
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def add_interface(options = {})
|
|
153
|
-
network_adapters.create options
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def save(options = {})
|
|
157
|
-
requires :name
|
|
158
|
-
|
|
159
|
-
data = \
|
|
160
|
-
if !persisted?
|
|
161
|
-
usable = %i(name memory_startup generation boot_device switch_name no_vhd new_vhd_path new_vhd_size_bytes).freeze
|
|
162
|
-
service.new_vm \
|
|
163
|
-
attributes.select { |k, _v| usable.include? k }
|
|
164
|
-
.merge(options)
|
|
165
|
-
.merge(_return_fields: self.class.attributes, _json_depth: 1)
|
|
166
|
-
else
|
|
167
|
-
service.set_vm options.merge(
|
|
168
|
-
computer_name: old.computer_name,
|
|
169
|
-
name: old.name,
|
|
170
|
-
passthru: true,
|
|
171
|
-
|
|
172
|
-
processor_count: changed!(:processor_count),
|
|
173
|
-
dynamic_memory: changed?(:dynamic_memory_enabled) && dynamic_memory_enabled,
|
|
174
|
-
static_memory: changed?(:dynamic_memory_enabled) && !dynamic_memory_enabled,
|
|
175
|
-
memory_minimum_bytes: changed?(:memory_minimum) && dynamic_memory_enabled && memory_minimum,
|
|
176
|
-
memory_maximum_bytes: changed?(:memory_maximum) && dynamic_memory_enabled && memory_maximum,
|
|
177
|
-
memory_startup_bytes: changed!(:memory_startup),
|
|
178
|
-
notes: changed!(:notes),
|
|
179
|
-
new_name: changed!(:name),
|
|
180
|
-
|
|
181
|
-
_return_fields: self.class.attributes,
|
|
182
|
-
_json_depth: 1
|
|
183
|
-
)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
merge_attributes(data)
|
|
187
|
-
@old = dup
|
|
188
|
-
self
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def reload
|
|
192
|
-
data = collection.get id
|
|
193
|
-
|
|
194
|
-
clear_lazy
|
|
195
|
-
merge_attributes(data.attributes)
|
|
196
|
-
@old = data
|
|
197
|
-
self
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def ready?
|
|
201
|
-
state_num == 2
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def mac_addresses
|
|
205
|
-
network_adapters.map(&:mac_address)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def ip_addresses
|
|
209
|
-
network_adapters.map(&:ip_addresses).flatten
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def public_ip_address
|
|
213
|
-
ip_addresses
|
|
214
|
-
.reject { |a| a =~ /^(169\.254|fe80)/ }
|
|
215
|
-
.first
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Servers < Fog::Hyperv::ComputerCollection
|
|
5
|
-
model Fog::Compute::Hyperv::Server
|
|
6
|
-
|
|
7
|
-
get_method :get_vm
|
|
8
|
-
|
|
9
|
-
def get(identity, filters = {})
|
|
10
|
-
guid = identity =~ /\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/
|
|
11
|
-
|
|
12
|
-
search = {}
|
|
13
|
-
search[:id] = identity if guid
|
|
14
|
-
search[:name] = identity unless guid
|
|
15
|
-
|
|
16
|
-
super search.merge(filters)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Switch < Fog::Hyperv::Model
|
|
5
|
-
identity :id
|
|
6
|
-
|
|
7
|
-
attribute :computer_name
|
|
8
|
-
# attribute :default_flow_minimum_bandwidth_absolute
|
|
9
|
-
# attribute :default_flow_minimum_bandwidth_weight
|
|
10
|
-
# attribute :is_deleted
|
|
11
|
-
attribute :name
|
|
12
|
-
attribute :net_adapter_interface_description
|
|
13
|
-
attribute :notes
|
|
14
|
-
attribute :switch_type, type: :enum, values: %i[Private Internal External]
|
|
15
|
-
|
|
16
|
-
def save
|
|
17
|
-
requires :name
|
|
18
|
-
|
|
19
|
-
data = \
|
|
20
|
-
if persisted?
|
|
21
|
-
service.set_vm_switch(
|
|
22
|
-
computer_name: old.computer_name,
|
|
23
|
-
name: old.name,
|
|
24
|
-
net_adapter_interface_description: old.net_adapter_interface_description,
|
|
25
|
-
switch_type: !old.net_adapter_interface_description && old.switch_type,
|
|
26
|
-
passthru: true,
|
|
27
|
-
|
|
28
|
-
default_flow_minimum_bandwidth_absolute: changed!(default_flow_minimum_bandwidth_absolute),
|
|
29
|
-
default_flow_minimum_bandwidth_weight: changed!(default_flow_minimum_bandwidth_weight),
|
|
30
|
-
notes: changed!(notes),
|
|
31
|
-
|
|
32
|
-
_return_fields: self.class.attributes,
|
|
33
|
-
_json_depth: 1
|
|
34
|
-
)
|
|
35
|
-
else
|
|
36
|
-
service.new_vm_switch(
|
|
37
|
-
computer_name: computer_name,
|
|
38
|
-
name: name,
|
|
39
|
-
net_adapter_interface_description: net_adapter_interface_description,
|
|
40
|
-
notes: notes,
|
|
41
|
-
switch_type: !net_adapter_interface_description && switch_type,
|
|
42
|
-
|
|
43
|
-
_return_fields: self.class.attributes,
|
|
44
|
-
_json_depth: 1
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
merge_attributes(data)
|
|
49
|
-
@old = dup
|
|
50
|
-
self
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def reload
|
|
54
|
-
data = collection.get(
|
|
55
|
-
name,
|
|
56
|
-
computer_name: computer_name
|
|
57
|
-
)
|
|
58
|
-
merge_attributes(data.attributes)
|
|
59
|
-
@old = data
|
|
60
|
-
self
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Fog
|
|
2
|
-
module Compute
|
|
3
|
-
class Hyperv
|
|
4
|
-
class Switches < Fog::Hyperv::ComputerCollection
|
|
5
|
-
model Fog::Compute::Hyperv::Switch
|
|
6
|
-
|
|
7
|
-
get_method :get_vm_switch
|
|
8
|
-
|
|
9
|
-
def get(name, filters = {})
|
|
10
|
-
super filters.merge(name: name)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -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
|