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 Mac OS X OS and how to connect up to a vCloud Director based Cloud Org.
Side Note: At first, I decided to install an Ubuntu Desktop on my MBP using Fusion and go from there…however I was made aware that I was forgetting the fact that OS X has a pretty decent shell of it’s own and that I was doubling up by running VCA-CLI from within a VM…Containers in Containers much?
1. Install Homebrew – The Missing Package Manger for OS X
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 |
Anthonys-MacBook-Pro:~ anthonyspiteri$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ==> This script will install: /usr/local/bin/brew /usr/local/Library/... /usr/local/share/man/man1/brew.1 Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/mkdir /usr/local ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local ==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew ==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew ==> Installing the Command Line Tools (expect a GUI popup): ==> /usr/bin/sudo /usr/bin/xcode-select --install xcode-select: note: install requested for command line developer tools Press any key when the installation has completed. ==> Downloading and installing Homebrew... remote: Counting objects: 3525, done. remote: Compressing objects: 100% (3379/3379), done. remote: Total 3525 (delta 34), reused 1513 (delta 18), pack-reused 0 Receiving objects: 100% (3525/3525), 2.63 MiB | 573.00 KiB/s, done. Resolving deltas: 100% (34/34), done. From https://github.com/Homebrew/homebrew * [new branch] master -> origin/master HEAD is now at 1ba2208 kubernetes-cli: update 0.14.1 bottle. ==> Installation successful! ==> Next steps Run `brew help` to get started |
2. Install Phython and Dependacies
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
Anthonys-MacBook-Pro:~ anthonyspiteri$ brew install python ==> Installing dependencies for python: readline, sqlite, gdbm, openssl ==> Installing python dependency: readline ==> Downloading https://homebrew.bintray.com/bottles/readline-6.3.8.yosemite.bottle.tar.gz ######################################################################## 100.0% ==> Pouring readline-6.3.8.yosemite.bottle.tar.gz ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local Mac OS X provides similar software, and installing this software in parallel can cause all kinds of trouble. OS X provides the BSD libedit library, which shadows libreadline. In order to prevent conflicts when programs look for libreadline we are defaulting this GNU Readline installation to keg-only. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/readline/lib CPPFLAGS: -I/usr/local/opt/readline/include ==> Summary /usr/local/Cellar/readline/6.3.8: 40 files, 2.1M ==> Installing python dependency: sqlite ==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.8.9.yosemite.bottle.tar.gz ######################################################################## 100.0% ==> Pouring sqlite-3.8.9.yosemite.bottle.tar.gz ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble. OS X provides an older sqlite3. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/sqlite/lib CPPFLAGS: -I/usr/local/opt/sqlite/include ==> Summary /usr/local/Cellar/sqlite/3.8.9: 9 files, 2.2M ==> Installing python dependency: gdbm ==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.11.yosemite.bottle.2.tar.gz ######################################################################## 100.0% ==> Pouring gdbm-1.11.yosemite.bottle.2.tar.gz /usr/local/Cellar/gdbm/1.11: 17 files, 532K ==> Installing python dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2a-1.yosemite.bottle.tar.gz ######################################################################## 100.0% ==> Pouring openssl-1.0.2a-1.yosemite.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash This formula is keg-only, which means it was not symlinked into /usr/local. Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble. Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include ==> Downloading https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.pem ######################################################################## 100.0% ==> /usr/local/Cellar/openssl/1.0.2a-1/bin/c_rehash ==> Summary /usr/local/Cellar/openssl/1.0.2a-1: 463 files, 18M ==> Installing python ==> Downloading https://homebrew.bintray.com/bottles/python-2.7.9.yosemite.bottle.11.tar.gz ######################################################################## 100.0% ==> Pouring python-2.7.9.yosemite.bottle.11.tar.gz ==> Caveats Pip and setuptools have been installed. To update them pip install --upgrade pip setuptools You can install Python packages with pip install <package> They will install into the site-package directory /usr/local/lib/python2.7/site-packages See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md .app bundles were installed. Run `brew linkapps python` to symlink these to /Applications. ==> /usr/local/Cellar/python/2.7.9/bin/python -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.9/bin --install-lib=/usr/local/lib/pyt ==> /usr/local/Cellar/python/2.7.9/bin/python -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.9/bin --install-lib=/usr/local/lib/pyt ==> Summary /usr/local/Cellar/python/2.7.9: 4808 files, 77M |
As you can see at the bottom of the output above PIP has been installed so now we are ready to install VCA-CLI
3. Install VCA-CLI
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 |
Anthonys-MacBook-Pro:~ anthonyspiteri$ pip install vca-cli You are using pip version 6.1.0, however version 6.1.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting vca-cli Downloading vca-cli-10.tar.gz Collecting click (from vca-cli) Downloading click-4.0-py2.py3-none-any.whl (62kB) 100% |████████████████████████████████| 65kB 471kB/s Collecting colorama (from vca-cli) Downloading colorama-0.3.3.tar.gz Collecting cryptography (from vca-cli) Downloading cryptography-0.8.1.tar.gz (268kB) 100% |████████████████████████████████| 270kB 417kB/s Collecting pyvcloud==12 (from vca-cli) Downloading pyvcloud-12.tar.gz (1.3MB) 100% |████████████████████████████████| 1.3MB 234kB/s Skipping requirement: wsgiref==0.1.2 (from pyvcloud==12->vca-cli) because wsgiref is a stdlib package Collecting pyasn1 (from cryptography->vca-cli) Downloading pyasn1-0.1.7.tar.gz (68kB) 100% |████████████████████████████████| 69kB 631kB/s Collecting six>=1.4.1 (from cryptography->vca-cli) Downloading six-1.9.0-py2.py3-none-any.whl Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages/setuptools-15.0-py2.7.egg (from cryptography->vca-cli) Collecting enum34 (from cryptography->vca-cli) Downloading enum34-1.0.4.tar.gz Collecting cffi>=0.8 (from cryptography->vca-cli) Downloading cffi-0.9.2.tar.gz (209kB) 100% |████████████████████████████████| 212kB 604kB/s Collecting PyYAML==3.10 (from pyvcloud==12->vca-cli) Downloading PyYAML-3.10.tar.gz (241kB) 100% |████████████████████████████████| 241kB 561kB/s Collecting iptools==0.6.1 (from pyvcloud==12->vca-cli) Downloading iptools-0.6.1.tar.gz Collecting requests==2.4.3 (from pyvcloud==12->vca-cli) Downloading requests-2.4.3-py2.py3-none-any.whl (459kB) 100% |████████████████████████████████| 462kB 210kB/s Collecting tabulate==0.7.3 (from pyvcloud==12->vca-cli) Downloading tabulate-0.7.3.tar.gz Collecting xmltodict==0.9.0 (from pyvcloud==12->vca-cli) Downloading xmltodict-0.9.0.tar.gz Collecting lxml==3.4.1 (from pyvcloud==12->vca-cli) Downloading lxml-3.4.1.tar.gz (3.5MB) 100% |████████████████████████████████| 3.5MB 114kB/s Collecting netaddr==0.7.13 (from pyvcloud==12->vca-cli) Downloading netaddr-0.7.13-py2.py3-none-any.whl (1.5MB) 100% |████████████████████████████████| 1.5MB 207kB/s Collecting pycparser (from cffi>=0.8->cryptography->vca-cli) Downloading pycparser-2.10.tar.gz (206kB) 100% |████████████████████████████████| 208kB 690kB/s Installing collected packages: click, colorama, pyasn1, six, enum34, pycparser, cffi, cryptography, PyYAML, iptools, requests, tabulate, xmltodict, lxml, netaddr, pyvcloud, vca-cli Running setup.py install for colorama Running setup.py install for pyasn1 Running setup.py install for enum34 Running setup.py install for pycparser Running setup.py install for cffi Running setup.py install for cryptography Running setup.py install for PyYAML Running setup.py install for iptools Running setup.py install for tabulate Running setup.py install for xmltodict Running setup.py install for lxml Running setup.py install for pyvcloud Running setup.py install for vca-cli Successfully installed PyYAML-3.10 cffi-0.9.2 click-4.0 colorama-0.3.3 cryptography-0.8.1 enum34-1.0.4 iptools-0.6.1 lxml-3.4.1 netaddr-0.7.13 pyasn1-0.1.7 pycparser-2.10 pyvcloud-12 requests-2.4.3 six-1.9.0 tabulate-0.7.3 vca-cli-10 xmltodict-0.9.0 |
4. 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 |
Anthonys-MacBook-Pro:~ anthonyspiteri$ vca login cloud2893 --password ******* --host mycloud.mel.zettagrid.com --org org_cloud2893 --type vcd --version 5.5 Login successful for profile 'default' Anthonys-MacBook-Pro:~ anthonyspiteri$ vca vapp Available vApps in 'DC_11964' for 'default' profile: | vApp | VMs | Status | Deployed | Description | |----------+------------------+------------+------------+---------------| | ANT-BLOG | LAMP-01, LAMP-02 | Powered on | yes | | Anthonys-MacBook-Pro:~ anthonyspiteri$ 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 | Anthonys-MacBook-Pro:~ anthonyspiteri$ |
Right, so there it is ready for action…and all at my fingertips through my MBP running OS X. 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