I'd like to update/enable the Lease (days) and Archive (days) Property values of a Blueprint and not having much success using the out-of-the-box "Create / update property to blueprint" Workflow in vRO.... I'm thinking this either can't be done or I'm not using the correct Property Names. At this point, I was only able to locate the following Properties:
__Cafe.Request.VM.LeaseDays
__Cafe.Request.VM.ArchiveDays
I am trying to avoid having to edit all my Blueprints on individual basis and apply changes globally.
Thx. Ron
Hello Ron,
You're right, using Cloudclient is a bit excessive.
I tried to find a way to do it by code and I had some luck.
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 archiveDaysInput = 90;
var maxNumberOfInstancesInput = 1;
var leaseDaysMinValueInput = 1;
var leaseDaysMaxValueInput = 45;
var globalPropertiesToUpdateInput = [
{name: "prop1", value: "value1", encrypted: false, readOnly: false, visibility: true},
{name: "prop2", value: "value2", encrypted: false, readOnly: false, visibility: true}
];
// Global vars
var vcaccafeHost = Server.findAllForType("vCACCAFE:VCACHost")[0];
var blueprintService = vcaccafeHost.createCompositionClient().getCompositionCompositeBlueprintService();
// 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);
// Update Properties
var blueprintProps = serviceBlueprintToUpdate.getProperties();
if(archiveDaysInput !== null) {
blueprintProps._archiveDays = new vCACCAFEComponentFieldValue()
blueprintProps._archiveDays.addFacetValue("defaultValue", vCACCAFEUnspecifiedEvaluator.fromInt(archiveDaysInput))
}
if(maxNumberOfInstancesInput !== null) {
blueprintProps._number_of_instances = new vCACCAFEComponentFieldValue()
blueprintProps._number_of_instances.addFacetValue("maxValue", vCACCAFEUnspecifiedEvaluator.fromInt(maxNumberOfInstancesInput))
}
if(leaseDaysMinValueInput !== null && leaseDaysMaxValueInput !== null) {
blueprintProps._leaseDays = new vCACCAFEComponentFieldValue()
blueprintProps._leaseDays.addFacetValue("minValue", vCACCAFEUnspecifiedEvaluator.fromInt(leaseDaysMinValueInput))
blueprintProps._leaseDays.addFacetValue("maxValue", vCACCAFEUnspecifiedEvaluator.fromInt(leaseDaysMaxValueInput))
blueprintProps._leaseDays.addFacetValue("defaultValue", vCACCAFEUnspecifiedEvaluator.fromInt(leaseDaysMinValueInput))
}
for each(var prop in globalPropertiesToUpdateInput) {
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));
blueprintProps[prop.name] = customPropertyData;
}
serviceBlueprintToUpdate.setProperties(blueprintProps);
// 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.
Hi RonPSSC,
I'm not sure I understood your question.
Do you want to update lease/archive days of an already created Deployment (and its resources) or during the creation of the deployment from a blueprint ?
I worked recently on that complex subject. Maybe I can help you if you give more details.
Emmanuel.
Hi Ron,
Ok, can you edit Properties in the Deployment request (as in attachment properties) ?
If you can, just add _leaseDays and _archiveDays values.
I tried, and it's ok for me.
Attachment blueprint : definition of lease and archive
Attachment properties : add properties during request
Attachement result : you can see 5 days of lease and 3 days of archive (even if the definition had 60 days of archive and no lease)
If it's not working, I had problems when archive value was not defined or 0 in the blueprint, re-try with a positive value in the blueprint definition.
Personally, I'm not requesting blueprint directly, but I'm using XaaS Blueprint and request blueprint by code from a vRO workflow script with a JSON payload.
Emmanuel.
Hi Emmanuel;
Appreciate the feedback but it's not quite exactly what I'm looking to achieve. :smileygrin:
I was essentially looking to update/hard code these Settings in the same manner as though I was within the Design layer of vRA....and I wanted to do this through a vRO Workflow of sorts.
Your tip however is very interesting.. I was not aware you could actually override these particular Settings during the Deployment/Request phase...!! At this point however, we don't have a use case for this... Ideally as well, we really wouldn't want a User to change this type of Setting during a request since we are trying to standardize these Properties.
Again though, thanks for this.
Ron
Hello Ron,
Ok, I'm sorry I didn't understand you would like to permanently change this settings inside the blueprints.
I suppose you have a lot of blueprints and that's why you need to do it by code.
Did you think to export, edit then reimport all your blueprints using cloudclient command ?
It's what I use to export my blueprints from DEV env to PROD env. It's really usefull.
After you export your yaml blueprints, you can change lease and update (in all yaml files) then reimport all. It will override all blueprints with new values.
If you are interesting and need more details, let me know.
Emmanuel.
Oh my, Emmanuel, that's a lot of work to simply change the Properties of a Blueprint..!
Yes, you are correct, we have a lot of Blueprints but I'm afraid using CloudClient to export all, then update the YAML content before re-importing, seems awfully excessive..
Thx for replying back on this again but I'm hoping the rest of the VMware Community can provide a more practical/functional/automated way of doing this..
I honestly find it a little surprising that this can't be done using vRO today.....at least...nothing that I'm aware of..
Cheers. Ron
Hello Ron,
You're right, using Cloudclient is a bit excessive.
I tried to find a way to do it by code and I had some luck.
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 archiveDaysInput = 90;
var maxNumberOfInstancesInput = 1;
var leaseDaysMinValueInput = 1;
var leaseDaysMaxValueInput = 45;
var globalPropertiesToUpdateInput = [
{name: "prop1", value: "value1", encrypted: false, readOnly: false, visibility: true},
{name: "prop2", value: "value2", encrypted: false, readOnly: false, visibility: true}
];
// Global vars
var vcaccafeHost = Server.findAllForType("vCACCAFE:VCACHost")[0];
var blueprintService = vcaccafeHost.createCompositionClient().getCompositionCompositeBlueprintService();
// 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);
// Update Properties
var blueprintProps = serviceBlueprintToUpdate.getProperties();
if(archiveDaysInput !== null) {
blueprintProps._archiveDays = new vCACCAFEComponentFieldValue()
blueprintProps._archiveDays.addFacetValue("defaultValue", vCACCAFEUnspecifiedEvaluator.fromInt(archiveDaysInput))
}
if(maxNumberOfInstancesInput !== null) {
blueprintProps._number_of_instances = new vCACCAFEComponentFieldValue()
blueprintProps._number_of_instances.addFacetValue("maxValue", vCACCAFEUnspecifiedEvaluator.fromInt(maxNumberOfInstancesInput))
}
if(leaseDaysMinValueInput !== null && leaseDaysMaxValueInput !== null) {
blueprintProps._leaseDays = new vCACCAFEComponentFieldValue()
blueprintProps._leaseDays.addFacetValue("minValue", vCACCAFEUnspecifiedEvaluator.fromInt(leaseDaysMinValueInput))
blueprintProps._leaseDays.addFacetValue("maxValue", vCACCAFEUnspecifiedEvaluator.fromInt(leaseDaysMaxValueInput))
blueprintProps._leaseDays.addFacetValue("defaultValue", vCACCAFEUnspecifiedEvaluator.fromInt(leaseDaysMinValueInput))
}
for each(var prop in globalPropertiesToUpdateInput) {
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));
blueprintProps[prop.name] = customPropertyData;
}
serviceBlueprintToUpdate.setProperties(blueprintProps);
// 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.
Hi Emmanuel;
Apologize for not responding....have been severely taxed on other stuff..
Sincerely appreciate all the work you're doing here.. Your scripting here most likely works. I just haven't had time to look at yet.
Regrettably though, since I'm not a seasoned coder, I believe that in order to make this into a dynamic-type Workflow, I'm going to have to create a few Input Parameters that can be defined at the point of execution.
At this point though, I'm not really sure how I'd wrap these Inputs into the Workflow. Based on what I can see now, I'd say at minimum, the Properties below would need to be defined as Inputs?? The issue is, I'm not sure if any more would be required, such as, VCAC Host, etc.??
blueprintName
archiveDaysInput
maxNumberOfInstancesInput
leaseDaysMinValueInput
leaseDaysMaxValueInput
Thx. Ron
Hi Ron,
You're right for vCAC Host.
Either you add it as Input Parameters, else you can retrieve it as I do, by taking the first one.
But if you think that, you can have more than one, then you should definetly use Input parameters (type vCAC:VCACHost).
If you validate my previous answer, can you mark it as solved, please? It will help others looking for the right answer among all anwsers...
(In addition, I'll earn some points :-D)
Thank you, Emmanuel.
Thx so much, Emmanuel, for you help in resolving this issue!!
Your solution does, in fact, work..! ... (Incidentally, I needed to change the VCAC Host Input parameters to (type vCACCAFE:VCACHost) instead of (type vCAC:VCACHost) as suggested immediately above..
I'm going to push my luck a little further here and ask you whether there is a way we could Input an "Array/vCACCAFE:CompositeBlueprint" instead of the single/string "BlueprintName" parameter when executing the Workflow? I tried to change the Type and it bombs..
I've attached a Workflow I was able to create based on your Coding above. Understandably, very simplistic, but am hoping you could figure out how to allow an Array of Composite Blueprints from which I can select. This would definitely increase its value and use within our shop.
Thx again..
Ron
Hmmmmmm, I think something is amok, Emmanuel...??
Your latest Workflow doesn't appear to like the Array of Composite Blueprints or the blueprintName Input Parameters....either individually (on their own) or even together...?? (I tried both scenarios)....
Sorry I'm not sure what's wrong but what I am hoping to do is to simply browse the vcaccafeHost Inventory and select an array of Blueprints...(as little as 1 and as many as "all" of them).....without having to input a Blueprint Name (as a string).. Hope I'm making sense..??
I've captured 1 of the Error Logs below for your review....
[2018-06-01 12:47:10.357] [E] Error in (Workflow:Custom Update Archive and Lease Days Properies on Blueprint / Update Blueprints (item2)#28) 403
[2018-06-01 12:47:10.369] [E] Workflow execution stack:
***
item: 'Custom Update Archive and Lease Days Properies on Blueprint/item2', state: 'failed', business state: 'null', exception: '403 (Workflow:Custom Update Archive and Lease Days Properies on Blueprint / Update Blueprints (item2)#28)'
workflow: 'Custom Update Archive and Lease Days Properies on Blueprint' (bfd62d81-618b-4cbf-ba82-1f5addb0debd)
| 'attribute': name=vcaccafeHost type=vCACCAFE:VCACHost value=dunes://service.dunes.ch/CustomSDKObject?id='4980ec1e-ecd5-49cb-85e3-33ec1ddd1d45'&dunesName='vCACCAFE:VCACHost'
| 'input': name=compositeBlueprintListInput type=Array/vCACCAFE:CompositeBlueprint value=#{#vCACCAFE:CompositeBlueprint#dunes://service.dunes.ch/CustomSDKObject?id='40b0374e-a37a-428e-995f-16d0c5f3efe6/IAAS_Linux'&dunesName='vCACCAFE:CompositeBlueprint'#;#vCACCAFE:CompositeBlueprint#dunes://service.dunes.ch/CustomSDKObject?id='40b0374e-a37a-428e-995f-16d0c5f3efe6/IAAS_Windows'&dunesName='vCACCAFE:CompositeBlueprint'#}#
| 'input': name=archiveDaysInput type=number value=20.0
| 'input': name=leaseDaysMinValueInput type=number value=30.0
| 'input': name=leaseDaysMaxValueInput type=number value=40.0
| 'input': name=maxNumberOfInstancesInput type=number value=50.0
| 'input': name=blueprintName type=string value=IAAS
| 'no outputs'
*** End of execution stack.
Hi again, Emmanuel;
Have you had an opportunity to review my last comment and, if so, were you able to figure this one out...?
If not, and I hate to be a royal pain, but was hoping you could augment your latest Workflow by allowing the selection of an array of Blueprints from the vcaccafeHost Inventory.
At this point the latest Workflow does not appear to work with any Input selection. Your 1st Workflow runs great however for "individual" Blueprints.
Thx again... Ron