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
@@ -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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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(: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
- })
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 uuid
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
- [$1.to_sym, config.value]
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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 uuid
40
- {:password => 'secret', :port => '5900', :enabled => 'true'}
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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, "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'
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(:interactiveSession => false,
24
- :username => options['user'],
25
- :password => options['password'])
23
+ auth = RbVmomi::VIM::NamePasswordAuthentication(interactiveSession: false,
24
+ username: options['user'],
25
+ password: options['password'])
26
26
 
27
- spec = RbVmomi::VIM::GuestProgramSpec(:programPath => options['command'],
28
- :arguments => options['args'],
29
- :workingDirectory => options['working_dir'])
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(:vm => vm_mob_ref, :auth => auth, :spec => spec)
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, "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
- return 12345
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["priority"]
8
- raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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.kind_of? RbVmomi::VIM::VirtualMachine
14
+ unless vm_mob_ref.is_a? RbVmomi::VIM::VirtualMachine
15
15
  raise Fog::Vsphere::Errors::NotFound,
16
- "Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
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 = {:pool => options['pool'], :host => options['host'], :state => options['state']}
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(:vm => vm_mob_ref))
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(:priority => "#{priority}"))
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["priority"]
36
- raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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'] then
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' => "running",
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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["power_state"] = "poweredOff"
30
+ vm['power_state'] = 'poweredOff'
31
31
  {
32
- 'task_state' => "running",
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
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'] then
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' => "running", 'reboot_type' => 'reboot_guest' }
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
26
- { 'task_state' => "running", 'reboot_type' => options['force'] ? 'reset_power' : 'reboot_guest' }
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
6
+ raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
7
7
  # Attach iso / disattach
8
- if options.has_key?('iso')
9
- raise ArgumentError, "datastore is a required parameter" unless options.key? 'datastore'
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
39
- if options.has_key?('iso')
40
- raise ArgumentError, "datastore is a required parameter" unless options.key? 'datastore'
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, "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 )
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, "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 )
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, "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'
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(:spec => RbVmomi::VIM.VirtualMachineConfigSpec(options['hardware_spec']))
9
+ task = vm_mob_ref.ReconfigVM_Task(spec: RbVmomi::VIM.VirtualMachineConfigSpec(options['hardware_spec']))
10
10
  task.wait_for_completion
11
- { 'task_state' => task.info.state }
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, "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'
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, "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 )
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, "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 )
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, "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
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, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
21
- raise ArgumentError, "volumes is a required parameter" unless options.key? 'volumes'
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
- :operation=>:edit,
28
- device: {
29
- backing: { diskMode: volume.mode, fileName: volume.filename },
30
- unitNumber: volume.unit_number,
31
- key: volume.key,
32
- controllerKey: volume.controller_key,
33
- capacityInKB: volume.size,
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