fog-vsphere 1.7.0.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -2
  3. data/.travis.yml +7 -6
  4. data/CHANGELOG.md +13 -2
  5. data/CONTRIBUTORS.md +0 -8
  6. data/Rakefile +1 -10
  7. data/gemfiles/Gemfile.1.9.2+ +9 -0
  8. data/lib/fog/vsphere/compute.rb +2 -0
  9. data/lib/fog/vsphere/models/compute/scsicontroller.rb +6 -1
  10. data/lib/fog/vsphere/models/compute/server.rb +37 -8
  11. data/lib/fog/vsphere/models/compute/volume.rb +62 -28
  12. data/lib/fog/vsphere/models/compute/volumes.rb +1 -1
  13. data/lib/fog/vsphere/requests/compute/create_vm.rb +32 -44
  14. data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +4 -11
  15. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +2 -1
  16. data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -14
  17. data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +3 -3
  18. data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -2
  19. data/lib/fog/vsphere/requests/compute/vm_migrate.rb +1 -0
  20. data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +26 -15
  21. data/lib/fog/vsphere/version.rb +1 -1
  22. data/tests/class_from_string_tests.rb +3 -3
  23. data/tests/compute_tests.rb +17 -16
  24. data/tests/helpers/mock_helper.rb +3 -3
  25. data/tests/models/compute/cluster_tests.rb +5 -4
  26. data/tests/models/compute/hosts_tests.rb +4 -2
  27. data/tests/models/compute/rules_tests.rb +16 -10
  28. data/tests/models/compute/server_tests.rb +29 -33
  29. data/tests/models/compute/servers_tests.rb +4 -2
  30. data/tests/requests/compute/current_time_tests.rb +4 -2
  31. data/tests/requests/compute/folder_destroy_tests.rb +7 -5
  32. data/tests/requests/compute/get_network_tests.rb +22 -18
  33. data/tests/requests/compute/list_child_snapshots_tests.rb +2 -1
  34. data/tests/requests/compute/list_clusters_tests.rb +6 -5
  35. data/tests/requests/compute/list_datastores_tests.rb +7 -6
  36. data/tests/requests/compute/list_hosts_tests.rb +4 -3
  37. data/tests/requests/compute/list_networks_tests.rb +7 -6
  38. data/tests/requests/compute/list_storage_pods_test.rb +4 -3
  39. data/tests/requests/compute/list_virtual_machines_tests.rb +20 -16
  40. data/tests/requests/compute/list_vm_cdroms_tests.rb +2 -1
  41. data/tests/requests/compute/list_vm_snapshots_tests.rb +2 -1
  42. data/tests/requests/compute/modify_vm_cdrom_tests.rb +4 -3
  43. data/tests/requests/compute/revert_to_snapshot_tests.rb +4 -2
  44. data/tests/requests/compute/set_vm_customvalue_tests.rb +2 -0
  45. data/tests/requests/compute/vm_clone_tests.rb +20 -20
  46. data/tests/requests/compute/vm_config_vnc_tests.rb +4 -3
  47. data/tests/requests/compute/vm_destroy_tests.rb +4 -1
  48. data/tests/requests/compute/vm_migrate_tests.rb +2 -1
  49. data/tests/requests/compute/vm_power_off_tests.rb +4 -2
  50. data/tests/requests/compute/vm_power_on_tests.rb +3 -1
  51. data/tests/requests/compute/vm_reboot_tests.rb +4 -2
  52. data/tests/requests/compute/vm_reconfig_cdrom_tests.rb +3 -2
  53. data/tests/requests/compute/vm_reconfig_cpus_tests.rb +3 -1
  54. data/tests/requests/compute/vm_reconfig_hardware_tests.rb +4 -2
  55. data/tests/requests/compute/vm_reconfig_memory_tests.rb +3 -1
  56. data/tests/requests/compute/vm_take_snapshot_tests.rb +3 -1
  57. metadata +4 -22
  58. data/.rubocop.yml +0 -8
  59. data/.rubocop_todo.yml +0 -217
  60. data/lib/fog/vsphere/models/compute/ticket.rb +0 -16
  61. data/lib/fog/vsphere/models/compute/tickets.rb +0 -25
  62. data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +0 -14
  63. data/lib/fog/vsphere/requests/compute/host_shutdown.rb +0 -14
  64. data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +0 -14
  65. data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +0 -34
  66. data/lib/fog/vsphere/requests/compute/vm_relocate.rb +0 -54
  67. data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +0 -29
  68. data/lib/fog/vsphere/requests/compute/vm_rename.rb +0 -24
  69. data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +0 -29
  70. data/lib/fog/vsphere/requests/compute/vm_suspend.rb +0 -54
  71. data/tests/models/compute/ticket_tests.rb +0 -12
  72. data/tests/models/compute/tickets_tests.rb +0 -8
  73. data/tests/requests/compute/vm_suspend_tests.rb +0 -23
@@ -20,7 +20,7 @@ module Fog
20
20
  vm_cfg[:cpuHotAddEnabled] = attributes[:cpuHotAddEnabled] if attributes.key?(:cpuHotAddEnabled)
21
21
  vm_cfg[:memoryHotAddEnabled] = attributes[:memoryHotAddEnabled] if attributes.key?(:memoryHotAddEnabled)
22
22
  vm_cfg[:firmware] = attributes[:firmware] if attributes.key?(:firmware)
23
- vm_cfg[:bootOptions] = boot_options(attributes) if attributes.key?(:boot_order) || attributes.key?(:boot_retry)
23
+ vm_cfg[:bootOptions] = boot_options(attributes, vm_cfg) if attributes.key?(:boot_order) || attributes.key?(:boot_retry)
24
24
  resource_pool = if attributes[:resource_pool] && attributes[:resource_pool] != 'Resources'
25
25
  get_raw_resource_pool(attributes[:resource_pool], attributes[:cluster], attributes[:datacenter])
26
26
  else
@@ -97,9 +97,12 @@ module Fog
97
97
  devices << nics.map { |nic| create_interface(nic, nics.index(nic), :add, attributes) }
98
98
  end
99
99
 
100
+ if (scsi_controllers = (attributes[:scsi_controllers] || attributes["scsi_controller"]))
101
+ devices << scsi_controllers.each_with_index.map { |controller, index| create_controller(controller, index) }
102
+ end
103
+
100
104
  if (disks = attributes[:volumes])
101
- devices << create_controller(attributes[:scsi_controller]||attributes["scsi_controller"]||{})
102
- devices << disks.map { |disk| create_disk(disk, disks.index(disk), :add, 1000, get_storage_pod(attributes)) }
105
+ devices << disks.map { |disk| create_disk(disk, :add, get_storage_pod(attributes)) }
103
106
  end
104
107
 
105
108
  if (cdroms = attributes[:cdroms])
@@ -108,12 +111,12 @@ module Fog
108
111
  devices.flatten
109
112
  end
110
113
 
111
- def boot_options attributes
114
+ def boot_options(attributes, vm_cfg)
112
115
  # NOTE: you must be using vsphere_rev 5.0 or greater to set boot_order
113
116
  # e.g. Fog::Compute.new(provider: "vsphere", vsphere_rev: "5.5", etc)
114
117
  options = {}
115
118
  if @vsphere_rev.to_f >= 5 and attributes[:boot_order]
116
- options[:bootOrder] = boot_order(attributes)
119
+ options[:bootOrder] = boot_order(attributes, vm_cfg)
117
120
  end
118
121
 
119
122
  # Set attributes[:boot_retry] to a delay in miliseconds to enable boot retries
@@ -121,11 +124,11 @@ module Fog
121
124
  options[:bootRetryEnabled] = true
122
125
  options[:bootRetryDelay] = attributes[:boot_retry]
123
126
  end
124
-
127
+
125
128
  options.empty? ? nil : RbVmomi::VIM::VirtualMachineBootOptions.new(options)
126
129
  end
127
130
 
128
- def boot_order attributes
131
+ def boot_order(attributes, vm_cfg)
129
132
  # attributes[:boot_order] may be an array like this ['network', 'disk']
130
133
  # stating, that we want to prefer network boots over disk boots
131
134
  boot_order = []
@@ -142,18 +145,17 @@ module Fog
142
145
  end
143
146
  end
144
147
  when 'disk'
145
- if disks = attributes[:volumes]
146
- disks.each do |disk|
147
- # we allow booting from all harddisks, the first disk has the highest priority
148
- boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableDiskDevice.new(
149
- :deviceKey => disk.key || get_disk_device_key(disks.index(disk)),
150
- )
151
- end
148
+ disks = vm_cfg[:deviceChange].map {|dev| dev[:device]}.select { |dev| dev.is_a? RbVmomi::VIM::VirtualDisk }
149
+ disks.each do |disk|
150
+ # we allow booting from all harddisks, the first disk has the highest priority
151
+ boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableDiskDevice.new(
152
+ :deviceKey => disk.key
153
+ )
152
154
  end
153
155
  when 'cdrom'
154
- boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableCdromDevice.new()
156
+ boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableCdromDevice.new
155
157
  when 'floppy'
156
- boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableFloppyDevice.new()
158
+ boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableFloppyDevice.new
157
159
  else
158
160
  raise "failed to create boot device because \"#{boot_device}\" is unknown"
159
161
  end
@@ -161,19 +163,6 @@ module Fog
161
163
  boot_order
162
164
  end
163
165
 
164
- def get_disk_device_key(index)
165
- # disk key is based on 2000 + the SCSI ID + the controller bus * 16
166
- # the scsi host adapter appears as SCSI ID 7, so we have to skip that
167
- # host adapter key is based on 1000 + bus id
168
- # fog assumes that there is only a single scsi controller, see device_change()
169
- if (index > 6) then
170
- _index = index + 1
171
- else
172
- _index = index
173
- end
174
- 2000 + _index
175
- end
176
-
177
166
  def create_nic_backing nic, attributes
178
167
  raw_network = get_raw_network(nic.network, attributes[:datacenter], if nic.virtualswitch then nic.virtualswitch end)
179
168
 
@@ -204,9 +193,9 @@ module Fog
204
193
  }
205
194
  end
206
195
 
207
- def create_controller options=nil
208
- options=if options
209
- controller_default_options.merge(Hash[options.map{|k,v| [k.to_sym,v] }])
196
+ def create_controller(controller=nil, index = 0)
197
+ options=if controller
198
+ controller_default_options.merge(controller.attributes)
210
199
  else
211
200
  controller_default_options
212
201
  end
@@ -218,15 +207,15 @@ module Fog
218
207
  {
219
208
  :operation => options[:operation],
220
209
  :device => controller_class.new({
221
- :key => options[:key],
222
- :busNumber => options[:bus_id],
210
+ :key => options[:key] || (1000 + index),
211
+ :busNumber => options[:bus_id] || index,
223
212
  :sharedBus => controller_get_shared_from_options(options),
224
213
  })
225
214
  }
226
215
  end
227
216
 
228
217
  def controller_default_options
229
- {:operation => "add", :type => RbVmomi::VIM.VirtualLsiLogicController.class, :key => 1000, :bus_id => 0, :shared => false }
218
+ {:operation => :add, :type => RbVmomi::VIM.VirtualLsiLogicController.class, :shared => false }
230
219
  end
231
220
 
232
221
  def controller_get_shared_from_options options
@@ -241,30 +230,29 @@ module Fog
241
230
  end
242
231
  end
243
232
 
244
- def create_disk disk, index = 0, operation = :add, controller_key = 1000, storage_pod = nil
245
- if (index > 6) then
246
- _index = index + 1
247
- else
248
- _index = index
249
- end
233
+ def create_disk(disk, operation = :add, storage_pod = nil)
250
234
  # If we deploy the vm on a storage pod, datastore has to be an empty string
251
235
  if storage_pod
252
236
  datastore = ''
253
237
  else
254
238
  datastore = "[#{disk.datastore}]"
255
239
  end
240
+
241
+ disk.set_unit_number
242
+ disk.set_key
243
+
256
244
  payload = {
257
245
  :operation => operation,
258
246
  :fileOperation => operation == :add ? :create : :destroy,
259
247
  :device => RbVmomi::VIM.VirtualDisk(
260
- :key => disk.key || _index,
248
+ :key => disk.key,
261
249
  :backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
262
250
  :fileName => datastore,
263
251
  :diskMode => disk.mode.to_sym,
264
252
  :thinProvisioned => disk.thin
265
253
  ),
266
- :controllerKey => controller_key,
267
- :unitNumber => _index,
254
+ :controllerKey => disk.controller_key,
255
+ :unitNumber => disk.unit_number,
268
256
  :capacityInKB => disk.size
269
257
  )
270
258
  }
@@ -11,21 +11,14 @@ module Fog
11
11
  def list_vm_scsi_controllers_raw(vm_id)
12
12
  get_vm_ref(vm_id).config.hardware.device.grep(RbVmomi::VIM::VirtualSCSIController).map do |ctrl|
13
13
  {
14
- type: ctrl.class.to_s,
15
- shared_bus: ctrl.sharedBus.to_s,
16
- unit_number: ctrl.scsiCtlrUnitNumber,
17
- key: ctrl.key
14
+ :type => ctrl.class.to_s,
15
+ :shared_bus => ctrl.sharedBus.to_s,
16
+ :unit_number => ctrl.scsiCtlrUnitNumber,
17
+ :key => ctrl.key,
18
18
  }
19
19
  end
20
20
  end
21
21
  end
22
- class Mock
23
- def list_vm_scsi_controllers(vm_id)
24
- raise Fog::Compute::Vsphere::NotFound, 'VM not Found' unless data[:servers].key?(vm_id)
25
- return [] unless data[:servers][vm_id].key?('scsi_controllers')
26
- data[:servers][vm_id]['scsi_controllers'].map { |h| h.merge(server_id: vm_id) }
27
- end
28
- end
29
22
  end
30
23
  end
31
24
  end
@@ -38,7 +38,8 @@ module Fog
38
38
  :size => vol.capacityInKB,
39
39
  :name => vol.deviceInfo.label,
40
40
  :key => vol.key,
41
- :unit_number => vol.unitNumber
41
+ :unit_number => vol.unitNumber,
42
+ :controller_key => vol.controllerKey
42
43
  }
43
44
  end
44
45
  end
@@ -3,25 +3,13 @@ module Fog
3
3
  class Vsphere
4
4
  class Real
5
5
  def add_vm_controller(controller)
6
- options = {}
7
- options[:operation] = 'add'
8
- options[:type] = controller.type
9
- options[:key] = controller.key
10
- options[:shared] = controller.shared_bus
11
-
12
- vm_reconfig_hardware('instance_uuid' => controller.server_id, 'hardware_spec' => {'deviceChange'=>[create_controller(options)]})
6
+ vm_reconfig_hardware('instance_uuid' => controller.server_id, 'hardware_spec' => {'deviceChange'=>[create_controller(controller)]})
13
7
  end
14
8
  end
15
9
 
16
10
  class Mock
17
11
  def add_vm_controller(controller)
18
- options = {}
19
- options[:operation] = 'add'
20
- options[:type] = RbVmomi::VIM.VirtualLsiLogicController.class
21
- options[:key] = 1000
22
- options[:shared] = false
23
-
24
- vm_reconfig_hardware('instance_uuid' => controller.server_id, 'hardware_spec' => {'deviceChange'=>[create_controller(options)]})
12
+ vm_reconfig_hardware('instance_uuid' => controller.server_id, 'hardware_spec' => {'deviceChange'=>[create_controller(controller)]})
25
13
  end
26
14
  end
27
15
  end
@@ -3,17 +3,17 @@ module Fog
3
3
  class Vsphere
4
4
  class Real
5
5
  def add_vm_volume(volume)
6
- vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, volume.unit_number, :add)]})
6
+ vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, :add)]})
7
7
  end
8
8
 
9
9
  def destroy_vm_volume(volume)
10
- vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, volume.unit_number, :remove)]})
10
+ vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_disk(volume, :remove)]})
11
11
  end
12
12
  end
13
13
 
14
14
  class Mock
15
15
  def add_vm_volume(volume)
16
- vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_cdrom(volume, volume.unit_number, :add)]})
16
+ vm_reconfig_hardware('instance_uuid' => volume.server_id, 'hardware_spec' => {'deviceChange'=>[create_cdrom(volume, :add)]})
17
17
  end
18
18
 
19
19
  def destroy_vm_volume(volume)
@@ -133,7 +133,7 @@ module Fog
133
133
  # Options['host']<~String>
134
134
  # The target host for the virtual machine. Optional.
135
135
  if options.key?('host') && !options['host'].empty? && !cluster_name.nil?
136
- host = get_raw_host(options['host'], attributes[:cluster], options['datacenter'])
136
+ host = get_raw_host(options['host'], cluster_name, options['datacenter'])
137
137
  else
138
138
  host = nil
139
139
  end
@@ -747,7 +747,7 @@ module Fog
747
747
  :device => template_volume }
748
748
  end
749
749
  end
750
- specs.concat(new_volumes.map { |volume| create_disk(volume, volumes.index(volume)) })
750
+ specs.concat(new_volumes.map { |volume| create_disk(volume) })
751
751
  return specs
752
752
  end
753
753
  end
@@ -15,6 +15,7 @@ module Fog
15
15
  raise Fog::Vsphere::Errors::NotFound,
16
16
  "Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
17
17
  end
18
+ options['host'] = get_raw_host(options['host'], options['cluster'], options['datacenter']) if options['host']
18
19
  task = vm_mob_ref.MigrateVM_Task(:pool => options['pool'], :host => options['host'], :priority => "#{priority}", :state => options['state'] )
19
20
  task.wait_for_completion
20
21
  { 'task_state' => task.info.state }
@@ -3,36 +3,47 @@ module Fog
3
3
  class Vsphere
4
4
  class Real
5
5
  def vm_reconfig_volumes(options = {})
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'
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
- hardware_spec[:deviceChange].push(create_disk(volume, :edit, filename: volume.filename))
12
+ hardware_spec[:deviceChange].push({
13
+ :operation=>:edit,
14
+ device: RbVmomi::VIM::VirtualDisk(
15
+ backing: RbVmomi::VIM::VirtualDiskFlatVer2BackingInfo( diskMode: volume.mode, fileName: volume.filename ),
16
+ unitNumber: volume.unit_number,
17
+ key: volume.key,
18
+ controllerKey: volume.controller_key,
19
+ capacityInKB: volume.size,
20
+ )
21
+ })
13
22
  end
14
- vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
23
+ vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec )
15
24
  end
16
25
  end
17
26
 
18
27
  class Mock
19
28
  def vm_reconfig_volumes(options = {})
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'
29
+ raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
30
+ raise ArgumentError, "volumes is a required parameter" unless options.key? 'volumes'
22
31
  hardware_spec = {
23
32
  deviceChange: []
24
33
  }
25
34
  options['volumes'].each do |volume|
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
- })
35
+ hardware_spec[:deviceChange].push({
36
+ :operation=>:edit,
37
+ device: {
38
+ backing: { diskMode: volume.mode, fileName: volume.filename },
39
+ unitNumber: volume.unit_number,
40
+ key: volume.key,
41
+ controllerKey: volume.controller_key,
42
+ capacityInKB: volume.size,
43
+ }
44
+ })
34
45
  end
35
- vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec)
46
+ vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec )
36
47
  end
37
48
  end
38
49
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '1.7.0.1'
3
+ VERSION = '1.7.1'
4
4
  end
5
5
  end
@@ -4,11 +4,11 @@ class A; class B; class C; end; end; end
4
4
 
5
5
  class TestClassFromString < Minitest::Test
6
6
  def test_empty_string
7
- assert_nil(Fog::Vsphere.class_from_string(''))
7
+ assert_equal(nil, Fog::Vsphere.class_from_string(''))
8
8
  end
9
9
 
10
10
  def test_nil
11
- assert_nil(Fog::Vsphere.class_from_string(nil))
11
+ assert_equal(nil, Fog::Vsphere.class_from_string(nil))
12
12
  end
13
13
 
14
14
  def test_name_as_class
@@ -20,7 +20,7 @@ class TestClassFromString < Minitest::Test
20
20
  end
21
21
 
22
22
  def test_unexpected_input
23
- assert_nil(Fog::Vsphere.class_from_string(8))
23
+ assert_equal(nil, Fog::Vsphere.class_from_string(8))
24
24
  end
25
25
 
26
26
  def test_nested_class_without_default_path
@@ -1,7 +1,8 @@
1
1
  Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do
2
+
2
3
  compute = Fog::Compute[:vsphere]
3
4
 
4
- tests('| convert_vm_mob_ref_to_attr_hash') do
5
+ tests("| convert_vm_mob_ref_to_attr_hash") do
5
6
  # Mock the RbVmomi::VIM::ManagedObject class
6
7
  class MockManagedObject
7
8
  attr_reader :parent, :_ref
@@ -10,42 +11,42 @@ Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do
10
11
  @parent = @_ref = 'vm-123'
11
12
  end
12
13
 
13
- def collect!(*_pathSet)
14
+ def collect! *pathSet
14
15
  { '_ref' => 'vm-123', 'name' => 'fakevm' }
15
16
  end
16
17
  end
17
18
 
18
19
  fake_vm_mob_ref = MockManagedObject.new
19
20
 
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
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
23
24
  end
24
- tests('The converted Hash should') do
25
+ tests("The converted Hash should") do
25
26
  attr_hash = compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref)
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? }
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? }
30
31
  end
31
32
  end
32
33
 
33
- tests('When passed a nil object') do
34
+ tests("When passed a nil object") do
34
35
  attr_hash = compute.send :convert_vm_mob_ref_to_attr_hash, nil
35
- test('it should return a nil object') do
36
+ test("it should return a nil object") do
36
37
  attr_hash.nil?
37
38
  end
38
39
  end
39
40
  end
40
41
 
41
- tests('Compute attributes') do
42
- %w[vsphere_is_vcenter vsphere_rev vsphere_username vsphere_server].each do |attr|
42
+ tests("Compute attributes") do
43
+ %w{ vsphere_is_vcenter vsphere_rev vsphere_username vsphere_server }.each do |attr|
43
44
  test("it should respond to #{attr}") { compute.respond_to? attr }
44
45
  end
45
46
  end
46
47
 
47
- tests('Compute collections') do
48
- %w[servers].each do |collection|
48
+ tests("Compute collections") do
49
+ %w{ servers }.each do |collection|
49
50
  test("it should respond to #{collection}") { compute.respond_to? collection }
50
51
  end
51
52
  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