How to use Reservation Policy to place VMDKs across different datastores

Reservation policy is often unused feature and to some extend not fully understood. Primary reason could be that reservation policy creation process very simple and during policy creation we don’t glue pieces together. That being said there are very valid use cases for using reservation policy and comes very handy in VM Placement. One of the core principles of Software Defined Datacenter (SDDC) suggests we need to have policy based automation and common management platform across the entire infrastructure.

With reservation policy we address this requirement. It is my personal belief that features in any products are aimed to solve some or other business problems. All we should attempt is to find those relevant business case or help someone find them. In this blog I aim for later.

Continue here

vCloud Automation Center 6.0 and vCenter Orchestrator Advance Automation -Part03

Part1, Part2 are simple in some ways & parts. Next part is bit difficult to understand. At least it was for me. I will explain what I’m going to do at high level. I’ll get Machine Name. Then I will get Machine Property –> Machine Property will give me custom property ( VM Size which  user be selecting from drop down menu as referred here and Backup Selection referred here ) finally I will Invoke VCO workflow.  In this workflow which needs VM Name input and VM Size, Backup Choice as input – I will put VM Name which I get from Get Machine Name property and VM Size, Backup choice which I got from Get Machine Property

image_thumb1

Now lets find where to do this and how to do this. Once you understand the basic concept it is way too simple. First open vCAC designer. In that first select load and then select “WFStubMachineProvisioned”. Why “WFStubMachineProvisioned”. Well, this workflow is called immediately when the status of VM is provisioned. More information is available in http://pubs.vmware.com/vCAC-60/topic/com.vmware.ICbase/PDF/vcloud-automation-center-60-extensibility.pdf guide

image_thumb8

 

image_thumb12

In below screen double click on “Machine Provisioned

image_thumb14

Scroll down till you find custom code and double click on the custom code

image_thumb16

From left hand side “DynamicOps.Cdk.Activities” Drag “GetMachineName

SNAGHTML10b7be85_thumb3

 

I have defined two variable for this custom code

  1. vmname (to capture VM Name)
  2. VMSize (to capture VM size e.g. Large, Medium and Small in string format)
  3. VarBackupOption (To capture user selection Yes/No in string format)

SNAGHTML10b93f29_thumb3

Double click on GetMachineName

image_thumb31

In Machine Id field put a pre-defined variable “VirtualMachineId”. This is standard value. Please do not change it. Under machine name put the variable vmname. This variable we have defined above.

Machine Name will pickup name from virtualmachineid and pass it to vmname. Finally variable vmname will hold the name of the vm. We are done with GetMachineName.

Click on the custom code as shown in above figure, it will take you back to custom code screen. Now from left hand side ”DynamicOps.Cdk.Activities” Drag “GetMachineProperty

image_thumb35

GetMachineProperty reads the custom property you have defined and the value associated with that property in vCAC. In our case I have defined custom property with name VMSize and it’s value will come from value select from drop down menu. This value (e.g. Large, Medium or Small) will be taken by variable VMSize

image_thumb42

You will notice VMSize property name is in Quotes however Property Value is without quotes. It is because VMSize in property value is variable which will be captured from user interaction in vCAC and VMSize in property name is coming from custom property defined in vCAC.

Conceptually this is how it is related

image_thumb45

 

I repeated the same procedure for Backup choice and here is how it looks below

image

VarBackupOption will hold the user selection string value which would be either Yes or No and pass it to vCO workflow

Now we have Virtual machine name captured in VMName variable, VMSize captured in VMSize variable and BackupOption capture in VarBackupOption we are ready for next drag and drop Smile . Drag vCO workflow by name InvokeVcoWorkflow

Simply put VMName and VMSize as input to VCO workflow.

image

 

Now below is how entire workflow looks like

image_thumb52

Now you are done with, simple Send and that updates the WFStubMachineProvisioned

image_thumb56

This is all you need to do. Request Virtual Machine and you will get what you have configured.

Complete log of VM provisioning via vCAC and VCO is presented below with sequence of action.

image

vCloud Automation Center 6.0 and vCenter Orchestrator Advance Automation -Part02

If you have reached this post from Google, check this post first. That is where problem is discussed and this the second part of the solution. First thing you need is to pass three information from vCAC i.e. VM Name, Size of the VM and whether you need any backup. VM Name is parameter you will get from vCAC but for Backup Selection and VM Size selection I have created a custom property in build profile. Here is how I have created below

First go to infrastructure tab

In Infrastructure tab go to –> Blueprint –> Property Dictionary

image

Create a New Property Definition

Provide Name –VMSize

Display Name –Virtual Machine Size

Control Type – DropDownList

Please ensure Required check box is selected

Once done please click on green arrow.

Then click on Edit to edit Property Attributes

image

In the property attribute, select ValueList, Put same name “VM Sizes” and provide value as Large, Medium and Small which reflect the size of VM.

image

Similar exercise you follow for backup option

Here is how it looks when user selects the VM Size

image

For backup service selection this is how it looks below

image

Just ensure blueprint is updated as follows

image

This completes vCenter Automation Part at basic Level. Now comes the 3rd and final part. Follow third part here

vCloud Automation Center 6.0 and vCenter Orchestrator Advance Automation -Part01

This post is about extending vCAC in-built workflows. In last two post (Post1, Post2) I used vCenter Orchestrator (vCO) workflows and executed them using vCloud Automation Center’s (vCAC) advance service designer. It was like taking vCAC as front end to execute those workflows without taking any benefits of vCloud Automation Center’s product. vCAC was purely acting as front end.

Advance service designer doesn’t follow any reservation, policies configured for a particular tenant. It is purely taking inputs from whatever is configured in vCenter Orchestrator workflow and executing it. As I think of it is of help but then I miss all configuration, tracking ownership, multi-tenancy and metering in built in vCAC. In order to cover this I need to do additional scripting which is referred as day-2 operation. To cater this problem, vCAC provides you a way where you can modify in-built workflows. Basic details are provided into this document. I won’t repeat it here. But in order to understand this post you must read it.

To extend workflow you need vCAC designer. It is part of vCAC and can be downloaded from https://vCACAppliance.hostname.com:5480/installer/. Install it. (it is next-next-next-Finish thing).

Problem Statement

User should be able to provision VM by selecting VM size within vCAC interface. Users should be able to understand what compute, storage details are provisioned when they select VM Size.

Here I’m going to modify my existing workflow which I created in post here. If you see the workflow there are three inputs needed

1. VM name

2. VM size

3. IP Address for the VM

If you review this post, 3rd point is automatically taken care. So I have to just focus on how to take two input (VM Name and VM Size) from vCAC and put in the vCO workflow. It was bit simple, just two inputs.

Cloning part will be taken care by vCAC but post provisioning task will be taken care by vCO workflow. So we need to only focus on creating a vCO workflow which will do the following

  1. Changing CPU count
  2. Change RAM
  3. Add Disk
  4. Add Backup Network if selected

If you execute this workflow from vCO or vCenter  VC:VirtualMachine as input is needed. But vCAC do not understand VC:VirtualMachine, it can only understand string input or can provide string output.  VC:VirtualMachine input is referred as complex object type. In order to deal with this input we need to put a wrapper around the workflow. How to put a wrapper around a workflow is explained by VCOTEAM.INFO. Thanks to this post. It is key post.

That post is a where you can start but that isn’t sufficient. You need more. If you refer below return type is array.

image

We need a VC:VirtualMachine as return type. I added script section and then I have created a new parameter with VC:VirtualMachine type with name as vm01 (referred in below screen)

image

In the first line of the script I converted array type i.e. Array/VC:VirtualMachine into VC:VirtualMachine and sent that as output. This is the core piece. If you understood this, you don’t need worry further. Everything else is straight forward. I thought so Winking smile

When I executed the VCO workflow from vCAC, it failed twice. First it failed with VMware tools not working and second time it failed with error “Hot add functionality” is disabled in VM.

First problem was when the provisioning activity was completed, my next workflow which was to shutdown the VM graceful was looking for VMware tools, it didn’t found vmware tools and abruptly failed. In order to shutdown VM gracefully VMware tools must be ready. So to address first problem I have to find a workflow which will check if VMware tools are ready. This can be easily checked by using “vim3WaitToolsStarted” action element. This workflow waits for VMware tools to be ready, as it is need to graceful shutdown VM.

Second problem was workflow didn’t wait for another workflow to be completed. After I shutdown VMs I have workflow which will change CPU count, then change RAM, Add Disk and finally powered ON the VM. So powered ON workflow didn’t wait to execute CPU count, Add Disk and RAM change workflow.  Therefore I use to get error about Hotplug not supported. It was like VM was started before even CPU and RAM change could be executed. So to solve this problem I added “vim3WaitTaskEnd” in-built workflow. This workflow checks previous tasks before executing next task.

With this additional work my final workflow was ready and shown below

image

NB: Except for the script section, everything in vCenter Orchestrator is in-built

Now next part is how to make vCAC to pick this VCO. I have discussed in next post here

Adding Backup vNetwork card in Bulk using vCenter Orchestrator

Last week I was given task to create a vCO workflow which will allow L1 sysadmins to add a network card to all VMs. I was arguing why not use Powershell? Powershell script was ready in minutes. IT manager was not comfortable with script as his experience were not good in the past and above all this task must be done by L1 during non-business hours. It should be easily executed by them.

I did took his point where in Level-1 won’t have sufficient knowledge to troubleshoot or understand the powershell script. But my point was workflow will take some time as I didn’t saw any built in workflow for it.

I started to search a better way to do it. simplest way was to use Onyx. Onyx didn’t  proved much of help here. Script given by Onyx is not at all workable. I spent lot of my time in understanding it. And some Google search. It wasn’t easy for me.

I took a powershell out from Onyx and started working on it. It gave me fare bit of idea how it should be achieved.

image

I have designed Workflow which could be seen above. In the workflow I first searched all the VMs in particular resource pool. You can search in the Custer, folder or other places. After I got the VMs, I have to add them network card. Since I’m expected to get more than one VM, I get all VMs in an array. To go through each VM, I used foreach loop.That is all.

User interface below only asks Level –I to select resource pool. Inside the resource pool all VMs will be added with additional network card.

image

In my case I selected TESTVMs resource pool as seen below

image

Press Submit and Booom, network cards are attached as seen below

image

Let me explain you the script. If you don’t read my comments go to the bottom of this post to download the script.


var managedObject = VM;<- VM is Virtual machine to which you wish to add network card
var spec = new VcVirtualMachineConfigSpec();<- You need to initialized virtual machine configuration spec
var myDeviceChange = new Array(); <- you also need to initialized a array to hold all changes.
var myVirtualMachineNICCard = new VcVirtualE1000(); <- you need to initialized  VcVirtualE1000 network card and below you fill all the required values
var configSpec = new VcVirtualDeviceConfigSpec(); <- initialized virtual machine device configuration specification

myVirtualMachineNICCard.key = 0;
myVirtualMachineNICCard.backing = new VcVirtualEthernetCardNetworkBackingInfo();
<- initialized virtual machine network backing information
myVirtualMachineNICCard.backing.deviceName = “VM Network”;
myVirtualMachineNICCard.connectable = new VcVirtualDeviceConnectInfo();
<- initialized virtual machine connectable information
myVirtualMachineNICCard.connectable.startConnected = true;
myVirtualMachineNICCard.connectable.allowGuestControl = true;
myVirtualMachineNICCard.connectable.connected = true;
myVirtualMachineNICCard.addressType = “generated”;
myVirtualMachineNICCard.wakeOnLanEnabled = true;
configSpec.operation = VcVirtualDeviceConfigSpecOperation.add;
<-since we want to add the network card, we use add
configSpec.device = myVirtualMachineNICCard
myDeviceChange.push(configSpec)
spec.deviceChange = myDeviceChange
managedObject.reconfigVM_Task(spec)


Script is the most difficult part for this post. I tried my best to explain it. Hope it helps you all.

I also took opportunity to update my previous post and now workflow looks as shown below. User gets option to select backup network. In order to implement it I used decision workflow. If user has selected Backup Network required as Yes, then green line will be followed where network card will be added and next workflow will be executed. If he says No, add backup network workflow is skipped and next workflow is followed.

image

image

Hope it helps.

Anyone want to use or modify this script can download it from here.

And modified workflow can be downloaded from here

Service Provisioning using vCenter Orchestrator (vCO)

I think we are living in the most dynamic time of our life. I have done good number of post on vCAC and want to do more. My plan is to focus on vCAC is to do with VMware Certified Design Expert – Cloud (VCDX-Cloud). It is long long journey. See here the amount work Derek has to put to get there

But this time I don’t want to focus on install and config ones. Main component of vCAC is its extensibility which is referred as XaaS in the document. You can only achieve it when you have some background in scripting and keen to develop new things. It is predicated that every infrastructure administrator must have some scripting and or developers skills to survive in IT in next decade. One of the link which support this is http://it20.info/2014/01/vchs-meets-vco-and-boris-becomes-a-hero/

I loving solving problems and while working in operations team it is the primary thing we do. But then optimize it, do it effectively, Do more with less where the constant instructions from the management. I fortunately got introduced to PowerShell quite early. I’m glad I know little bit of it. I did good amount of scripting on PowerShell. I use to blog about it here. But with self-service provisioning, agility attributes of cloud computing I realized this skill is not sufficient. You need to know a how to orchestrator thing. With PowerShell this is possible but it increases code complexity and also it becomes very difficult to maintain and update the code every time environment changes.

I’m working on the project where I have to provide an end user option to provision VM with different SLA e.g. Gold, Silver and Bronze. User should be able to select VM as per SLA. User should be made aware of what comes with Gold, Silver and Bronze VMs. User must be able to select whether he wish to backup his VM.

Here is how I have crudely defined Gold, Silver and Bronze Services

image

Lets now focus on how to allow user to select these VMs.

vCO  have lot of built-in workflow. For this exercise lets use in-built one. It is well suited for our objective.

Let me define workflow. Workflows consist of a schema, attributes, and parameters. Schema is nothing but actual program or script (If I may call ). Attributes are something we pre-define like declaring variables right at the top of the script. Parameters are of two types. Input and out parameters. Input parameters are where user input is needed or some form of input is needed. Output parameter is result of execution of workflow.

I have duplicated three workflows based on inbuilt workflow by name “create simple virtual machine”.

image

Renamed them as Gold VM, Silver VM and Bronze VM as seen below. This is pretty basic.

image

Now the challenge was how to invoke these workflows when user selects services he needs. I created a new workflow by name Coca cola services. Inside this I created an input parameter by name Services. Since we want end user to select services, I have to change the presentation for the input parameter in the form of drop down list. Go to the presentation tab, select Services and select blue triangle and select the Properties as Predefined answers. In Predefined answers Insert Values as Gold, Silver and Bronze

image

This will create a drop down menu from which user can select the service . Now I have to initiate the action based on user selection. e.g. If users selects Gold, I want Gold VM workflow to be initiated or if user selects Silver, I want Silver VM workflow to be initiated and similar for bronze. This can be achieved in workflow by using decision.

Since user input defined are string parameter, In decision I have selected Services if it Gold – it is True condition.

image

Drag decision into this place as shown/ Below is the complete workflow schema

image

Here you have simple Go-No-go kind of workflow. I have defined here if you see Gold, please Go and initiate GOLD VM 1.1 workflow. If you see No-go, I have dragged and dropped another decision and there I have defined if you get from user Silver request, Go for silver VM 1.1 workflow and again for No-go, I have dropped another decision, here for bronze I have requested to execute Bronze VM 1.1 workflow.

If you know little bit of scripting this is as simple as below. And if you look at the workflow it is reflecting similar picture

 ServiceWorkflow

So if you know the workflow elements, it makes things much easier. If you know scripting you will understand how much pain has been reduced by vCO. Thanks vCO team for this.

So this covers the service tiering. Now the next portion is of allowing user to select backup.

This was bit difficult for me to construct at surface.Got hold of vCenter Orchestrator Book and there I got a hint. I have to modify default workflow. Since we need to give user an option to select Backup. So when user selects he wants backup I want to add additional network and that network card must get attached to Backup port group. Logic is quite simple here, User selects the Radio button (yes/no), if says Yes, I wrote a this code to additional network card.

   1:  //Add Backup Network
   2:  if(

BackupVM

==true){
   3:  deviceConfigSpec = System.getModule("com.VMware.library.vc.vm.spec.config.device").createVirtualEthernetCardNetworkConfigSpec(

vmBackupNetwork

);
   4:  deviceConfigSpecs[ii++] = deviceConfigSpec;
   5:  }

Don’t worry much about this code. Just worry about the variables here.

1) BackupVM is input variable which I have defined, and defined it as Boolean type. If User select Yes, it will create VM network

2) vmBackupNetwork is an attribute I have defined in each workflow (Gold VM1.1, Silver1.1 & Bronze1.1) which will always attach itself to backup network as shown below

image

After you save, validate workflow below Presentation screen is seen. This is just a workflow. We need to get this executed from vCloud Automation Center. Let me keep this for next post.

image