VMware Cloud Community
marcdevin
Contributor
Contributor

vCAC 6.1 - how to retrieve VCACCAFE item ID during MachineProvisioned step using vCenter Orchestrator extension

Hello VMware community,

I have a question regarding vCAC 6.1 provisioning extension using vCenter Orchestrator.

During MachineProvisioned workflow (ExternalWFStubs.MachineProvisioned), I can manipulate VCAC:VirtualMachine which corresponds to the VM object in the IaaS part of vCloud Automation Center.

Actually I would like to retrieve the ID of the VCACCAFE:VirtualMachine (ResourceId of the item in the vCAC CAFE portal).

I try to retrieve the CatalogResource using:

vCACCAFEEntitiesFinder.findCatalogResources(host, vmHostname).

But it seems that the vCACCAFE object is not available until the end of the MachineProvisioned workflow.

Is there another way to retrieve the VCACCAFE VM id at the MachineProvisioned step ?

Thanks a lot for your help,

Regards

Tags (3)
Reply
0 Kudos
11 Replies
sbeaver
Leadership
Leadership

Would you be looking for this by chance?

var machineId = vCACVm.virtualMachineID

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
marcdevin
Contributor
Contributor

Hello thanks for reply.

Unfortunatly this is not the ID I am looking for.

This one is the ID of the vCAC:VirtualMachine (IaaS object).

I am looking for the ID of the vCACCAFE:Resource (vCACCAFE object) of type "Virtual Machine" binded to the vCAC:VirtualMachine (IaaS object).

Regards.

Reply
0 Kudos
SeanKohler
Expert
Expert

Yeah... it is a catalog resource.  The resource type just happens to be of type "Virtual Machine". (through resourceTypeRef property which has a composite object id/label)  This distinction is important...

So you have to get your vcacCafe:CatalogResource object and then run the .getId() method on it.  I don't think the workflow runner supplies this object when it runs the MachineProvisioned.  (if it does, then you should be able to assign it to an input and run it)  It is no matter.  It does supply the VC:VirtualMachine...

SCRIPT INPUTS

vCACCAFE:VCACHost cafeHost

VC:VirtualMachine vcVm

SCRIPT

var stringName = vcVm.name;

//Get the resource using the vRO plugin inventory method with a CAFE plugin filter on name for CatalogResource
//Would probably be an array of one.
var myResources = Server.findAllForType("VCACCAFE:CatalogResource",stringName);


for each (resource in myResources){
//In this loop, resource is your object of VCACCafe:CatalogResource

if (resource.getName() == stringName){
  System.log(resource.getName());
  System.log(resource.getId());  // If this truly is all you need

  //Operations?
  var resourceOperations = resource.getOperations();
  for each (operation in resourceOperations){
   System.log("? " + operation.getName());
  }
  System.log("Nope... not going to find any, but... ");

  // Differences between execution objects and source objects
  System.log("When you GET the object by ID through the entities finder...");
  System.log("And your Plugin Service Account has permissions in the business group to see resource operations...");
  resourceTarget = vCACCAFEEntitiesFinder.getCatalogResource(cafeHost,resource.getId());
  System.log(resourceTarget.getName());
  for each (operation in resourceTarget.getOperations()){
   System.log(operation.getName());
  }
}
}

marcdevin
Contributor
Contributor

Hello,

Thanks a lot for your help.

This is basically what I try to do in the Machine Provisionned step.

But the issue is that myResources is empty at this stage of the provisioning process.

If I re-execute this code after the server is provisionned (Status "On" in "CAFE Items" tab), then it returns an array of 1 CatalogResource of type "Virtual Machine"...

Unfortunatly I would really need to get this ID during provisionning process.

Regards.

Reply
0 Kudos
SeanKohler
Expert
Expert

Oh.... you are on 6.1.  Yeah that is bug.  We had the same thing happen. You really need to get to 6.2.1 minimum, if you can.  There area lot of enhancements you are missing.

Hi,

I made a mistake here.  The resource item isn't available during the machine provisioned stub.  It isn't available until later in the IaaS workflow process.  I went back and looked at our notes, and we were missing the VC:VirtualMachine object in 6.1 MP stub.  When we upgraded, it fixed that problem.  Apologies for the misinformation.

Reply
0 Kudos
marcdevin
Contributor
Contributor

Oh... I wish it could exist an easier way than upgraded vCAC...

Anyway, I set your answer as "correct" even if I am not able to verify Smiley Happy

Reply
0 Kudos
SeanKohler
Expert
Expert

Well this is what I would recommend.

Put in a long sleep counter into MachineProvisioned.

Manually refresh the VCAC portion of the vRO (VCO) plugin over and over and see if your object becomes available at some point (in the Items folder).  See if it also has an ID represented there.

If it does become available, note the time it took to become available from the point MachineProvisioned started.  And if it does eventually become available, set your machine provisioned to loop until it is available and then continue.

Use a...

try{

     //get vcaccafe resource

     } catch(error){

          //log could not get it

          //sleep

     }

so that your MachineProvisioned doesn't bomb out on looking for the resource.  Loop that try/catch over and over until it does get the resource or some number of iterations (representing a period of time) is hit.

If it doesn't become available... well...  you need to upgrade.

Reply
0 Kudos
marcdevin
Contributor
Contributor

Unfortunatly after more than half an hour in Machine Provision workflow, there is still no CatalogResource object...

Thanks for your help.

Reply
0 Kudos
SeanKohler
Expert
Expert

Bah... that is unfortunate. Sorry to hear that as I had hopes that it would work.

Upgrade.  Come visit us in 6.2 land.  All of your dreams will come true!  Smiley Happy  Make sure you are running vRO 6.x.

Reply
0 Kudos
marcdevin
Contributor
Contributor

Ok thanks for the check.

So as a conclusion, it is impossible to retrieve this CatalogResource object during vRO provision workflow extension...

Regards.

Reply
0 Kudos
SeanKohler
Expert
Expert

Yes.  The Resource isn't created at that point.  (Again my apologies for the misinformation.)

There may be a way at the end of the Machine Provisioned stub to run an Async workflow that kicks off the work you want to do against that resource item.

End of page one in this discussion...

Can't set lease with ASD

Reply
0 Kudos