1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/vcloud_director/README.md

954 lines
27 KiB
Markdown
Raw Normal View History

2013-09-26 06:10:39 -04:00
# VMware vCloud Director 5.1 API client
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
## Introduction
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
Collection and Model representation in vcloud_director fog provider.
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
```no-highlight
organizations
organization
2013-09-26 06:10:39 -04:00
vdcs -> vdc -> vapps -> vapp -> vms -> vm -> customizations -> script
2013-07-10 07:15:40 -04:00
-> network
-> disks -> disk
-> tags -> tag
-> power_on
networks -> network
catalogs -> catalog -> catalog_items -> catalog_item -> instantiate_vapp
medias -> media
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
### Actions
2013-07-10 07:15:40 -04:00
Every collection supports the following methods:
2013-09-26 06:10:39 -04:00
Method Name | Lazy Load
----------------- | ---------
get(id) | false
2013-07-10 07:15:40 -04:00
get_by_name(name) | false
all | true
all(false) | false
2013-09-26 06:10:39 -04:00
### Lazy Loading
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
When listing a collection (eg: `vdc.vapps`), lazy load will be used by default
to improve the performance, otherwise it will make as many requests as items
are in the collection.
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
You can disable lazy load using the explict caller and passing a *false*
option: `vdc.vapps.all(false)`.
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
Attributes showing the value **NonLoaded** will be populated when accessing the
value, if there are more than one **NonLoaded** values the first time accessing
on any of those values will populate the others.
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
You can explicitly load those attributes with the `reload` method:
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
```ruby
2013-07-10 07:15:40 -04:00
org = vcloud.organizations.first
org.reload
```
2013-09-26 06:10:39 -04:00
Lazy load isn't used with `get` and `get_by_name` methods are used.
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
## Initialization
2013-07-10 07:15:40 -04:00
```ruby
2013-09-26 06:10:39 -04:00
vcloud = Fog::Compute::VcloudDirector.new(
:vcloud_director_username => "<username>@<org_name>",
:vcloud_director_password => "<password>",
:vcloud_director_host => 'api.example.com',
:vcloud_director_show_progress => false, # task progress bar on/off
2013-09-26 06:10:39 -04:00
)
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
## Organizations
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### List Organizations
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
Note that when listing, by default only the attributes `id`, `name`, `type`,
and `href` are loaded. To disable lazy loading, and load all attributes, just
specify `false`. Another option is to reload a specific item:
`vcloud.organizations.first.reload`
2013-07-10 07:15:40 -04:00
```ruby
vcloud.organizations
```
```
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Organizations
2013-07-10 07:15:40 -04:00
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Organization
2013-07-10 07:15:40 -04:00
id="c6a4c623-c158-41cf-a87a-dbc1637ad55a",
name="DevOps",
type="application/vnd.vmware.vcloud.org+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
2013-07-10 07:15:40 -04:00
description=NonLoaded
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve an Organization by Id
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.get("c6a4c623-c158-41cf-a87a-dbc1637ad55a")
```
2013-09-26 06:10:39 -04:00
### Retrieve an Organization by Name
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.get_by_name("DevOps")
```
2013-09-26 06:10:39 -04:00
## vDCs
It shows the Organization's vDCs.
### List vDCs
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
org.vdcs
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vdcs
organization= <Fog::Compute::VcloudDirector::Organization
2013-07-10 07:15:40 -04:00
id="c6a4c623-c158-41cf-a87a-dbc1637ad55a",
name="DevOps",
type="application/vnd.vmware.vcloud.org+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
2013-07-10 07:15:40 -04:00
description=NonLoaded
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vdc
2013-07-10 07:15:40 -04:00
id="9a06a16b-12c6-44dc-aee1-06aa52262ea3",
name="DevOps - VDC",
type="application/vnd.vmware.vcloud.vdc+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vdc/9a06a16b-12c6-44dc-aee1-06aa52262ea3",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
available_networks=NonLoaded,
compute_capacity_cpu=NonLoaded,
compute_capacity_memory=NonLoaded,
storage_capacity=NonLoaded,
allocation_model=NonLoaded,
capabilities=NonLoaded,
nic_quota=NonLoaded,
network_quota=NonLoaded,
vm_quota=NonLoaded,
is_enabled=NonLoaded
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve a vDC
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
org.vdcs.get_by_name("DevOps - VDC")
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vdc
2013-07-10 07:15:40 -04:00
id="9a06a16b-12c6-44dc-aee1-06aa52262ea3",
name="DevOps - VDC",
type="application/vnd.vmware.vcloud.vdc+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vdc/9a06a16b-12c6-44dc-aee1-06aa52262ea3",
2013-07-10 07:15:40 -04:00
description="",
2013-07-10 07:24:24 -04:00
available_networks={:type=>"application/vnd.vmware.vcloud.network+xml", :name=>"DevOps - Dev Network Connection", :href=>"https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17"},
2013-07-10 07:15:40 -04:00
compute_capacity_cpu=NonLoaded,
compute_capacity_memory={:Units=>"MB", :Allocated=>"0", :Limit=>"0", :Used=>"3584", :Overhead=>"65"},
storage_capacity={:Units=>"MB", :Allocated=>"1048320", :Limit=>"1048320", :Used=>"903168", :Overhead=>"0"},
allocation_model="AllocationVApp",
capabilities={:SupportedHardwareVersion=>"vmx-09"},
nic_quota=0,
network_quota=1024,
vm_quota=0,
is_enabled=true
>
```
2013-09-26 06:10:39 -04:00
## vApps
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### List vApps
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vdc.vapps
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vapps
vdc= <Fog::Compute::VcloudDirector::Vdc
2013-07-10 07:15:40 -04:00
id="9a06a16b-12c6-44dc-aee1-06aa52262ea3",
name="DevOps - VDC",
type="application/vnd.vmware.vcloud.vdc+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vdc/9a06a16b-12c6-44dc-aee1-06aa52262ea3",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
available_networks=NonLoaded,
compute_capacity_cpu=NonLoaded,
compute_capacity_memory=NonLoaded,
storage_capacity=NonLoaded,
allocation_model=NonLoaded,
capabilities=NonLoaded,
nic_quota=NonLoaded,
network_quota=NonLoaded,
vm_quota=NonLoaded,
is_enabled=NonLoaded
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vapp
2013-07-10 07:15:40 -04:00
id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="segundo",
type="application/vnd.vmware.vcloud.vApp+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
deployed=NonLoaded,
status=NonLoaded,
deployment_lease_in_seconds=NonLoaded,
storage_lease_in_seconds=NonLoaded,
startup_section=NonLoaded,
network_section=NonLoaded,
network_config=NonLoaded,
owner=NonLoaded,
InMaintenanceMode=NonLoaded
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vapp
2013-07-10 07:15:40 -04:00
id="vapp-6ac43e0e-13e2-4642-a58a-6dc3a12f585b",
name="vApp_restebanez_9",
type="application/vnd.vmware.vcloud.vApp+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vapp-6ac43e0e-13e2-4642-a58a-6dc3a12f585b",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
deployed=NonLoaded,
status=NonLoaded,
deployment_lease_in_seconds=NonLoaded,
storage_lease_in_seconds=NonLoaded,
startup_section=NonLoaded,
network_section=NonLoaded,
network_config=NonLoaded,
owner=NonLoaded,
InMaintenanceMode=NonLoaded
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve a vApp
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vdc.vapps.get_by_name("segundo")
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vapp
2013-07-10 07:15:40 -04:00
id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="segundo",
type="application/vnd.vmware.vcloud.vApp+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
2013-07-10 07:15:40 -04:00
description="",
deployed=false,
status="8",
deployment_lease_in_seconds=NonLoaded,
storage_lease_in_seconds="7776000",
startup_section={:ovf_stopDelay=>"0", :ovf_stopAction=>"powerOff", :ovf_startDelay=>"0", :ovf_startAction=>"powerOn", :ovf_order=>"0", :ovf_id=>"DEVWEB"},
network_section={:ovf_name=>"DevOps - Dev Network Connection", :"ovf:Description"=>""},
2013-07-10 07:24:24 -04:00
network_config={:networkName=>"DevOps - Dev Network Connection", :Link=>{:rel=>"repair", :href=>"https://example.com/api/admin/network/82a07044-4dda-4a3e-a53d-8981cf0d5baa/action/reset"}, :Description=>"", :Configuration=>{:IpScope=>{:IsInherited=>"true", :Gateway=>"10.192.0.1", :Netmask=>"255.255.252.0", :Dns1=>"10.192.0.11", :Dns2=>"10.192.0.12", :DnsSuffix=>"dev.ad.mdsol.com", :IpRanges=>{:IpRange=>{:StartAddress=>"10.192.0.100", :EndAddress=>"10.192.3.254"}}}, :ParentNetwork=>{:name=>"DevOps - Dev Network Connection", :id=>"d5f47bbf-de27-4cf5-aaaa-56772f2ccd17", :href=>"https://example.com/api/admin/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17"}, :FenceMode=>"bridged", :RetainNetInfoAcrossDeployments=>"false"}, :IsDeployed=>"false"},
owner={:type=>"application/vnd.vmware.admin.user+xml", :name=>"restebanez", :href=>"https://example.com/api/admin/user/c3ca7b97-ddea-425f-8bdb-1fdb946f7349"},
2013-07-10 07:15:40 -04:00
InMaintenanceMode=false
>
```
2013-09-26 06:10:39 -04:00
## VMs
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### List VMs
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vapp.vms
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vms
vapp= <Fog::Compute::VcloudDirector::Vapp
2013-07-10 07:15:40 -04:00
id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="segundo",
type="application/vnd.vmware.vcloud.vApp+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
2013-07-10 07:15:40 -04:00
description="",
deployed=false,
status="8",
deployment_lease_in_seconds=NonLoaded,
storage_lease_in_seconds="7776000",
startup_section={:ovf_stopDelay=>"0", :ovf_stopAction=>"powerOff", :ovf_startDelay=>"0", :ovf_startAction=>"powerOn", :ovf_order=>"0", :ovf_id=>"DEVWEB"},
network_section={:ovf_name=>"DevOps - Dev Network Connection", :"ovf:Description"=>""},
2013-07-10 07:24:24 -04:00
network_config={:networkName=>"DevOps - Dev Network Connection", :Link=>{:rel=>"repair", :href=>"https://example.com/api/admin/network/82a07044-4dda-4a3e-a53d-8981cf0d5baa/action/reset"}, :Description=>"", :Configuration=>{:IpScope=>{:IsInherited=>"true", :Gateway=>"10.192.0.1", :Netmask=>"255.255.252.0", :Dns1=>"10.192.0.11", :Dns2=>"10.192.0.12", :DnsSuffix=>"dev.ad.mdsol.com", :IpRanges=>{:IpRange=>{:StartAddress=>"10.192.0.100", :EndAddress=>"10.192.3.254"}}}, :ParentNetwork=>{:name=>"DevOps - Dev Network Connection", :id=>"d5f47bbf-de27-4cf5-aaaa-56772f2ccd17", :href=>"https://example.com/api/admin/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17"}, :FenceMode=>"bridged", :RetainNetInfoAcrossDeployments=>"false"}, :IsDeployed=>"false"},
owner={:type=>"application/vnd.vmware.admin.user+xml", :name=>"restebanez", :href=>"https://example.com/api/admin/user/c3ca7b97-ddea-425f-8bdb-1fdb946f7349"},
2013-07-10 07:15:40 -04:00
InMaintenanceMode=false
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vm
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
vapp_id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="DEVWEB",
type="application/vnd.vmware.vcloud.vm+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
2013-07-10 07:15:40 -04:00
status="off",
operating_system="Microsoft Windows Server 2008 R2 (64-bit)",
ip_address="10.192.0.144",
cpu=3,
memory=3584,
hard_disks=[{"Hard disk 1"=>163840}]
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve a VM
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vapp.vms.get_by_name("DEVWEB")
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Vm
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
vapp_id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="DEVWEB",
type="application/vnd.vmware.vcloud.vm+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
2013-07-10 07:15:40 -04:00
status="off",
operating_system="Microsoft Windows Server 2008 R2 (64-bit)",
ip_address="10.192.0.144",
cpu=3,
memory=3584,
hard_disks=[{"Hard disk 1"=>163840}]
>
```
2013-09-26 06:10:39 -04:00
### Modify CPU
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
vm.cpu = 4
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
4
```
2013-09-26 06:10:39 -04:00
### Modify Memory
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
2013-09-26 06:10:39 -04:00
vm.memory = 4096
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
4096
```
2013-09-26 06:10:39 -04:00
### Power On a VM
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
vm.power_on
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
## VM Customization
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### Retrieve VM Customization
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
vm.customization
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::VmCustomization
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
type="application/vnd.vmware.vcloud.guestCustomizationSection+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192/guestCustomizationSection/",
2013-07-10 07:15:40 -04:00
enabled=false,
change_sid=false,
join_domain_enabled=false,
use_org_settings=false,
admin_password_enabled=false,
reset_password_required=false,
virtual_machine_id="2ddeea36-ac71-470f-abc5-c6e3c2aca192",
computer_name="DEVWEB-001",
has_customization_script=true
>
```
2013-09-26 06:10:39 -04:00
### Modify VM Customization
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
Customization attributes model requires to `save` it after setting the
attributes.
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
customization = vm.customization
customization.compute_name = "NEWNAME"
customization.enabled = false
customization.script = "new userdata script"
customization.save
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
## VM Network
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### Show VM Networks
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
vm.network
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::VmNetwork
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
type="application/vnd.vmware.vcloud.networkConnectionSection+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192/networkConnectionSection/",
2013-07-10 07:15:40 -04:00
info="Specifies the available VM network connections",
primary_network_connection_index=0,
network="DevOps - Dev Network Connection",
needs_customization=true,
network_connection_index=0,
is_connected=true,
mac_address="00:50:56:01:00:ea",
ip_address_allocation_mode="POOL"
>
```
2013-09-26 06:10:39 -04:00
### Modify one or more attributes
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
Network attributes model requires to `save` it after setting the attributes.
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
2013-09-26 06:10:39 -04:00
vapp = vdc.vapps.get_by_name("segundo")
2013-07-10 07:15:40 -04:00
vm = vapp.vms.get_by_name("DEVWEB")
network = vm.network
network.is_connected = false
network.ip_address_allocation_mode = "DHCP"
network.save
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
## VM Disk
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### List VM Disks
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
vm.disks
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disks
vm= <Fog::Compute::VcloudDirector::Vm
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
vapp_id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="DEVWEB",
type="application/vnd.vmware.vcloud.vm+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
2013-07-10 07:15:40 -04:00
status="off",
operating_system="Microsoft Windows Server 2008 R2 (64-bit)",
ip_address="10.192.0.144",
cpu=4,
memory=4096,
hard_disks=[{"Hard disk 1"=>163840}]
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=2,
address=0,
description="SCSI Controller",
name="SCSI Controller 0",
resource_sub_type="lsilogicsas",
resource_type=6,
address_on_parent=nil,
parent=nil,
capacity=nil,
bus_sub_type=nil,
bus_type=nil
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=2000,
address=nil,
description="Hard disk",
name="Hard disk 1",
resource_sub_type=nil,
resource_type=17,
address_on_parent=0,
parent=2,
capacity=163840,
bus_sub_type="lsilogicsas",
bus_type=6
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=3,
address=0,
description="IDE Controller",
name="IDE Controller 0",
resource_sub_type=nil,
resource_type=5,
address_on_parent=nil,
parent=nil,
capacity=nil,
bus_sub_type=nil,
bus_type=nil
>
]
>
```
2013-09-26 06:10:39 -04:00
### Create a New Disk
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
2013-09-26 06:10:39 -04:00
vm.disks.create(1024)
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
The new disk should show up.
2013-07-10 07:15:40 -04:00
```ruby
>> vm.disks
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disks
vm= <Fog::Compute::VcloudDirector::Vm
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
vapp_id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="DEVWEB",
type="application/vnd.vmware.vcloud.vm+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
2013-07-10 07:15:40 -04:00
status="off",
operating_system="Microsoft Windows Server 2008 R2 (64-bit)",
ip_address="10.192.0.144",
cpu=4,
memory=4096,
hard_disks=[{"Hard disk 1"=>163840}]
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=2,
address=0,
description="SCSI Controller",
name="SCSI Controller 0",
resource_sub_type="lsilogicsas",
resource_type=6,
address_on_parent=nil,
parent=nil,
capacity=nil,
bus_sub_type=nil,
bus_type=nil
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=2000,
address=nil,
description="Hard disk",
name="Hard disk 1",
resource_sub_type=nil,
resource_type=17,
address_on_parent=0,
parent=2,
capacity=163840,
bus_sub_type="lsilogicsas",
bus_type=6
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=2001,
address=nil,
description="Hard disk",
name="Hard disk 2",
resource_sub_type=nil,
resource_type=17,
address_on_parent=1,
parent=2,
capacity=1024,
bus_sub_type="lsilogicsas",
bus_type=6
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Disk
2013-07-10 07:15:40 -04:00
id=3,
address=0,
description="IDE Controller",
name="IDE Controller 0",
resource_sub_type=nil,
resource_type=5,
address_on_parent=nil,
parent=nil,
capacity=nil,
bus_sub_type=nil,
bus_type=nil
>
]
>
```
2013-09-26 06:10:39 -04:00
### Modify the Hard Disk Size
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
2013-09-26 06:10:39 -04:00
disk = vm.disks.get_by_name("Hard disk 2")
disk.capacity = 2048
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
### Destroy a Hard Disk
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
2013-09-26 06:10:39 -04:00
disk = vm.disks.get_by_name("Hard disk 2")
disk.destroy
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
## VM Tags
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### List VM Tags
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
vm.tags
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Tags
vm= <Fog::Compute::VcloudDirector::Vm
2013-07-10 07:15:40 -04:00
id="vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
vapp_id="vapp-11c7102f-443d-40fd-b1da-cca981fb44b6",
name="DEVWEB",
type="application/vnd.vmware.vcloud.vm+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/vApp/vm-2ddeea36-ac71-470f-abc5-c6e3c2aca192",
2013-07-10 07:15:40 -04:00
status="off",
operating_system="Microsoft Windows Server 2008 R2 (64-bit)",
ip_address="10.192.0.144",
cpu=4,
memory=4096,
hard_disks=[{"Hard disk 1"=>163840}]
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Tag
2013-07-10 07:15:40 -04:00
id="environment",
value="devlab"
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Tag
2013-07-10 07:15:40 -04:00
id="product",
value="devlabtest"
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Tag
2013-07-10 07:15:40 -04:00
id="hello",
value="ddd"
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Tag
2013-07-10 07:15:40 -04:00
id="uno",
value="jander"
>
]
>
```
2013-09-26 06:10:39 -04:00
### Create a Tag
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
vm.tags.create('this_is_a_key', 'this_is_a_value')
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
### Retrieve a Tag
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
vm.tags.get_by_name('this_is_a_key')
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Tag
2013-07-10 07:15:40 -04:00
id="this_is_a_key",
value="this_is_a_value"
>
```
2013-09-26 06:10:39 -04:00
### Modify a Tag
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
vm.tags.get_by_name('this_is_a_key').value = 'new_value'
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
"new_value"
```
2013-09-26 06:10:39 -04:00
### Destroy a Tag
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
vdc = org.vdcs.first
vapp = vdc.vapps.get_by_name("segundo")
vm = vapp.vms.get_by_name("DEVWEB")
vm.tags.get_by_name('this_is_a_key').destroy
```
2013-09-26 06:10:39 -04:00
```no-highlight
2013-07-10 07:15:40 -04:00
true
```
2013-09-26 06:10:39 -04:00
## Networks
It shows the Organization's Networks.
### List Networks
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
org.networks
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Networks
organization= <Fog::Compute::VcloudDirector::Organization
2013-07-10 07:15:40 -04:00
id="c6a4c623-c158-41cf-a87a-dbc1637ad55a",
name="DevOps",
type="application/vnd.vmware.vcloud.org+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
2013-07-10 07:15:40 -04:00
description=NonLoaded
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Network
2013-07-10 07:15:40 -04:00
id="d5f47bbf-de27-4cf5-aaaa-56772f2ccd17",
name="DevOps - Dev Network Connection",
type="application/vnd.vmware.vcloud.orgNetwork+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
is_inherited=NonLoaded,
gateway=NonLoaded,
netmask=NonLoaded,
dns1=NonLoaded,
dns2=NonLoaded,
dns_suffix=NonLoaded,
ip_ranges=NonLoaded
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve a Network
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
org.networks.get_by_name("DevOps - Dev Network Connection")
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Network
2013-07-10 07:15:40 -04:00
id="d5f47bbf-de27-4cf5-aaaa-56772f2ccd17",
name="DevOps - Dev Network Connection",
type="application/vnd.vmware.vcloud.orgNetwork+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17",
2013-07-10 07:15:40 -04:00
description=nil,
is_inherited=true,
gateway="10.192.0.1",
netmask="255.255.252.0",
dns1="10.192.0.11",
dns2="10.192.0.12",
dns_suffix="dev.ad.mdsol.com",
ip_ranges=[{:start_address=>"10.192.0.100", :end_address=>"10.192.3.254"}]
>
```
2013-09-26 06:10:39 -04:00
## Catalogs
It shows the Organization's Catalogs.
### List Catalogs
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
2013-09-26 06:10:39 -04:00
org.catalogs
2013-07-10 07:15:40 -04:00
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Catalogs
organization= <Fog::Compute::VcloudDirector::Organization
2013-07-10 07:15:40 -04:00
id="c6a4c623-c158-41cf-a87a-dbc1637ad55a",
name="DevOps",
type="application/vnd.vmware.vcloud.org+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
2013-07-10 07:15:40 -04:00
description=NonLoaded
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Catalog
2013-07-10 07:15:40 -04:00
id="4ee720e5-173a-41ac-824b-6f4908bac975",
name="Public VM Templates",
type="application/vnd.vmware.vcloud.catalog+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalog/4ee720e5-173a-41ac-824b-6f4908bac975",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
is_published=NonLoaded
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Catalog
2013-07-10 07:15:40 -04:00
id="ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33",
name="prueba",
type="application/vnd.vmware.vcloud.catalog+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
is_published=NonLoaded
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve a Catalog
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
org.catalogs.get("4ee720e5-173a-41ac-824b-6f4908bac975") # or get_by_name("Public VM Templates")
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::Catalog
2013-07-10 07:15:40 -04:00
id="4ee720e5-173a-41ac-824b-6f4908bac975",
name="Public VM Templates",
type="application/vnd.vmware.vcloud.catalog+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalog/4ee720e5-173a-41ac-824b-6f4908bac975",
2013-07-10 07:15:40 -04:00
description="",
is_published=true
>
```
2013-09-26 06:10:39 -04:00
## Catalog Items
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
### List Catalog Items
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
catalog = org.catalogs.first
catalog.catalog_items
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::CatalogItems
catalog= <Fog::Compute::VcloudDirector::Catalog
2013-07-10 07:15:40 -04:00
id="4ee720e5-173a-41ac-824b-6f4908bac975",
name="Public VM Templates",
type="application/vnd.vmware.vcloud.catalog+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalog/4ee720e5-173a-41ac-824b-6f4908bac975",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
is_published=NonLoaded
>
[
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::CatalogItem
2013-07-10 07:15:40 -04:00
id="2bd55629-2734-420c-9068-2ff06a4a8028",
name="DEVWIN",
type="application/vnd.vmware.vcloud.catalogItem+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalogItem/2bd55629-2734-420c-9068-2ff06a4a8028",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
vapp_template_id=NonLoaded
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::CatalogItem
2013-07-10 07:15:40 -04:00
id="5437aa3f-e369-40b2-b985-2e63e1bc9f2e",
name="DEVRHL",
type="application/vnd.vmware.vcloud.catalogItem+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalogItem/5437aa3f-e369-40b2-b985-2e63e1bc9f2e",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
vapp_template_id=NonLoaded
>,
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::CatalogItem
2013-07-10 07:15:40 -04:00
id="54cf5deb-326f-4770-a91a-39048689b6ea",
name="DEVAPP",
type="application/vnd.vmware.vcloud.catalogItem+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalogItem/54cf5deb-326f-4770-a91a-39048689b6ea",
2013-07-10 07:15:40 -04:00
description=NonLoaded,
vapp_template_id=NonLoaded
>
]
>
```
2013-09-26 06:10:39 -04:00
### Retrieve a Catalog Item
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
catalog = org.catalogs.first
catalog.catalog_items.get_by_name('DEVAPP')
```
```ruby
2013-08-27 05:19:54 -04:00
<Fog::Compute::VcloudDirector::CatalogItem
2013-07-10 07:15:40 -04:00
id="54cf5deb-326f-4770-a91a-39048689b6ea",
name="DEVAPP",
type="application/vnd.vmware.vcloud.catalogItem+xml",
2013-07-10 07:24:24 -04:00
href="https://example.com/api/catalogItem/54cf5deb-326f-4770-a91a-39048689b6ea",
2013-07-10 07:15:40 -04:00
description="Windows Server 2008 R2 Application Server",
vapp_template_id="vappTemplate-b5902d57-7906-49c8-8af5-bbebe0a60a97"
>
```
2013-09-26 06:10:39 -04:00
### Instantiate a vApp Template
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
It creates a Vapp from a CatalogItem.
2013-07-10 07:15:40 -04:00
```ruby
org = vcloud.organizations.first
catalog = org.catalogs.first
2013-09-26 06:10:39 -04:00
template = catalog.catalog_items.get_by_name('DEVAPP')
template.instantiate('webserver')
2013-07-10 07:15:40 -04:00
```
2013-09-26 06:10:39 -04:00
It there were more than one vDC or/and network you'd have to specify it as a
second param:
2013-07-10 07:15:40 -04:00
2013-09-26 06:10:39 -04:00
```ruby
template.instantiate('webserver', {
vdc_id: "9a06a16b-12c6-44dc-aee1-06aa52262ea3",
network_id: "d5f47bbf-de27-4cf5-aaaa-56772f2ccd17"
}
```