Hey,
I have few custom properties on my blueprint, what I'm trying to do, is to get them in one of my stubs.
I managed to get the CatalogResource of the deployment, but can't find any way to get the properties.
Does anyone have an idea how to do so?
Thanks,
Yev Berman
Here are some good blog posts on dealing with the information.
http://www.thevirtualist.org/vra-event-broker-pass-basic-custom-properties-vro/
and also some sample templates
Event Broker Workflow Templates - Samples - VMware {code}
I include this code in a scriptable task at the start of our blueprint deployment event subscriptions. Pretty sure its taken directly from the samples I linked above:
//Collect info from payload input
lifecycleState = payload.get("lifecycleState");
componentId = payload.get("componentId");
blueprintName = payload.get("blueprintName");
componentTypeId = payload.get("componentTypeId");
machine = payload.get("machine");
machineProperties= machine.get("properties");
requestId = payload.get("requestId");
endpointId = payload.get("endpointId");
//COLLECT vRA INFO TO USE IN LOGGING
System.log("------List Properties------");
System.log("requestId: " + requestId);
System.log("machine.id: " + machine.get("id"))
System.log("machine.name: " + machine.get("name"))
System.log("machine.type: " + machine.get("type"))
System.log("machine.owner: " + machine.get("owner"))
System.log("machine.externalReference: " + machine.get("externalReference"))
System.log("lifecycleState.event: " + lifecycleState.get("event"))
System.log("lifecycleState.phase: " + lifecycleState.get("phase"))
System.log("lifecycleState.state: " + lifecycleState.get("state"))
System.log("componentId: " + componentId);
System.log("blueprintName: " + blueprintName );
System.log("componentTypeId: " + componentTypeId);
System.log("endpointId: " + endpointId);
vmName = machine.get("name");
//Collect vRA VM properties from VM Entity
var properties = new Properties();
properties.put("VirtualMachineID", machine.get("id"));
virtualMachineEntity = vCACEntityManager.readModelEntity(host.id, "ManagementModelEntities.svc", "VirtualMachines", properties, null);
var vCACVm = virtualMachineEntity.getInventoryObject();
//Get vCenter object if required
var moRef = machine.get("externalReference");
if (moRef != null) {
var vCenterVm = System.getModule("com.qualcomm.basic").QCgetvCenterVmFromvCACVm(vCACVm);
if (!vCenterVm) {
System.log("No vCenter object exists yet");
}
else {
System.debug("Found matching vCenterVm: " + vCenterVm.name);
}
}
vmProperties = new Properties();
var virtualMachinePropertiesEntities = virtualMachineEntity.getLink(host, "VirtualMachineProperties");
for each (var virtualMachinePropertiesEntity in virtualMachinePropertiesEntities) {
var propertyName = virtualMachinePropertiesEntity.getProperty("PropertyName");
var propertyValue = virtualMachinePropertiesEntity.getProperty("PropertyValue");
System.debug("Found property " + propertyName + " = " + propertyValue);
vmProperties.put(propertyName, propertyValue);
}
getting Error as host not defined - for this i have added new attribute, to point VCAC:VCACHOST
and now getting error as
at line 32 : java.lang.NullPointerException
Hope you to set the host in the attribute. Please verify the value by add this line.
System.debug(" Host : "+host);