ruby_vcloud_sdk 0.4.8 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +296 -0
- data/lib/ruby_vcloud_sdk.rb +0 -4
- data/lib/ruby_vcloud_sdk/catalog.rb +377 -0
- data/lib/ruby_vcloud_sdk/catalog_item.rb +26 -0
- data/lib/ruby_vcloud_sdk/client.rb +25 -882
- data/lib/ruby_vcloud_sdk/config.rb +1 -7
- data/lib/ruby_vcloud_sdk/connection/connection.rb +114 -54
- data/lib/ruby_vcloud_sdk/cpu.rb +11 -0
- data/lib/ruby_vcloud_sdk/disk.rb +55 -0
- data/lib/ruby_vcloud_sdk/edge_gateway.rb +32 -0
- data/lib/ruby_vcloud_sdk/infrastructure.rb +135 -0
- data/lib/ruby_vcloud_sdk/ip_ranges.rb +95 -0
- data/lib/ruby_vcloud_sdk/memory.rb +11 -0
- data/lib/ruby_vcloud_sdk/network.rb +32 -0
- data/lib/ruby_vcloud_sdk/powerable.rb +78 -0
- data/lib/ruby_vcloud_sdk/resources.rb +13 -0
- data/lib/ruby_vcloud_sdk/session.rb +46 -0
- data/lib/ruby_vcloud_sdk/vapp.rb +122 -0
- data/lib/ruby_vcloud_sdk/vdc.rb +210 -0
- data/lib/ruby_vcloud_sdk/vdc_storage_profile.rb +23 -0
- data/lib/ruby_vcloud_sdk/version.rb +1 -1
- data/lib/ruby_vcloud_sdk/vm.rb +132 -0
- data/lib/ruby_vcloud_sdk/xml/constants.rb +6 -4
- data/lib/ruby_vcloud_sdk/xml/wrapper.rb +109 -30
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes.rb +45 -2
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/admin_catalog.rb +13 -4
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/allocated_ip_addresses.rb +9 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/catalog_item.rb +6 -14
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/disk.rb +24 -14
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/disk_attach_or_detach_params.rb +0 -2
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/disk_create_params.rb +1 -3
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/edge_gateway.rb +13 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/gateway_interface.rb +22 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/hard_disk_item_wrapper.rb +4 -4
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/ip_address.rb +10 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/ip_range.rb +13 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/ip_ranges.rb +9 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/ip_scope.rb +6 -32
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/item.rb +1 -7
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/link.rb +14 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/media.rb +4 -20
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/media_insert_or_eject_params.rb +1 -3
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb +0 -4
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb +0 -2
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/org.rb +44 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/org_vdc_network.rb +11 -3
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/query_result_records.rb +14 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/recompose_vapp_params.rb +42 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/session.rb +5 -5
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/supported_versions.rb +19 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/task.rb +1 -1
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/upload_vapp_template_params.rb +2 -4
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vapp.rb +13 -22
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vapp_template.rb +0 -2
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vcloud.rb +5 -3
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb +72 -15
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb +8 -6
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vm.rb +29 -25
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vms.rb +12 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminCatalog.xml +6 -1
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RecomposeVAppParams.xml +16 -1
- metadata +116 -233
- data/README +0 -1
- data/Rakefile +0 -50
- data/lib/ruby_vcloud_sdk/util.rb +0 -21
- data/spec/assets/admin_org_response.xml +0 -75
- data/spec/assets/catalog_add_item_response.xml +0 -8
- data/spec/assets/catalog_add_vapp_request.xml +0 -5
- data/spec/assets/catalog_item_added_response.xml +0 -19
- data/spec/assets/catalog_response.xml +0 -19
- data/spec/assets/existing_media_busy_response.xml +0 -19
- data/spec/assets/existing_media_catalog_item.xml +0 -8
- data/spec/assets/existing_media_delete_task_done.xml +0 -6
- data/spec/assets/existing_media_done_response.xml +0 -11
- data/spec/assets/existing_vapp_resolver_response.xml +0 -3
- data/spec/assets/existing_vapp_template_catalog_resolver_response.xml +0 -3
- data/spec/assets/existing_vapp_template_instantiate_response.xml +0 -20
- data/spec/assets/existing_vapp_template_instantiate_task_error_response.xml +0 -7
- data/spec/assets/existing_vapp_template_instantiate_task_start_response.xml +0 -7
- data/spec/assets/existing_vapp_template_instantiate_task_success_response.xml +0 -7
- data/spec/assets/existing_vapp_template_item_response.xml +0 -8
- data/spec/assets/existing_vapp_template_ready_response.xml +0 -79
- data/spec/assets/finalize_upload_task_done_response.xml +0 -7
- data/spec/assets/finalize_upload_task_response.xml +0 -7
- data/spec/assets/indy_disk_attach_request.xml +0 -3
- data/spec/assets/indy_disk_attach_task.xml +0 -6
- data/spec/assets/indy_disk_attach_task_error.xml +0 -6
- data/spec/assets/indy_disk_create_error.xml +0 -1
- data/spec/assets/indy_disk_create_request.xml +0 -4
- data/spec/assets/indy_disk_create_response.xml +0 -19
- data/spec/assets/indy_disk_delete_task.xml +0 -6
- data/spec/assets/indy_disk_detach_request.xml +0 -3
- data/spec/assets/indy_disk_detach_task.xml +0 -6
- data/spec/assets/indy_disk_response.xml +0 -11
- data/spec/assets/instantiated_suspended_vapp_response.xml +0 -209
- data/spec/assets/instantiated_vapp_delelete_done_task.xml +0 -5
- data/spec/assets/instantiated_vapp_delelete_running_task.xml +0 -6
- data/spec/assets/instantiated_vapp_network_config_add_network_request.xml +0 -36
- data/spec/assets/instantiated_vapp_network_config_modify_network_task_success.xml +0 -6
- data/spec/assets/instantiated_vapp_network_config_remove_network_request.xml +0 -6
- data/spec/assets/instantiated_vapp_network_config_section_response.xml +0 -17
- data/spec/assets/instantiated_vapp_off_response.xml +0 -206
- data/spec/assets/instantiated_vapp_on_response.xml +0 -205
- data/spec/assets/instantiated_vapp_power_task_running.xml +0 -6
- data/spec/assets/instantiated_vapp_power_task_success.xml +0 -6
- data/spec/assets/instantiated_vapp_response.xml +0 -205
- data/spec/assets/instantiated_vm_change_task_running.xml +0 -6
- data/spec/assets/instantiated_vm_change_task_success.xml +0 -6
- data/spec/assets/instantiated_vm_cpu_response.xml +0 -11
- data/spec/assets/instantiated_vm_insert_media_task_done.xml +0 -6
- data/spec/assets/instantiated_vm_memory_response.xml +0 -11
- data/spec/assets/instantiated_vm_modify_task_running.xml +0 -6
- data/spec/assets/instantiated_vm_modify_task_success.xml +0 -5
- data/spec/assets/instantiated_vm_network_section_response.xml +0 -11
- data/spec/assets/instantiated_vm_response.xml +0 -149
- data/spec/assets/media_add_to_catalog_request.xml +0 -5
- data/spec/assets/media_add_to_catalog_response.xml +0 -8
- data/spec/assets/media_delete_task_done.xml +0 -6
- data/spec/assets/media_upload_pending_response.xml +0 -13
- data/spec/assets/media_upload_request.xml +0 -2
- data/spec/assets/metadata_set_request.xml +0 -3
- data/spec/assets/metadata_set_task_done.xml +0 -6
- data/spec/assets/org_network_response.xml +0 -22
- data/spec/assets/reconfigure_vm_request.xml +0 -133
- data/spec/assets/reconfigure_vm_task.xml +0 -8
- data/spec/assets/session.xml +0 -7
- data/spec/assets/test-config.yml +0 -38
- data/spec/assets/undeploy_params.xml +0 -1
- data/spec/assets/vapp_template_catalog_resolver_response.xml +0 -3
- data/spec/assets/vapp_template_delelete_done_task.xml +0 -5
- data/spec/assets/vapp_template_delelete_running_task.xml +0 -6
- data/spec/assets/vapp_template_instantiate_request.xml +0 -8
- data/spec/assets/vapp_template_instantiate_with_locality_request.xml +0 -14
- data/spec/assets/vapp_template_no_disk_response.xml +0 -27
- data/spec/assets/vapp_template_ready_response.xml +0 -79
- data/spec/assets/vapp_template_upload_complete.xml +0 -28
- data/spec/assets/vapp_template_upload_failed.xml +0 -28
- data/spec/assets/vapp_template_upload_request.xml +0 -4
- data/spec/assets/vapp_template_upload_response.xml +0 -25
- data/spec/assets/vcloud_response.xml +0 -56
- data/spec/assets/vdc_response.xml +0 -57
- data/spec/spec_helper.rb +0 -107
- data/spec/unit/client_response.rb +0 -700
- data/spec/unit/client_spec.rb +0 -1152
@@ -1,6 +1,5 @@
|
|
1
1
|
module VCloudSdk
|
2
2
|
module Xml
|
3
|
-
|
4
3
|
class MediaInsertOrEjectParams < Wrapper
|
5
4
|
def media_href=(value)
|
6
5
|
media["href"] = value
|
@@ -9,9 +8,8 @@ module VCloudSdk
|
|
9
8
|
private
|
10
9
|
|
11
10
|
def media
|
12
|
-
|
11
|
+
get_nodes("Media", nil, true).first
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
15
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module VCloudSdk
|
2
|
+
module Xml
|
3
|
+
class Org < Wrapper
|
4
|
+
def vdc_link(name)
|
5
|
+
get_nodes(XML_TYPE[:LINK],
|
6
|
+
{ type: MEDIA_TYPE[:VDC],
|
7
|
+
name: name },
|
8
|
+
true).first
|
9
|
+
end
|
10
|
+
|
11
|
+
def catalogs
|
12
|
+
get_nodes(XML_TYPE[:LINK],
|
13
|
+
{ type: MEDIA_TYPE[:CATALOG] },
|
14
|
+
true)
|
15
|
+
end
|
16
|
+
|
17
|
+
def catalog_link(name)
|
18
|
+
get_nodes(XML_TYPE[:LINK],
|
19
|
+
{ type: MEDIA_TYPE[:CATALOG],
|
20
|
+
name: name },
|
21
|
+
true).first
|
22
|
+
end
|
23
|
+
|
24
|
+
def networks
|
25
|
+
get_nodes(XML_TYPE[:LINK],
|
26
|
+
{ type: MEDIA_TYPE[:ORG_NETWORK] },
|
27
|
+
true)
|
28
|
+
end
|
29
|
+
|
30
|
+
def network(name)
|
31
|
+
get_nodes(XML_TYPE[:LINK],
|
32
|
+
{ type: MEDIA_TYPE[:ORG_NETWORK],
|
33
|
+
name: name },
|
34
|
+
true).first
|
35
|
+
end
|
36
|
+
|
37
|
+
def disks
|
38
|
+
get_nodes(XML_TYPE[:LINK],
|
39
|
+
{ type: MEDIA_TYPE[:DISK] },
|
40
|
+
true)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,11 +1,19 @@
|
|
1
1
|
module VCloudSdk
|
2
2
|
module Xml
|
3
|
-
|
4
3
|
class OrgVdcNetwork < Wrapper
|
5
4
|
def ip_scope
|
6
|
-
get_nodes(
|
5
|
+
get_nodes(:IpScope).first
|
6
|
+
end
|
7
|
+
|
8
|
+
def ip_ranges
|
9
|
+
get_nodes(:IpRanges).first
|
7
10
|
end
|
8
|
-
end
|
9
11
|
|
12
|
+
def allocated_addresses_link
|
13
|
+
get_nodes(XML_TYPE[:LINK],
|
14
|
+
{ type: MEDIA_TYPE[:ALLOCATED_NETWORK_IPS] },
|
15
|
+
true).first
|
16
|
+
end
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module VCloudSdk
|
2
|
+
module Xml
|
3
|
+
class QueryResultRecords < Wrapper
|
4
|
+
# Reference: http://pubs.vmware.com/vcd-55/index.jsp?topic=%2Fcom.vmware.vcloud.api.reference.doc_55%2Fdoc%2Ftypes%2FQueryResultOrgVdcStorageProfileRecordType.html
|
5
|
+
def org_vdc_storage_profile_records
|
6
|
+
get_nodes("OrgVdcStorageProfileRecord")
|
7
|
+
end
|
8
|
+
|
9
|
+
def edge_gateway_records
|
10
|
+
get_nodes("EdgeGatewayRecord")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module VCloudSdk
|
2
|
+
module Xml
|
3
|
+
class RecomposeVAppParams < Wrapper
|
4
|
+
def description
|
5
|
+
get_nodes("Description").first
|
6
|
+
end
|
7
|
+
|
8
|
+
def description=(desc)
|
9
|
+
description.content = desc
|
10
|
+
end
|
11
|
+
|
12
|
+
def all_eulas_accepted=(value)
|
13
|
+
eulas_node = get_nodes("AllEULAsAccepted").first
|
14
|
+
eulas_node.content = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_source_item(entity_to_add_href)
|
18
|
+
return unless entity_to_add_href
|
19
|
+
|
20
|
+
node_sourced_item = create_child("SourcedItem",
|
21
|
+
namespace.prefix,
|
22
|
+
namespace.href)
|
23
|
+
node_source = add_child("Source",
|
24
|
+
namespace.prefix,
|
25
|
+
namespace.href,
|
26
|
+
node_sourced_item)
|
27
|
+
node_source["href"] = entity_to_add_href
|
28
|
+
|
29
|
+
get_nodes("AllEULAsAccepted").first.node.before(node_sourced_item)
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_delete_item(entity_to_delete_href)
|
33
|
+
return unless entity_to_delete_href
|
34
|
+
|
35
|
+
node_delete_item = create_child("DeleteItem")
|
36
|
+
node_delete_item["href"] = entity_to_delete_href
|
37
|
+
|
38
|
+
get_nodes("AllEULAsAccepted").first.node.after(node_delete_item)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -2,14 +2,14 @@ module VCloudSdk
|
|
2
2
|
module Xml
|
3
3
|
|
4
4
|
class Session < Wrapper
|
5
|
-
def
|
6
|
-
get_nodes(
|
7
|
-
|
5
|
+
def organization
|
6
|
+
get_nodes(XML_TYPE[:LINK],
|
7
|
+
{ type: VCloudSdk::Xml::MEDIA_TYPE[:ORGANIZATION] }).first
|
8
8
|
end
|
9
9
|
|
10
10
|
def entity_resolver
|
11
|
-
get_nodes(
|
12
|
-
|
11
|
+
get_nodes(XML_TYPE[:LINK],
|
12
|
+
{ type: VCloudSdk::Xml::MEDIA_TYPE[:ENTITY] }).first
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VCloudSdk
|
2
|
+
module Xml
|
3
|
+
|
4
|
+
class SupportedVersions < Wrapper
|
5
|
+
def login_url
|
6
|
+
ns = namespace.href # Typically it's 'http://www.vmware.com/vcloud/versions'
|
7
|
+
get_nodes('VersionInfo', nil, false, ns).each do |node|
|
8
|
+
if node.get_nodes('Version', nil, false, ns).first.content \
|
9
|
+
== VCloudSdk::Client::VCLOUD_VERSION_NUMBER
|
10
|
+
return node.get_nodes("LoginUrl", nil, false, ns).first
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module VCloudSdk
|
2
2
|
module Xml
|
3
|
-
|
4
3
|
class VApp < Wrapper
|
5
4
|
def description
|
6
5
|
get_nodes("Description").first.content
|
@@ -10,36 +9,28 @@ module VCloudSdk
|
|
10
9
|
get_nodes("NetworkConfigSection").first
|
11
10
|
end
|
12
11
|
|
13
|
-
def power_on_link
|
14
|
-
get_nodes("Link", {"rel" => "power:powerOn"}, true).first
|
15
|
-
end
|
16
|
-
|
17
|
-
def power_off_link
|
18
|
-
get_nodes("Link", {"rel" => "power:powerOff"}, true).first
|
19
|
-
end
|
20
|
-
|
21
12
|
def reboot_link
|
22
13
|
get_nodes("Link", {"rel" => "power:reboot"}, true).first
|
23
14
|
end
|
24
15
|
|
25
|
-
def
|
26
|
-
get_nodes(
|
27
|
-
end
|
28
|
-
|
29
|
-
def running_tasks
|
30
|
-
get_nodes("Task", {"status" => "running"})
|
16
|
+
def tasks
|
17
|
+
get_nodes(XML_TYPE[:TASK])
|
31
18
|
end
|
32
19
|
|
33
|
-
def
|
34
|
-
get_nodes("
|
20
|
+
def discard_state
|
21
|
+
get_nodes("Link", {"rel" => "discardState"}, true).first
|
35
22
|
end
|
36
23
|
|
37
|
-
def
|
38
|
-
get_nodes(
|
24
|
+
def recompose_vapp_link
|
25
|
+
link = get_nodes(XML_TYPE[:LINK],
|
26
|
+
{ rel: "recompose" },
|
27
|
+
true).first
|
39
28
|
end
|
40
29
|
|
41
|
-
def
|
42
|
-
get_nodes(
|
30
|
+
def vdc_link
|
31
|
+
get_nodes(XML_TYPE[:LINK],
|
32
|
+
{ type: MEDIA_TYPE[:VDC] },
|
33
|
+
true).first
|
43
34
|
end
|
44
35
|
|
45
36
|
def vms
|
@@ -47,7 +38,7 @@ module VCloudSdk
|
|
47
38
|
end
|
48
39
|
|
49
40
|
def vm(name)
|
50
|
-
get_nodes("Vm",
|
41
|
+
get_nodes("Vm", name: name).first
|
51
42
|
end
|
52
43
|
end
|
53
44
|
|
@@ -3,11 +3,13 @@ module VCloudSdk
|
|
3
3
|
|
4
4
|
class VCloud < Wrapper
|
5
5
|
def organizations
|
6
|
-
get_nodes(
|
6
|
+
get_nodes('OrganizationReference')
|
7
7
|
end
|
8
8
|
|
9
|
-
def organization
|
10
|
-
|
9
|
+
def organization
|
10
|
+
# TODO: check and make sure that
|
11
|
+
# there is only one "OrganizationReference" node in response
|
12
|
+
get_nodes('OrganizationReference').first
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -1,54 +1,111 @@
|
|
1
1
|
module VCloudSdk
|
2
2
|
module Xml
|
3
|
-
|
4
3
|
class Vdc < Wrapper
|
5
4
|
def add_disk_link
|
6
|
-
|
5
|
+
get_nodes(XML_TYPE[:LINK],
|
6
|
+
type: MEDIA_TYPE[:DISK_CREATE_PARAMS])
|
7
|
+
.first
|
7
8
|
end
|
8
9
|
|
9
10
|
def disks(name = nil)
|
10
11
|
if name.nil?
|
11
|
-
get_nodes("ResourceEntity",
|
12
|
+
get_nodes("ResourceEntity",
|
13
|
+
type: MEDIA_TYPE[:DISK])
|
12
14
|
else
|
13
15
|
get_nodes("ResourceEntity",
|
14
|
-
|
16
|
+
type: MEDIA_TYPE[:DISK], name: name)
|
17
|
+
.first
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def instantiate_vapp_template_link
|
19
|
-
get_nodes(
|
20
|
-
|
22
|
+
get_nodes(XML_TYPE[:LINK],
|
23
|
+
type: MEDIA_TYPE[:INSTANTIATE_VAPP_TEMPLATE_PARAMS])
|
24
|
+
.first
|
21
25
|
end
|
22
26
|
|
23
27
|
def upload_link
|
24
|
-
get_nodes(
|
25
|
-
|
28
|
+
get_nodes(XML_TYPE[:LINK],
|
29
|
+
type: MEDIA_TYPE[:UPLOAD_VAPP_TEMPLATE_PARAMS])
|
30
|
+
.first
|
26
31
|
end
|
27
32
|
|
28
33
|
def upload_media_link
|
29
|
-
get_nodes(
|
34
|
+
get_nodes(XML_TYPE[:LINK],
|
35
|
+
type: MEDIA_TYPE[:MEDIA])
|
36
|
+
.first
|
37
|
+
end
|
38
|
+
|
39
|
+
def vapps
|
40
|
+
get_nodes(:ResourceEntity, type: MEDIA_TYPE[:VAPP])
|
41
|
+
end
|
42
|
+
|
43
|
+
def edge_gateways_link
|
44
|
+
get_nodes(XML_TYPE[:LINK],
|
45
|
+
rel: "edgeGateways")
|
46
|
+
.first
|
30
47
|
end
|
31
48
|
|
32
49
|
# vApp Template names are not unique so multiple ones can be returned.
|
33
50
|
def get_vapp_templates(name)
|
34
51
|
get_nodes("ResourceEntity",
|
35
|
-
|
52
|
+
type: MEDIA_TYPE[:VAPP_TEMPLATE], name: name)
|
36
53
|
end
|
37
54
|
|
38
55
|
def available_networks
|
39
|
-
get_nodes("Network",
|
56
|
+
get_nodes("Network",
|
57
|
+
type: MEDIA_TYPE[:NETWORK])
|
40
58
|
end
|
41
59
|
|
42
60
|
def available_network(name)
|
43
61
|
get_nodes("Network",
|
44
|
-
|
62
|
+
type: MEDIA_TYPE[:NETWORK], name: name)
|
63
|
+
.first
|
45
64
|
end
|
46
65
|
|
47
66
|
def storage_profiles
|
48
|
-
get_nodes(
|
49
|
-
{"type"=>MEDIA_TYPE[:VDC_STORAGE_PROFILE]})
|
67
|
+
get_nodes(:VdcStorageProfile, type: MEDIA_TYPE[:VDC_STORAGE_PROFILE])
|
50
68
|
end
|
51
|
-
end
|
52
69
|
|
70
|
+
def storage_profile(name)
|
71
|
+
get_nodes(:VdcStorageProfile,
|
72
|
+
type: MEDIA_TYPE[:VDC_STORAGE_PROFILE], name: name)
|
73
|
+
.first
|
74
|
+
end
|
75
|
+
|
76
|
+
def available_cpu_cores
|
77
|
+
cpu_resource = get_nodes("ComputeCapacity")
|
78
|
+
.first.get_nodes("Cpu").first
|
79
|
+
available_cpu_clock_speed = get_available_resource(cpu_resource)
|
80
|
+
|
81
|
+
# clock units can only be MHz or GHz
|
82
|
+
units = cpu_resource.get_nodes("Units").first.content
|
83
|
+
if units == "MHz"
|
84
|
+
available_cpu_clock_speed = available_cpu_clock_speed / 1000
|
85
|
+
end
|
86
|
+
|
87
|
+
# We assume 1 GHz is converted to 1 vCpu core
|
88
|
+
available_cpu_clock_speed
|
89
|
+
end
|
90
|
+
|
91
|
+
def available_memory_mb
|
92
|
+
memory_resource = get_nodes("ComputeCapacity")
|
93
|
+
.first.get_nodes("Memory").first
|
94
|
+
available_memory = get_available_resource(memory_resource)
|
95
|
+
|
96
|
+
# clock units can only be MB or GB
|
97
|
+
units = memory_resource.get_nodes("Units").first.content
|
98
|
+
available_memory = available_memory * 1024 if units == "GB"
|
99
|
+
available_memory
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def get_available_resource(resource_node)
|
105
|
+
limited_resource = resource_node.get_nodes("Limit").first.content.to_i
|
106
|
+
return -1 if limited_resource == 0
|
107
|
+
limited_resource - resource_node.get_nodes("Used").first.content.to_i
|
108
|
+
end
|
109
|
+
end
|
53
110
|
end
|
54
111
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module VCloudSdk
|
2
2
|
module Xml
|
3
|
-
|
4
3
|
class VirtualHardwareSection < Wrapper
|
5
4
|
def add_item(item)
|
6
5
|
system_node = get_nodes("System", nil, true, OVF).first
|
@@ -8,8 +7,10 @@ module VCloudSdk
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def edit_link
|
11
|
-
get_nodes(
|
12
|
-
|
10
|
+
get_nodes(XML_TYPE[:LINK],
|
11
|
+
{ rel: XML_TYPE[:EDIT],
|
12
|
+
type: MEDIA_TYPE[:VIRTUAL_HARDWARE_SECTION] },
|
13
|
+
true).first
|
13
14
|
end
|
14
15
|
|
15
16
|
def cpu
|
@@ -54,8 +55,10 @@ module VCloudSdk
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def hard_disks
|
57
|
-
items = hardware.
|
58
|
-
|
58
|
+
items = hardware.select do |h|
|
59
|
+
h.get_rasd_content(
|
60
|
+
RASD_TYPES[:RESOURCE_TYPE]) == HARDWARE_TYPE[:HARD_DISK]
|
61
|
+
end
|
59
62
|
items.map { |i| HardDiskItemWrapper.new(i) }
|
60
63
|
end
|
61
64
|
|
@@ -63,6 +66,5 @@ module VCloudSdk
|
|
63
66
|
get_nodes("Item", nil, false, OVF)
|
64
67
|
end
|
65
68
|
end
|
66
|
-
|
67
69
|
end
|
68
70
|
end
|