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
@@ -15,15 +15,15 @@ module Fog
|
|
15
15
|
# hash with diskId wich is key attribute of volume,
|
16
16
|
# and datastore to relocate to.
|
17
17
|
def vm_relocate(options = {})
|
18
|
-
raise ArgumentError,
|
18
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
19
19
|
|
20
20
|
# Find the VM Object
|
21
21
|
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
22
22
|
vm_mob_ref = connection.searchIndex.FindAllByUuid(search_filter).first
|
23
23
|
|
24
|
-
unless vm_mob_ref.
|
24
|
+
unless vm_mob_ref.is_a? RbVmomi::VIM::VirtualMachine
|
25
25
|
raise Fog::Vsphere::Errors::NotFound,
|
26
|
-
|
26
|
+
"Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
|
27
27
|
end
|
28
28
|
options['host'] = get_raw_host(options['host'], options['cluster'], options['datacenter']) if options['host']
|
29
29
|
if options['disks']
|
@@ -33,11 +33,11 @@ module Fog
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
spec = RbVmomi::VIM::VirtualMachineRelocateSpec(
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
36
|
+
pool: options['pool'],
|
37
|
+
host: options['host'],
|
38
|
+
disk: options['disks']
|
39
39
|
)
|
40
|
-
task = vm_mob_ref.RelocateVM_Task(:
|
40
|
+
task = vm_mob_ref.RelocateVM_Task(spec: spec, priority: options['priority'])
|
41
41
|
task.wait_for_completion
|
42
42
|
{ 'task_state' => task.info.state }
|
43
43
|
end
|
@@ -45,7 +45,7 @@ module Fog
|
|
45
45
|
|
46
46
|
class Mock
|
47
47
|
def vm_relocate(options = {})
|
48
|
-
raise ArgumentError,
|
48
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
49
49
|
{ 'task_state' => 'success' }
|
50
50
|
end
|
51
51
|
end
|
@@ -5,7 +5,7 @@ module Fog
|
|
5
5
|
def vm_remove_snapshot(vm_id, snapshot_id, remove_children = false)
|
6
6
|
vm = servers.get(vm_id)
|
7
7
|
snapshot = vm.snapshots.get(snapshot_id).mo_ref
|
8
|
-
task = snapshot.RemoveSnapshot_Task(:
|
8
|
+
task = snapshot.RemoveSnapshot_Task(removeChildren: remove_children)
|
9
9
|
|
10
10
|
task.wait_for_completion
|
11
11
|
|
@@ -17,7 +17,7 @@ module Fog
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Mock
|
20
|
-
def vm_remove_snapshot(
|
20
|
+
def vm_remove_snapshot(_vm_id, _snapshot_id)
|
21
21
|
{
|
22
22
|
'task_state' => 'success',
|
23
23
|
'was_cancelled' => false
|
@@ -3,10 +3,10 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_rename(options = {})
|
6
|
-
raise ArgumentError,
|
7
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
|
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.Rename_Task(:
|
9
|
+
task = vm_mob_ref.Rename_Task(newName: options['name'])
|
10
10
|
task.wait_for_completion
|
11
11
|
{ 'task_state' => task.info.state }
|
12
12
|
end
|
@@ -14,8 +14,8 @@ module Fog
|
|
14
14
|
|
15
15
|
class Mock
|
16
16
|
def vm_rename(options = {})
|
17
|
-
raise ArgumentError,
|
18
|
-
raise ArgumentError,
|
17
|
+
raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
|
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,14 +3,14 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def vm_take_snapshot(options = {})
|
6
|
-
raise ArgumentError,
|
7
|
-
raise ArgumentError,
|
6
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
7
|
+
raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
|
8
8
|
vm = get_vm_ref(options['instance_uuid'])
|
9
9
|
task = vm.CreateSnapshot_Task(
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
10
|
+
name: options['name'],
|
11
|
+
description: options['description'] || '',
|
12
|
+
memory: options['memory'] || true,
|
13
|
+
quiesce: options['quiesce'] || false
|
14
14
|
)
|
15
15
|
|
16
16
|
task.wait_for_completion
|
@@ -24,8 +24,8 @@ module Fog
|
|
24
24
|
|
25
25
|
class Mock
|
26
26
|
def vm_take_snapshot(options = {})
|
27
|
-
raise ArgumentError,
|
28
|
-
raise ArgumentError,
|
27
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
28
|
+
raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
|
29
29
|
{
|
30
30
|
'task_state' => 'success',
|
31
31
|
'was_cancelled' => false
|
data/lib/fog/vsphere/version.rb
CHANGED
data/tests/compute_tests.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do
|
2
|
-
|
3
2
|
compute = Fog::Compute[:vsphere]
|
4
3
|
|
5
|
-
tests(
|
4
|
+
tests('| convert_vm_mob_ref_to_attr_hash') do
|
6
5
|
# Mock the RbVmomi::VIM::ManagedObject class
|
7
6
|
class MockManagedObject
|
8
7
|
attr_reader :parent, :_ref
|
@@ -11,42 +10,42 @@ Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do
|
|
11
10
|
@parent = @_ref = 'vm-123'
|
12
11
|
end
|
13
12
|
|
14
|
-
def collect!
|
13
|
+
def collect!(*_pathSet)
|
15
14
|
{ '_ref' => 'vm-123', 'name' => 'fakevm' }
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
fake_vm_mob_ref = MockManagedObject.new
|
20
19
|
|
21
|
-
tests(
|
22
|
-
test(
|
23
|
-
compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref).
|
20
|
+
tests('When converting an incomplete vm object') do
|
21
|
+
test('it should return a Hash') do
|
22
|
+
compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref).is_a? Hash
|
24
23
|
end
|
25
|
-
tests(
|
24
|
+
tests('The converted Hash should') do
|
26
25
|
attr_hash = compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref)
|
27
|
-
test(
|
28
|
-
test(
|
29
|
-
test(
|
30
|
-
test(
|
26
|
+
test('have a name') { attr_hash['name'] == 'fakevm' }
|
27
|
+
test('have a mo_ref') { attr_hash['mo_ref'] == 'vm-123' }
|
28
|
+
test('have an id') { attr_hash['id'] == 'vm-123' }
|
29
|
+
test('not have a instance_uuid') { attr_hash['instance_uuid'].nil? }
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
tests(
|
33
|
+
tests('When passed a nil object') do
|
35
34
|
attr_hash = compute.send :convert_vm_mob_ref_to_attr_hash, nil
|
36
|
-
test(
|
35
|
+
test('it should return a nil object') do
|
37
36
|
attr_hash.nil?
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
|
-
tests(
|
43
|
-
%w
|
41
|
+
tests('Compute attributes') do
|
42
|
+
%w[vsphere_is_vcenter vsphere_rev vsphere_username vsphere_server].each do |attr|
|
44
43
|
test("it should respond to #{attr}") { compute.respond_to? attr }
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
tests(
|
49
|
-
%w
|
47
|
+
tests('Compute collections') do
|
48
|
+
%w[servers].each do |collection|
|
50
49
|
test("it should respond to #{collection}") { compute.respond_to? collection }
|
51
50
|
end
|
52
51
|
end
|
@@ -2,8 +2,8 @@ Fog.mock! if ENV['FOG_MOCK'] == 'true'
|
|
2
2
|
|
3
3
|
if Fog.mock?
|
4
4
|
Fog.credentials = {
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
5
|
+
vsphere_server: 'fake_vsphere_server',
|
6
|
+
vsphere_username: 'fake_vsphere_username',
|
7
|
+
vsphere_password: 'fake_vsphere_password'
|
8
8
|
}.merge(Fog.credentials)
|
9
9
|
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:vsphere] | cluster collection', ['vsphere']) do
|
2
|
-
|
3
2
|
compute = Fog::Compute[:vsphere]
|
4
3
|
|
5
4
|
tests('Cluster collection') do
|
6
5
|
clusters = compute.datacenters.first.clusters
|
7
6
|
|
8
|
-
test('should not be empty') {
|
9
|
-
test('should be a kind of Fog::Compute::Vsphere::Clusters') { clusters.
|
7
|
+
test('should not be empty') { !clusters.empty? }
|
8
|
+
test('should be a kind of Fog::Compute::Vsphere::Clusters') { clusters.is_a? Fog::Compute::Vsphere::Clusters }
|
10
9
|
test('should get a cluster') { clusters.get('Solutionscluster').id == '1d4d9a3f-e4e8-4c40-b7fc-263850068fa4' }
|
11
10
|
end
|
12
11
|
|
13
12
|
tests('A cluster should') do
|
14
13
|
cluster = compute.datacenters.first.clusters.get('Solutionscluster')
|
15
14
|
|
16
|
-
test('have datastores') { cluster.datastores.first.
|
17
|
-
test('have networks') { cluster.networks.first.
|
15
|
+
test('have datastores') { cluster.datastores.first.is_a? Fog::Compute::Vsphere::Datastore }
|
16
|
+
test('have networks') { cluster.networks.first.is_a? Fog::Compute::Vsphere::Network }
|
18
17
|
end
|
19
18
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:vsphere] | hosts collection', ['vsphere']) do
|
2
|
-
|
3
2
|
compute = Fog::Compute[:vsphere]
|
4
3
|
cluster = compute.datacenters.first.clusters.get('Solutionscluster')
|
5
4
|
hosts = cluster.hosts
|
6
5
|
|
7
6
|
tests('The hosts collection') do
|
8
|
-
test('should not be empty') {
|
9
|
-
test('should be a kind of Fog::Compute::Vsphere::Hosts') { hosts.
|
7
|
+
test('should not be empty') { !hosts.empty? }
|
8
|
+
test('should be a kind of Fog::Compute::Vsphere::Hosts') { hosts.is_a? Fog::Compute::Vsphere::Hosts }
|
10
9
|
test('should get hosts') { hosts.get('host1.example.com').name == 'host1.example.com' }
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
@@ -1,34 +1,28 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:vsphere] | rules collection', ['vsphere']) do
|
2
|
-
|
3
2
|
compute = Fog::Compute[:vsphere]
|
4
3
|
cluster = compute.datacenters.first.clusters.get('Solutionscluster')
|
5
4
|
servers = compute.servers
|
6
5
|
rules = cluster.rules
|
7
|
-
|
6
|
+
|
8
7
|
tests('The rules collection') do
|
9
|
-
test('should not be empty') {
|
10
|
-
test('should be a kind of Fog::Compute::Vsphere::Rules') { rules.
|
8
|
+
test('should not be empty') { !rules.empty? }
|
9
|
+
test('should be a kind of Fog::Compute::Vsphere::Rules') { rules.is_a? Fog::Compute::Vsphere::Rules }
|
11
10
|
test('should get rules') { rules.get('anti-affinity-foo').key == 4242 }
|
12
11
|
test('should destroy rules') { rules.first.destroy; rules.reload; rules.empty? }
|
13
12
|
test('should create rules') do
|
14
|
-
r = rules.new(
|
15
|
-
|
16
|
-
|
17
|
-
type: RbVmomi::VIM::ClusterAffinityRuleSpec
|
18
|
-
})
|
13
|
+
r = rules.new(name: 'affinity-foo',
|
14
|
+
enabled: true,
|
15
|
+
type: RbVmomi::VIM::ClusterAffinityRuleSpec)
|
19
16
|
r.vms = [servers.get('5032c8a5-9c5e-ba7a-3804-832a03e16381'), servers.get('502916a3-b42e-17c7-43ce-b3206e9524dc')]
|
20
17
|
r.save
|
21
18
|
rules.reload
|
22
19
|
rules.get('affinity-foo').key > 0
|
23
20
|
end
|
24
21
|
raises(ArgumentError, 'should not create rules with <2 vms') do
|
25
|
-
rules.create(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
vm_ids: ['5032c8a5-9c5e-ba7a-3804-832a03e16381']
|
30
|
-
})
|
22
|
+
rules.create(name: 'affinity-foo',
|
23
|
+
enabled: true,
|
24
|
+
type: RbVmomi::VIM::ClusterAffinityRuleSpec,
|
25
|
+
vm_ids: ['5032c8a5-9c5e-ba7a-3804-832a03e16381'])
|
31
26
|
end
|
32
27
|
end
|
33
|
-
|
34
28
|
end
|
@@ -5,71 +5,70 @@ Shindo.tests('Fog::Compute[:vsphere] | server model', ['vsphere']) do
|
|
5
5
|
tests('The server model should') do
|
6
6
|
tests('have the action') do
|
7
7
|
test('reload') { server.respond_to? 'reload' }
|
8
|
-
%w
|
8
|
+
%w[stop suspend destroy reboot].each do |action|
|
9
9
|
test(action) { server.respond_to? action }
|
10
10
|
test("#{action} returns successfully") { server.send(action.to_sym) ? true : false }
|
11
11
|
end
|
12
12
|
test('start') { server.respond_to?('start') }
|
13
|
-
test(
|
13
|
+
test('start returns false, because it is already poweredOn') { server.start ? true : false }
|
14
14
|
test('guest_processes') { server.respond_to? 'guest_processes' }
|
15
15
|
test('take_snapshot') do
|
16
|
-
test('responds') { server.respond_to? 'take_snapshot'}
|
17
|
-
test('returns successfully') { server.take_snapshot('name' => 'foobar').
|
16
|
+
test('responds') { server.respond_to? 'take_snapshot' }
|
17
|
+
test('returns successfully') { server.take_snapshot('name' => 'foobar').is_a? Hash }
|
18
18
|
end
|
19
19
|
test('snapshots') do
|
20
|
-
test('responds') { server.respond_to? 'snapshots'}
|
21
|
-
test('returns successfully') { server.snapshots.
|
20
|
+
test('responds') { server.respond_to? 'snapshots' }
|
21
|
+
test('returns successfully') { server.snapshots.is_a? Fog::Compute::Vsphere::Snapshots }
|
22
22
|
end
|
23
23
|
test('find_snapshot') do
|
24
|
-
test('responds') { server.respond_to? 'find_snapshot'}
|
24
|
+
test('responds') { server.respond_to? 'find_snapshot' }
|
25
25
|
test('returns successfully') do
|
26
|
-
server.find_snapshot('snapshot-0101').
|
26
|
+
server.find_snapshot('snapshot-0101').is_a? Fog::Compute::Vsphere::Snapshot
|
27
27
|
end
|
28
28
|
test('returns correct snapshot') do
|
29
29
|
server.find_snapshot('snapshot-0101').ref == 'snapshot-0101'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
tests('revert_snapshot') do
|
33
|
-
test('responds') { server.respond_to? 'revert_snapshot'}
|
33
|
+
test('responds') { server.respond_to? 'revert_snapshot' }
|
34
34
|
tests('returns correctly') do
|
35
|
-
test('when correct input given') { server.revert_snapshot('snapshot-0101').
|
35
|
+
test('when correct input given') { server.revert_snapshot('snapshot-0101').is_a? Hash }
|
36
36
|
test('when incorrect input given') do
|
37
37
|
raises(ArgumentError) { server.revert_snapshot(1) }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
test('tickets') do
|
42
|
-
test('acquire ticket successfully') { server.acquire_ticket.
|
42
|
+
test('acquire ticket successfully') { server.acquire_ticket.is_a? Fog::Compute::Vsphere::Ticket }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
tests('have attributes') do
|
46
46
|
model_attribute_hash = server.attributes
|
47
|
-
attributes = [
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
tests(
|
47
|
+
attributes = %i[id
|
48
|
+
instance_uuid
|
49
|
+
uuid
|
50
|
+
power_state
|
51
|
+
tools_state
|
52
|
+
mo_ref
|
53
|
+
tools_version
|
54
|
+
hostname
|
55
|
+
mac_addresses
|
56
|
+
operatingsystem
|
57
|
+
connection_state
|
58
|
+
hypervisor
|
59
|
+
name
|
60
|
+
public_ip_address]
|
61
|
+
tests('The server model should respond to') do
|
62
62
|
attributes.each do |attribute|
|
63
|
-
test(
|
63
|
+
test(attribute.to_s) { server.respond_to? attribute }
|
64
64
|
end
|
65
65
|
end
|
66
|
-
tests(
|
66
|
+
tests('The attributes hash should have key') do
|
67
67
|
attributes.each do |attribute|
|
68
|
-
test(
|
68
|
+
test(attribute.to_s) { model_attribute_hash.key? attribute }
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
|
-
test('be a kind of Fog::Compute::Vsphere::Server') { server.
|
72
|
+
test('be a kind of Fog::Compute::Vsphere::Server') { server.is_a? Fog::Compute::Vsphere::Server }
|
73
73
|
end
|
74
|
-
|
75
74
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:vsphere] | servers collection', ['vsphere']) do
|
2
|
-
|
3
2
|
servers = Fog::Compute[:vsphere].servers
|
4
3
|
|
5
4
|
tests('The servers collection') do
|
6
|
-
test('should not be empty') {
|
7
|
-
test('should be a kind of Fog::Compute::Vsphere::Servers') { servers.
|
5
|
+
test('should not be empty') { !servers.empty? }
|
6
|
+
test('should be a kind of Fog::Compute::Vsphere::Servers') { servers.is_a? Fog::Compute::Vsphere::Servers }
|
8
7
|
tests('should be able to reload itself').succeeds { servers.reload }
|
9
8
|
tests('should be able to get a model') do
|
10
9
|
tests('by managed object reference').succeeds { servers.get 'jefftest' }
|
11
10
|
tests('by instance uuid').succeeds { servers.get '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
|
12
11
|
end
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:vsphere] | hosts collection', ['vsphere']) do
|
2
|
-
|
3
2
|
servers = Fog::Compute[:vsphere].servers
|
4
3
|
server = servers.last
|
5
4
|
ticket = server.acquire_ticket
|
6
5
|
|
7
6
|
tests('A ticket') do
|
8
|
-
test('should have a ticket') {
|
9
|
-
test('should have a host') {
|
10
|
-
test('should have a port') { ticket.port.
|
11
|
-
test('should have a ssl ssl_thumbprint') {
|
7
|
+
test('should have a ticket') { !ticket.ticket.empty? }
|
8
|
+
test('should have a host') { !ticket.host.empty? }
|
9
|
+
test('should have a port') { ticket.port.is_a?(Integer) }
|
10
|
+
test('should have a ssl ssl_thumbprint') { !ticket.ssl_thumbprint.empty? }
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|