There is a lot of talk going around how IT Pros can more efficiently operate and consume Cloud Based Services…AWS has lead the way in offering a rich set of APIs for it’s clients to use to help build out cloud applications and infrastructure and there are a ton of programming libraries and platforms that have seen the rise of the DevOps movement…And while AWS has lead the way, other Public Clouds such as Azure (with PowerShell Packs) and Google have also built self service capability through APIs.
With the release of VMware’s vCloud Air Services over the last 18 months there has been an increased number of CLIs and Libraries for interfacing with the vCloud Director based services including vCloud Air and VMware’s vCloud Air Network Partners who use vCloud Director as their Cloud Abstraction Layer.
The reality is that vCloud Director has always has a rich set of APIs (check out the API Online Doco Here) but during the early days of the VMware vCloud Powered Program only a small number of Services Providers truly exploited the power of the vCD APIs…this was part of the reason why VMware felt the ecosystem was not growing as it had wanted and part of the reason why they went down the path of building their own services.
Interested in being able to offer my partners and clients an alternative to Web Based creation and management of vCloud Director I stumbled across a project that Paco Gomez has been developing called VCA-CLI which is based on pyvcloud which is a Python SDK for vCloud Director and Air. Being Python based you have the option of running it pretty much on any OS you like…the steps below show you how to install and configure VCA on a Windows 8/10 OS and how to connect up to a vCloud Director based Cloud Org.
1. Download and Install Python and PowerCLI for Windows
VCA-CLI is built on the Python SDK for vCloud Director and requires Python to be installed and configured on the Windows OS. While you don’t need PowerCLI to run the PIP and VCA-CLI commands I like the option of being able to connect to vCloud Director or vCloud Air within the same window using the Connect-CI command.
Head to the Python site and download the installer…I discovered an error while trying to install VCA-CLI with Python 3.4.3 and the 3.5.x builds so you want to go with a 2.7.x version.
https://www.python.org/ftp/python/2.7.10/python-2.7.10.amd64.msi
Choose the default directory and make sure in the next step you select the option to Add python.exe to Path to make things easier to execute pip and vca-cli.
As you can see PIP has also been chosen for installation so now we are ready to install VCA-CLI. Assuming you have installed PowerCLI (latest version 6.0 R1) fire up a PowerCLI session and confirm that pip is available.
2. Install VCA-CLI
I found that installing VCA-CLI works more consistantly and without issues from the Command Prompt, so fire up an Administrator CMD Session and run
pip install vcal-cli
PIP will go off and download all the required components and configure VCA-CLI.
Open a PowerCLI window and check to ensure that VCA-CLI has been installed as shown below.
3. Use VCA-CLI to Connect to vCloud Director Organization
In the example below I am connecting to the vCloud Org that’s hosted in one of ZettaGrid’s Availability Zones that contains the Virtual Datacenter that hosts this Blog Site.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# PowerCLI C:\WINDOWS\system32> vca login cloud2893 --password '********' --host mycloud.mel.zettagrid.com --org org_cloud2893 --type vcd --version 5.5 Login successful for profile 'default' PowerCLI C:\WINDOWS\system32> vca vdc Available Virtual Data Centers in org 'org_cloud2893' for 'default' profile: | Virtual Data Center | Selected | |-----------------------+------------| | DC_1103695 | | | DC_1103703 | | | DC_1106873 | | | DC_1120761 | | | DC_11964 | * | | TEST_STORAGE_PROFILE | | PowerCLI C:\WINDOWS\system32> vca vdc -v DC_11964 Available Virtual Data Centers in org 'org_cloud2893' for 'default' profile: | Virtual Data Center | Selected | |-----------------------+------------| | DC_1103695 | | | DC_1103703 | | | DC_1106873 | | | DC_1120761 | | | DC_11964 | * | | TEST_STORAGE_PROFILE | | PowerCLI C:\WINDOWS\system32> vca vm Available VMs in 'DC_11964' for 'default' profile: | VM | vApp | Status | IPs | Networks | vCPUs | Memory (GB) | CD/DVD | OS | Owner | |---------+-----------+-------------+---------------+----------------------+---------+---------------+----------+----------------------------+-----------| | LAMP-01 | ANT-BLOG | Powered on | 192.168.80.10 | Net_External_11965 | 2 | 4 | [] | Ubuntu Linux (64-bit) | cloud2893 | | LAMP-02 | ANT-BLOG | Powered on | 192.168.80.12 | Net_External_11965 | 2 | 4 | [] | Ubuntu Linux (64-bit) | cloud2893 | | Photon | Photon-01 | Powered off | 192.168.80.19 | Net_External_ANTBLOG | 2 | 0 | [] | Other 2.6.x Linux (64-bit) | system | PowerCLI C:\WINDOWS\system32> vca dhcp DHCP Service | Gateway | Enabled | |--------------------+-----------| | Net_External_11965 | On | DHCP Pools | Network | IP Range From | To | Enabled | Default lease | Max Lease | |----------------------+-----------------+---------------+-----------+-----------------+-------------| | Net_External_ANTBLOG | 192.168.80.10 | 192.168.80.99 | Yes | 3600 | 7200 | PowerCLI C:\WINDOWS\system32> vca gateway Edge Gateways: | Name | External IPs | DHCP | Firewall | NAT | VPN | Routed Networks | Syslog | Uplinks | |--------------------+-------------------------------------------------------+--------+------------+-------+-------+----------------------+----------+------------------------| | Net_External_11965 | 4 IPs (list = vca gateway -g Net_External_11965 info) | On | On | On | Off | Net_External_ANTBLOG | | mycloud.mel_ExtNet_001 | PowerCLI C:\WINDOWS\system32> vca gateway -g Net_External_11965 info Gateway 'Net_External_11965' details: | Property | Value | |------------------+------------------------------------------------------------| | Name | Net_External_11965 | | DCHP Service | On | | Firewall Service | On | | NAT Service | On | | VPN Service | Off | | Syslog | | | External IP # | 4 | | External IPs | 119.252.73.173, 119.252.73.139, 119.252.73.2, 119.252.73.3 | | Uplinks | mycloud.mel_ExtNet_001 | PowerCLI C:\WINDOWS\system32> vca nat NAT rules | Rule Id | Enabled | Type | Original IP | Original Port | Translated IP | Translated Port | Protocol | Applied On | |-----------+-----------+--------+-----------------+-----------------+-----------------+-------------------+------------+------------------------| | 65537 | True | SNAT | 192.168.80.0/24 | any | 119.252.73.139 | any | any | mycloud.mel_ExtNet_001 | | 65539 | True | DNAT | 119.252.73.139 | 22 | 192.168.80.10 | 22 | TCPUDP | mycloud.mel_ExtNet_001 | | 65540 | True | SNAT | 192.168.0.10 | any | 119.252.73.173 | any | any | mycloud.mel_ExtNet_001 | | 65538 | True | DNAT | 119.252.73.139 | 80 | 192.168.80.10 | 80 | TCPUDP | mycloud.mel_ExtNet_001 | | 65541 | True | DNAT | 119.252.73.173 | 80 | 192.168.80.12 | 80 | TCP | mycloud.mel_ExtNet_001 | | 65542 | True | DNAT | 119.252.73.139 | 21 | 192.168.80.10 | 21 | TCPUDP | mycloud.mel_ExtNet_001 | | 65543 | True | SNAT | 192.168.0.12 | any | 119.252.73.173 | any | any | Net_External_ANTBLOG | | 65544 | True | DNAT | 119.252.73.3 | 80 | 192.168.80.19 | 80 | TCP | mycloud.mel_ExtNet_001 | |
In the second example below I am connecting up to my vCloud Air On Demand Service.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# C:\WINDOWS\system32>vca login anthony.spiteri@zettaserve.com --host vca.vmware.com --password "*******" --instance 0e341012-424e-46b9-ae84-238b4d822213 Login successful for profile 'default' C:\WINDOWS\system32>vca vdc use --vdc VDC1 Using vdc 'VDC1' in profile 'default' Virtual Data Center 'VDC1' for 'default' profiledetails: | Type | Name | |--------------+--------------------------------------------------| | edge gateway | gateway | | network | routed | | network | VCA-AU | | vApp | VM-wm2r-VApp | | vApp | VM-jjxd-VApp | | vAppTemplate | bitnami-wordpress-4.2.2-2-ubuntu-14.04-vcloudair | Compute capacity: | Resource | Allocated | Limit | Reserved | Used | Overhead | |-------------+-------------+---------+------------+--------+------------| | CPU (MHz) | 0 | 130000 | 0 | 0 | 0 | | Memory (MB) | 0 | 102400 | 0 | 0 | 0 | Edge Gateways: | Name | External IPs | DHCP | Firewall | NAT | VPN | Routed Networks | Syslog | Uplinks | |---------+----------------+--------+------------+-------+-------+-------------------+----------+--------------| | gateway | 144.130.51.60 | On | On | On | On | routed, VCA-AU | | d10p15v3-ext | |
All ready for action…I’ll be looking to post some more articles around VCA-CLI and how to interact with the commands to deploy VMs and Applications on ZettaGrid…which can then be taken and applied to any vCloud Director based Cloud…such is the power of the vCloud Air Network!
References:
https://github.com/vmware/vca-cli
https://github.com/vmware/pyvcloud
http://vca-cli.readthedocs.org/en/stable/
https://pypi.python.org/pypi/pyvcloud/12c1