fog-vsphere 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +217 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/Rakefile +10 -1
- data/fog-vsphere.gemspec +2 -2
- data/lib/fog/bin/vsphere.rb +1 -1
- data/lib/fog/vsphere/compute.rb +320 -301
- data/lib/fog/vsphere/models/compute/cdrom.rb +10 -10
- data/lib/fog/vsphere/models/compute/cdroms.rb +2 -2
- data/lib/fog/vsphere/models/compute/cluster.rb +20 -20
- data/lib/fog/vsphere/models/compute/clusters.rb +1 -1
- data/lib/fog/vsphere/models/compute/customfields.rb +4 -4
- data/lib/fog/vsphere/models/compute/customvalues.rb +8 -8
- data/lib/fog/vsphere/models/compute/datacenter.rb +16 -16
- data/lib/fog/vsphere/models/compute/datastores.rb +1 -1
- data/lib/fog/vsphere/models/compute/folder.rb +2 -2
- data/lib/fog/vsphere/models/compute/folders.rb +2 -2
- data/lib/fog/vsphere/models/compute/hosts.rb +4 -4
- data/lib/fog/vsphere/models/compute/interface.rb +12 -12
- data/lib/fog/vsphere/models/compute/interfaces.rb +14 -16
- data/lib/fog/vsphere/models/compute/interfacetype.rb +2 -2
- data/lib/fog/vsphere/models/compute/interfacetypes.rb +6 -8
- data/lib/fog/vsphere/models/compute/networks.rb +1 -1
- data/lib/fog/vsphere/models/compute/resource_pools.rb +1 -1
- data/lib/fog/vsphere/models/compute/rule.rb +8 -9
- data/lib/fog/vsphere/models/compute/rules.rb +9 -10
- data/lib/fog/vsphere/models/compute/scsicontroller.rb +1 -1
- data/lib/fog/vsphere/models/compute/server.rb +68 -80
- data/lib/fog/vsphere/models/compute/servers.rb +12 -13
- data/lib/fog/vsphere/models/compute/servertype.rb +6 -6
- data/lib/fog/vsphere/models/compute/servertypes.rb +2 -2
- data/lib/fog/vsphere/models/compute/snapshot.rb +5 -6
- data/lib/fog/vsphere/models/compute/snapshots.rb +1 -1
- data/lib/fog/vsphere/models/compute/ticket.rb +0 -1
- data/lib/fog/vsphere/models/compute/volume.rb +12 -14
- data/lib/fog/vsphere/models/compute/volumes.rb +10 -10
- data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +8 -8
- data/lib/fog/vsphere/requests/compute/create_folder.rb +5 -5
- data/lib/fog/vsphere/requests/compute/create_group.rb +16 -16
- data/lib/fog/vsphere/requests/compute/create_rule.rb +13 -13
- data/lib/fog/vsphere/requests/compute/create_vm.rb +117 -119
- data/lib/fog/vsphere/requests/compute/destroy_group.rb +8 -8
- data/lib/fog/vsphere/requests/compute/destroy_rule.rb +8 -8
- data/lib/fog/vsphere/requests/compute/folder_destroy.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_cluster.rb +2 -2
- data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +16 -16
- data/lib/fog/vsphere/requests/compute/get_datacenter.rb +7 -7
- data/lib/fog/vsphere/requests/compute/get_datastore.rb +1 -2
- data/lib/fog/vsphere/requests/compute/get_folder.rb +24 -24
- data/lib/fog/vsphere/requests/compute/get_host.rb +2 -3
- data/lib/fog/vsphere/requests/compute/get_interface_type.rb +6 -6
- data/lib/fog/vsphere/requests/compute/get_network.rb +7 -10
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -2
- data/lib/fog/vsphere/requests/compute/get_server_type.rb +14 -14
- data/lib/fog/vsphere/requests/compute/get_storage_pod.rb +2 -2
- data/lib/fog/vsphere/requests/compute/get_template.rb +1 -2
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +26 -26
- data/lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb +6 -7
- data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +1 -1
- data/lib/fog/vsphere/requests/compute/host_shutdown.rb +1 -1
- data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +1 -1
- data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +37 -39
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +8 -9
- data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +57 -59
- data/lib/fog/vsphere/requests/compute/list_customfields.rb +5 -6
- data/lib/fog/vsphere/requests/compute/list_datacenters.rb +17 -17
- data/lib/fog/vsphere/requests/compute/list_datastores.rb +16 -15
- data/lib/fog/vsphere/requests/compute/list_folders.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_groups.rb +5 -5
- data/lib/fog/vsphere/requests/compute/list_hosts.rb +30 -14
- data/lib/fog/vsphere/requests/compute/list_interface_types.rb +7 -7
- data/lib/fog/vsphere/requests/compute/list_networks.rb +12 -16
- data/lib/fog/vsphere/requests/compute/list_processes.rb +14 -14
- data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +13 -14
- data/lib/fog/vsphere/requests/compute/list_rules.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_server_types.rb +24 -26
- data/lib/fog/vsphere/requests/compute/list_storage_pods.rb +8 -8
- data/lib/fog/vsphere/requests/compute/list_templates.rb +4 -5
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +15 -15
- data/lib/fog/vsphere/requests/compute/list_vm_cdroms.rb +16 -12
- data/lib/fog/vsphere/requests/compute/list_vm_customvalues.rb +3 -4
- data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +54 -56
- data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +7 -7
- data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +36 -36
- data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +43 -36
- data/lib/fog/vsphere/requests/compute/modify_vm_cdrom.rb +4 -4
- data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -2
- data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +26 -19
- data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +7 -7
- data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +2 -2
- data/lib/fog/vsphere/requests/compute/update_vm.rb +111 -0
- data/lib/fog/vsphere/requests/compute/upload_iso.rb +10 -10
- data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +3 -3
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +245 -247
- data/lib/fog/vsphere/requests/compute/vm_config_vnc.rb +15 -15
- data/lib/fog/vsphere/requests/compute/vm_destroy.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_execute.rb +16 -16
- data/lib/fog/vsphere/requests/compute/vm_migrate.rb +11 -11
- data/lib/fog/vsphere/requests/compute/vm_power_off.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_power_on.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reboot.rb +5 -5
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cdrom.rb +11 -11
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +6 -6
- data/lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +14 -16
- data/lib/fog/vsphere/requests/compute/vm_relocate.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_rename.rb +5 -5
- data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +1 -1
- data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +8 -8
- data/lib/fog/vsphere/version.rb +1 -1
- data/tests/compute_tests.rb +16 -17
- data/tests/helpers/mock_helper.rb +3 -3
- data/tests/models/compute/cluster_tests.rb +4 -5
- data/tests/models/compute/hosts_tests.rb +2 -4
- data/tests/models/compute/rules_tests.rb +10 -16
- data/tests/models/compute/server_tests.rb +30 -31
- data/tests/models/compute/servers_tests.rb +2 -4
- data/tests/models/compute/ticket_tests.rb +4 -6
- data/tests/models/compute/tickets_tests.rb +1 -3
- data/tests/requests/compute/current_time_tests.rb +2 -4
- data/tests/requests/compute/folder_destroy_tests.rb +5 -7
- data/tests/requests/compute/get_network_tests.rb +20 -23
- data/tests/requests/compute/list_child_snapshots_tests.rb +1 -2
- data/tests/requests/compute/list_clusters_tests.rb +5 -6
- data/tests/requests/compute/list_datastores_tests.rb +6 -7
- data/tests/requests/compute/list_hosts_tests.rb +3 -4
- data/tests/requests/compute/list_networks_tests.rb +6 -7
- data/tests/requests/compute/list_storage_pods_test.rb +3 -4
- data/tests/requests/compute/list_virtual_machines_tests.rb +16 -20
- data/tests/requests/compute/list_vm_cdroms_tests.rb +1 -2
- data/tests/requests/compute/list_vm_snapshots_tests.rb +1 -2
- data/tests/requests/compute/modify_vm_cdrom_tests.rb +3 -4
- data/tests/requests/compute/revert_to_snapshot_tests.rb +2 -4
- data/tests/requests/compute/set_vm_customvalue_tests.rb +0 -2
- data/tests/requests/compute/update_vm_tests.rb +13 -0
- data/tests/requests/compute/vm_clone_tests.rb +20 -20
- data/tests/requests/compute/vm_config_vnc_tests.rb +3 -4
- data/tests/requests/compute/vm_destroy_tests.rb +1 -4
- data/tests/requests/compute/vm_migrate_tests.rb +1 -2
- data/tests/requests/compute/vm_power_off_tests.rb +2 -4
- data/tests/requests/compute/vm_power_on_tests.rb +1 -3
- data/tests/requests/compute/vm_reboot_tests.rb +2 -4
- data/tests/requests/compute/vm_reconfig_cdrom_tests.rb +2 -3
- data/tests/requests/compute/vm_reconfig_cpus_tests.rb +1 -3
- data/tests/requests/compute/vm_reconfig_hardware_tests.rb +2 -4
- data/tests/requests/compute/vm_reconfig_memory_tests.rb +1 -3
- data/tests/requests/compute/vm_take_snapshot_tests.rb +1 -3
- metadata +9 -4
@@ -2,42 +2,42 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
|
-
def vm_config_vnc(options = {
|
6
|
-
raise ArgumentError,
|
5
|
+
def vm_config_vnc(options = {})
|
6
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
7
7
|
|
8
8
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
9
9
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
10
|
-
task = vm_mob_ref.ReconfigVM_Task(:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
task = vm_mob_ref.ReconfigVM_Task(spec: {
|
11
|
+
extraConfig: [
|
12
|
+
{ key: 'RemoteDisplay.vnc.enabled', value: options[:enabled] ? 'true' : 'false' },
|
13
|
+
{ key: 'RemoteDisplay.vnc.password', value: options[:password].to_s },
|
14
|
+
{ key: 'RemoteDisplay.vnc.port', value: options[:port].to_s || '5910' }
|
15
|
+
]
|
16
|
+
})
|
17
17
|
task.wait_for_completion
|
18
18
|
{ 'task_state' => task.info.state }
|
19
19
|
end
|
20
20
|
|
21
21
|
# return a hash of VNC attributes required to view the console
|
22
|
-
def vm_get_vnc
|
22
|
+
def vm_get_vnc(uuid)
|
23
23
|
search_filter = { :uuid => uuid, 'vmSearch' => true, 'instanceUuid' => true }
|
24
24
|
vm = connection.searchIndex.FindAllByUuid(search_filter).first
|
25
25
|
Hash[vm.config.extraConfig.map do |config|
|
26
26
|
if config.key =~ /^RemoteDisplay\.vnc\.(\w+)$/
|
27
|
-
[
|
27
|
+
[Regexp.last_match(1).to_sym, config.value]
|
28
28
|
end
|
29
29
|
end.compact]
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
class Mock
|
34
|
-
def vm_config_vnc(options = {
|
35
|
-
raise ArgumentError,
|
34
|
+
def vm_config_vnc(options = {})
|
35
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
36
36
|
{ 'task_state' => 'success' }
|
37
37
|
end
|
38
38
|
|
39
|
-
def vm_get_vnc
|
40
|
-
{:
|
39
|
+
def vm_get_vnc(_uuid)
|
40
|
+
{ password: 'secret', port: '5900', enabled: 'true' }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -3,7 +3,7 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_destroy(options = {})
|
6
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
7
7
|
|
8
8
|
vm_mob_ref = get_vm_ref(options['instance_uuid'])
|
9
9
|
task = vm_mob_ref.Destroy_Task
|
@@ -14,7 +14,7 @@ module Fog
|
|
14
14
|
|
15
15
|
class Mock
|
16
16
|
def vm_destroy(options = {})
|
17
|
-
raise ArgumentError,
|
17
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
18
18
|
{ 'task_state' => 'success' }
|
19
19
|
end
|
20
20
|
end
|
@@ -12,34 +12,34 @@ module Fog
|
|
12
12
|
# * 'user'<~String> *REQUIRED* the ssh username you would like to login as
|
13
13
|
# * 'password'<~String> *REQUIRED* the ssh password for the user you would like to log in as
|
14
14
|
def vm_execute(options = {})
|
15
|
-
raise ArgumentError,
|
16
|
-
raise ArgumentError,
|
17
|
-
raise ArgumentError,
|
18
|
-
raise ArgumentError,
|
15
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
16
|
+
raise ArgumentError, 'command is a required parameter' unless options.key? 'command'
|
17
|
+
raise ArgumentError, 'user is a required parameter' unless options.key? 'user'
|
18
|
+
raise ArgumentError, 'password is a required parameter' unless options.key? 'password'
|
19
19
|
|
20
20
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
21
21
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
22
22
|
|
23
|
-
auth = RbVmomi::VIM::NamePasswordAuthentication(:
|
24
|
-
:
|
25
|
-
:
|
23
|
+
auth = RbVmomi::VIM::NamePasswordAuthentication(interactiveSession: false,
|
24
|
+
username: options['user'],
|
25
|
+
password: options['password'])
|
26
26
|
|
27
|
-
spec = RbVmomi::VIM::GuestProgramSpec(:
|
28
|
-
:
|
29
|
-
:
|
27
|
+
spec = RbVmomi::VIM::GuestProgramSpec(programPath: options['command'],
|
28
|
+
arguments: options['args'],
|
29
|
+
workingDirectory: options['working_dir'])
|
30
30
|
|
31
31
|
gom = connection.serviceContent.guestOperationsManager
|
32
|
-
gom.processManager.StartProgramInGuest(:
|
32
|
+
gom.processManager.StartProgramInGuest(vm: vm_mob_ref, auth: auth, spec: spec)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
class Mock
|
37
37
|
def vm_execute(options = {})
|
38
|
-
raise ArgumentError,
|
39
|
-
raise ArgumentError,
|
40
|
-
raise ArgumentError,
|
41
|
-
raise ArgumentError,
|
42
|
-
|
38
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
39
|
+
raise ArgumentError, 'command is a required parameter' unless options.key? 'command'
|
40
|
+
raise ArgumentError, 'user is a required parameter' unless options.key? 'user'
|
41
|
+
raise ArgumentError, 'password is a required parameter' unless options.key? 'password'
|
42
|
+
12_345
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -3,27 +3,27 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_migrate(options = {})
|
6
|
-
#priority is the only required option, and it has a sane default option.
|
7
|
-
priority = options['priority'].nil? ? 'defaultPriority' : options[
|
8
|
-
raise ArgumentError,
|
6
|
+
# priority is the only required option, and it has a sane default option.
|
7
|
+
priority = options['priority'].nil? ? 'defaultPriority' : options['priority']
|
8
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
9
9
|
|
10
10
|
# Find the VM Object
|
11
11
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
12
12
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
13
13
|
|
14
|
-
unless vm_mob_ref.
|
14
|
+
unless vm_mob_ref.is_a? RbVmomi::VIM::VirtualMachine
|
15
15
|
raise Fog::Vsphere::Errors::NotFound,
|
16
|
-
|
16
|
+
"Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
|
17
17
|
end
|
18
18
|
options['host'] = get_raw_host(options['host'], options['cluster'], options['datacenter']) if options['host']
|
19
|
-
task_options = {:
|
19
|
+
task_options = { pool: options['pool'], host: options['host'], state: options['state'] }
|
20
20
|
if options['check']
|
21
21
|
checker = connection.serviceContent.vmProvisioningChecker
|
22
|
-
task = checker.CheckMigrate_Task(task_options.merge(:
|
22
|
+
task = checker.CheckMigrate_Task(task_options.merge(vm: vm_mob_ref))
|
23
23
|
task.wait_for_completion
|
24
|
-
{'error' => task.info.result[0].error, 'warning' => task.info.result[0].warning}
|
24
|
+
{ 'error' => task.info.result[0].error, 'warning' => task.info.result[0].warning }
|
25
25
|
else
|
26
|
-
task = vm_mob_ref.MigrateVM_Task(task_options.merge(:
|
26
|
+
task = vm_mob_ref.MigrateVM_Task(task_options.merge(priority: priority.to_s))
|
27
27
|
task.wait_for_completion
|
28
28
|
{ 'task_state' => task.info.state }
|
29
29
|
end
|
@@ -32,8 +32,8 @@ module Fog
|
|
32
32
|
|
33
33
|
class Mock
|
34
34
|
def vm_migrate(options = {})
|
35
|
-
priority = options['priority'].nil? ? 'defaultPriority' : options[
|
36
|
-
raise ArgumentError,
|
35
|
+
priority = options['priority'].nil? ? 'defaultPriority' : options['priority']
|
36
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
37
37
|
{ 'task_state' => 'success' }
|
38
38
|
end
|
39
39
|
end
|
@@ -4,20 +4,20 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def vm_power_off(options = {})
|
6
6
|
options = { 'force' => false }.merge(options)
|
7
|
-
raise ArgumentError,
|
7
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
8
8
|
|
9
9
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
10
10
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
11
11
|
|
12
|
-
if options['force']
|
12
|
+
if options['force']
|
13
13
|
task = vm_mob_ref.PowerOffVM_Task
|
14
14
|
task.wait_for_completion
|
15
15
|
{ 'task_state' => task.info.result, 'power_off_type' => 'cut_power' }
|
16
16
|
else
|
17
17
|
vm_mob_ref.ShutdownGuest
|
18
18
|
{
|
19
|
-
'task_state' =>
|
20
|
-
'power_off_type' => 'shutdown_guest'
|
19
|
+
'task_state' => 'running',
|
20
|
+
'power_off_type' => 'shutdown_guest'
|
21
21
|
}
|
22
22
|
end
|
23
23
|
end
|
@@ -25,12 +25,12 @@ module Fog
|
|
25
25
|
|
26
26
|
class Mock
|
27
27
|
def vm_power_off(options = {})
|
28
|
-
raise ArgumentError,
|
28
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
29
29
|
vm = get_virtual_machine(options['instance_uuid'])
|
30
|
-
vm[
|
30
|
+
vm['power_state'] = 'poweredOff'
|
31
31
|
{
|
32
|
-
'task_state' =>
|
33
|
-
'power_off_type' => options['force'] ? 'cut_power' : 'shutdown_guest'
|
32
|
+
'task_state' => 'running',
|
33
|
+
'power_off_type' => options['force'] ? 'cut_power' : 'shutdown_guest'
|
34
34
|
}
|
35
35
|
end
|
36
36
|
end
|
@@ -3,7 +3,7 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_power_on(options = {})
|
6
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
7
7
|
|
8
8
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
9
9
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
@@ -17,7 +17,7 @@ module Fog
|
|
17
17
|
|
18
18
|
class Mock
|
19
19
|
def vm_power_on(options = {})
|
20
|
-
raise ArgumentError,
|
20
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
21
21
|
{ 'task_state' => 'success' }
|
22
22
|
end
|
23
23
|
end
|
@@ -4,26 +4,26 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def vm_reboot(options = {})
|
6
6
|
options = { 'force' => false }.merge(options)
|
7
|
-
raise ArgumentError,
|
7
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
8
8
|
|
9
9
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
10
10
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
11
11
|
|
12
|
-
if options['force']
|
12
|
+
if options['force']
|
13
13
|
task = vm_mob_ref.ResetVM_Task
|
14
14
|
task.wait_for_completion
|
15
15
|
{ 'task_state' => task.info.result, 'reboot_type' => 'reset_power' }
|
16
16
|
else
|
17
17
|
vm_mob_ref.RebootGuest
|
18
|
-
{ 'task_state' =>
|
18
|
+
{ 'task_state' => 'running', 'reboot_type' => 'reboot_guest' }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
class Mock
|
24
24
|
def vm_reboot(options = {})
|
25
|
-
raise ArgumentError,
|
26
|
-
{ 'task_state'
|
25
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
26
|
+
{ 'task_state' => 'running', 'reboot_type' => options['force'] ? 'reset_power' : 'reboot_guest' }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -3,10 +3,10 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_reconfig_cdrom(options = {})
|
6
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
7
7
|
# Attach iso / disattach
|
8
|
-
if options.
|
9
|
-
raise ArgumentError,
|
8
|
+
if options.key?('iso')
|
9
|
+
raise ArgumentError, 'datastore is a required parameter' unless options.key? 'datastore'
|
10
10
|
backing = RbVmomi::VIM::VirtualCdromIsoBackingInfo(
|
11
11
|
fileName: "[#{options['datastore']}] #{options['iso']}"
|
12
12
|
)
|
@@ -24,25 +24,25 @@ module Fog
|
|
24
24
|
connectable: RbVmomi::VIM::VirtualDeviceConnectInfo(
|
25
25
|
startConnected: options['start_connected'] || false,
|
26
26
|
connected: options['connected'] || false,
|
27
|
-
allowGuestControl: options['allow_guest_control'] || true
|
27
|
+
allowGuestControl: options['allow_guest_control'] || true
|
28
28
|
)
|
29
29
|
)
|
30
30
|
}]
|
31
31
|
}
|
32
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
32
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
class Mock
|
37
37
|
def vm_reconfig_cdrom(options = {})
|
38
|
-
raise ArgumentError,
|
39
|
-
if options.
|
40
|
-
raise ArgumentError,
|
38
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
39
|
+
if options.key?('iso')
|
40
|
+
raise ArgumentError, 'datastore is a required parameter' unless options.key? 'datastore'
|
41
41
|
backing = {
|
42
42
|
fileName: "[#{options['datastore']}] #{options['iso']}"
|
43
43
|
}
|
44
44
|
else
|
45
|
-
backing = {deviceName: ''}
|
45
|
+
backing = { deviceName: '' }
|
46
46
|
end
|
47
47
|
cdrom_obj = list_vm_cdroms(options['instance_uuid']).first
|
48
48
|
hardware_spec = {
|
@@ -55,12 +55,12 @@ module Fog
|
|
55
55
|
connectable: {
|
56
56
|
startConnected: options['start_connected'] || false,
|
57
57
|
connected: options['connected'] || false,
|
58
|
-
allowGuestControl: options['allow_guest_control'] || true
|
58
|
+
allowGuestControl: options['allow_guest_control'] || true
|
59
59
|
}
|
60
60
|
}
|
61
61
|
}]
|
62
62
|
}
|
63
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
63
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -3,19 +3,19 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_reconfig_cpus(options = {})
|
6
|
-
raise ArgumentError,
|
7
|
-
raise ArgumentError,
|
8
|
-
hardware_spec={'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket']}
|
9
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
6
|
+
raise ArgumentError, 'cpus is a required parameter' unless options.key? 'cpus'
|
7
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
8
|
+
hardware_spec = { 'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket'] }
|
9
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Mock
|
14
14
|
def vm_reconfig_cpus(options = {})
|
15
|
-
raise ArgumentError,
|
16
|
-
raise ArgumentError,
|
17
|
-
hardware_spec={'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket']}
|
18
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
15
|
+
raise ArgumentError, 'cpus is a required parameter' unless options.key? 'cpus'
|
16
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
17
|
+
hardware_spec = { 'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket'] }
|
18
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -3,19 +3,19 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_reconfig_hardware(options = {})
|
6
|
-
raise ArgumentError,
|
7
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'hardware_spec is a required parameter' unless options.key? 'hardware_spec'
|
7
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
8
8
|
vm_mob_ref = get_vm_ref(options['instance_uuid'])
|
9
|
-
task = vm_mob_ref.ReconfigVM_Task(:
|
9
|
+
task = vm_mob_ref.ReconfigVM_Task(spec: RbVmomi::VIM.VirtualMachineConfigSpec(options['hardware_spec']))
|
10
10
|
task.wait_for_completion
|
11
|
-
|
11
|
+
{ 'task_state' => task.info.state }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
class Mock
|
16
16
|
def vm_reconfig_hardware(options = {})
|
17
|
-
raise ArgumentError,
|
18
|
-
raise ArgumentError,
|
17
|
+
raise ArgumentError, 'hardware_spec is a required parameter' unless options.key? 'hardware_spec'
|
18
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
19
19
|
{ 'task_state' => 'success' }
|
20
20
|
end
|
21
21
|
end
|
@@ -3,19 +3,19 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_reconfig_memory(options = {})
|
6
|
-
raise ArgumentError,
|
7
|
-
raise ArgumentError,
|
8
|
-
hardware_spec={'memoryMB' => options['memory']}
|
9
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
6
|
+
raise ArgumentError, 'memory is a required parameter' unless options.key? 'memory'
|
7
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
8
|
+
hardware_spec = { 'memoryMB' => options['memory'] }
|
9
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Mock
|
14
14
|
def vm_reconfig_memory(options = {})
|
15
|
-
raise ArgumentError,
|
16
|
-
raise ArgumentError,
|
17
|
-
hardware_spec={'memoryMB' => options['memory']}
|
18
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
15
|
+
raise ArgumentError, 'memory is a required parameter' unless options.key? 'memory'
|
16
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
17
|
+
hardware_spec = { 'memoryMB' => options['memory'] }
|
18
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -3,38 +3,36 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_reconfig_volumes(options = {})
|
6
|
-
raise ArgumentError,
|
7
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
7
|
+
raise ArgumentError, 'volumes is a required parameter' unless options.key? 'volumes'
|
8
8
|
hardware_spec = {
|
9
9
|
deviceChange: []
|
10
10
|
}
|
11
11
|
options['volumes'].each do |volume|
|
12
12
|
hardware_spec[:deviceChange].push(create_disk(volume, :edit, filename: volume.filename))
|
13
13
|
end
|
14
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
14
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
class Mock
|
19
19
|
def vm_reconfig_volumes(options = {})
|
20
|
-
raise ArgumentError,
|
21
|
-
raise ArgumentError,
|
20
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
21
|
+
raise ArgumentError, 'volumes is a required parameter' unless options.key? 'volumes'
|
22
22
|
hardware_spec = {
|
23
23
|
deviceChange: []
|
24
24
|
}
|
25
25
|
options['volumes'].each do |volume|
|
26
|
-
hardware_spec[:deviceChange].push(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
})
|
26
|
+
hardware_spec[:deviceChange].push(operation: :edit,
|
27
|
+
device: {
|
28
|
+
backing: { diskMode: volume.mode, fileName: volume.filename },
|
29
|
+
unitNumber: volume.unit_number,
|
30
|
+
key: volume.key,
|
31
|
+
controllerKey: volume.controller_key,
|
32
|
+
capacityInKB: volume.size
|
33
|
+
})
|
36
34
|
end
|
37
|
-
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec
|
35
|
+
vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|