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.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.rubocop_todo.yml +217 -0
  4. data/.travis.yml +1 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Rakefile +10 -1
  7. data/fog-vsphere.gemspec +2 -2
  8. data/lib/fog/bin/vsphere.rb +1 -1
  9. data/lib/fog/vsphere/compute.rb +320 -301
  10. data/lib/fog/vsphere/models/compute/cdrom.rb +10 -10
  11. data/lib/fog/vsphere/models/compute/cdroms.rb +2 -2
  12. data/lib/fog/vsphere/models/compute/cluster.rb +20 -20
  13. data/lib/fog/vsphere/models/compute/clusters.rb +1 -1
  14. data/lib/fog/vsphere/models/compute/customfields.rb +4 -4
  15. data/lib/fog/vsphere/models/compute/customvalues.rb +8 -8
  16. data/lib/fog/vsphere/models/compute/datacenter.rb +16 -16
  17. data/lib/fog/vsphere/models/compute/datastores.rb +1 -1
  18. data/lib/fog/vsphere/models/compute/folder.rb +2 -2
  19. data/lib/fog/vsphere/models/compute/folders.rb +2 -2
  20. data/lib/fog/vsphere/models/compute/hosts.rb +4 -4
  21. data/lib/fog/vsphere/models/compute/interface.rb +12 -12
  22. data/lib/fog/vsphere/models/compute/interfaces.rb +14 -16
  23. data/lib/fog/vsphere/models/compute/interfacetype.rb +2 -2
  24. data/lib/fog/vsphere/models/compute/interfacetypes.rb +6 -8
  25. data/lib/fog/vsphere/models/compute/networks.rb +1 -1
  26. data/lib/fog/vsphere/models/compute/resource_pools.rb +1 -1
  27. data/lib/fog/vsphere/models/compute/rule.rb +8 -9
  28. data/lib/fog/vsphere/models/compute/rules.rb +9 -10
  29. data/lib/fog/vsphere/models/compute/scsicontroller.rb +1 -1
  30. data/lib/fog/vsphere/models/compute/server.rb +68 -80
  31. data/lib/fog/vsphere/models/compute/servers.rb +12 -13
  32. data/lib/fog/vsphere/models/compute/servertype.rb +6 -6
  33. data/lib/fog/vsphere/models/compute/servertypes.rb +2 -2
  34. data/lib/fog/vsphere/models/compute/snapshot.rb +5 -6
  35. data/lib/fog/vsphere/models/compute/snapshots.rb +1 -1
  36. data/lib/fog/vsphere/models/compute/ticket.rb +0 -1
  37. data/lib/fog/vsphere/models/compute/volume.rb +12 -14
  38. data/lib/fog/vsphere/models/compute/volumes.rb +10 -10
  39. data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +8 -8
  40. data/lib/fog/vsphere/requests/compute/create_folder.rb +5 -5
  41. data/lib/fog/vsphere/requests/compute/create_group.rb +16 -16
  42. data/lib/fog/vsphere/requests/compute/create_rule.rb +13 -13
  43. data/lib/fog/vsphere/requests/compute/create_vm.rb +117 -119
  44. data/lib/fog/vsphere/requests/compute/destroy_group.rb +8 -8
  45. data/lib/fog/vsphere/requests/compute/destroy_rule.rb +8 -8
  46. data/lib/fog/vsphere/requests/compute/folder_destroy.rb +3 -3
  47. data/lib/fog/vsphere/requests/compute/get_cluster.rb +2 -2
  48. data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +16 -16
  49. data/lib/fog/vsphere/requests/compute/get_datacenter.rb +7 -7
  50. data/lib/fog/vsphere/requests/compute/get_datastore.rb +1 -2
  51. data/lib/fog/vsphere/requests/compute/get_folder.rb +24 -24
  52. data/lib/fog/vsphere/requests/compute/get_host.rb +2 -3
  53. data/lib/fog/vsphere/requests/compute/get_interface_type.rb +6 -6
  54. data/lib/fog/vsphere/requests/compute/get_network.rb +7 -10
  55. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -2
  56. data/lib/fog/vsphere/requests/compute/get_server_type.rb +14 -14
  57. data/lib/fog/vsphere/requests/compute/get_storage_pod.rb +2 -2
  58. data/lib/fog/vsphere/requests/compute/get_template.rb +1 -2
  59. data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +26 -26
  60. data/lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb +6 -7
  61. data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +1 -1
  62. data/lib/fog/vsphere/requests/compute/host_shutdown.rb +1 -1
  63. data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +1 -1
  64. data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +37 -39
  65. data/lib/fog/vsphere/requests/compute/list_clusters.rb +8 -9
  66. data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +57 -59
  67. data/lib/fog/vsphere/requests/compute/list_customfields.rb +5 -6
  68. data/lib/fog/vsphere/requests/compute/list_datacenters.rb +17 -17
  69. data/lib/fog/vsphere/requests/compute/list_datastores.rb +16 -15
  70. data/lib/fog/vsphere/requests/compute/list_folders.rb +4 -4
  71. data/lib/fog/vsphere/requests/compute/list_groups.rb +5 -5
  72. data/lib/fog/vsphere/requests/compute/list_hosts.rb +30 -14
  73. data/lib/fog/vsphere/requests/compute/list_interface_types.rb +7 -7
  74. data/lib/fog/vsphere/requests/compute/list_networks.rb +12 -16
  75. data/lib/fog/vsphere/requests/compute/list_processes.rb +14 -14
  76. data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +13 -14
  77. data/lib/fog/vsphere/requests/compute/list_rules.rb +4 -4
  78. data/lib/fog/vsphere/requests/compute/list_server_types.rb +24 -26
  79. data/lib/fog/vsphere/requests/compute/list_storage_pods.rb +8 -8
  80. data/lib/fog/vsphere/requests/compute/list_templates.rb +4 -5
  81. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +15 -15
  82. data/lib/fog/vsphere/requests/compute/list_vm_cdroms.rb +16 -12
  83. data/lib/fog/vsphere/requests/compute/list_vm_customvalues.rb +3 -4
  84. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +54 -56
  85. data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +7 -7
  86. data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +36 -36
  87. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +43 -36
  88. data/lib/fog/vsphere/requests/compute/modify_vm_cdrom.rb +4 -4
  89. data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -2
  90. data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +26 -19
  91. data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +7 -7
  92. data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +2 -2
  93. data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +2 -2
  94. data/lib/fog/vsphere/requests/compute/update_vm.rb +111 -0
  95. data/lib/fog/vsphere/requests/compute/upload_iso.rb +10 -10
  96. data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +3 -3
  97. data/lib/fog/vsphere/requests/compute/vm_clone.rb +245 -247
  98. data/lib/fog/vsphere/requests/compute/vm_config_vnc.rb +15 -15
  99. data/lib/fog/vsphere/requests/compute/vm_destroy.rb +2 -2
  100. data/lib/fog/vsphere/requests/compute/vm_execute.rb +16 -16
  101. data/lib/fog/vsphere/requests/compute/vm_migrate.rb +11 -11
  102. data/lib/fog/vsphere/requests/compute/vm_power_off.rb +8 -8
  103. data/lib/fog/vsphere/requests/compute/vm_power_on.rb +2 -2
  104. data/lib/fog/vsphere/requests/compute/vm_reboot.rb +5 -5
  105. data/lib/fog/vsphere/requests/compute/vm_reconfig_cdrom.rb +11 -11
  106. data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +8 -8
  107. data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +6 -6
  108. data/lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb +8 -8
  109. data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +14 -16
  110. data/lib/fog/vsphere/requests/compute/vm_relocate.rb +8 -8
  111. data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +2 -2
  112. data/lib/fog/vsphere/requests/compute/vm_rename.rb +5 -5
  113. data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +1 -1
  114. data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +8 -8
  115. data/lib/fog/vsphere/version.rb +1 -1
  116. data/tests/compute_tests.rb +16 -17
  117. data/tests/helpers/mock_helper.rb +3 -3
  118. data/tests/models/compute/cluster_tests.rb +4 -5
  119. data/tests/models/compute/hosts_tests.rb +2 -4
  120. data/tests/models/compute/rules_tests.rb +10 -16
  121. data/tests/models/compute/server_tests.rb +30 -31
  122. data/tests/models/compute/servers_tests.rb +2 -4
  123. data/tests/models/compute/ticket_tests.rb +4 -6
  124. data/tests/models/compute/tickets_tests.rb +1 -3
  125. data/tests/requests/compute/current_time_tests.rb +2 -4
  126. data/tests/requests/compute/folder_destroy_tests.rb +5 -7
  127. data/tests/requests/compute/get_network_tests.rb +20 -23
  128. data/tests/requests/compute/list_child_snapshots_tests.rb +1 -2
  129. data/tests/requests/compute/list_clusters_tests.rb +5 -6
  130. data/tests/requests/compute/list_datastores_tests.rb +6 -7
  131. data/tests/requests/compute/list_hosts_tests.rb +3 -4
  132. data/tests/requests/compute/list_networks_tests.rb +6 -7
  133. data/tests/requests/compute/list_storage_pods_test.rb +3 -4
  134. data/tests/requests/compute/list_virtual_machines_tests.rb +16 -20
  135. data/tests/requests/compute/list_vm_cdroms_tests.rb +1 -2
  136. data/tests/requests/compute/list_vm_snapshots_tests.rb +1 -2
  137. data/tests/requests/compute/modify_vm_cdrom_tests.rb +3 -4
  138. data/tests/requests/compute/revert_to_snapshot_tests.rb +2 -4
  139. data/tests/requests/compute/set_vm_customvalue_tests.rb +0 -2
  140. data/tests/requests/compute/update_vm_tests.rb +13 -0
  141. data/tests/requests/compute/vm_clone_tests.rb +20 -20
  142. data/tests/requests/compute/vm_config_vnc_tests.rb +3 -4
  143. data/tests/requests/compute/vm_destroy_tests.rb +1 -4
  144. data/tests/requests/compute/vm_migrate_tests.rb +1 -2
  145. data/tests/requests/compute/vm_power_off_tests.rb +2 -4
  146. data/tests/requests/compute/vm_power_on_tests.rb +1 -3
  147. data/tests/requests/compute/vm_reboot_tests.rb +2 -4
  148. data/tests/requests/compute/vm_reconfig_cdrom_tests.rb +2 -3
  149. data/tests/requests/compute/vm_reconfig_cpus_tests.rb +1 -3
  150. data/tests/requests/compute/vm_reconfig_hardware_tests.rb +2 -4
  151. data/tests/requests/compute/vm_reconfig_memory_tests.rb +1 -3
  152. data/tests/requests/compute/vm_take_snapshot_tests.rb +1 -3
  153. 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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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.kind_of? RbVmomi::VIM::VirtualMachine
24
+ unless vm_mob_ref.is_a? RbVmomi::VIM::VirtualMachine
25
25
  raise Fog::Vsphere::Errors::NotFound,
26
- "Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
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
- :pool => options['pool'],
37
- :host => options['host'],
38
- :disk => options['disks']
36
+ pool: options['pool'],
37
+ host: options['host'],
38
+ disk: options['disks']
39
39
  )
40
- task = vm_mob_ref.RelocateVM_Task(:spec => spec, :priority => options["priority"])
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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(:removeChildren => remove_children)
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(vm_id, snapshot_id)
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, "name is a required parameter" unless options.key? 'name'
7
- raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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(:newName => options['name'])
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, "name is a required parameter" unless options.key? 'name'
18
- raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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
@@ -17,7 +17,7 @@ module Fog
17
17
  end
18
18
 
19
19
  class Mock
20
- def vm_revert_snapshot(vm_id, snapshot_id)
20
+ def vm_revert_snapshot(_vm_id, _snapshot_id)
21
21
  {
22
22
  'task_state' => 'success',
23
23
  'was_cancelled' => false
@@ -3,14 +3,14 @@ module Fog
3
3
  class Vsphere
4
4
  class Real
5
5
  def vm_take_snapshot(options = {})
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'
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
- :name => options['name'],
11
- :description => options['description'] || '',
12
- :memory => options['memory'] || true,
13
- :quiesce => options['quiesce'] || false
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
28
- raise ArgumentError, "name is a required parameter" unless options.key? 'name'
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
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '2.1.1'.freeze
3
+ VERSION = '2.2.0'.freeze
4
4
  end
5
5
  end
@@ -1,8 +1,7 @@
1
1
  Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do
2
-
3
2
  compute = Fog::Compute[:vsphere]
4
3
 
5
- tests("| convert_vm_mob_ref_to_attr_hash") do
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! *pathSet
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("When converting an incomplete vm object") do
22
- test("it should return a Hash") do
23
- compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref).kind_of? Hash
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("The converted Hash should") do
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("have a name") { attr_hash['name'] == 'fakevm' }
28
- test("have a mo_ref") {attr_hash['mo_ref'] == 'vm-123' }
29
- test("have an id") { attr_hash['id'] == 'vm-123' }
30
- test("not have a instance_uuid") { attr_hash['instance_uuid'].nil? }
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("When passed a nil object") do
33
+ tests('When passed a nil object') do
35
34
  attr_hash = compute.send :convert_vm_mob_ref_to_attr_hash, nil
36
- test("it should return a nil object") do
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("Compute attributes") do
43
- %w{ vsphere_is_vcenter vsphere_rev vsphere_username vsphere_server }.each do |attr|
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("Compute collections") do
49
- %w{ servers }.each do |collection|
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
- :vsphere_server => 'fake_vsphere_server',
6
- :vsphere_username => 'fake_vsphere_username',
7
- :vsphere_password => 'fake_vsphere_password'
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') { not clusters.empty? }
9
- test('should be a kind of Fog::Compute::Vsphere::Clusters') { clusters.kind_of? Fog::Compute::Vsphere::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.kind_of? Fog::Compute::Vsphere::Datastore }
17
- test('have networks') { cluster.networks.first.kind_of? Fog::Compute::Vsphere::Network }
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') { not hosts.empty? }
9
- test('should be a kind of Fog::Compute::Vsphere::Hosts') { hosts.kind_of? Fog::Compute::Vsphere::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') { not rules.empty? }
10
- test('should be a kind of Fog::Compute::Vsphere::Rules') { rules.kind_of? Fog::Compute::Vsphere::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
- name: 'affinity-foo',
16
- enabled: true,
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
- name: 'affinity-foo',
27
- enabled: true,
28
- type: RbVmomi::VIM::ClusterAffinityRuleSpec,
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(stop suspend destroy reboot).each do |action|
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("start returns false, because it is already poweredOn") { server.start ? true : false }
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').kind_of? Hash }
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.kind_of? Fog::Compute::Vsphere::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').kind_of? Fog::Compute::Vsphere::Snapshot
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').kind_of? Hash }
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.kind_of? Fog::Compute::Vsphere::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 = [ :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
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("#{attribute}") { server.respond_to? attribute }
63
+ test(attribute.to_s) { server.respond_to? attribute }
64
64
  end
65
65
  end
66
- tests("The attributes hash should have key") do
66
+ tests('The attributes hash should have key') do
67
67
  attributes.each do |attribute|
68
- test("#{attribute}") { model_attribute_hash.key? attribute }
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.kind_of? Fog::Compute::Vsphere::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') { not servers.empty? }
7
- test('should be a kind of Fog::Compute::Vsphere::Servers') { servers.kind_of? Fog::Compute::Vsphere::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') { not ticket.ticket.empty? }
9
- test('should have a host') { not ticket.host.empty? }
10
- test('should have a port') { ticket.port.kind_of?(Integer) }
11
- test('should have a ssl ssl_thumbprint') { not ticket.ssl_thumbprint.empty? }
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