Is there any way to update the Properties (Property Groups and Custom) on a vSphere (vCenter) Machine Type in a vRA Blueprint using vRO?
Since I'm unable to locate any Inventory Element associated with a vSphere Machine Type in vRO, I'm not sure if this can be done.
I believe the vRA Property Name that I'm trying to target using vRO is VirtualMachine.Cafe.Blueprint.Component.Id
Thx. Ron
Yes, you'll just use the addUpdatePropertyFromVirtualMachineEntity action.
Sincerely appreciate the input and am hoping you can clarify your suggestion of using the addUpdatePropertyFromVirtualMachineEntity Action a little further if you can.
This Action element relies on a virtualmachineEntity (vCAC:Entity) as an "input" parameter. How do I locate or equate a value of this type from a Blueprint Property such as a VirtualMachine.Cafe.Blueprint.Component.Id?? I am trying to update properties of a vSphere Component in a vRA Blueprint (as opposed to an already-provisioned VM) so that I can potentially make global changes via vRO Workflows instead of having to edit all my Blueprints and apply the same Custom properties to each and every machine type within my Blueprints.
Hope I'm making sense...Maybe I'm missing something which is why I'll need a little extra help..
Thx again..
Ron
Ah, my mistake, I just misunderstood what you were after. For updating custom properties on a blueprint itself, that I'm not so sure about.
@RonPSSC, did you ever figure out how to do this? I am facing the same challenge.
How can I update the value of a vRA Blueprint custom property , using vRO?
Thanks!
Hello Ron,
Here is some code that can update a blueprint from vRO Workflow Script. Tell me if it's working for you.
// Inputs for update Blueprint
var blueprintName = "BP-IAAS";
var vSpherePropertiesToUpdateInput = [
{name: "propVSphere1", value: "propVSphere1", encrypted: false, readOnly: false, visibility: true},
{name: "propVSphere2", value: "propVSphere2", encrypted: false, readOnly: false, visibility: true}
];
var vSpherePropertyGroupsToUpdateInput = ["Event Subscription Properties Group"]
// Global vars
var vcaccafeHost = Server.findAllForType("vCACCAFE:VCACHost")[0];
var blueprintService = vcaccafeHost.createCompositionClient().getCompositionCompositeBlueprintService();
// Retrieve Id of Property Groups
var vSpherePropertyGroupsIds = [];
var propertyGroups = vCACCAFEEntitiesFinder.getPropertyGroups(vcaccafeHost);
for each(var propertyGroup in propertyGroups) {
var propertyGroupName = propertyGroup.getName();
var propertyGroupId = propertyGroup.getId();
for each(var name in vSpherePropertyGroupsToUpdateInput) {
if(name.toLowerCase() == propertyGroupName.toLowerCase()) {
System.debug("Add Property Group " + propertyGroup.getName());
vSpherePropertyGroupsIds.push(propertyGroupId);
break;
}
}
}
// Search Composite Blueprint
var filter = new Array();
filter[0] = vCACCAFEFilterParam.equal("name", vCACCAFEFilterParam.string(blueprintName));
var odataQuery = vCACCAFEOdataQuery.query().addFilter(filter);
var pageOdataRequest = new vCACCAFEPageOdataRequest(odataQuery) ;
var compositeBlueprints = blueprintService.getBlueprints(pageOdataRequest).getContent();
if(compositeBlueprints.length === 1) {
var serviceBlueprintToUpdate = blueprintService.getBlueprint(compositeBlueprints[0].id);
var components = serviceBlueprintToUpdate.getComponents();
for each(key in components.keys){
var component = components.get(key); // Type : vCACCAFEComponentDeclaration
if(component.type == "Infrastructure.CatalogItem.Machine.Virtual.vSphere") {
var customPropertyData = new vCACCAFEComponentFieldValue();
for each(var prop in vSpherePropertiesToUpdateInput) {
var customPropertyData = new vCACCAFEComponentFieldValue();
customPropertyData.addFacetValue("defaultValue", vCACCAFEConstantValue.fromString(prop.value));
customPropertyData.addFacetValue("encrypted", vCACCAFEConstantValue.fromBoolean(prop.encrypted));
customPropertyData.addFacetValue("readOnly", vCACCAFEConstantValue.fromBoolean(prop.readOnly));
customPropertyData.addFacetValue("visibility", vCACCAFEConstantValue.fromBoolean(prop.visibility));
component.addComponentFieldValue(prop.name, customPropertyData);
}
component.setPropertyGroups(vSpherePropertyGroupsIds);
}
}
// Update blueprint
blueprintService.createOrUpdateBlueprint(serviceBlueprintToUpdate);
System.log("Update composite blueprint with name '" + serviceBlueprintToUpdate.name + "' successfull");
} else if(compositeBlueprints.length > 1) {
var errorMsg = "More than one composite blueprint with name '" + blueprintName + "' found! Can't manage it.";
for each(var blueprint in compositeBlueprints) {
System.error("Found composite blueprint with name '" + blueprint.getName() + "'");
}
System.error(errorMsg);
throw errorMsg;
} else {
System.warn("No composite blueprint to publish with name '" + blueprintName + "'");
}
Emmanuel.