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
@@ -20,7 +20,7 @@ module Fog
20
20
  # mydc = vspconn.datacenters.first
21
21
  # folders = mydc.vm_folders
22
22
  #
23
- def list_folders(filters = { })
23
+ def list_folders(filters = {})
24
24
  path = filters[:path] || filters['path'] || ''
25
25
  datacenter_name = filters[:datacenter]
26
26
  get_raw_vmfolders(path, datacenter_name).map do |folder|
@@ -35,14 +35,14 @@ module Fog
35
35
  child_folders(folder).flatten.compact
36
36
  end
37
37
 
38
- def child_folders folder
38
+ def child_folders(folder)
39
39
  [folder, folder.childEntity.grep(RbVmomi::VIM::Folder).map(&method(:child_folders)).flatten]
40
40
  end
41
41
  end
42
42
  class Mock
43
43
  def list_folders(options = {})
44
- options.reject! {|k,v| v.nil? } # ignore options with nil value
45
- self.data[:folders].values.select {|folder| options.all? {|k,v| folder[k.to_s] == v.to_s }}
44
+ options.reject! { |_k, v| v.nil? } # ignore options with nil value
45
+ data[:folders].values.select { |folder| options.all? { |k, v| folder[k.to_s] == v.to_s } }
46
46
  end
47
47
  end
48
48
  end
@@ -4,7 +4,7 @@ module Fog
4
4
  class Real
5
5
  def list_groups(filters = {})
6
6
  cluster = get_raw_cluster(filters[:cluster], filters[:datacenter])
7
- cluster.configurationEx.group.map {|g| group_attributes g, filters}
7
+ cluster.configurationEx.group.map { |g| group_attributes g, filters }
8
8
  end
9
9
 
10
10
  protected
@@ -15,14 +15,14 @@ module Fog
15
15
  attributes[:cluster] = filters[:cluster]
16
16
  attributes[:name] = group[:name]
17
17
  attributes[:type] = group.class
18
- if group.class.to_s == 'ClusterVmGroup' then attributes[:vm_ids] = group[:vm].map {|vm| vm.config.instanceUuid} end
19
- if group.class.to_s == 'ClusterHostGroup' then attributes[:hosts] = group[:host].map {|host| host.name} end
20
- return attributes
18
+ if group.class.to_s == 'ClusterVmGroup' then attributes[:vm_ids] = group[:vm].map { |vm| vm.config.instanceUuid } end
19
+ if group.class.to_s == 'ClusterHostGroup' then attributes[:hosts] = group[:host].map(&:name) end
20
+ attributes
21
21
  end
22
22
  end
23
23
  class Mock
24
24
  def list_groups(filters = {})
25
- self.data[:groups].values.select {|g| g[:datacenter] == filters[:datacenter] && g[:cluster] == filters[:cluster]}
25
+ data[:groups].values.select { |g| g[:datacenter] == filters[:datacenter] && g[:cluster] == filters[:cluster] }
26
26
  end
27
27
  end
28
28
  end
@@ -12,9 +12,25 @@ module Fog
12
12
  hsh.merge(
13
13
  datacenter: filters[:datacenter],
14
14
  cluster: filters[:cluster],
15
- ipaddress: (host['config.network.vnic'].first.spec.ip.ipAddress rescue nil),
16
- ipaddress6: (host['config.network.vnic'].first.spec.ip.ipV6Config.ipV6Address.first.ipAddress rescue nil),
17
- vm_ids: Proc.new { host['vm'].map {|vm| vm.config.instanceUuid rescue nil} }
15
+ ipaddress: (begin
16
+ host['config.network.vnic'].first.spec.ip.ipAddress
17
+ rescue
18
+ nil
19
+ end),
20
+ ipaddress6: (begin
21
+ host['config.network.vnic'].first.spec.ip.ipV6Config.ipV6Address.first.ipAddress
22
+ rescue
23
+ nil
24
+ end),
25
+ vm_ids: proc {
26
+ host['vm'].map do |vm|
27
+ begin
28
+ vm.config.instanceUuid
29
+ rescue
30
+ nil
31
+ end
32
+ end
33
+ }
18
34
  )
19
35
  end
20
36
  end
@@ -29,28 +45,28 @@ module Fog
29
45
 
30
46
  def property_collector_results(filter_spec)
31
47
  property_collector = connection.serviceContent.propertyCollector
32
- property_collector.RetrieveProperties(:specSet => [filter_spec])
48
+ property_collector.RetrieveProperties(specSet: [filter_spec])
33
49
  end
34
50
 
35
51
  def compute_resource_host_traversal_spec
36
52
  RbVmomi::VIM.TraversalSpec(
37
- :name => 'computeResourceHostTraversalSpec',
38
- :type => 'ComputeResource',
39
- :path => 'host',
40
- :skip => false
53
+ name: 'computeResourceHostTraversalSpec',
54
+ type: 'ComputeResource',
55
+ path: 'host',
56
+ skip: false
41
57
  )
42
58
  end
43
59
 
44
60
  def host_system_filter_spec(obj)
45
61
  RbVmomi::VIM.PropertyFilterSpec(
46
- :objectSet => [
47
- :obj => obj,
48
- :selectSet => [
62
+ objectSet: [
63
+ obj: obj,
64
+ selectSet: [
49
65
  compute_resource_host_traversal_spec
50
66
  ]
51
67
  ],
52
- :propSet => [
53
- { :type => 'HostSystem', :pathSet => host_system_attribute_mapping.values + ['config.network.vnic', 'vm'] }
68
+ propSet: [
69
+ { type: 'HostSystem', pathSet: host_system_attribute_mapping.values + ['config.network.vnic', 'vm'] }
54
70
  ]
55
71
  )
56
72
  end
@@ -75,7 +91,7 @@ module Fog
75
91
 
76
92
  class Mock
77
93
  def list_hosts(filters = {})
78
- self.data[:hosts].values.select {|r| r[:datacenter] == filters[:datacenter] && r[:cluster] == filters[:cluster]}
94
+ data[:hosts].values.select { |r| r[:datacenter] == filters[:datacenter] && r[:cluster] == filters[:cluster] }
79
95
  end
80
96
  end
81
97
  end
@@ -2,21 +2,21 @@ module Fog
2
2
  module Compute
3
3
  class Vsphere
4
4
  class Real
5
- def list_interface_types(filters={})
5
+ def list_interface_types(filters = {})
6
6
  datacenter_name = filters[:datacenter]
7
7
  servertype_name = filters[:servertype]
8
- get_raw_server_type(servertype_name, datacenter_name)[:supportedEthernetCard].map do | nictype |
9
- next if filters.key?(:id) and filters[:id] != nictype
8
+ get_raw_server_type(servertype_name, datacenter_name)[:supportedEthernetCard].map do |nictype|
9
+ next if filters.key?(:id) && (filters[:id] != nictype)
10
10
  interface_type_attributes(nictype, servertype_name, datacenter_name)
11
11
  end.compact
12
12
  end
13
13
 
14
14
  def interface_type_attributes(nic, servertype, datacenter)
15
15
  {
16
- :id => nic,
17
- :name => nic,
18
- :datacenter => datacenter,
19
- :servertype => servertype
16
+ id: nic,
17
+ name: nic,
18
+ datacenter: datacenter,
19
+ servertype: servertype
20
20
  }
21
21
  end
22
22
  end
@@ -2,7 +2,7 @@ module Fog
2
2
  module Compute
3
3
  class Vsphere
4
4
  class Real
5
- def list_networks(filters = { })
5
+ def list_networks(filters = {})
6
6
  datacenter_name = filters[:datacenter]
7
7
  cluster_name = filters.fetch(:cluster, nil)
8
8
  # default to show all networks
@@ -24,7 +24,7 @@ module Fog
24
24
  protected
25
25
 
26
26
  def network_attributes(network, datacenter)
27
- if network.kind_of?(RbVmomi::VIM::DistributedVirtualPortgroup)
27
+ if network.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup)
28
28
  id = network.key
29
29
  virtualswitch = network.config.distributedVirtualSwitch.name
30
30
  vlanid = raw_network_vlan(network.config.defaultPortConfig)
@@ -34,12 +34,12 @@ module Fog
34
34
  vlanid = nil
35
35
  end
36
36
  {
37
- :id => id,
38
- :name => network.name,
39
- :accessible => network.summary.accessible,
40
- :datacenter => datacenter,
41
- :virtualswitch => virtualswitch,
42
- :vlanid => vlanid
37
+ id: id,
38
+ name: network.name,
39
+ accessible: network.summary.accessible,
40
+ datacenter: datacenter,
41
+ virtualswitch: virtualswitch,
42
+ vlanid: vlanid
43
43
  }
44
44
  end
45
45
 
@@ -49,8 +49,6 @@ module Fog
49
49
  case network
50
50
  when RbVmomi::VIM::VMwareDVSPortSetting
51
51
  raw_network_vlan_id(network.vlan)
52
- else
53
- nil
54
52
  end
55
53
  end
56
54
 
@@ -58,8 +56,6 @@ module Fog
58
56
  case vlan
59
57
  when RbVmomi::VIM::VmwareDistributedVirtualSwitchVlanIdSpec
60
58
  vlan.vlanId
61
- else
62
- nil
63
59
  end
64
60
  end
65
61
  end
@@ -68,11 +64,11 @@ module Fog
68
64
  datacenter_name = filters[:datacenter]
69
65
  cluster_name = filters.fetch(:cluster, nil)
70
66
  if cluster_name.nil?
71
- self.data[:networks].values.select { |d| d['datacenter'] == datacenter_name } or
72
- raise Fog::Compute::Vsphere::NotFound
67
+ data[:networks].values.select { |d| d['datacenter'] == datacenter_name } ||
68
+ raise(Fog::Compute::Vsphere::NotFound)
73
69
  else
74
- self.data[:networks].values.select { |d| d['datacenter'] == datacenter_name && d['cluster'].include?(cluster_name) } or
75
- raise Fog::Compute::Vsphere::NotFound
70
+ data[:networks].values.select { |d| d['datacenter'] == datacenter_name && d['cluster'].include?(cluster_name) } ||
71
+ raise(Fog::Compute::Vsphere::NotFound)
76
72
  end
77
73
  end
78
74
  end
@@ -6,32 +6,32 @@ module Fog
6
6
  vm = get_vm_ref(vm_id)
7
7
 
8
8
  auth = RbVmomi::VIM::NamePasswordAuthentication(
9
- :username => opts[:user],
10
- :password => opts[:password],
11
- :interactiveSession => false
9
+ username: opts[:user],
10
+ password: opts[:password],
11
+ interactiveSession: false
12
12
  )
13
13
 
14
14
  p_manager = connection.serviceContent.guestOperationsManager.processManager
15
- processes = p_manager.ListProcessesInGuest(:vm => vm, :auth => auth)
15
+ processes = p_manager.ListProcessesInGuest(vm: vm, auth: auth)
16
16
  processes.map do |pi|
17
17
  Process.new(
18
- :cmd_line => pi.cmdLine,
19
- :end_time => pi.endTime,
20
- :exit_code => pi.exitCode,
21
- :name => pi.name,
22
- :owner => pi.owner,
23
- :pid => pi.pid,
24
- :start_time => pi.startTime
18
+ cmd_line: pi.cmdLine,
19
+ end_time: pi.endTime,
20
+ exit_code: pi.exitCode,
21
+ name: pi.name,
22
+ owner: pi.owner,
23
+ pid: pi.pid,
24
+ start_time: pi.startTime
25
25
  )
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
30
  class Mock
31
- def list_processes(vm_id, opts = {})
31
+ def list_processes(_vm_id, _opts = {})
32
32
  [
33
- Process.new(:name => 'winlogon'),
34
- Process.new(:name => 'init')
33
+ Process.new(name: 'winlogon'),
34
+ Process.new(name: 'init')
35
35
  ]
36
36
  end
37
37
  end
@@ -2,7 +2,7 @@ module Fog
2
2
  module Compute
3
3
  class Vsphere
4
4
  class Real
5
- def list_resource_pools(filters = { })
5
+ def list_resource_pools(filters = {})
6
6
  datacenter_name = filters[:datacenter]
7
7
  cluster_name = filters[:cluster]
8
8
  cluster = get_raw_cluster(cluster_name, datacenter_name)
@@ -21,14 +21,14 @@ module Fog
21
21
  end
22
22
 
23
23
  def traverse_raw_resource_pools(pools, rp)
24
- if rp
24
+ if rp
25
25
  if rp.respond_to? :resourcePool
26
26
  traverse_raw_resource_pools(pools, rp.resourcePool)
27
27
  end
28
28
  if rp.respond_to? :each
29
- rp.each do |resourcePool|
30
- traverse_raw_resource_pools(pools, resourcePool)
31
- end
29
+ rp.each do |resourcePool|
30
+ traverse_raw_resource_pools(pools, resourcePool)
31
+ end
32
32
  else
33
33
  pools << rp
34
34
  end
@@ -36,22 +36,21 @@ module Fog
36
36
  end
37
37
 
38
38
  def resource_pool_attributes(resource_pool, cluster, datacenter)
39
- name = folder_path(resource_pool).gsub(/^.*Resources(\/|)/,'')
39
+ name = folder_path(resource_pool).gsub(/^.*Resources(\/|)/, '')
40
40
  name = 'Resources' if name.empty?
41
41
  {
42
- :id => managed_obj_id(resource_pool),
43
- :name => name,
44
- :configured_memory_mb => resource_pool.summary.configuredMemoryMB,
45
- :overall_status => resource_pool.overallStatus,
46
- :cluster => cluster,
47
- :datacenter => datacenter
42
+ id: managed_obj_id(resource_pool),
43
+ name: name,
44
+ configured_memory_mb: resource_pool.summary.configuredMemoryMB,
45
+ overall_status: resource_pool.overallStatus,
46
+ cluster: cluster,
47
+ datacenter: datacenter
48
48
  }
49
49
  end
50
50
  end
51
51
 
52
52
  class Mock
53
- def list_resource_pools(filters = { })
54
- end
53
+ def list_resource_pools(filters = {}); end
55
54
  end
56
55
  end
57
56
  end
@@ -4,7 +4,7 @@ module Fog
4
4
  class Real
5
5
  def list_rules(filters = {})
6
6
  cluster = get_raw_cluster(filters[:cluster], filters[:datacenter])
7
- cluster.configurationEx.rule.map {|r| rule_attributes r, filters}
7
+ cluster.configurationEx.rule.map { |r| rule_attributes r, filters }
8
8
  end
9
9
 
10
10
  protected
@@ -18,18 +18,18 @@ module Fog
18
18
  attributes[:enabled] = rule[:enabled]
19
19
  attributes[:type] = rule.class
20
20
  if rule.class.to_s == 'ClusterAntiAffinityRuleSpec' || rule.class.to_s == 'ClusterAffinityRuleSpec'
21
- attributes[:vm_ids] = rule[:vm].map {|vm| vm.config.instanceUuid}
21
+ attributes[:vm_ids] = rule[:vm].map { |vm| vm.config.instanceUuid }
22
22
  elsif rule.class.to_s == 'ClusterVmHostRuleInfo'
23
23
  attributes[:mandatory] = rule[:mandatory]
24
24
  attributes[:vmGroupName] = rule[:vmGroupName]
25
25
  attributes[:affineHostGroupName] = rule[:affineHostGroupName]
26
26
  end
27
- return attributes
27
+ attributes
28
28
  end
29
29
  end
30
30
  class Mock
31
31
  def list_rules(filters = {})
32
- self.data[:rules].values.select {|r| r[:datacenter] == filters[:datacenter] && r[:cluster] == filters[:cluster]}
32
+ data[:rules].values.select { |r| r[:datacenter] == filters[:datacenter] && r[:cluster] == filters[:cluster] }
33
33
  end
34
34
  end
35
35
  end
@@ -2,22 +2,20 @@ module Fog
2
2
  module Compute
3
3
  class Vsphere
4
4
  class Real
5
- def list_server_types(filters={})
5
+ def list_server_types(filters = {})
6
6
  datacenter_name = filters[:datacenter]
7
- servertypes=raw_server_types(datacenter_name)
7
+ servertypes = raw_server_types(datacenter_name)
8
8
  if servertypes
9
- servertypes.map do | servertype |
10
- server_type_attributes(servertype, datacenter_name)
9
+ servertypes.map do |servertype|
10
+ server_type_attributes(servertype, datacenter_name)
11
11
  end.compact
12
- else
13
- nil
14
12
  end
15
- #select{ | guestdesc | guestdesc.select{ | k, v | filter.has_key?(k) and filter[k] == v }==filter }
13
+ # select{ | guestdesc | guestdesc.select{ | k, v | filter.has_key?(k) and filter[k] == v }==filter }
16
14
  end
17
15
 
18
- def raw_server_types(datacenter_name, filter={})
19
- datacenter=find_raw_datacenter(datacenter_name)
20
- environmentBrowser=datacenter.hostFolder.childEntity.grep(RbVmomi::VIM::ComputeResource).first.environmentBrowser
16
+ def raw_server_types(datacenter_name, _filter = {})
17
+ datacenter = find_raw_datacenter(datacenter_name)
18
+ environmentBrowser = datacenter.hostFolder.childEntity.grep(RbVmomi::VIM::ComputeResource).first.environmentBrowser
21
19
  if environmentBrowser
22
20
  environmentBrowser.QueryConfigOption[:guestOSDescriptor]
23
21
  end
@@ -27,26 +25,26 @@ module Fog
27
25
 
28
26
  def server_type_attributes(servertype, datacenter)
29
27
  {
30
- :id => servertype.id,
31
- :name => servertype.id,
32
- :family => servertype.family,
33
- :fullname => servertype.fullName,
34
- :datacenter => datacenter,
28
+ id: servertype.id,
29
+ name: servertype.id,
30
+ family: servertype.family,
31
+ fullname: servertype.fullName,
32
+ datacenter: datacenter
35
33
  }
36
34
  end
37
35
  end
38
36
  class Mock
39
- def list_server_types(datacenter_name)
40
- [{:id=>"rhel6Guest",
41
- :name=>"rhel6Guest",
42
- :family=>"linuxGuest",
43
- :fullname=>"Red Hat Enterprise Linux 6 (32-Bit)",
44
- :datacenter=>"Solutions"},
45
- {:id=>"rhel5_64Guest",
46
- :name=>"rhel5_64Guest",
47
- :family=>"linuxGuest",
48
- :fullname=>"Red Hat Enterprise Linux 5 (64-Bit)",
49
- :datacenter=>"Solutions"}]
37
+ def list_server_types(_datacenter_name)
38
+ [{ id: 'rhel6Guest',
39
+ name: 'rhel6Guest',
40
+ family: 'linuxGuest',
41
+ fullname: 'Red Hat Enterprise Linux 6 (32-Bit)',
42
+ datacenter: 'Solutions' },
43
+ { id: 'rhel5_64Guest',
44
+ name: 'rhel5_64Guest',
45
+ family: 'linuxGuest',
46
+ fullname: 'Red Hat Enterprise Linux 5 (64-Bit)',
47
+ datacenter: 'Solutions' }]
50
48
  end
51
49
  end
52
50
  end
@@ -2,7 +2,7 @@ module Fog
2
2
  module Compute
3
3
  class Vsphere
4
4
  class Real
5
- def list_storage_pods(filters = { })
5
+ def list_storage_pods(filters = {})
6
6
  datacenter_name = filters[:datacenter]
7
7
  raw_storage_pods(datacenter_name).map do |storage_pod|
8
8
  storage_pod_attributes(storage_pod, datacenter_name)
@@ -19,20 +19,20 @@ module Fog
19
19
 
20
20
  def storage_pod_attributes(storage_pod, datacenter)
21
21
  {
22
- :id => managed_obj_id(storage_pod),
23
- :name => storage_pod.name,
24
- :freespace => storage_pod.summary.freeSpace,
25
- :capacity => storage_pod.summary.capacity,
26
- :datacenter => datacenter,
22
+ id: managed_obj_id(storage_pod),
23
+ name: storage_pod.name,
24
+ freespace: storage_pod.summary.freeSpace,
25
+ capacity: storage_pod.summary.capacity,
26
+ datacenter: datacenter
27
27
  }
28
28
  end
29
29
  end
30
30
  class Mock
31
31
  def list_storage_pods(filters = {})
32
32
  if filters.key?(:datacenter)
33
- self.data[:storage_pods].select{|h| h[:datacenter] == filters[:datacenter] }
33
+ data[:storage_pods].select { |h| h[:datacenter] == filters[:datacenter] }
34
34
  else
35
- self.data[:storage_pods]
35
+ data[:storage_pods]
36
36
  end
37
37
  end
38
38
  end