Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7584171
snapshots capabilities added
Jun 14, 2016
b4207ba
added more functions
Jun 15, 2016
5611ecb
README changed with new functionalities, modified catalog class
Jun 16, 2016
158d7d2
README modified with objects structure
acolominas Jun 16, 2016
31b9751
README
acolominas Jun 16, 2016
c14bb3b
Update README.md
acolominas Jun 16, 2016
e0f60d4
Update README.md
acolominas Jun 16, 2016
4721d91
Update README.md
acolominas Jun 16, 2016
80ab6df
Update README.md
acolominas Jun 16, 2016
13e5ed7
Update README.md
acolominas Jun 16, 2016
3e90c97
Update README.md
acolominas Jun 16, 2016
7e620c0
Update README.md
acolominas Jun 16, 2016
b12bbe5
Update README.md
acolominas Jun 16, 2016
8619512
Update README.md
acolominas Jun 16, 2016
ec8c85c
Update README.md
acolominas Jun 16, 2016
6737a14
Update README.md
acolominas Jun 16, 2016
5320141
Update README.md
acolominas Jun 16, 2016
2fa4b7b
Update README.md
acolominas Jun 16, 2016
5ba29ba
Update README.md
acolominas Jun 16, 2016
c01028d
Update README.md
acolominas Jun 16, 2016
d4bcf65
Update README.md
acolominas Jun 16, 2016
50c05c8
Update README.md
acolominas Jun 16, 2016
2393d61
Update README.md
acolominas Jun 16, 2016
7445242
README Object Structure
acolominas Jun 16, 2016
75c990b
README
acolominas Jun 16, 2016
a5b8abd
README
acolominas Jun 16, 2016
c2b1a46
afegida documentacio
Jun 21, 2016
7ad13e0
Added shutdown VM/VAPP, find_nic_by_mac
Jun 23, 2016
8776e8c
working in reconfigure
Jun 28, 2016
4fd0d86
Guest customization capability added
Jul 11, 2016
d92b4b0
vm customization added
Jul 12, 2016
524a302
working on gem
Jul 12, 2016
407ba7e
working on edge_gateway
Jul 27, 2016
5a7c226
FirewallCapabilyAdded
CSUC Sep 13, 2016
e6be472
bug fix: Adding multiple NIC
CSUC Sep 27, 2016
87c2a15
Configure NAT rules capability added
acolominas Oct 27, 2016
1f03b36
Added Disk resize capability during instanstiation
CSUC Jan 5, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 125 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
## Ruby VCloud SDK is a gem to simplify making vCloud Director API calls.
#Ruby VCloud SDK

Ruby VCloud SDK is a gem to simplify making vCloud Director API calls.
Copyright (c) VMware, Inc.

## Object Structure



Client |-> VDC |-> Vapp |-> Vm |-> Nic
| | | |
| | | |-> Internal Disk
| | | |
| | | |-> Disk
| | | |
| | | |-> Vapp
| | |
| | |-> Network
| |
| |-> Network |-> IpRanges
| |
| |-> Disk |-> Vm
| |
| |-> Resources
| |
| |-> Edge Gateway |-> IpRanges
| |
| |-> Vdc Storage Profile
|
|-> Catalog |-> Catalog Item |-> Template Vapp |-> Envelope
| |
| |-> OVF Directory
|
|-> RightRecord
|
|-> Session |-> Connection

## Object Model

Client


#### Client
------
find_vdc_by_name
parameters:
name (String): name of VDC
Expand Down Expand Up @@ -55,7 +90,8 @@ Copyright (c) VMware, Inc.
throws:
'RestClient::BadRequest' for un-expected errors

VDC
#### VDC
---

storage_profiles
returns: array of storage profile objects
Expand Down Expand Up @@ -102,6 +138,15 @@ Copyright (c) VMware, Inc.
'ObjectNotFoundError' when vapp with the name does not exist
'RestClient::BadRequest' for un-expected errors

find_vapp_by_id
parameters:
id (String): id of vapp
returns:
vapp object matching id
throws:
'ObjectNotFoundError' when vapp with the id does not exist
'RestClient::BadRequest' for un-expected errors

vapp_exists?
parameters:
name (String): name of vapp
Expand Down Expand Up @@ -202,7 +247,8 @@ Copyright (c) VMware, Inc.
'CloudError' when any disk deletion failure occurs
'RestClient::BadRequest' for un-expected errors

Catalog
#### Catalog
-------

items
returns: array of catalog item objects
Expand Down Expand Up @@ -299,7 +345,8 @@ Copyright (c) VMware, Inc.
'ApiError' when instantiating vapp template task is not successful
'RestClient::BadRequest' for un-expected error

Network
#### Network
-------

ip_ranges
returns: IpRanges object
Expand All @@ -311,7 +358,17 @@ Copyright (c) VMware, Inc.
throws:
'RestClient::BadRequest' for un-expected errors

VApp
#### VApp
----

id
returns: vApp's id

name
returns: vApp's name

status:
returns: vApp's status

delete
returns: nil
Expand All @@ -332,6 +389,15 @@ Copyright (c) VMware, Inc.
'VappSuspendedError' if VApp is suspended
'RestClient::BadRequest' for un-expected errors

reboot
returns: vApp object

reset
returns: vApp object

suspend:
returns: vApp object

recompose_from_vapp_template
parameters:
catalog_name (String): name of catalog
Expand Down Expand Up @@ -403,7 +469,31 @@ Copyright (c) VMware, Inc.
'ObjectNotFoundError' when network with the name does not exist
'RestClient::BadRequest' for un-expected errors

VM
create_snapshot
parameters:
snapshot_hash (Hash): hash with :name and :description
returns: nil
throws:

remove_snapshot
returns: nil
throws:

revert_snapshot
returns: nil
throws:

#### VM
---

id
returns: VM's id

status
returns: VM's status

href
returns: VM's href

vcpu:
returns: number of virtual cpus of VM
Expand Down Expand Up @@ -434,6 +524,9 @@ Copyright (c) VMware, Inc.
'CloudError' when the memory size is less than or equal to 0
'RestClient::BadRequest' for un-expected errors

ip_address
returns: The IP address(es) of the VM

nics
returns: array of NIC objects
throws:
Expand Down Expand Up @@ -479,6 +572,17 @@ Copyright (c) VMware, Inc.
'VmSuspendedError' if VM is suspended
'RestClient::BadRequest' for un-expected errors

reboot
returns: VM object

reset
returns: VM object

suspend:
returns: VM object

undeploy:

insert_media
parameters:
catalog_name (String): name of catalog
Expand Down Expand Up @@ -522,6 +626,9 @@ Copyright (c) VMware, Inc.
'ObjectNotFoundError' if specified nic index does not exist
'RestClient::BadRequest' for un-expected errors

install_vmtools
returns: nil

product_section_properties
returns:
array of hash values representing properties of product section of VM
Expand Down Expand Up @@ -563,14 +670,16 @@ Copyright (c) VMware, Inc.
'ObjectNotFoundError' if no disk matching the given name
'RestClient::BadRequest' for un-expected errors

VdcStorageProfile
#### VdcStorageProfile
-----------------

available_storage
returns:
integer number of available storage in MB, i.e. storageLimitMB - storageUsedMB
-1 if 'storageLimitMB' is 0

EdgeGateway
#### EdgeGateway
-----------

public_ips:
returns: IpRanges object
Expand All @@ -579,19 +688,20 @@ Copyright (c) VMware, Inc.


## Example

VCloud_SDK is straightforward to use. Here is an example of creating vApp from vApp template.

1. Create vCloud client object

client = VCloudSdk::Client.new(url, username, password)
`client = VCloudSdk::Client.new(url, username, password)`

Note that the parameter 'username' should be the VDC user_name@organization_name. For example,
the VDC user name is admin, the organization name is myorg, then the 'username' parameter
the VDC user name is admin, the organization name is myorg, then the 'username' parameter
here should be admin@myorg.
2. Find the catalog where the vapp template is stored
catalog = client.find_catalog_by_name(catalog_name)
`catalog = client.find_catalog_by_name(catalog_name)`

3. Create vApp from that vapp template
vapp = instantiate_vapp_template(vapp_template_name, vdc_name, vapp_name)
`vapp = catalog.instantiate_vapp_template(vapp_template_name, vdc_name, vapp_name)`

31 changes: 25 additions & 6 deletions lib/ruby_vcloud_sdk/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(session, link)
@link = link
end

def name
def name
admin_xml.name
end

Expand Down Expand Up @@ -132,18 +132,34 @@ def upload_vapp_template(
find_vapp_template_by_name(template_name)
end

def find_vapp_template_by_id(uuid)
##CUTRE
link = nil
admin_xml.catalog_items.each do |item_link|
link = item_link if uuid == item_link[:id]
end
fail ObjectNotFoundError, "Catalog Item '#{uuid}' is not found" if link.nil?

item = VCloudSdk::CatalogItem.new(@session, link)
check_item_type(item, Xml::MEDIA_TYPE[:VAPP_TEMPLATE])
item

end

def find_vapp_template_by_name(name)
find_item(name, Xml::MEDIA_TYPE[:VAPP_TEMPLATE])
end

def instantiate_vapp_template(template_name, vdc_name, vapp_name,
description = nil, disk_locality = nil, network_config = nil)
description = nil, disk_locality = nil, network_config = nil, vm_params = nil)

instantiate_vapp_params = create_instantiate_vapp_params(
template_name, vapp_name, description, disk_locality, network_config)
catalog_item = find_vapp_template_by_name(template_name)
vm_link = catalog_item.vapp_template.vm_link

vdc = find_vdc_by_name vdc_name
instantiate_vapp_params = create_instantiate_vapp_params(
template_name, vapp_name, description, disk_locality, network_config,vm_params,vm_link)

vdc = find_vdc_by_name vdc_name
vapp = connection.post(vdc.instantiate_vapp_template_link,
instantiate_vapp_params)
vapp.running_tasks.each do |task|
Expand Down Expand Up @@ -330,7 +346,7 @@ def retrieve_vapp_template_xml_node(template_name)
end

def create_instantiate_vapp_params(template_name,
vapp_name, description, disk_locality, network_config)
vapp_name, description, disk_locality, network_config,vm_params,vm_link)

source_vapp_template = retrieve_vapp_template_xml_node(template_name)

Expand All @@ -346,6 +362,9 @@ def create_instantiate_vapp_params(template_name,
instantiate_vapp_params.linked_clone = false
instantiate_vapp_params.set_locality = locality_spec(
source_vapp_template, disk_locality)

disk = vm_params.first
instantiate_vapp_params.disk_size(disk[:id],disk[:size],vm_link)

instantiate_vapp_params
end
Expand Down
Loading