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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class FloppyDrive < Fog::Hyperv::Model
|
|
5
|
+
# @!attribute [r] id
|
|
6
|
+
# @return [String] the combined GUID of this floppy drive
|
|
7
|
+
identity :id, type: :string
|
|
8
|
+
|
|
9
|
+
# @!attribute [r] vm_id
|
|
10
|
+
# @return [String] the GUID of the VM this BIOS configuration is attached to
|
|
11
|
+
attribute :vm_id, type: :string
|
|
12
|
+
# @!attribute [r] computer_name
|
|
13
|
+
# @return [String] the name of the computer running the VM that this BIOS configuration is attached to
|
|
14
|
+
attribute :computer_name, type: :string
|
|
15
|
+
|
|
16
|
+
# @!attribute [r] name
|
|
17
|
+
# @return [String] the name of this floppy drive
|
|
18
|
+
attribute :name, type: :string
|
|
19
|
+
# @!attribute path
|
|
20
|
+
# @return [String] the path this floppy drive is serving
|
|
21
|
+
attribute :path
|
|
22
|
+
# @!attribute pool_name
|
|
23
|
+
# @return [String] the pool storing this floppy drive's image
|
|
24
|
+
attribute :pool_name
|
|
25
|
+
|
|
26
|
+
def update
|
|
27
|
+
requires :vm_id, :id
|
|
28
|
+
|
|
29
|
+
changes = {
|
|
30
|
+
resource_pool_name: changed!(:pool_name)
|
|
31
|
+
}.compact
|
|
32
|
+
changes[:path] = path if changed? :path
|
|
33
|
+
return self unless changes.any?
|
|
34
|
+
|
|
35
|
+
merge_attributes(
|
|
36
|
+
service.set_vm_floppy_disk_drive(
|
|
37
|
+
computer_name:,
|
|
38
|
+
vm_id:,
|
|
39
|
+
id:,
|
|
40
|
+
|
|
41
|
+
**changes,
|
|
42
|
+
|
|
43
|
+
_always_include: changes.keys,
|
|
44
|
+
_return_fields: self.class.attributes
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def reload
|
|
50
|
+
requires :vm_id, :id
|
|
51
|
+
|
|
52
|
+
data = service.get_vm_floppy_disk_drive(
|
|
53
|
+
computer_name:,
|
|
54
|
+
vm_id:,
|
|
55
|
+
id:,
|
|
56
|
+
|
|
57
|
+
_return_fields: self.class.attributes
|
|
58
|
+
)
|
|
59
|
+
return unless data
|
|
60
|
+
|
|
61
|
+
merge_attributes(data)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class FloppyDrives < Fog::Hyperv::Collection
|
|
5
|
+
model Fog::Hyperv::Compute::FloppyDrive
|
|
6
|
+
|
|
7
|
+
get_method :get_vm_floppy_disk_drive
|
|
8
|
+
|
|
9
|
+
attribute :computer_name
|
|
10
|
+
attribute :vm_id
|
|
11
|
+
|
|
12
|
+
requires :vm_id
|
|
13
|
+
|
|
14
|
+
def get(id, **filters)
|
|
15
|
+
super(_by_id: id, **filters)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fog/hyperv/model'
|
|
4
|
+
|
|
5
|
+
class Fog::Hyperv::Compute
|
|
6
|
+
# A hard drive attached to a VM
|
|
7
|
+
class HardDrive < Fog::Hyperv::Model
|
|
8
|
+
# @!attribute [r] id
|
|
9
|
+
# @return [String] the GUID of this hard drive
|
|
10
|
+
identity :id
|
|
11
|
+
|
|
12
|
+
# @!attribute [r] computer_name
|
|
13
|
+
# @return [String] the name of the computer running the VM that this hard drive is attached to
|
|
14
|
+
attribute :computer_name
|
|
15
|
+
# @!attribute [r] vm_id
|
|
16
|
+
# @return [String] the GUID of the VM this hard drive is attached to
|
|
17
|
+
attribute :vm_id
|
|
18
|
+
|
|
19
|
+
# @!attribute controller_location
|
|
20
|
+
# @return [String] the controller location this hard drive is attached to
|
|
21
|
+
attribute :controller_location
|
|
22
|
+
# @!attribute controller_number
|
|
23
|
+
# @return [Integer] the controller number this hard drive is attached to
|
|
24
|
+
attribute :controller_number, type: :integer
|
|
25
|
+
# @!attribute [r] controller_type
|
|
26
|
+
# @return [:IDE, :SCSI] the controller type this hard drive is attached to
|
|
27
|
+
attribute :controller_type, type: :hypervenum, values: %i[IDE SCSI]
|
|
28
|
+
# @!attribute disk
|
|
29
|
+
# @return [Object] the attached physical disk
|
|
30
|
+
attribute :disk
|
|
31
|
+
# attribute :is_deleted
|
|
32
|
+
# @!attribute maximum_iops
|
|
33
|
+
# @return [Integer] the maximum number of IOPS allocated for this hard drive
|
|
34
|
+
attribute :maximum_iops, type: :integer
|
|
35
|
+
# @!attribute minimum_iops
|
|
36
|
+
# @return [Integer] the minimum number of IOPS allocated for this hard drive
|
|
37
|
+
attribute :minimum_iops, type: :integer
|
|
38
|
+
# @!attribute [r] name
|
|
39
|
+
# @return [String] the name of this hard drive
|
|
40
|
+
attribute :name
|
|
41
|
+
# @!attribute path
|
|
42
|
+
# @return [String] the path to the VHD file for this hard drive
|
|
43
|
+
attribute :path
|
|
44
|
+
# @!attribute pool_name
|
|
45
|
+
# @return [String] the name of the pool storing this hard drive's image
|
|
46
|
+
attribute :pool_name
|
|
47
|
+
# @!attribute support_persistent_reservations
|
|
48
|
+
# @return [Boolean] if the underlying hard drive supports SCSI persistent reservations.
|
|
49
|
+
# This should be set when multiple VMs share the same underlying disk.
|
|
50
|
+
attribute :support_persistent_reservations
|
|
51
|
+
# TODO? VM Snapshots?
|
|
52
|
+
|
|
53
|
+
attribute :allow_unverified_paths, type: :boolean
|
|
54
|
+
|
|
55
|
+
has_one :vhd, :vhds
|
|
56
|
+
|
|
57
|
+
def initialize(attributes = {})
|
|
58
|
+
vhd = attributes[:vhd]
|
|
59
|
+
attributes[:path] ||= vhd&.path
|
|
60
|
+
|
|
61
|
+
super
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @!attribute vhd
|
|
65
|
+
# @return [Vhd,nil] the VHD that is attached to this hard drive
|
|
66
|
+
def vhd
|
|
67
|
+
return associations[:vhd] if associations[:vhd]
|
|
68
|
+
return unless path
|
|
69
|
+
|
|
70
|
+
associations[:vhd] = service.vhds.get(path, computer_name:)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def vhd=(new_vhd)
|
|
74
|
+
raise ArgumentError, 'Must be a VHD' unless new_vhd.nil? || new_vhd.is_a?(Vhd)
|
|
75
|
+
|
|
76
|
+
attributes[:path] = new_vhd&.path
|
|
77
|
+
associations[:vhd] = new_vhd
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# @return [Boolean] does the hard drive have a VHD attached?
|
|
81
|
+
def vhd?
|
|
82
|
+
!vhd.nil?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# @!attribute [r] size_bytes
|
|
86
|
+
# @return [Integer,nil] the size of the underlying VHD if any
|
|
87
|
+
def size_bytes
|
|
88
|
+
vhd&.size
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def create
|
|
92
|
+
requires :vm_id
|
|
93
|
+
requires_one :controller_location, :controller_number, :controller_type, :path
|
|
94
|
+
|
|
95
|
+
if associations[:vhd]
|
|
96
|
+
vhd.save if !vhd.persisted? || vhd.dirty?
|
|
97
|
+
attributes[:path] ||= vhd.path
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
merge_attributes(
|
|
101
|
+
service.add_vm_hard_disk_drive(
|
|
102
|
+
computer_name:,
|
|
103
|
+
vm_id:,
|
|
104
|
+
|
|
105
|
+
allow_unverified_paths:,
|
|
106
|
+
controller_location:,
|
|
107
|
+
controller_number:,
|
|
108
|
+
controller_type:,
|
|
109
|
+
# disk_number: disk&.number,
|
|
110
|
+
maximum_iops:,
|
|
111
|
+
minimum_iops:,
|
|
112
|
+
path:,
|
|
113
|
+
resource_pool_name: pool_name,
|
|
114
|
+
|
|
115
|
+
_return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def update
|
|
121
|
+
requires :id, :vm_id
|
|
122
|
+
|
|
123
|
+
changes = {
|
|
124
|
+
maximum_iops: changed!(:maximum_iops),
|
|
125
|
+
minimum_iops: changed!(:minimum_iops),
|
|
126
|
+
resource_pool_name: changed!(:pool_name),
|
|
127
|
+
support_persistent_reservations: changed!(:support_persistent_reservations),
|
|
128
|
+
to_controller_location: changed!(:controller_location),
|
|
129
|
+
to_controller_number: changed!(:controller_number),
|
|
130
|
+
to_controller_type: changed!(:controller_type)
|
|
131
|
+
}.compact
|
|
132
|
+
changes[:path] = path if changed?(:path)
|
|
133
|
+
|
|
134
|
+
if changes.any?
|
|
135
|
+
merge_attributes(
|
|
136
|
+
service.set_vm_hard_disk_drive(
|
|
137
|
+
computer_name: old.computer_name,
|
|
138
|
+
vm_id: old.vm_id,
|
|
139
|
+
id: old.id,
|
|
140
|
+
|
|
141
|
+
**changes,
|
|
142
|
+
allow_unverified_paths:,
|
|
143
|
+
|
|
144
|
+
_always_include: changes.keys,
|
|
145
|
+
_return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
if associations[:vhd]
|
|
151
|
+
vhd.save if !vhd.persisted? || vhd.dirty?
|
|
152
|
+
associations[:vhd] = nil if changed?(:path)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
self
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def reload
|
|
159
|
+
requires :id, :vm_id
|
|
160
|
+
|
|
161
|
+
data = service.get_vm_hard_disk_drive(
|
|
162
|
+
computer_name:,
|
|
163
|
+
vm_id:,
|
|
164
|
+
id:,
|
|
165
|
+
|
|
166
|
+
_return_fields: self.class.attributes - %i[allow_unverified_paths vhd]
|
|
167
|
+
)
|
|
168
|
+
return unless data
|
|
169
|
+
|
|
170
|
+
merge_attributes(data)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def destroy(underlying: false)
|
|
174
|
+
return unless persisted?
|
|
175
|
+
|
|
176
|
+
requires :id, :vm_id
|
|
177
|
+
|
|
178
|
+
service.remove_vm_hard_disk_drive(
|
|
179
|
+
computer_name:,
|
|
180
|
+
vm_id:,
|
|
181
|
+
id:
|
|
182
|
+
)
|
|
183
|
+
vhd.destroy if underlying && vhd?
|
|
184
|
+
true
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class HardDrives < Fog::Hyperv::Collection
|
|
5
|
+
model Fog::Hyperv::Compute::HardDrive
|
|
6
|
+
|
|
7
|
+
get_method :get_vm_hard_disk_drive
|
|
8
|
+
|
|
9
|
+
attribute :computer_name
|
|
10
|
+
attribute :vm_id
|
|
11
|
+
|
|
12
|
+
requires :vm_id
|
|
13
|
+
|
|
14
|
+
def get(id, **filters)
|
|
15
|
+
raise ArgumentError, 'Must provide a GUID' if id.nil? || id.empty?
|
|
16
|
+
|
|
17
|
+
super(_by_id: id, **filters)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
def search_attributes
|
|
23
|
+
super.merge(
|
|
24
|
+
_return_fields: model.attributes - %i[allow_unverified_paths vhd]
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Fog::Hyperv::Compute
|
|
4
|
+
class Host < Fog::Hyperv::Model
|
|
5
|
+
# @!attribute [r] name
|
|
6
|
+
# @return [String] the name of the host
|
|
7
|
+
identity :name
|
|
8
|
+
alias computer_name :name
|
|
9
|
+
|
|
10
|
+
# @!attribute [r] fully_qualified_domain_name
|
|
11
|
+
# @return [String] the FQDN of this host
|
|
12
|
+
attribute :fully_qualified_domain_name
|
|
13
|
+
# @!attribute [r] logical_processor_count
|
|
14
|
+
# @return [Integer] the number of logical CPUs on this host
|
|
15
|
+
attribute :logical_processor_count, type: :integer
|
|
16
|
+
# @!attribute [r] memory_capacity
|
|
17
|
+
# @return [Integer] the amount of memory on this host
|
|
18
|
+
attribute :memory_capacity, type: :integer
|
|
19
|
+
# @!attribute [r] mac_address_minimum
|
|
20
|
+
# @return [String] the lowest possible MAC address for VMs on this host
|
|
21
|
+
attribute :mac_address_minimum
|
|
22
|
+
# @!attribute [r] mac_address_maximum
|
|
23
|
+
# @return [String] the highest possible MAC address for VMs on this host
|
|
24
|
+
attribute :mac_address_maximum
|
|
25
|
+
# @!attribute [r] maximum_storage_migrations
|
|
26
|
+
# @return [String] the maximum number of simulatenous storage migrations on this host
|
|
27
|
+
attribute :maximum_storage_migrations, type: :integer
|
|
28
|
+
# @!attribute [r] maximum_virtual_machine_migrations
|
|
29
|
+
# @return [String] the maximum number of simulatenous VMM migrations on this host
|
|
30
|
+
attribute :maximum_virtual_machine_migrations, type: :integer
|
|
31
|
+
# @!attribute [r] virtual_hard_disk_path
|
|
32
|
+
# @return [String] the path where VHDs will be stored on this host
|
|
33
|
+
attribute :virtual_hard_disk_path
|
|
34
|
+
# @!attribute [r] virtual_machine_path
|
|
35
|
+
# @return [String] the path where VMs will be stored on this host
|
|
36
|
+
attribute :virtual_machine_path
|
|
37
|
+
|
|
38
|
+
# @!attribute [r] network_adapters
|
|
39
|
+
# @return [Array<NetworkAdapter>] the network adapters on this host
|
|
40
|
+
collection :network_adapters
|
|
41
|
+
# @!attribute [r] servers
|
|
42
|
+
# @return [Array<Server>] the VMs running on this host
|
|
43
|
+
collection :servers
|
|
44
|
+
# @!attribute [r] switches
|
|
45
|
+
# @return [Array<Switch>] the network switches available on this host
|
|
46
|
+
collection :switches
|
|
47
|
+
|
|
48
|
+
# @!attribute [r] secure_boot_templates
|
|
49
|
+
# @return [Array<String>] the available secure boot templates on this host
|
|
50
|
+
def secure_boot_templates
|
|
51
|
+
service.get_vm_host_sbt(computer_name: name)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def reload
|
|
55
|
+
requires :name
|
|
56
|
+
|
|
57
|
+
data = service.get_vm_host(
|
|
58
|
+
computer_name:,
|
|
59
|
+
name:
|
|
60
|
+
)
|
|
61
|
+
return unless data
|
|
62
|
+
|
|
63
|
+
merge_attributes(data)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|