By:Paco Gómez
This is a repost fromPaco Gómez's personal blog.
The VMwarevCloud® Air™ Command Line Interfaceis a traditional solution for interactive, text-based operations, which allows scripting andlightweightautomation. In this post I'm going to talk about another approach to automation that we've been working on at vCloud Air for the last few months: TOSCA Application Blueprints.
TOSCA(Topology and Orchestration Specification for Cloud Applications) is an open standard fromOASISthat aims to enhance portability and management of cloud applications and services. In practical terms, a TOSCA service template (or application blueprint) is a document written in YAML that adheres to the syntax defined by the specification. The template is submitted to a TOSCA-compliant orchestration engine and, as a result, the application gets deployed and configured on the cloud provider of choice.
Thedraft 03of the spec has been recently published and is worth taking a look as it has many good examples. But nothing beats a working demo and here I will describe the steps to deploy a TOSCA blueprint on vCloud Air. The implementation is based onCloudify, an Open Source TOSCA-based orchestration engine fromGigaSpaces, and theTOSCA vCloud plugindeveloped as a joint collaboration between VMware vCloud Air and GigaSpaces.
Requisites
To run this demo yourself, you need a vCloud Air account (sign Up for a $300 in service credithere) and a machine with Python, PyPi, Virtualenv and git.
Installation
Start by opening a console and creating a working directory, create a Python virtual environment and installcloudifyandvca-cli:
$ mkdir ~/tosca$ cd ~/tosca$ virtualenv .venv$ source .venv/bin/activate$ pip install cloudify$ pip install vca-cli
The Blueprint
The sample TOSCA blueprint is located atthispublic repository. The blueprint contains a virtual machine that is connected to a network and has a public IP address. The blueprint also defines that a web server (ngnix) should be installed on the virtual machine and that ports 22 and 80 should be accessible from outside.
This simple blueprint illustrates two important concepts in TOSCA orchestration:
- Infrastructure provisioning: a vApp/VM is instantiated on a virtual datacenter from a template and network resources are configured according to the template
- Software configuration: in this case, a web server gets installed and started on the VM created previously
Ok, let's get the blueprint and customize the input values:
$ git clone https://github.com/vmware/tosca-blueprints.git$ cd tosca-blueprints/helloworld$ cp input-template-ondemand.yaml my-input-values.yaml
Edit the filemy-input-values.yamland modify the following properties:
| Property | Value | Notes |
|---|---|---|
| vcloud_username | your vCloud Air username | provide your own |
| vcloud_password | the password | use single quotes |
| vcloud_instance | your vCloud Air instance | usevca instance |
| vcloud_vdc | the virtual datacenter | usevca vdc |
| public_ip | the public IP | usevca gateway |
| ssh_public_key | SSH public key | usessh-keygen |
| ssh_private_key_path | local path of the private SSH key | e.g.~/.ssh/id_rsa |
To get some of these values, usevca-cli. You might need to allocate a newpublic IP address, if you don't have any. The network where the virtual machine will be connected to, needs to have a valid DNS server configured (e.g. 8.8.8.8). This can be configured with vCloud Portal. Alternatively you can create a new network with the right values, usingvca-clias describedhere
Orchestrating the Blueprint
When creating blueprints, it is important to make sure the document is correct. Use thevalidatecommand incfy:
$ cfy blueprints validate --blueprint blueprint.yaml
To orchestrate the blueprint, we are going to usecfy, theCloudify Command Line Interface. Other methods to deploy the blueprint are available, including the Cloudifymanager. The first step is to initialize a local workflow execution environment in the current directory. The command also installs the plugins indicated in the blueprint:
$ cfy local init -p blueprint.yaml -i my-input-values.yaml \ --install-plugins
We are now ready to deploy our application, by running theinstallworkflow of the blueprint:
$ cfy local execute -w install --task-retries 10 \ --task-retry-interval 10
After a few minutes, we should get a message indicating that the workflow ended successfully:
2015-06-05 08:40:10 CFY <local> 'install' workflow execution succeeded
To check that the application is up and running, open a browser to the public IP specified in the blueprint:
$ open http://107.189.85.67
You should get the familiar welcome page ofngnix. You can also usevca-clito check the created VM and the NAT rules configured by the blueprint:
$ vca vmAvailable VMs in 'VDC1' for 'default' profile:| VM | vApp | Status | IPs | Networks | vCPUs | Memory (GB) | |--------+--------+------------+---------------+------------------------+---------+---------------+-| hellow | hellow | Powered on | 192.168.109.2 | default-routed-network | 3 | 2 | $ vca natNAT rules| Rule Id | Enabled | Type | Original IP | Original Port | Translated IP | Translated Port | Protocol | Applied On ||-----------+-----------+--------+---------------+-----------------+-----------------+-------------------+------------+--------------|| 65537 | True | SNAT | 192.168.109.2 | any | 107.189.85.67 | any | any | d3p4v54-ext || 65538 | True | DNAT | 107.189.85.67 | 22 | 192.168.109.2 | 22 | tcp | d3p4v54-ext || 65539 | True | DNAT | 107.189.85.67 | 80 | 192.168.109.2 | 80 | tcp | d3p4v54-ext |
Cleaning Up
When the time comes to tear down the application, just execute theuninstallworkflow of the blueprint:
$ cfy local execute -w uninstall[messages ommitted]CFY <local> 'uninstall' workflow execution succeeded
After the workflow ends, the provisioned VM will be deleted and the NAT rules created by theinstallworkflow will be also deleted, leaving your virtual datacenter in the same state as it was before.
Summary
Application orchestration represents a higher level of abstraction that is designed for automating deployments on the cloud. vCloud Air customers can now write application blueprints in TOSCA and deploy service templates using Cloudify and the plugin for vCloud.
If you’re ready to get started with the hybrid cloud, visitvCloud.VMware.com.
For future updates, follow us on Twitter and Facebook at@vCloudandFacebook.com/VMwarevCloud.
from vmwarenews.de , Original Post Here