fog-vsphere 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +217 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/Rakefile +10 -1
- data/fog-vsphere.gemspec +2 -2
- data/lib/fog/bin/vsphere.rb +1 -1
- data/lib/fog/vsphere/compute.rb +320 -301
- data/lib/fog/vsphere/models/compute/cdrom.rb +10 -10
- data/lib/fog/vsphere/models/compute/cdroms.rb +2 -2
- data/lib/fog/vsphere/models/compute/cluster.rb +20 -20
- data/lib/fog/vsphere/models/compute/clusters.rb +1 -1
- data/lib/fog/vsphere/models/compute/customfields.rb +4 -4
- data/lib/fog/vsphere/models/compute/customvalues.rb +8 -8
- data/lib/fog/vsphere/models/compute/datacenter.rb +16 -16
- data/lib/fog/vsphere/models/compute/datastores.rb +1 -1
- data/lib/fog/vsphere/models/compute/folder.rb +2 -2
- data/lib/fog/vsphere/models/compute/folders.rb +2 -2
- data/lib/fog/vsphere/models/compute/hosts.rb +4 -4
- data/lib/fog/vsphere/models/compute/interface.rb +12 -12
- data/lib/fog/vsphere/models/compute/interfaces.rb +14 -16
- data/lib/fog/vsphere/models/compute/interfacetype.rb +2 -2
- data/lib/fog/vsphere/models/compute/interfacetypes.rb +6 -8
- data/lib/fog/vsphere/models/compute/networks.rb +1 -1
- data/lib/fog/vsphere/models/compute/resource_pools.rb +1 -1
- data/lib/fog/vsphere/models/compute/rule.rb +8 -9
- data/lib/fog/vsphere/models/compute/rules.rb +9 -10
- data/lib/fog/vsphere/models/compute/scsicontroller.rb +1 -1
- data/lib/fog/vsphere/models/compute/server.rb +68 -80
- data/lib/fog/vsphere/models/compute/servers.rb +12 -13
- data/lib/fog/vsphere/models/compute/servertype.rb +6 -6
- data/lib/fog/vsphere/models/compute/servertypes.rb +2 -2
- data/lib/fog/vsphere/models/compute/snapshot.rb +5 -6
- data/lib/fog/vsphere/models/compute/snapshots.rb +1 -1
- data/lib/fog/vsphere/models/compute/ticket.rb +0 -1
- data/lib/fog/vsphere/models/compute/volume.rb +12 -14
- data/lib/fog/vsphere/models/compute/volumes.rb +10 -10
- data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +8 -8
- data/lib/fog/vsphere/requests/compute/create_folder.rb +5 -5
- data/lib/fog/vsphere/requests/compute/create_group.rb +16 -16
- data/lib/fog/vsphere/requests/compute/create_rule.rb +13 -13
- data/lib/fog/vsphere/requests/compute/create_vm.rb +117 -119
- data/lib/fog/vsphere/requests/compute/destroy_group.rb +8 -8
- data/lib/fog/vsphere/requests/compute/destroy_rule.rb +8 -8
- data/lib/fog/vsphere/requests/compute/folder_destroy.rb +3 -3
- data/lib/fog/vsphere/requests/compute/get_cluster.rb +2 -2
- data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +16 -16
- data/lib/fog/vsphere/requests/compute/get_datacenter.rb +7 -7
- data/lib/fog/vsphere/requests/compute/get_datastore.rb +1 -2
- data/lib/fog/vsphere/requests/compute/get_folder.rb +24 -24
- data/lib/fog/vsphere/requests/compute/get_host.rb +2 -3
- data/lib/fog/vsphere/requests/compute/get_interface_type.rb +6 -6
- data/lib/fog/vsphere/requests/compute/get_network.rb +7 -10
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -2
- data/lib/fog/vsphere/requests/compute/get_server_type.rb +14 -14
- data/lib/fog/vsphere/requests/compute/get_storage_pod.rb +2 -2
- data/lib/fog/vsphere/requests/compute/get_template.rb +1 -2
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +26 -26
- data/lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb +6 -7
- data/lib/fog/vsphere/requests/compute/host_finish_maintenance.rb +1 -1
- data/lib/fog/vsphere/requests/compute/host_shutdown.rb +1 -1
- data/lib/fog/vsphere/requests/compute/host_start_maintenance.rb +1 -1
- data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +37 -39
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +8 -9
- data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +57 -59
- data/lib/fog/vsphere/requests/compute/list_customfields.rb +5 -6
- data/lib/fog/vsphere/requests/compute/list_datacenters.rb +17 -17
- data/lib/fog/vsphere/requests/compute/list_datastores.rb +16 -15
- data/lib/fog/vsphere/requests/compute/list_folders.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_groups.rb +5 -5
- data/lib/fog/vsphere/requests/compute/list_hosts.rb +30 -14
- data/lib/fog/vsphere/requests/compute/list_interface_types.rb +7 -7
- data/lib/fog/vsphere/requests/compute/list_networks.rb +12 -16
- data/lib/fog/vsphere/requests/compute/list_processes.rb +14 -14
- data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +13 -14
- data/lib/fog/vsphere/requests/compute/list_rules.rb +4 -4
- data/lib/fog/vsphere/requests/compute/list_server_types.rb +24 -26
- data/lib/fog/vsphere/requests/compute/list_storage_pods.rb +8 -8
- data/lib/fog/vsphere/requests/compute/list_templates.rb +4 -5
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +15 -15
- data/lib/fog/vsphere/requests/compute/list_vm_cdroms.rb +16 -12
- data/lib/fog/vsphere/requests/compute/list_vm_customvalues.rb +3 -4
- data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +54 -56
- data/lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb +7 -7
- data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +36 -36
- data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +43 -36
- data/lib/fog/vsphere/requests/compute/modify_vm_cdrom.rb +4 -4
- data/lib/fog/vsphere/requests/compute/modify_vm_controller.rb +2 -2
- data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +26 -19
- data/lib/fog/vsphere/requests/compute/modify_vm_volume.rb +7 -7
- data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +2 -2
- data/lib/fog/vsphere/requests/compute/update_vm.rb +111 -0
- data/lib/fog/vsphere/requests/compute/upload_iso.rb +10 -10
- data/lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb +3 -3
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +245 -247
- data/lib/fog/vsphere/requests/compute/vm_config_vnc.rb +15 -15
- data/lib/fog/vsphere/requests/compute/vm_destroy.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_execute.rb +16 -16
- data/lib/fog/vsphere/requests/compute/vm_migrate.rb +11 -11
- data/lib/fog/vsphere/requests/compute/vm_power_off.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_power_on.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_reboot.rb +5 -5
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cdrom.rb +11 -11
- data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +6 -6
- data/lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb +14 -16
- data/lib/fog/vsphere/requests/compute/vm_relocate.rb +8 -8
- data/lib/fog/vsphere/requests/compute/vm_remove_snapshot.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_rename.rb +5 -5
- data/lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb +1 -1
- data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +8 -8
- data/lib/fog/vsphere/version.rb +1 -1
- data/tests/compute_tests.rb +16 -17
- data/tests/helpers/mock_helper.rb +3 -3
- data/tests/models/compute/cluster_tests.rb +4 -5
- data/tests/models/compute/hosts_tests.rb +2 -4
- data/tests/models/compute/rules_tests.rb +10 -16
- data/tests/models/compute/server_tests.rb +30 -31
- data/tests/models/compute/servers_tests.rb +2 -4
- data/tests/models/compute/ticket_tests.rb +4 -6
- data/tests/models/compute/tickets_tests.rb +1 -3
- data/tests/requests/compute/current_time_tests.rb +2 -4
- data/tests/requests/compute/folder_destroy_tests.rb +5 -7
- data/tests/requests/compute/get_network_tests.rb +20 -23
- data/tests/requests/compute/list_child_snapshots_tests.rb +1 -2
- data/tests/requests/compute/list_clusters_tests.rb +5 -6
- data/tests/requests/compute/list_datastores_tests.rb +6 -7
- data/tests/requests/compute/list_hosts_tests.rb +3 -4
- data/tests/requests/compute/list_networks_tests.rb +6 -7
- data/tests/requests/compute/list_storage_pods_test.rb +3 -4
- data/tests/requests/compute/list_virtual_machines_tests.rb +16 -20
- data/tests/requests/compute/list_vm_cdroms_tests.rb +1 -2
- data/tests/requests/compute/list_vm_snapshots_tests.rb +1 -2
- data/tests/requests/compute/modify_vm_cdrom_tests.rb +3 -4
- data/tests/requests/compute/revert_to_snapshot_tests.rb +2 -4
- data/tests/requests/compute/set_vm_customvalue_tests.rb +0 -2
- data/tests/requests/compute/update_vm_tests.rb +13 -0
- data/tests/requests/compute/vm_clone_tests.rb +20 -20
- data/tests/requests/compute/vm_config_vnc_tests.rb +3 -4
- data/tests/requests/compute/vm_destroy_tests.rb +1 -4
- data/tests/requests/compute/vm_migrate_tests.rb +1 -2
- data/tests/requests/compute/vm_power_off_tests.rb +2 -4
- data/tests/requests/compute/vm_power_on_tests.rb +1 -3
- data/tests/requests/compute/vm_reboot_tests.rb +2 -4
- data/tests/requests/compute/vm_reconfig_cdrom_tests.rb +2 -3
- data/tests/requests/compute/vm_reconfig_cpus_tests.rb +1 -3
- data/tests/requests/compute/vm_reconfig_hardware_tests.rb +2 -4
- data/tests/requests/compute/vm_reconfig_memory_tests.rb +1 -3
- data/tests/requests/compute/vm_take_snapshot_tests.rb +1 -3
- metadata +9 -4
@@ -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
|
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! {|
|
45
|
-
|
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
|
20
|
-
|
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
|
-
|
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: (
|
16
|
-
|
17
|
-
|
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(:
|
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
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
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
|
-
:
|
47
|
-
:
|
48
|
-
:
|
62
|
+
objectSet: [
|
63
|
+
obj: obj,
|
64
|
+
selectSet: [
|
49
65
|
compute_resource_host_traversal_spec
|
50
66
|
]
|
51
67
|
],
|
52
|
-
:
|
53
|
-
{ :
|
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
|
-
|
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 |
|
9
|
-
next if filters.key?(:id)
|
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
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
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.
|
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
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
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
|
-
|
72
|
-
raise
|
67
|
+
data[:networks].values.select { |d| d['datacenter'] == datacenter_name } ||
|
68
|
+
raise(Fog::Compute::Vsphere::NotFound)
|
73
69
|
else
|
74
|
-
|
75
|
-
raise
|
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
|
-
:
|
10
|
-
:
|
11
|
-
:
|
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(:
|
15
|
+
processes = p_manager.ListProcessesInGuest(vm: vm, auth: auth)
|
16
16
|
processes.map do |pi|
|
17
17
|
Process.new(
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
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(
|
31
|
+
def list_processes(_vm_id, _opts = {})
|
32
32
|
[
|
33
|
-
Process.new(:
|
34
|
-
Process.new(:
|
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
|
-
|
30
|
-
|
31
|
-
|
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
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
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
|
-
|
27
|
+
attributes
|
28
28
|
end
|
29
29
|
end
|
30
30
|
class Mock
|
31
31
|
def list_rules(filters = {})
|
32
|
-
|
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 |
|
10
|
-
|
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,
|
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
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
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(
|
40
|
-
[{:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
{:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
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
|
-
|
33
|
+
data[:storage_pods].select { |h| h[:datacenter] == filters[:datacenter] }
|
34
34
|
else
|
35
|
-
|
35
|
+
data[:storage_pods]
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|