fog 1.27.0 → 1.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +71 -0
- data/Rakefile +2 -2
- data/bin/fog +2 -2
- data/fog.gemspec +4 -3
- data/lib/fog/bin/clodo.rb +1 -1
- data/lib/fog/bin/openstack.rb +5 -0
- data/lib/fog/digitalocean/examples/getting_started.md +46 -4
- data/lib/fog/digitalocean/models/compute/server.rb +1 -3
- data/lib/fog/digitalocean/models/compute/servers.rb +30 -0
- data/lib/fog/fogdocker/compute.rb +3 -2
- data/lib/fog/fogdocker/requests/compute/container_action.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_all.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_commit.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_create.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_delete.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_get.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_all.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_create.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_delete.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_get.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_search.rb +1 -1
- data/lib/fog/google/compute.rb +2 -1
- data/lib/fog/google/core.rb +42 -12
- data/lib/fog/google/dns.rb +2 -1
- data/lib/fog/google/monitoring.rb +1 -1
- data/lib/fog/google/sql.rb +1 -1
- data/lib/fog/hp/requests/storage/get_object.rb +5 -3
- data/lib/fog/joyent/compute.rb +2 -0
- data/lib/fog/openstack.rb +1 -0
- data/lib/fog/openstack/baremetal.rb +370 -0
- data/lib/fog/openstack/core.rb +1 -0
- data/lib/fog/openstack/docs/orchestration.md +318 -0
- data/lib/fog/openstack/docs/storage.md +1 -7
- data/lib/fog/openstack/models/baremetal/chassis.rb +60 -0
- data/lib/fog/openstack/models/baremetal/chassis_collection.rb +38 -0
- data/lib/fog/openstack/models/baremetal/driver.rb +30 -0
- data/lib/fog/openstack/models/baremetal/drivers.rb +21 -0
- data/lib/fog/openstack/models/baremetal/node.rb +85 -0
- data/lib/fog/openstack/models/baremetal/nodes.rb +38 -0
- data/lib/fog/openstack/models/baremetal/port.rb +61 -0
- data/lib/fog/openstack/models/baremetal/ports.rb +38 -0
- data/lib/fog/openstack/models/orchestration/event.rb +20 -0
- data/lib/fog/openstack/models/orchestration/events.rb +28 -0
- data/lib/fog/openstack/models/orchestration/resource.rb +32 -0
- data/lib/fog/openstack/models/orchestration/resource_schemas.rb +17 -0
- data/lib/fog/openstack/models/orchestration/resources.rb +35 -0
- data/lib/fog/openstack/models/orchestration/stack.rb +91 -24
- data/lib/fog/openstack/models/orchestration/stacks.rb +38 -4
- data/lib/fog/openstack/models/orchestration/template.rb +15 -0
- data/lib/fog/openstack/models/orchestration/templates.rb +44 -0
- data/lib/fog/openstack/orchestration.rb +48 -2
- data/lib/fog/openstack/requests/baremetal/create_chassis.rb +44 -0
- data/lib/fog/openstack/requests/baremetal/create_node.rb +54 -0
- data/lib/fog/openstack/requests/baremetal/create_port.rb +46 -0
- data/lib/fog/openstack/requests/baremetal/delete_chassis.rb +25 -0
- data/lib/fog/openstack/requests/baremetal/delete_node.rb +25 -0
- data/lib/fog/openstack/requests/baremetal/delete_port.rb +25 -0
- data/lib/fog/openstack/requests/baremetal/get_chassis.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/get_driver.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/get_driver_properties.rb +40 -0
- data/lib/fog/openstack/requests/baremetal/get_node.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/get_port.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/list_chassis.rb +48 -0
- data/lib/fog/openstack/requests/baremetal/list_chassis_detailed.rb +31 -0
- data/lib/fog/openstack/requests/baremetal/list_drivers.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/list_nodes.rb +40 -0
- data/lib/fog/openstack/requests/baremetal/list_nodes_detailed.rb +31 -0
- data/lib/fog/openstack/requests/baremetal/list_ports.rb +48 -0
- data/lib/fog/openstack/requests/baremetal/list_ports_detailed.rb +31 -0
- data/lib/fog/openstack/requests/baremetal/patch_chassis.rb +42 -0
- data/lib/fog/openstack/requests/baremetal/patch_node.rb +41 -0
- data/lib/fog/openstack/requests/baremetal/patch_port.rb +41 -0
- data/lib/fog/openstack/requests/compute/create_server.rb +1 -0
- data/lib/fog/openstack/requests/orchestration/abandon_stack.rb +15 -0
- data/lib/fog/openstack/requests/orchestration/build_info.rb +15 -0
- data/lib/fog/openstack/requests/orchestration/create_stack.rb +31 -12
- data/lib/fog/openstack/requests/orchestration/delete_stack.rb +28 -5
- data/lib/fog/openstack/requests/orchestration/get_stack_template.rb +20 -0
- data/lib/fog/openstack/requests/orchestration/list_resource_events.rb +23 -0
- data/lib/fog/openstack/requests/orchestration/list_resource_types.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/list_resources.rb +23 -0
- data/lib/fog/openstack/requests/orchestration/list_stack_data.rb +27 -0
- data/lib/fog/openstack/requests/orchestration/list_stack_events.rb +23 -0
- data/lib/fog/openstack/requests/orchestration/preview_stack.rb +16 -0
- data/lib/fog/openstack/requests/orchestration/show_event_details.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_data.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_metadata.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_schema.rb +15 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_template.rb +20 -0
- data/lib/fog/openstack/requests/orchestration/show_stack_details.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/update_stack.rb +34 -7
- data/lib/fog/openstack/requests/orchestration/validate_template.rb +16 -0
- data/lib/fog/openstack/volume.rb +0 -1
- data/lib/fog/ovirt/compute.rb +6 -0
- data/lib/fog/ovirt/models/compute/server.rb +10 -0
- data/lib/fog/ovirt/models/compute/template.rb +1 -0
- data/lib/fog/ovirt/models/compute/volumes.rb +1 -2
- data/lib/fog/ovirt/requests/compute/attach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/detach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/list_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/mock_files/disks.xml +58 -0
- data/lib/fog/vcloud_director/models/compute/task.rb +2 -2
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +3 -0
- data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +20 -11
- data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +41 -0
- data/lib/fog/vsphere/requests/compute/get_network.rb +35 -6
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -1
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +19 -13
- data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +92 -0
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +16 -11
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +6 -5
- data/lib/fog/xenserver/requests/compute/create_sr.rb +3 -4
- data/lib/tasks/changelog_task.rb +1 -0
- data/tests/helper.rb +3 -3
- data/tests/helpers/mock_helper.rb +0 -4
- data/tests/openstack/requests/baremetal/chassis_tests.rb +48 -0
- data/tests/openstack/requests/baremetal/driver_tests.rb +40 -0
- data/tests/openstack/requests/baremetal/node_tests.rb +65 -0
- data/tests/openstack/requests/baremetal/port_tests.rb +56 -0
- data/tests/openstack/requests/compute/server_tests.rb +2 -0
- data/tests/openstack/requests/orchestration/stack_tests.rb +2 -2
- data/tests/vsphere/requests/compute/get_network_tests.rb +48 -0
- metadata +88 -23
- data/lib/fog/aws.rb +0 -23
- data/lib/fog/bin/riakcs.rb +0 -25
- data/lib/fog/openstack/requests/orchestration/list_stacks.rb +0 -47
- data/lib/fog/riakcs.rb +0 -2
- data/lib/fog/riakcs/core.rb +0 -121
- data/lib/fog/riakcs/provisioning.rb +0 -98
- data/lib/fog/riakcs/requests/provisioning/create_user.rb +0 -77
- data/lib/fog/riakcs/requests/provisioning/disable_user.rb +0 -23
- data/lib/fog/riakcs/requests/provisioning/enable_user.rb +0 -23
- data/lib/fog/riakcs/requests/provisioning/get_user.rb +0 -41
- data/lib/fog/riakcs/requests/provisioning/list_users.rb +0 -43
- data/lib/fog/riakcs/requests/provisioning/regrant_secret.rb +0 -23
- data/lib/fog/riakcs/requests/provisioning/update_user.rb +0 -23
- data/lib/fog/riakcs/requests/usage/get_usage.rb +0 -68
- data/lib/fog/riakcs/usage.rb +0 -62
- data/tests/riakcs/requests/provisioning/provisioning_tests.rb +0 -174
- data/tests/riakcs/requests/usage/usage_tests.rb +0 -29
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def detach_volume(id, options)
|
6
|
+
raise ArgumentError, "instance id is a required parameter" unless id
|
7
|
+
raise ArgumentError, "volume id is a required parameter for detach-volume" unless options.key? :id
|
8
|
+
|
9
|
+
client.detach_volume(id, options[:id])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def detach_volume(id, options)
|
15
|
+
raise ArgumentError, "instance id is a required parameter" unless id
|
16
|
+
raise ArgumentError, "volume id is a required parameter for detach-volume" unless options.key? :id
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Ovirt
|
4
|
+
class Real
|
5
|
+
def list_volumes
|
6
|
+
client.disks.map {|ovirt_obj| ovirt_attrs ovirt_obj}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
class Mock
|
10
|
+
def list_volumes
|
11
|
+
xml = read_xml 'disks.xml'
|
12
|
+
Nokogiri::XML(xml).xpath('/disks/disk').map do |vol|
|
13
|
+
ovirt_attrs OVIRT::Volume::new(self, vol)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<disks>
|
2
|
+
<disk href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05" id="4d1abf9a-da81-4de2-bf20-f5f060018e05">
|
3
|
+
<actions>
|
4
|
+
<link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/export" rel="export"/>
|
5
|
+
<link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/move" rel="move"/>
|
6
|
+
<link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/copy" rel="copy"/>
|
7
|
+
</actions>
|
8
|
+
<name>Disk 2</name>
|
9
|
+
<link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/permissions" rel="permissions"/>
|
10
|
+
<link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/statistics" rel="statistics"/>
|
11
|
+
<alias>Disk 2</alias>
|
12
|
+
<image_id>d6034a90-39fa-46ee-888f-208a76f3baa4</image_id>
|
13
|
+
<storage_domains>
|
14
|
+
<storage_domain id="a23a4329-33b9-4246-a393-4f91071825b6"/>
|
15
|
+
</storage_domains>
|
16
|
+
<size>4294967296</size>
|
17
|
+
<provisioned_size>4294967296</provisioned_size>
|
18
|
+
<actual_size>1073741824</actual_size>
|
19
|
+
<status>
|
20
|
+
<state>ok</state>
|
21
|
+
</status>
|
22
|
+
<interface>virtio</interface>
|
23
|
+
<format>cow</format>
|
24
|
+
<sparse>true</sparse>
|
25
|
+
<bootable>false</bootable>
|
26
|
+
<shareable>false</shareable>
|
27
|
+
<wipe_after_delete>false</wipe_after_delete>
|
28
|
+
<propagate_errors>false</propagate_errors>
|
29
|
+
</disk>
|
30
|
+
<disk href="/api/disks/cfebdac5-cefb-488a-8b55-f5f273a1e863" id="cfebdac5-cefb-488a-8b55-f5f273a1e863">
|
31
|
+
<actions>
|
32
|
+
<link href="/api/disks/cfebdac5-cefb-488a-8b55-f5f273a1e863/export" rel="export"/>
|
33
|
+
<link href="/api/disks/cfebdac5-cefb-488a-8b55-f5f273a1e863/move" rel="move"/>
|
34
|
+
<link href="/api/disks/cfebdac5-cefb-488a-8b55-f5f273a1e863/copy" rel="copy"/>
|
35
|
+
</actions>
|
36
|
+
<name>Disk 3</name>
|
37
|
+
<link href="/api/disks/cfebdac5-cefb-488a-8b55-f5f273a1e863/permissions" rel="permissions"/>
|
38
|
+
<link href="/api/disks/cfebdac5-cefb-488a-8b55-f5f273a1e863/statistics" rel="statistics"/>
|
39
|
+
<alias>Disk 3</alias>
|
40
|
+
<image_id>3d7edbe9-54e1-484c-a77c-3d170f1906bb</image_id>
|
41
|
+
<storage_domains>
|
42
|
+
<storage_domain id="c8431bb5-f57b-4ce8-8ba0-17c1859bc767"/>
|
43
|
+
</storage_domains>
|
44
|
+
<size>21474836480</size>
|
45
|
+
<provisioned_size>21474836480</provisioned_size>
|
46
|
+
<actual_size>1073741824</actual_size>
|
47
|
+
<status>
|
48
|
+
<state>ok</state>
|
49
|
+
</status>
|
50
|
+
<interface>virtio</interface>
|
51
|
+
<format>cow</format>
|
52
|
+
<sparse>true</sparse>
|
53
|
+
<bootable>false</bootable>
|
54
|
+
<shareable>false</shareable>
|
55
|
+
<wipe_after_delete>false</wipe_after_delete>
|
56
|
+
<propagate_errors>false</propagate_errors>
|
57
|
+
</disk>
|
58
|
+
</disks>
|
@@ -36,10 +36,10 @@ module Fog
|
|
36
36
|
def non_running?
|
37
37
|
if @service.show_progress? && (@last_progress ||= 0) < 100
|
38
38
|
if status == 'running'
|
39
|
-
Formatador.redisplay_progressbar(progress, 100, :label => operation_name, :started_at => start_time)
|
39
|
+
Fog::Formatador.redisplay_progressbar(progress, 100, :label => operation_name, :started_at => start_time)
|
40
40
|
@last_progress = progress
|
41
41
|
elsif status == 'success'
|
42
|
-
Formatador.redisplay_progressbar(100, 100, :label => operation_name, :started_at => start_time)
|
42
|
+
Fog::Formatador.redisplay_progressbar(100, 100, :label => operation_name, :started_at => start_time)
|
43
43
|
@last_progress = 100
|
44
44
|
end
|
45
45
|
end
|
data/lib/fog/version.rb
CHANGED
data/lib/fog/vsphere/compute.rb
CHANGED
@@ -41,6 +41,7 @@ module Fog
|
|
41
41
|
|
42
42
|
request_path 'fog/vsphere/requests/compute'
|
43
43
|
request :current_time
|
44
|
+
request :cloudinit_to_customspec
|
44
45
|
request :list_virtual_machines
|
45
46
|
request :vm_power_off
|
46
47
|
request :vm_power_on
|
@@ -58,6 +59,8 @@ module Fog
|
|
58
59
|
request :get_network
|
59
60
|
request :list_datastores
|
60
61
|
request :get_datastore
|
62
|
+
request :list_compute_resources
|
63
|
+
request :get_compute_resource
|
61
64
|
request :list_templates
|
62
65
|
request :get_template
|
63
66
|
request :get_folder
|
@@ -3,24 +3,33 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def cloudinit_to_customspec(user_data)
|
6
|
-
raise ArgumentError, "user_data
|
7
|
-
custom_spec = Hash.new
|
6
|
+
raise ArgumentError, "user_data can't be nil" if user_data.nil?
|
7
|
+
custom_spec = { 'customization_spec' => Hash.new }
|
8
8
|
user_data = YAML.load(user_data)
|
9
|
-
custom_spec['hostname']
|
10
|
-
custom_spec['ipsettings']
|
11
|
-
custom_spec['ipsettings']['subnetMask']
|
12
|
-
custom_spec['
|
13
|
-
custom_spec['
|
14
|
-
custom_spec['dnsSuffixList']
|
15
|
-
custom_spec['time_zone']
|
9
|
+
custom_spec['hostname'] = user_data['hostname'] if user_data.key?('hostname')
|
10
|
+
custom_spec['ipsettings'] = { 'ip' => user_data['ip'] } if user_data.key?('ip')
|
11
|
+
custom_spec['ipsettings']['subnetMask'] = user_data['netmask'] if user_data.key?('netmask')
|
12
|
+
custom_spec['ipsettings']['dnsServerList'] = user_data['dns'] if user_data.key?('dns')
|
13
|
+
custom_spec['domain'] = user_data['domain'] if user_data.key?('domain')
|
14
|
+
custom_spec['dnsSuffixList'] = user_data['domain'] if user_data.key?('domain')
|
15
|
+
custom_spec['time_zone'] = user_data['timezone'] if user_data.key?('timezone')
|
16
16
|
custom_spec
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class Mock
|
21
21
|
def cloudinit_to_customspec(user_data)
|
22
|
-
raise ArgumentError, "user_data
|
23
|
-
|
22
|
+
raise ArgumentError, "user_data can't be nil" if user_data.nil?
|
23
|
+
custom_spec = { 'customization_spec' => Hash.new }
|
24
|
+
user_data = YAML.load(user_data)
|
25
|
+
custom_spec['hostname'] = user_data['hostname'] if user_data.key?('hostname')
|
26
|
+
custom_spec['ipsettings'] = { 'ip' => user_data['ip'] } if user_data.key?('ip')
|
27
|
+
custom_spec['ipsettings']['subnetMask'] = user_data['netmask'] if user_data.key?('netmask')
|
28
|
+
custom_spec['ipsettings']['dnsServerList'] = user_data['dns'] if user_data.key?('dns')
|
29
|
+
custom_spec['domain'] = user_data['domain'] if user_data.key?('domain')
|
30
|
+
custom_spec['dnsSuffixList'] = user_data['domain'] if user_data.key?('domain')
|
31
|
+
custom_spec['time_zone'] = user_data['timezone'] if user_data.key?('timezone')
|
32
|
+
custom_spec
|
24
33
|
end
|
25
34
|
end
|
26
35
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Vsphere
|
4
|
+
class Real
|
5
|
+
def get_compute_resource(name, datacenter_name)
|
6
|
+
compute_resource = get_raw_compute_resource(name, datacenter_name)
|
7
|
+
raise(Fog::Compute::Vsphere::NotFound) unless compute_resource
|
8
|
+
compute_resource_attributes(compute_resource, datacenter_name)
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def get_raw_compute_resource(name, datacenter_name)
|
14
|
+
find_raw_datacenter(datacenter_name).find_compute_resource(name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def get_compute_resource(name, datacenter_name)
|
20
|
+
{
|
21
|
+
:id=>"domain-s7",
|
22
|
+
:name=>"fake-host",
|
23
|
+
:totalCpu=>33504,
|
24
|
+
:totalMemory=>154604142592,
|
25
|
+
:numCpuCores=>12,
|
26
|
+
:numCpuThreads=>24,
|
27
|
+
:effectiveCpu=>32247,
|
28
|
+
:effectiveMemory=>135733,
|
29
|
+
:numHosts=>1,
|
30
|
+
:numEffectiveHosts=>1,
|
31
|
+
:overallStatus=>"gray",
|
32
|
+
:overallCpuUsage=>15682,
|
33
|
+
:overallMemoryUsage=>132755,
|
34
|
+
:effective=>true,
|
35
|
+
:isSingleHost=>true
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -10,15 +10,44 @@ module Fog
|
|
10
10
|
|
11
11
|
protected
|
12
12
|
|
13
|
-
def get_raw_network(name, datacenter_name,
|
13
|
+
def get_raw_network(name, datacenter_name, distributedswitch=nil)
|
14
|
+
finder = choose_finder(name, distributedswitch)
|
15
|
+
networks = get_all_raw_networks(datacenter_name)
|
16
|
+
networks.find { |n| finder.call(n) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Shared
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def get_all_raw_networks(datacenter_name)
|
14
25
|
dc = find_raw_datacenter(datacenter_name)
|
26
|
+
@connection.serviceContent.viewManager.
|
27
|
+
CreateContainerView({
|
28
|
+
:container => dc.networkFolder,
|
29
|
+
:type => ["Network"],
|
30
|
+
:recursive => true
|
31
|
+
}).view
|
32
|
+
end
|
15
33
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
34
|
+
def choose_finder(name, distributedswitch)
|
35
|
+
case distributedswitch
|
36
|
+
when String
|
37
|
+
# only the one will do
|
38
|
+
Proc.new { |n| (n.name == name) &&
|
39
|
+
(n.class.to_s == "DistributedVirtualPortgroup") &&
|
40
|
+
(n.config.distributedVirtualSwitch.name == distributedswitch)
|
41
|
+
}
|
42
|
+
when :dvs
|
43
|
+
# the first distributed virtual switch will do - selected by network - gives control to vsphere
|
44
|
+
Proc.new { |n| (n.name == name) && (n.class.to_s == "DistributedVirtualPortgroup") }
|
45
|
+
else
|
46
|
+
# the first matching network will do, seems like the non-distributed networks come first
|
47
|
+
Proc.new { |n| (n.name == name) }
|
48
|
+
end
|
21
49
|
end
|
50
|
+
|
22
51
|
end
|
23
52
|
|
24
53
|
class Mock
|
@@ -13,7 +13,7 @@ module Fog
|
|
13
13
|
def get_raw_resource_pool(name, cluster_name, datacenter_name)
|
14
14
|
dc = find_raw_datacenter(datacenter_name)
|
15
15
|
cluster = dc.find_compute_resource(cluster_name)
|
16
|
-
cluster.resourcePool.find name
|
16
|
+
name.nil? ? cluster.resourcePool : cluster.resourcePool.find( name)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -3,6 +3,7 @@ module Fog
|
|
3
3
|
class Vsphere
|
4
4
|
class Real
|
5
5
|
def get_virtual_machine(id, datacenter_name = nil)
|
6
|
+
# The larger the VM list the longer it will take if not searching based on UUID.
|
6
7
|
convert_vm_mob_ref_to_attr_hash(get_vm_ref(id, datacenter_name))
|
7
8
|
end
|
8
9
|
|
@@ -11,21 +12,26 @@ module Fog
|
|
11
12
|
def get_vm_ref(id, dc = nil)
|
12
13
|
raw_datacenter = find_raw_datacenter(dc) if dc
|
13
14
|
vm = case is_uuid?(id)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
# UUID based
|
16
|
+
when true
|
17
|
+
params = {:uuid => id, :vmSearch => true, :instanceUuid => true}
|
18
|
+
params[:datacenter] = raw_datacenter if dc
|
19
|
+
@connection.searchIndex.FindByUuid(params)
|
20
|
+
else
|
21
|
+
# try to find based on VM name
|
22
|
+
if dc
|
23
|
+
get_vm_by_name(id, dc)
|
24
|
+
else
|
25
|
+
raw_datacenters.map { |d| get_vm_by_name(id, d["name"])}.compact.first
|
26
|
+
end
|
27
|
+
end
|
27
28
|
vm ? vm : raise(Fog::Compute::Vsphere::NotFound, "#{id} was not found")
|
28
29
|
end
|
30
|
+
|
31
|
+
def get_vm_by_name(name, dc)
|
32
|
+
vms = raw_list_all_virtual_machines(dc)
|
33
|
+
vms.keep_if { |v| v["name"] == name }.first
|
34
|
+
end
|
29
35
|
end
|
30
36
|
|
31
37
|
class Mock
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Vsphere
|
4
|
+
class Real
|
5
|
+
def list_compute_resources(filters = { })
|
6
|
+
datacenter_name = filters[:datacenter]
|
7
|
+
# default to show all compute_resources
|
8
|
+
only_active = filters[:effective] || false
|
9
|
+
compute_resources = raw_compute_resources datacenter_name
|
10
|
+
|
11
|
+
compute_resources.map do |compute_resource|
|
12
|
+
summary = compute_resource.summary
|
13
|
+
next if only_active and summary.numEffectiveHosts == 0
|
14
|
+
compute_resource_attributes(compute_resource, datacenter_name)
|
15
|
+
end.compact
|
16
|
+
end
|
17
|
+
|
18
|
+
def raw_compute_resources(datacenter_name)
|
19
|
+
find_raw_datacenter(datacenter_name).find_compute_resource('').children
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def compute_resource_attributes compute_resource, datacenter
|
25
|
+
overall_usage = compute_resource.host.inject({:overallCpuUsage=>0, :overallMemoryUsage=>0}) do |sum, host|
|
26
|
+
{
|
27
|
+
:overallCpuUsage => sum[:overallCpuUsage]+(host.summary.quickStats.overallCpuUsage || 0),
|
28
|
+
:overallMemoryUsage=> sum[:overallMemoryUsage]+(host.summary.quickStats.overallMemoryUsage || 0)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
{
|
32
|
+
:id => managed_obj_id(compute_resource),
|
33
|
+
:name => compute_resource.name,
|
34
|
+
:totalCpu => compute_resource.summary.totalCpu,
|
35
|
+
:totalMemory => compute_resource.summary.totalMemory,
|
36
|
+
:numCpuCores => compute_resource.summary.numCpuCores,
|
37
|
+
:numCpuThreads => compute_resource.summary.numCpuThreads,
|
38
|
+
:effectiveCpu => compute_resource.summary.effectiveCpu,
|
39
|
+
:effectiveMemory => compute_resource.summary.effectiveMemory,
|
40
|
+
:numHosts => compute_resource.summary.numHosts,
|
41
|
+
:numEffectiveHosts => compute_resource.summary.numEffectiveHosts,
|
42
|
+
:overallStatus => compute_resource.summary.overallStatus,
|
43
|
+
:overallCpuUsage => overall_usage[:overallCpuUsage],
|
44
|
+
:overallMemoryUsage => overall_usage[:overallMemoryUsage],
|
45
|
+
:effective => compute_resource.summary.numEffectiveHosts > 0,
|
46
|
+
:isSingleHost => compute_resource.summary.numHosts == 1
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
class Mock
|
52
|
+
def list_compute_resources(filters = { })
|
53
|
+
[
|
54
|
+
{
|
55
|
+
:id=>"domain-s7",
|
56
|
+
:name=>"fake-host",
|
57
|
+
:totalCpu=>33504,
|
58
|
+
:totalMemory=>154604142592,
|
59
|
+
:numCpuCores=>12,
|
60
|
+
:numCpuThreads=>24,
|
61
|
+
:effectiveCpu=>32247,
|
62
|
+
:effectiveMemory=>135733,
|
63
|
+
:numHosts=>1,
|
64
|
+
:numEffectiveHosts=>1,
|
65
|
+
:overallStatus=>"gray",
|
66
|
+
:overallCpuUsage=>15682,
|
67
|
+
:overallMemoryUsage=>132755,
|
68
|
+
:effective=>true,
|
69
|
+
:isSingleHost=>true
|
70
|
+
}, {
|
71
|
+
:id=>"domain-s74",
|
72
|
+
:name=>"fake-cluster",
|
73
|
+
:totalCpu=>41484,
|
74
|
+
:totalMemory=>51525996544,
|
75
|
+
:numCpuCores=>12,
|
76
|
+
:numCpuThreads=>24,
|
77
|
+
:effectiveCpu=>37796,
|
78
|
+
:effectiveMemory=>45115,
|
79
|
+
:numHosts=>2,
|
80
|
+
:numEffectiveHosts=>2,
|
81
|
+
:overallStatus=>"gray",
|
82
|
+
:overallCpuUsage=>584,
|
83
|
+
:overallMemoryUsage=>26422,
|
84
|
+
:effective=>true,
|
85
|
+
:isSingleHost=>false
|
86
|
+
}
|
87
|
+
]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -17,6 +17,7 @@ module Fog
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
|
20
21
|
private
|
21
22
|
|
22
23
|
def list_all_virtual_machines_in_folder(path, datacenter_name)
|
@@ -29,23 +30,27 @@ module Fog
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def list_all_virtual_machines(options = { })
|
32
|
-
|
33
|
-
|
34
|
-
vms = datacenters.map do |dc|
|
35
|
-
@connection.serviceContent.viewManager.CreateContainerView({
|
36
|
-
:container => dc.vmFolder,
|
37
|
-
:type => ["VirtualMachine"],
|
38
|
-
:recursive => true
|
39
|
-
}).view
|
40
|
-
end.flatten
|
41
|
-
|
42
|
-
vms = convert_vm_view_to_attr_hash(vms)
|
33
|
+
raw_vms = raw_list_all_virtual_machines(options[:datacenter])
|
34
|
+
vms = convert_vm_view_to_attr_hash(raw_vms)
|
43
35
|
|
44
36
|
# remove all template based virtual machines
|
45
37
|
vms.delete_if { |v| v['template'] }
|
46
38
|
vms
|
47
39
|
end
|
48
40
|
|
41
|
+
def raw_list_all_virtual_machines(datacenter_name = nil)
|
42
|
+
## Moved this to its own function since trying to get a list of all virtual machines
|
43
|
+
## to parse for a find function took way too long. The raw list returned will make it
|
44
|
+
## much faster to interact for some functions.
|
45
|
+
datacenters = find_datacenters(datacenter_name)
|
46
|
+
datacenters.map do |dc|
|
47
|
+
@connection.serviceContent.viewManager.CreateContainerView({
|
48
|
+
:container => dc.vmFolder,
|
49
|
+
:type => ["VirtualMachine"],
|
50
|
+
:recursive => true
|
51
|
+
}).view
|
52
|
+
end.flatten
|
53
|
+
end
|
49
54
|
def get_folder_path(folder, root = nil)
|
50
55
|
if (not folder.methods.include?('parent')) or (folder == root)
|
51
56
|
return
|