VMware Cloud Community
uncle_meat
Contributor
Contributor

How to dynamically set vCAC Custom Properties.

Hello,

Currently in vCAC 6.0, to manage the deployment of VMs into different networks / environments, I am using multiple Blueprints.

Production, Development, and Test are the three environments. These correspond to a single Network Name, Network Profile, and vCenter Folder. I have tried using the method outlined in the following article: vCloud Automation Center – vCAC 5.1 – Creating Relational Drop Down Fields — Dai.... However, this obviously results in having a bunch of drop down boxes in the Catalog Item request form, which is undesirable.

All I need to do is set the following properties based on a single drop down box option:

VirtualMachine.Network0.ProfileName

VirtualMachine.Network0.Name

VMware.VirtualCenter.Folder

For example; if the requester selects 'Production' from the 'Environment' drop down box, then the value for Network Profile Name is 'vCAC Production', Network Name is 'vCAC Production', and the Folder is '/VRM/Prod/'.

Thanks

Reply
0 Kudos
12 Replies
pwmiller
Enthusiast
Enthusiast

To be honest, I'm going through this right now. I have both good and bad news: It's possible to do this, but it's really hard unless you already have experience with vCenter Orchestrator (vCO) or already are quite familiar with javascript.

So: you're going to have to look into product extensibility through vCO (the preferred, but poorly documented method today) to do this sort of thing. Your steps:

  • If you've got the appliance configured and are using the embedded vCO (not recommended for production configurations), use this, otherwise, export the .dar for the vCAC plugin from that embedded vCO and import it into a standalone vCO appliance. You'll probably want to add some of the other .dar files too (AD plugin, powershell, REST, AMQP, SOAP, vCenter Server, etc...) Currently, it seems that VMware has not yet released the vCAC plugin that matches the 6.0.x version embedded in the vCAC appliance. The 5.2 version is released, but is not current - use the documentation from this.
  • Configure vCO for extensibility. The best documentation I've found is here: http://portal.sliderocket.com/vmware/vCAC-extensibility-package. Understand that you're not going to be using the "Advanced Service Designer" but using the IaaS extensibility components (because setting NetworkN.ProfileName is an IaaS construct). 
  • You should extend the buildingmachine workflow stub, and set the name of your VirtualMachine.NetworkN.ProfileName when the machine is building. You may also find that you need to set the network in vSphere because despite setting the VirtualMachine.NetworkN.ProfileName, vCAC doesn't actually like set the network properly. vCO fortunately has workflows to change the network of a VM. I'll update you on what I had to do to make this work after I take a closer look at my vCO scripts tomorrow...
  • Be aware that some properties are not going to work 'the way you think they should' (such as machine naming, memory sizing, cpu sizing, disk sizing) and require changes to the vCAC provisioning model when using the buildingmachine stub. To do this, your best bet is to follow something like this: http://www.vcoteam.info/articles/learn-vco/269-working-with-vcloud-automation-center-infrastructure-.... Further, you will not be able to hide certain properties despite the value of the 'isHidden' parameter (see my other thread about hiding the selectors for #CPUs, Memory in the provisioning). 

Of course, getting support on vCO will be nearly impossible, since VMware will not help troubleshoot your vCO scripts. I'd recommend staying as close as possible to vanilla IaaS provisioning as you can.

Have fun - it's not nearly as scary as I've made it out to be, but be prepared for some frustrations while you get this closer to working.

uncle_meat
Contributor
Contributor

Thanks for that answer. It's looking like it will be better to stick with multiple blueprints for the time being. It's simply too unintuitive, and not documented well enough (as far as I can see). For example, when assigning a vCO workflow to a blueprint's virtual machine state change, how do you know what variables are parsed to that vCO workflow?

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso

There is a sample workflow which shows all of the parameters that are passed in by default and one example of how you can pass in another value by virtue of a naming convention.  I ended up writing a small action that returns all the extended properties along with some other information not directly passed in as parameters but you can easily retrieve it since they do pass in the vCAC:VirtualMachine .  The sample is located at vCloud Automation Center\Extensibility\Workflow template .

Reply
0 Kudos
uncle_meat
Contributor
Contributor

Yeah, but for some reason, I haven't been able to retrieve any custom properties (ENV and OS) through vCO. Perhaps it's just me not correctly understanding how to do it, but I haven't been able to find any useful documentation or examples. The following is what I have written and thought would work.

if (vCACVmProperties.get('ENV') == 'prod') {

  NetworkName = 'vCAC Production';

  Folder = '\\VRM\\Prod\\';

} else if (vCACVmProperties.get('ENV') == 'dev') {

  NetworkName = 'vCAC Development';

  Folder = '\\VRM\\Dev\\';

} else if (vCACVmProperties.get('ENV') == 'test') {

  NetworkName = 'vCAC Test';

  Folder = '\\VRM\\Test\\';

}

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity(vCACHost,virtualMachineEntity,'VirtualMachine.Network0.Name',NetworkName);

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity(vCACHost,virtualMachineEntity,'VirtualMachine.Network0.ProfileName',NetworkName);

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity(vCACHost,virtualMachineEntity,'VMware.VirtualCenter.Folder',Folder);

I have assigned this to my blueprint using the 'Assign a state change workflow to a blueprint and its virtual machines' workflow. It does not work, and I can't figure out how I can trouble shoot this, I assume that vCACVmProperties.get('ENV') is returning nothing, and therefore the 'NetworkName' and 'Folder' are not being set.

Reply
0 Kudos
Techstarts
Expert
Expert

For example, when assigning a vCO workflow to a blueprint's virtual machine state change, how do you know what variables are parsed to that vCO workflow?

I can answer above question

Have a look at these posts.

1) http://vzare.com/2014/03/18/vcloud-automation-center-6-0-and-vcenter-orchestrator-advance-automation...

2) Setting the Machine Name of a vCAC-provisioned VM to comply with a Corporate Standard – Pa...

Hope it helps

Preetam Zare

vZare.com

With Great Regards,
Reply
0 Kudos
uncle_meat
Contributor
Contributor

Thanks Preetam, qc4vmware already answered that question for me. I am now just having problems getting any custom variables.

Reply
0 Kudos
chrisheartland
Enthusiast
Enthusiast

Did you ever get this to work? Your script looks ok for the most part. If it's not working I would make the single quotes ' into double quotes ". That's what I do for all of my javascripting. Also, to see what your variable it being set to, do System.debug(variable);

That will at least tell you if you're variable is "something" or null.

I checked some of my code. I know for a fact this works in my environment:

var classification = vCACVmProperties.get("Custom.EnvType");

if (classification.search("prod") > -1)

     {

          NetworkName = "vCAC Production";

     }

Reply
0 Kudos
uncle_meat
Contributor
Contributor

Not in the way that I wanted to - I ended up keeping vCAC simple, and using vCO for any functionality similar this.

Reply
0 Kudos
chrisheartland
Enthusiast
Enthusiast

Oh ok. If you have the time and need see if my code works for you. I'm interested to find out.

Reply
0 Kudos
zebduin
Enthusiast
Enthusiast

I may have understood the original question, but if you are asking how would someone retrieve the string value of a custom property that they created in vCAC, I can help with that.

For instance - if I wanted to install roles and features based on vCAC input, I would create custom properties such as:

Install.IIS

Install.dotNet

I could present these choices via a checkbox via the property dictionary, and in vCO I could use a decision item where

To be able to pass the custom properties I mentioned above and declare as a variable I would use the commands shown below:

pastedImage_0.png

Reply
0 Kudos
uncle_meat
Contributor
Contributor

Thanks vjDuBB, but this isn't actually what I was asking.

Reply
0 Kudos
AntLeguy
Enthusiast
Enthusiast

Hello,

With the extensibility package comes an action called "addUpdatePropertyFromVirtualMachineEntity" and this is what you want !

You just need to provide :

-the vCACHost

-the vCACEntity (which you can get by yourVCACVM.getEntity() )

-the propertyName

-the propertyValue

-4 booleans : isHidden,isRuntime, isEncrypted,doNotUpdate

I tested it, it works,

Hope it helps Smiley Wink

Reply
0 Kudos