Press "Enter" to skip to content

Change VM vCPU Allocation vCO Flow then Imported to vCAC 6

Hey all,
As per my last post ive been doing a bit more with vCAC and vCO due to job requirements, and getting my head around vCO has been a little challanging There is some great information out there but just not enough to understand how to put particular flows together specially with scripting.

I will go through a test flow I did to get my head around managing VMs based on their properties like changing or adding resources etc. Then plug that into vCAC 6. So here goes me trying to explain this.

The below flow is a flow i created to just play around with VM services, the idea of this flow is to take a virtual machine and either increase or decrease the vCPU allocation taking into account hot add features. This can be expanded to work with many VM related changes but I chose vCPU as its something more likely to be used and had some complexity to it.
vcac01

1) Inputs
There are 3 inputs virtual machine name, number of vCPUs requested and polling
vcac02

2) Extract virtual machine information. This is an out of the box workflow you can search for the workflow or its located under vCenter -> virtual machine management -> others.
Below is the virtual binding which shows the inputs and outputs. For all the outputs I just used “create parameter/attribute in workflow” and accepted the defaults. The output on this flow all I needed was cpu count and could have set all the others to null.
vcac03

3) First decision, This is a custom decision under generic. The inputs I need is virtual machine, vCPU number requested and the current CPU count of the virtual machine.
The code I use under the scripting tab is:
if (vcpuNum > cpuCount)
{
return false;
}
else
{
return true;
}

vcac04
vcac05

4) We will follow the path down if the vCPU request is larger than the current assigned vCPU. The next decision we need to make is, is the VM powered on. This again is using a custom decision object, The only input is the virtual machine with the below code in the scripting tab.
return virtualmachineName.runtime.powerState.value == "poweredOff";
vcac06

5)If it comes back true and the vm is powered off we go straight into changeVMvCPU object this action is out of the box search for it and drag it onto the schema, the inputs are the virtual machine and the number of vCPUs the customer wants to set, and the output is a VC task which I left default as actionResult
vcac07

6)The next action object is the vim3waittaskend, which just waits for the previous task to end. The input is the task from the previous action. This fork in the flow is completed.
vcac08

7) Now we jump back up to the is the VM powered on and move onto the false branch meaning that the VM is powered on. So now we look to see if the VM supports hot add. The in parameter is the virtualmachine. The code under the scripting tab is as below:
System.log(virtualmachineName.config.cpuHotAddEnabled);
return virtualmachineName.config.cpuHotAddEnabled;

vcac09
vcac10

8) If the result is True we would jump back up to step 5 as we can just add vCPUs while the machine is powered on.

9) If the result is false and hot add vCPU is not supported or enabled we need to power down the virtual machine. For this we use the shutdownVMandForce which is an out of the box action item which will attempt to shutdown the guest OS and if it has not shutdown it will force a power off in 10min by default this number can be changed with the timeout parameter. The inputs are virtual machine, Polling and timeout. as per all action items the script under scripting tab can not be edited and is self generated.
vcac11

10) once the VM is shutdown we can change the vCPU allocation This is using the same action object as we used previously which is changeVMvCPU. the inputs are virtual machine, vCPU number to change too and the output is a task
vcac12

11) Now we wait for the task to finish with the action object vim3WaitTaskEnd with input as the task generated by the action item before it.
vcac13

12) Now we need to start the VM, This is down with the startVM action object and its only input is the Virtual machine.
vcac14

13) Now we jump all the way back to the first decision branch and if the vCPU number is smaller than the current allocated vCPU we need to shutdown as we cant hot remove. So we use the ShutdownVMandForce action object again. The inputs are the same as the others mentioned.
vcac15

14) Again we use the changeVMvCPU action object with the virtual machine and vCPU number as inputs.
vcac16

15) the rest of the the objects are identical to step 9 and down again.

16) Below are the Presentation settings I used I set the polling rate to 30s but I do not have this visible in vCAC.
vcac17
vcac18
vcac19

18) Now its time to debug, try all possible scenarios so that every branch in the flow is actioned. I will show one below. Hit the debug button and follow the prompt.
vcac20
vcac21

19) Now we want to add this into vCAC. I will not go through setting up Advanced services. This must be configured before continuing. We go to the Advance Services Tab -> blueprints and hit the green plus to add a new blueprint. Under the workflow tab we want to select the flow we just created.
vcac22

20) Now we enter in a name and description for the flow under the details tab.
vcac23

21) Now we make the form more presentable
vcac24

a) Change the virtual machine label and add a good description
vcac25

b)Change the vcpuNUM label and give it a description
vcac26

c)Change the Polling field to visible no
vcac27

Now thats all done publish this blueprint and add this catalog item to a groups service and entitlements.
Lets give it a run.
vcac28

vcac30

vcac31

Going through this helped me understand it a little bit more and get more or an understanding on what can be done with very little scripting.

Cheers

2 Comments

  1. Tom
    Tom June 13, 2014

    Wonderfully detailed, thank you! My only hangup was during validation – vim3WaitTaskEnd asked for progress:boolean (I set to NULL?) and pollRate:number (I set to input:polling?)
    I simplified the first decision tree too – if vCPU is smaller, after shutdown point it to the changeVMvCPU after the next decision.
    THANKS!

    • Scott Norris
      Scott Norris June 14, 2014

      Hi Tom glad you got something out of the post., Simplifying the tree is a great idea, might change mine too 🙂

      Yes for the vim3WaitTaskEnd I set progress to NULL too and I should have set pollRate as polling since I did set it, but completely forgot and had it as NULL as well. PollRate has a default setting or interval which by setting polling you can change. You definitely set it right.

      Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti SPAM BOT Question * Time limit is exhausted. Please reload CAPTCHA.