VMware Cloud Community
vamsee83
Contributor
Contributor

Automating vSphere Blueprint creation in vCAC

Hi,

Is their any way i can automate the vSphere blueprint creation in vCAC? Through vCO or vCAC REST API's.

Please suggest any ideas.

0 Kudos
10 Replies
admin
Immortal
Immortal

Yes there is with the vCAC VCO plugin, but what exactly do you want to automate? I mean, what is the workflow that you have in mind for a user creating these automated blueprints?

0 Kudos
GrantOrchardVMw
Commander
Commander

I need a masterclass in vCO from you.... all I can see is the following (a few missing due to screen resolution):

pastedImage_0.png

I wouldn't expect to look in the vcaccafe class for this... right?

Grant

Grant http://grantorchard.com
0 Kudos
vamsee83
Contributor
Contributor

Hi,

This is the scenario in my mind, which I would like to automate.

1) create a vSphere blueprint, which will have build information with provisioning workflow "cloneWorkflow" providing the template and properties with custom build profiles and publish the blueprint. I'm looking for some workflow which can do this with all inputs from user OR if their is any API's which comes with vCO vCAC plugin i can use them and write a workflow.

2) After blueprint is created, I need to create a service and assign this as a catalog item and create a entitlement and assign this service to it. I think for this i can use workflow's which comes with vCO vCAC plugin.

For the first step i need to know the API's i need use or if their is any out-of-box workflow which can do it.

0 Kudos
dcornwell
Enthusiast
Enthusiast

I also have the need to create blueprints with vCO.  For two reasons:

1. configuration management - so I can re-create the system after a crash, and so I can replicate the dev system in test and in production

2. ease of use for me -- I am pre-createing dozens of very similar blueprints for this system, I want to be able to define them in an xml file and run a workflow to create the entities rather than toiling through the vCAC interface (lovely though it is.)

I have been able to create the blueprints from a vCO workflow.  The blueprints show up in the vCAC inventory, but fail in deployment.  I am revisiting which properties I defined.

Here is the code that  creates the blueprint:

var blueprintEntity = vCACEntityManager.createModelEntity(iaasHost.id, modelName, entitySetName, blueprintInputProperties, links, headers);

if( blueprintEntity != null) {

System.log("Created blueprint: " + blueprintName);

}

qc4vmware
Virtuoso
Virtuoso

It is in com.vmware.library.vcaccafe.request .  You will be requesting a catalog item which will in turn deploy the blueprint in the IaaS server.  This was the missing link.  Prior to the 6.0.1 plugin if you used the workflow for deploying a IaaS resource you couldn't manage it.  The mapping was never created so it wouldn't show up in your items list.  You could delete it and manage it at the reservation or compute resource level but not from the 6.x gui.

0 Kudos
vamsee83
Contributor
Contributor

Thanks dcornwell, that worked for me too.

But I'm seeing one more issue. Once we create the blueprint using createModelEntity() and published, Its showing up in vCAC UI cool. But, if we go to catalog management and try to assign that to a service, its not showing up in the list of catalogItems to select. Its weird. Let me know if you saw that and have a solution.

crepreoperty ---> properties of blueprint, providing all the properties.

var createdEntity= vCACEntityManager.createModelEntity(host.id, "ManagementModelEntities.svc", "VirtualMachineTemplates", creproperty, null);

0 Kudos
dcornwell
Enthusiast
Enthusiast

Still working on this?  I hadn't originally needed to access the blueprint inventory objects from the workflow, but now I am working on something where I need it.

The built-in workflow "Force Data Collection" will update the inventory, but it is an ansynchronous workflow.

I have tried telling vco to bypass the inventory service via the vco properties file, but it didn't help.

I am looking for a way to force data collection to be more frequent in vco via a system setting.  In the meantime, I am using the Force Data Collection workflow.

0 Kudos
AlexJudge
VMware Employee
VMware Employee

Resurrecting this thread as I'm trying to do the same thing, and I'm not getting very far... I'm not a developer so I'm having to learn some of this on the go.

My goal is to create new IaaS blueprints which link to vCenter template VMs. I need to do this in bulk on a regular basis.

I have a workflow with a single scriptable task that looks like this (all of the properties are being passed in via Input Parameters).

var blueprintInputProperties = new Properties()

blueprintInputProperties.put("virtualMachineTemplateName" , blueprintName);

blueprintInputProperties.put("virtualMachineTemplateDescription" , blueprintDesc);

blueprintInputProperties.put("expireDays" , expireDays);

blueprintInputProperties.put("leaseDays" , leaseDays);

blueprintInputProperties.put("enabled" , isEnabled);

blueprintInputProperties.put("memoryMB" , memoryMB);

blueprintInputProperties.put("diskSize0GB" , diskSize0);

blueprintInputProperties.put("cpuCount", cpuCount);

blueprintInputProperties.put("VirtualMachineName", vmName);

var links=null

var headers=null

var blueprintEntity = vCACEntityManager.createModelEntity(iaasHost.id,modelName,entitySetName,blueprintInputProperties,links,headers);

if(blueprintEntity!=null){

System.log("Created blueprint: ")+blueprintEntity;

}

This workflow will run and it doesn't produce any errors, however the log output is empty, and no blueprint gets created in vRA

[2015-05-14 18:04:59.600] [I] Created blueprint:

Can anyone point me in the right direction?

0 Kudos
rszymczak
Hot Shot
Hot Shot

Alex, you're on the right path.

I'll be working on this within the next weeks and let you guys know my findings. I already got a workflow which will clone a given vSphere blueprint and change some of the properties (around ~2000 lines of code - but I know it's possible) but yet I didn't have the need to create a new blueprint. This changed with my latest customer request. Will keep you posted.

0 Kudos
rszymczak
Hot Shot
Hot Shot

So it turns out that the best way to do it is using the vRA REST API and the vRO entityManager class for IAAS object creation. A good example and starting point, showing nearly everything you need, is provided within this package .

With some modifications I was able to rewrite the code (cleanup, simplify) and add features such as multi tenant support, linked clone creation and automatic publishing of created workflows. I can confirm that this method works and is stable.

Another way, but this needs revision, would be to use the IAAS APIs directly. As of vRA 6.1 they come with some API methods that allow you to create blueprints directly, documented at https://your-vra-iaas-server/WAPI/Help?pluginId=DynamicOps_6.1. In my tests I found that the VMware CloudClient CLI is using those APIs for blueprint creation.

Decrypting the SSL between the CloudClient and the IAAS appliance (that TLS1.2 DH cr** cost me hours of my lifetime) I was able to verify the process. However: authentication for this process is not documented and even after a hole day analysing the network traffic, reversing the code and writing some Java classes that would implement the RFC draft I had no working solution to generate / request the bearer token that is used for the requests to the IAAS component.

The best I was able to do was to spoof the token used by the CloudClient and reproduce the requests.

Seems like IAAS is using the very old 00 version of draft-ietf-oauth-v2-http-mac-00 - OAuth 2.0 Message Authentication Code (MAC) Tokens and some other propriatary fields that are not defined by the standard as of version 00 (so it's a mix between various DRAFT versions of the RFC)

I tried reaching out to the devs with no luck on this. So while the IAAS API would be the perfect fit to do this I ended up using the vRO EntityManager. I guess, given the fact how to authenticate with the IAAS API is not documented, this API should be considered "private" and not used. However I than don't understand why the API documentation is accessable at iaas-server/WAPI as besides of VMware I don't belive anyone on this planet is using it (which is probably better, looking at that auth. draft used there). This definitly lead atleast me into the wrong direction on this subject.

So, to conclude:

- You can do it

- Use vRO EntityManager for CRUD blueprint operations

- Use vRA REST API for catalog operations

Greets

Robert

0 Kudos