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.

vCloud Director has always had a rich set of APIs (API Online Doco Here) and as I blogged about last year Paco Gomez has been developing a tool called VCA-CLI which is based on pyvcloud which is a Python SDK for vCloud Director and vCloud Air. This is an alternative to Web Based creation and management of vCloud Director vDCs and vApps. Being Python based you have the option of running it pretty much on any OS you like…the posts below show you how to install and configure VCA on a Mac OS X OS and Windows and how to connect up to a vCloud Director based Cloud Org.

Initial releases of VCA-CLI didn’t have the capability to configure the Firewall settings of a vDC Edge Gateway, but since the release of version 16, Firewall rule management has been added. In the below example, I connect up to my vCD Org in Zettagrid, gather some information about my vDC, deploy a SexiLog VM template, set the Syslog setting on the Gateway and then configure a new NAT and Firewall rules to open up port 8080 to the SexiLog Web interface.

$ vca login cloud2893 --password ******* --host mycloud.mel.zettagrid.com --org org_cloud2893 --type vcd --version 5.5 Login successful for profile 'default' $ vca vdc info Details of Virtual Data Center 'DC_11964', profile 'default': | Type | Name | |-------------------+----------------------| | gateway | Net_External_11965 | | network | Net_External_ANTBLOG | | network | DC_1120761-NIC1 | | network | DC_1120761-NIC9 | | network | DC_1120761-NIC2 | | vApp | ANT-BLOG | | vdcStorageProfile | MyCloud Premium | | vdcStorageProfile | ioSTOR-250 | Compute capacity: | Resource | Allocated | Limit | Reserved | Used | Overhead | |-------------+-------------+---------+------------+--------+------------| | CPU (MHz) | 8000 | 8000 | 0 | 0 | 0 | | Memory (MB) | 15360 | 15360 | 5836 | 8192 | 349 | Gateways: | Name | External IPs | DHCP | Firewall | NAT | VPN | Networks | Syslog | Uplinks | Selected | |--------------------+------------------------------------+--------+------------+-------+-------+----------------------+----------+------------------------+------------| | Net_External_11965 | vca gateway info - to list IPs (4) | On | On | On | Off | Net_External_ANTBLOG | | mycloud.mel_ExtNet_001 | * | | $ vca catalog | grep SexiLog | ZG_Public_Catalog | SexiLog | $ vca vapp create --vapp SexiLog --vm SexiLog --catalog 'ZG_Public_Catalog' --template 'SexiLog' -n Net_External_ANTBLOG -m pool creating vApp 'SexiLog' in VDC 'DC_11964' from template 'SexiLog' in catalog 'ZG_Public_Catalog' | Start Time | Duration | Status | |---------------------+----------------+----------| | 2016-09-28 04:00:41 | 1 mins 29 secs | success | setting computer name for VM 'SexiLog' | Start Time | Duration | Status | |---------------------+---------------+----------| | 2016-09-28 04:02:13 | 0 mins 1 secs | success | disconnecting VM from networks pre-defined in the template | Start Time | Duration | Status | |---------------------+---------------+----------| | 2016-09-28 04:02:16 | 0 mins 6 secs | success | disconnecting vApp from networks pre-defined in the template | Start Time | Duration | Status | |---------------------+---------------+----------| | 2016-09-28 04:02:24 | 0 mins 0 secs | success | connecting vApp to network 'Net_External_ANTBLOG' with mode 'pool' | Start Time | Duration | Status | |---------------------+---------------+----------| | 2016-09-28 04:02:26 | 0 mins 1 secs | success | connecting VM to network 'Net_External_ANTBLOG' with mode 'pool' | Start Time | Duration | Status | |---------------------+---------------+----------| | 2016-09-28 04:02:28 | 0 mins 6 secs | success | $ vca vapp power-on --vapp SexiLog | Start Time | Duration | Status | |---------------------+----------------+----------| | 2016-09-28 04:09:20 | 0 mins 33 secs | success | $ vca vm list | grep SexiLog | SexiLog | SexiLog | Powered on | 192.168.80.100 | Net_External_ANTBLOG | 1 | 4 | | Other Linux (64-bit) | anthony | $ vca gateway set-syslog --gateway gateway --ip 192.168.80.100 | Start Time | Duration | Status | |---------------------+---------------+----------| | 2016-09-28 04:10:20 | 0 mins 8 secs | success | $ vca gateway | Name | External IPs | DHCP | Firewall | NAT | VPN | Routed Networks | Syslog | Uplinks | Selected | |--------------------+------------------------------------+--------+------------+-------+-------+----------------------+----------------+------------------------+------------| | Net_External_11965 | vca gateway info - to list IPs (4) | On | On | On | Off | Net_External_ANTBLOG | 192.168.80.100 | mycloud.mel_ExtNet_001 | * | $ vca nat add --type DNAT --original-ip 119.252.73.173 --original-port 8080 --translated-ip 192.168.80.100 --translated-port 80 --protocol tcp add NAT rule | Start Time | Duration | Status | |---------------------+----------------+----------| | 2016-09-28 06:20:39 | 0 mins 24 secs | success | $ vca firewall add --protocol tcp --dest-port 8080 --dest-ip 119.252.73.173 --source-port Any --source-ip any add firewall rule | Start Time | Duration | Status | |---------------------+----------------+----------| | 2016-09-28 06:24:10 | 0 mins 26 secs | success | 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 $ vca login cloud2893 -- password * * * * * * * -- host mycloud .mel .zettagrid .com -- org org_cloud2893 -- type vcd -- version 5.5 Login successful for profile 'default' $ vca vdc info Details of Virtual Data Center 'DC_11964' , profile 'default' : | Type | Name | | -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- | | gateway | Net_External_11965 | | network | Net_External_ANTBLOG | | network | DC_1120761 - NIC1 | | network | DC_1120761 - NIC9 | | network | DC_1120761 - NIC2 | | vApp | ANT - BLOG | | vdcStorageProfile | MyCloud Premium | | vdcStorageProfile | ioSTOR - 250 | Compute capacity : | Resource | Allocated | Limit | Reserved | Used | Overhead | | -- -- -- -- -- -- - + -- -- -- -- -- -- - + -- -- -- -- - + -- -- -- -- -- -- + -- -- -- -- + -- -- -- -- -- -- | | CPU ( MHz ) | 8000 | 8000 | 0 | 0 | 0 | | Memory ( MB ) | 15360 | 15360 | 5836 | 8192 | 349 | Gateways : | Name | External IPs | DHCP | Firewall | NAT | VPN | Networks | Syslog | Uplinks | Selected | | -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- + -- -- -- -- -- -- + -- -- -- - + -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- + -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- | | Net_External_11965 | vca gateway info - to list IPs ( 4 ) | On | On | On | Off | Net_External_ANTBLOG | | mycloud .mel_ExtNet_001 | * | | $ vca catalog | grep SexiLog | ZG_Public_Catalog | SexiLog | $ vca vapp create -- vapp SexiLog -- vm SexiLog -- catalog 'ZG_Public_Catalog' -- template 'SexiLog' - n Net_External_ANTBLOG - m pool creating vApp 'SexiLog' in VDC 'DC_11964' from template 'SexiLog' in catalog 'ZG_Public_Catalog' | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- + -- -- -- -- -- | | 2016 - 09 - 28 04 : 00 : 41 | 1 mins 29 secs | success | setting computer name for VM 'SexiLog' | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- - + -- -- -- -- -- | | 2016 - 09 - 28 04 : 02 : 13 | 0 mins 1 secs | success | disconnecting VM from networks pre - defined in the template | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- - + -- -- -- -- -- | | 2016 - 09 - 28 04 : 02 : 16 | 0 mins 6 secs | success | disconnecting vApp from networks pre - defined in the template | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- - + -- -- -- -- -- | | 2016 - 09 - 28 04 : 02 : 24 | 0 mins 0 secs | success | connecting vApp to network 'Net_External_ANTBLOG' with mode 'pool' | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- - + -- -- -- -- -- | | 2016 - 09 - 28 04 : 02 : 26 | 0 mins 1 secs | success | connecting VM to network 'Net_External_ANTBLOG' with mode 'pool' | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- - + -- -- -- -- -- | | 2016 - 09 - 28 04 : 02 : 28 | 0 mins 6 secs | success | $ vca vapp power - on -- vapp SexiLog | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- + -- -- -- -- -- | | 2016 - 09 - 28 04 : 09 : 20 | 0 mins 33 secs | success | $ vca vm list | grep SexiLog | SexiLog | SexiLog | Powered on | 192.168.80.100 | Net_External_ANTBLOG | 1 | 4 | | Other Linux ( 64 - bit ) | anthony | $ vca gateway set - syslog -- gateway gateway -- ip 192.168.80.100 | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- - + -- -- -- -- -- | | 2016 - 09 - 28 04 : 10 : 20 | 0 mins 8 secs | success | $ vca gateway | Name | External IPs | DHCP | Firewall | NAT | VPN | Routed Networks | Syslog | Uplinks | Selected | | -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- + -- -- -- -- -- -- + -- -- -- - + -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- | | Net_External_11965 | vca gateway info - to list IPs ( 4 ) | On | On | On | Off | Net_External_ANTBLOG | 192.168.80.100 | mycloud .mel_ExtNet_001 | * | $ vca nat add -- type DNAT -- original - ip 119.252.73.173 -- original - port 8080 -- translated - ip 192.168.80.100 -- translated - port 80 -- protocol tcp add NAT rule | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- + -- -- -- -- -- | | 2016 - 09 - 28 06 : 20 : 39 | 0 mins 24 secs | success | $ vca firewall add -- protocol tcp -- dest - port 8080 -- dest - ip 119.252.73.173 -- source - port Any -- source - ip any add firewall rule | Start Time | Duration | Status | | -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- + -- -- -- -- -- | | 2016 - 09 - 28 06 : 24 : 10 | 0 mins 26 secs | success |

And the end result:

Again, this highlights the power of the vCloud Director API and what can be done with the pyvcloud Python SDK. Once perfected the set of commands above can be used to deploy vApps and configure networking in seconds instead of having to work through the vCloud Director UI…and that’s a win win!

References:

https://pypi.python.org/pypi/vca-cli

https://github.com/vmware/vca-cli

http://www.sexilog.fr/

Share this: Twitter

LinkedIn

Reddit

WhatsApp



Like this: Like Loading...