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
@@ -8,18 +8,17 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def get_vm_first_scsi_controller_raw(vm_id)
|
11
|
-
ctrl=get_vm_ref(vm_id).config.hardware.device.grep(RbVmomi::VIM::VirtualSCSIController).select{ |
|
11
|
+
ctrl = get_vm_ref(vm_id).config.hardware.device.grep(RbVmomi::VIM::VirtualSCSIController).select { |ctrl| ctrl.key == 1000 }.first
|
12
12
|
{
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
13
|
+
type: ctrl.class.to_s,
|
14
|
+
shared_bus: ctrl.sharedBus.to_s,
|
15
|
+
unit_number: ctrl.scsiCtlrUnitNumber,
|
16
|
+
key: ctrl.key
|
17
17
|
}
|
18
18
|
end
|
19
19
|
end
|
20
20
|
class Mock
|
21
|
-
def get_vm_first_scsi_controller(vm_id)
|
22
|
-
end
|
21
|
+
def get_vm_first_scsi_controller(vm_id); end
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
@@ -4,7 +4,7 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def host_finish_maintenance(name, cluster_name, datacenter_name, timeout = 0)
|
6
6
|
host_ref = get_host(name, cluster_name, datacenter_name)
|
7
|
-
task = host_ref.ExitMaintenanceMode_Task(:
|
7
|
+
task = host_ref.ExitMaintenanceMode_Task(timeout: timeout)
|
8
8
|
task.wait_for_completion
|
9
9
|
{ 'task_state' => task.info.state }
|
10
10
|
end
|
@@ -4,7 +4,7 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def host_shutdown(name, cluster_name, datacenter_name, force = false)
|
6
6
|
host_ref = get_host(name, cluster_name, datacenter_name)
|
7
|
-
task = host_ref.ShutdownHost_Task(:
|
7
|
+
task = host_ref.ShutdownHost_Task(force: force)
|
8
8
|
task.wait_for_completion
|
9
9
|
{ 'task_state' => task.info.state }
|
10
10
|
end
|
@@ -4,7 +4,7 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def host_start_maintenance(name, cluster_name, datacenter_name, timeout = 0, evacuate_powered_off_vms = false)
|
6
6
|
host_ref = get_host(name, cluster_name, datacenter_name)
|
7
|
-
task = host_ref.EnterMaintenanceMode_Task(:
|
7
|
+
task = host_ref.EnterMaintenanceMode_Task(timeout: timeout, evacuatePoweredOffVms: evacuate_powered_off_vms)
|
8
8
|
task.wait_for_completion
|
9
9
|
{ 'task_state' => task.info.state }
|
10
10
|
end
|
@@ -4,7 +4,7 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def list_child_snapshots(snapshot, opts = {})
|
6
6
|
normalized_snapshot = Hash === snapshot ?
|
7
|
-
Snapshot.new(snapshot.update(:
|
7
|
+
Snapshot.new(snapshot.update(service: self)) : snapshot
|
8
8
|
|
9
9
|
child_snapshots = normalized_snapshot.tree_node.childSnapshotList.map do |snap|
|
10
10
|
item = child_snapshot_info(snap, normalized_snapshot)
|
@@ -19,50 +19,48 @@ module Fog
|
|
19
19
|
|
20
20
|
protected
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
end
|
22
|
+
def child_snapshot_info(snap_tree, parent_snap)
|
23
|
+
{
|
24
|
+
name: snap_tree.name,
|
25
|
+
quiesced: snap_tree.quiesced,
|
26
|
+
description: snap_tree.description,
|
27
|
+
create_time: snap_tree.createTime,
|
28
|
+
power_state: snap_tree.state,
|
29
|
+
ref: snap_tree.snapshot._ref,
|
30
|
+
mo_ref: snap_tree.snapshot,
|
31
|
+
tree_node: snap_tree,
|
32
|
+
snapshot_name_chain: "#{parent_snap.snapshot_name_chain}/#{snap_tree.name}",
|
33
|
+
ref_chain: "#{parent_snap.ref_chain}/#{snap_tree.snapshot._ref}",
|
34
|
+
server_id: parent_snap.server_id
|
35
|
+
}
|
36
|
+
end
|
39
37
|
end
|
40
38
|
class Mock
|
41
|
-
def list_child_snapshots(
|
39
|
+
def list_child_snapshots(_snapshot, _opts = {})
|
42
40
|
[
|
43
41
|
{
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
42
|
+
name: 'clean',
|
43
|
+
quiesced: false,
|
44
|
+
description: '',
|
45
|
+
create_time: Time.now.utc,
|
46
|
+
power_state: 'poweredOn',
|
47
|
+
ref: 'snapshot-0101',
|
48
|
+
mo_ref: nil,
|
49
|
+
tree_node: nil,
|
50
|
+
snapshot_name_chain: '123/clean',
|
51
|
+
ref_chain: '123/snap-0101'
|
54
52
|
},
|
55
53
|
{
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
54
|
+
name: 'dirty',
|
55
|
+
quiesced: false,
|
56
|
+
description: '',
|
57
|
+
create_time: Time.now.utc,
|
58
|
+
power_state: 'poweredOn',
|
59
|
+
ref: 'snapshot-0102',
|
60
|
+
mo_ref: nil,
|
61
|
+
tree_node: nil,
|
62
|
+
snapshot_name_chain: '123/dirty',
|
63
|
+
ref_chain: '123/snap-0102'
|
66
64
|
}
|
67
65
|
]
|
68
66
|
end
|
@@ -2,11 +2,10 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
|
-
|
6
5
|
def list_clusters(filters = {})
|
7
6
|
datacenter_name = filters[:datacenter] if filters.key? :datacenter
|
8
7
|
if datacenter_name.nil?
|
9
|
-
list_datacenters.map { |dc| list_clusters(:
|
8
|
+
list_datacenters.map { |dc| list_clusters(datacenter: dc[:name]) }.flatten
|
10
9
|
else
|
11
10
|
raw_clusters(datacenter_name).map do |cluster|
|
12
11
|
if cluster.instance_of? RbVmomi::VIM::ClusterComputeResource
|
@@ -35,13 +34,13 @@ module Fog
|
|
35
34
|
|
36
35
|
def cluster_attributes(cluster, datacenter_name)
|
37
36
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
37
|
+
id: managed_obj_id(cluster),
|
38
|
+
name: cluster.name,
|
39
|
+
full_path: cluster_path(cluster, datacenter_name),
|
40
|
+
num_host: cluster.summary.numHosts,
|
41
|
+
num_cpu_cores: cluster.summary.numCpuCores,
|
42
|
+
overall_status: cluster.summary.overallStatus,
|
43
|
+
datacenter: datacenter_name || parent_attribute(cluster.path, :datacenter)[1]
|
45
44
|
}
|
46
45
|
end
|
47
46
|
|
@@ -2,89 +2,87 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
|
-
def list_compute_resources(filters = {
|
5
|
+
def list_compute_resources(filters = {})
|
6
6
|
datacenter_name = filters[:datacenter]
|
7
7
|
# default to show all compute_resources
|
8
8
|
only_active = filters[:effective] || false
|
9
9
|
compute_resources = raw_compute_resources datacenter_name
|
10
|
-
|
10
|
+
|
11
11
|
compute_resources.map do |compute_resource|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
next if compute_resource.instance_of? RbVmomi::VIM::Folder
|
13
|
+
summary = compute_resource.summary
|
14
|
+
next if only_active && (summary.numEffectiveHosts == 0)
|
15
|
+
compute_resource_attributes(compute_resource, datacenter_name)
|
17
16
|
end.compact
|
18
17
|
end
|
19
|
-
|
18
|
+
|
20
19
|
def raw_compute_resources(datacenter_name)
|
21
20
|
find_raw_datacenter(datacenter_name).find_compute_resource('').children
|
22
21
|
end
|
23
22
|
|
24
23
|
protected
|
25
24
|
|
26
|
-
def compute_resource_attributes
|
27
|
-
overall_usage = compute_resource.host.inject(
|
25
|
+
def compute_resource_attributes(compute_resource, _datacenter)
|
26
|
+
overall_usage = compute_resource.host.inject(overallCpuUsage: 0, overallMemoryUsage: 0) do |sum, host|
|
28
27
|
{
|
29
|
-
:
|
30
|
-
:
|
28
|
+
overallCpuUsage: sum[:overallCpuUsage] + (host.summary.quickStats.overallCpuUsage || 0),
|
29
|
+
overallMemoryUsage: sum[:overallMemoryUsage] + (host.summary.quickStats.overallMemoryUsage || 0)
|
31
30
|
}
|
32
31
|
end
|
33
32
|
{
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
33
|
+
id: managed_obj_id(compute_resource),
|
34
|
+
name: compute_resource.name,
|
35
|
+
totalCpu: compute_resource.summary.totalCpu,
|
36
|
+
totalMemory: compute_resource.summary.totalMemory,
|
37
|
+
numCpuCores: compute_resource.summary.numCpuCores,
|
38
|
+
numCpuThreads: compute_resource.summary.numCpuThreads,
|
39
|
+
effectiveCpu: compute_resource.summary.effectiveCpu,
|
40
|
+
effectiveMemory: compute_resource.summary.effectiveMemory,
|
41
|
+
numHosts: compute_resource.summary.numHosts,
|
42
|
+
numEffectiveHosts: compute_resource.summary.numEffectiveHosts,
|
43
|
+
overallStatus: compute_resource.summary.overallStatus,
|
44
|
+
overallCpuUsage: overall_usage[:overallCpuUsage],
|
45
|
+
overallMemoryUsage: overall_usage[:overallMemoryUsage],
|
46
|
+
effective: compute_resource.summary.numEffectiveHosts > 0,
|
47
|
+
isSingleHost: compute_resource.summary.numHosts == 1
|
49
48
|
}
|
50
49
|
end
|
51
|
-
|
52
50
|
end
|
53
51
|
class Mock
|
54
|
-
def list_compute_resources(
|
52
|
+
def list_compute_resources(_filters = {})
|
55
53
|
[
|
56
54
|
{
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
55
|
+
id: 'domain-s7',
|
56
|
+
name: 'fake-host',
|
57
|
+
totalCpu: 33_504,
|
58
|
+
totalMemory: 154_604_142_592,
|
59
|
+
numCpuCores: 12,
|
60
|
+
numCpuThreads: 24,
|
61
|
+
effectiveCpu: 32_247,
|
62
|
+
effectiveMemory: 135_733,
|
63
|
+
numHosts: 1,
|
64
|
+
numEffectiveHosts: 1,
|
65
|
+
overallStatus: 'gray',
|
66
|
+
overallCpuUsage: 15_682,
|
67
|
+
overallMemoryUsage: 132_755,
|
68
|
+
effective: true,
|
69
|
+
isSingleHost: true
|
72
70
|
}, {
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
71
|
+
id: 'domain-s74',
|
72
|
+
name: 'fake-cluster',
|
73
|
+
totalCpu: 41_484,
|
74
|
+
totalMemory: 51_525_996_544,
|
75
|
+
numCpuCores: 12,
|
76
|
+
numCpuThreads: 24,
|
77
|
+
effectiveCpu: 37_796,
|
78
|
+
effectiveMemory: 45_115,
|
79
|
+
numHosts: 2,
|
80
|
+
numEffectiveHosts: 2,
|
81
|
+
overallStatus: 'gray',
|
82
|
+
overallCpuUsage: 584,
|
83
|
+
overallMemoryUsage: 26_422,
|
84
|
+
effective: true,
|
85
|
+
isSingleHost: false
|
88
86
|
}
|
89
87
|
]
|
90
88
|
end
|
@@ -2,19 +2,18 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
|
-
def list_customfields
|
5
|
+
def list_customfields
|
6
6
|
connection.serviceContent.customFieldsManager.field.map do |customfield|
|
7
7
|
{
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
8
|
+
key: customfield.key.to_i,
|
9
|
+
name: customfield.name,
|
10
|
+
type: customfield.type
|
11
11
|
}
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
15
|
class Mock
|
16
|
-
def list_vm_customfields
|
17
|
-
end
|
16
|
+
def list_vm_customfields; end
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -2,50 +2,50 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
|
-
def list_datacenters
|
5
|
+
def list_datacenters(_filters = {})
|
6
6
|
raw_datacenters.map do |dc|
|
7
7
|
{
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
8
|
+
id: managed_obj_id(dc),
|
9
|
+
name: dc.name,
|
10
|
+
path: raw_getpathmo(dc),
|
11
|
+
status: dc.overallStatus
|
12
12
|
}
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
protected
|
17
17
|
|
18
|
-
def raw_getpathmo
|
19
|
-
if mo.parent
|
20
|
-
[
|
18
|
+
def raw_getpathmo(mo)
|
19
|
+
if mo.parent.nil? || (mo.parent.name == connection.rootFolder.name)
|
20
|
+
[mo.name]
|
21
21
|
else
|
22
|
-
[
|
22
|
+
[raw_getpathmo(mo.parent), mo.name].flatten
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def raw_datacenters
|
26
|
+
def raw_datacenters(folder = nil)
|
27
27
|
folder ||= connection.rootFolder
|
28
28
|
@raw_datacenters ||= get_raw_datacenters_from_folder folder
|
29
29
|
end
|
30
30
|
|
31
|
-
def get_raw_datacenters_from_folder
|
32
|
-
folder.childEntity.map do |
|
31
|
+
def get_raw_datacenters_from_folder(folder = nil)
|
32
|
+
folder.childEntity.map do |childE|
|
33
33
|
if childE.is_a? RbVmomi::VIM::Datacenter
|
34
|
-
|
34
|
+
childE
|
35
35
|
elsif childE.is_a? RbVmomi::VIM::Folder
|
36
|
-
|
36
|
+
get_raw_datacenters_from_folder childE
|
37
37
|
end
|
38
38
|
end.flatten
|
39
39
|
end
|
40
40
|
|
41
|
-
def find_datacenters
|
41
|
+
def find_datacenters(name = nil)
|
42
42
|
name ? [find_raw_datacenter(name)] : raw_datacenters
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
class Mock
|
47
|
-
def list_datacenters
|
48
|
-
|
47
|
+
def list_datacenters(_filters = {})
|
48
|
+
data[:datacenters].values
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -2,13 +2,13 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
|
-
def list_datastores(filters = {
|
5
|
+
def list_datastores(filters = {})
|
6
6
|
datacenter_name = filters[:datacenter]
|
7
7
|
cluster_name = filters.fetch(:cluster, nil)
|
8
8
|
# default to show all datastores
|
9
9
|
only_active = filters[:accessible] || false
|
10
10
|
raw_datastores(datacenter_name, cluster_name).map do |datastore|
|
11
|
-
next if only_active
|
11
|
+
next if only_active && !datastore.summary.accessible
|
12
12
|
datastore_attributes(datastore, datacenter_name)
|
13
13
|
end.compact
|
14
14
|
end
|
@@ -20,18 +20,19 @@ module Fog
|
|
20
20
|
get_raw_cluster(cluster, datacenter_name).datastore
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
23
24
|
protected
|
24
25
|
|
25
|
-
def datastore_attributes
|
26
|
+
def datastore_attributes(datastore, datacenter)
|
26
27
|
{
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
28
|
+
id: managed_obj_id(datastore),
|
29
|
+
name: datastore.name,
|
30
|
+
accessible: datastore.summary.accessible,
|
31
|
+
type: datastore.summary.type,
|
32
|
+
freespace: datastore.summary.freeSpace,
|
33
|
+
capacity: datastore.summary.capacity,
|
34
|
+
uncommitted: datastore.summary.uncommitted,
|
35
|
+
datacenter: datacenter
|
35
36
|
}
|
36
37
|
end
|
37
38
|
end
|
@@ -40,11 +41,11 @@ module Fog
|
|
40
41
|
datacenter_name = filters[:datacenter]
|
41
42
|
cluster_name = filters.fetch(:cluster, nil)
|
42
43
|
if cluster_name.nil?
|
43
|
-
|
44
|
-
raise
|
44
|
+
data[:datastores].values.select { |d| d['datacenter'] == datacenter_name } ||
|
45
|
+
raise(Fog::Compute::Vsphere::NotFound)
|
45
46
|
else
|
46
|
-
|
47
|
-
raise
|
47
|
+
data[:datastores].values.select { |d| d['datacenter'] == datacenter_name && d['cluster'].include?(cluster_name) } ||
|
48
|
+
raise(Fog::Compute::Vsphere::NotFound)
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|