mercoledì 9 aprile 2014

VMware: Automate OpenStack vApp deployment using PowerCLI

For those who wants to try OpenStack on VMware vSphere without struggling with GIT pulls and manual file edit the OpenStack Team at VMware provides the VOVA, (Vsphere Openstack Virtual Appliance) an Ubuntu virtual machine which comes with OpenStack Havana pre-installed and pre-configured to run on vSphere. To be clear this is not the entire OpenStack's stack, this comprises Nova, Glance, Cinder, and Keystone but according to the official community on VMTN there's the possibility to bring in another stack component like Neutron. This one will  require VMware NSX though.

OpenStack on vSphere requires though some infrastructure configurations in order to work, this is not the simple deploy the ova file and everything works. An initial setup must be performed in order to successfully deploy the VOVA.

Let's start by linking the official OpenStack on vSphere documentation in which you will find all instructions for a correct deployment as well as the link for downloading the OpenStack virtual appliance.

As official documentation states we will work with two different clusters: a management cluster where the VOVA vApp will be deployed and one or more OpenStack clusters. These clusters will be managed by OpenStack to deploy instances in. As best practice DRS will be enabled in both clusters and will be set in fully automated mode.

At least two datastores are also required: one, presented only to ESXi hosts belonging to management cluster, in which VOVA will be deployed and one, or preferably more, presented to all ESXi hosts in the OpenStack clusters that will be used by instances.

Networking-side some changes must be implemented: a new vSwitch with a private br100 PortGroup will be created on hosts in both OpenStack and management cluster. This PortGroup will be used by all OpenStack instances as well as by VOVA that will have NICs associated to different PortGroups: one on the br100 PortGroup forwarding packets received on that interface towards the outside network and vice-versa while the other on classic VM Network PortGroup to communicate with the rest of the network.

This is a logical schema giving an idea on how the environment should be configured:



Since some work is required in order to successfully use OpenStack on vSphere why not to automate its deployment using PowerCLI?

The following script:

-Connects to a vCenter Server
-Creates a Datacenter
-Creates two clusters: a Management and an OpenStack one
-Adds ESXi hosts to both clusters
-Configures ESXi hosts networking creating a vSwitch1 and a br100 PortGroup
-Deploys the OpenStack virtual appliance in one host belonging to the management cluster
-Configures OpenStack virtual appliance editing OVF Environment
-Starts up OpenStack and points user's browser to starting page

Here's how the final result will look like from vCenter:



This is the PowerCLI code, as usual you can find it also in my GitHub repository. Automate OpenStack vApp Deployment.ps1



The code is pretty well commented but some parts requires a further clarification:

 Import-vApp -VMHost $MgmtHosts[0] -Source $SourceFilePath -Datastore $InstallDatastore -DiskStorageFormat $DiskFormat -Force:$true  

imports a vApp in ova or ovf format to a designated ESXi host and datastore. DiskStorageFormat parameter is used to select how the vApp will be deployed in the datastore (Thin, Thick Lazy or Thick Eager).

The following code is used to edit OVF environment properties for the vApp since once deployed it needs to be configured in order to work properly.

These are the properties defined in VOVA:

 <PropertySection>  
    <Property oe:key="vami.DNS.VOVA" oe:value=""/>  
    <Property oe:key="vami.gateway.VOVA" oe:value=""/>  
    <Property oe:key="vami.ip0.VOVA" oe:value=""/>  
    <Property oe:key="vami.netmask0.VOVA" oe:value=""/>  
    <Property oe:key="vm.vmname" oe:value="VOVA"/>  
    <Property oe:key="vmware.cluster_name" oe:value=""/>  
    <Property oe:key="vmware.datacenter_name" oe:value=""/>  
    <Property oe:key="vmware.datastore_regex" oe:value=""/>  
    <Property oe:key="vmware.host_ip" oe:value=""/>  
    <Property oe:key="vmware.host_port" oe:value=""/>  
    <Property oe:key="vmware.password" oe:value=""/>  
    <Property oe:key="vmware.username" oe:value=""/>  
 </PropertySection>  

Credit for the code snippet goes to Alan Renouf .In his article Alan explains how to automate LogInsight vApp deployment by changing OVF environment properties using PowerCLI.

 $VirtualMachineConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec  
 $VirtualMachineConfigSpec.vAppConfig = New-Object VMware.Vim.VmConfigSpec  
 $VirtualMachineConfigSpec.vAppConfig.property = New-Object VMware.Vim.VAppPropertySpec[] (x)  
 $VirtualMachineConfigSpec.vAppConfig.property[x] = New-Object VMware.Vim.VAppPropertySpec  
 $VirtualMachineConfigSpec.vAppConfig.property[x].operation = "edit"  
 $VirtualMachineConfigSpec.vAppConfig.property[x].info = New-Object VMware.Vim.VAppPropertyInfo  
 $VirtualMachineConfigSpec.vAppConfig.property[x].info.key = "Integer Key"  
 $VirtualMachineConfigSpec.vAppConfig.property[x].info.value = "Value"  
 $Reconfig = $appVOVA.ExtensionData  
 $Configtask = $Reconfig.ReconfigVM_Task($VirtualMachineConfigSpec)  

After the deployment your browser will be pointed to OpenStack console and you should see something similar to this:



Username is demo while password is vmware.

To create a new instance go to Instances



Launch Instance, select availability zone, instance name, flavor i.e. the "size" of the instance, instance boot source and finally the image to deploy. By default VOVA comprises a Debian image ready to be deployed.



Instance should take a few minutes to start the first time because VOVA will copy Debian image in one OpenStack managed datastore, subsequent deployments will be faster since files are already there.





Root privileges on deployed instances as well as in VOVA console can be accessed using root as username and vmware as password.

That's all!!

2 commenti:

  1. Very interesting + well explained post.

    One correction: VOVA is not just Nova, it actually includes Glance, Cinder, and Keystone (i.e., most of the core OpenStack services). VOVA does not currently include Neutron and instead relies on nova-network, as this allows users to setup OpenStack without requiring VMware NSX, which is a prerequisite for Neutron with vSphere.

    RispondiElimina
  2. Thanks dan for your comment, really appreciated.
    I fix the inaccuracy in the post above.
    Thank you!! :)

    RispondiElimina