I am using code for all day 2 operations on a vm. Destroy/Power on etc. However, the scale-in function does not seem to work for me.
I i get the operations for the deployment like this .. but it does not execute a scale in. any ideas ?
var form = vCACCAFERequestsHelper.getRequestFormForResourceAction(operation);
System.log("Expected inputs:");
var fields = vCACCAFERequestsHelper.getFormKeys(form);
System.log(fields.length);
for each (var field in fields) {
System.log( " - " + field);
}
System.log("Creating scale in request...");
var request = vCACCAFERequestsHelper.requestResourceAction(operation, form);
System.log("Scale in request submitted.");
System.log("request.stateName: " + request.stateName);
System.log("request.executionStatus: " + request.executionStatus.value());
I suspect the high view count vs. no reply thus far is because you have posted something many people are interested in, but very few have accomplished ... Well, I have this working in class I teach internally and to partners... While I'm not going to provide my entire workflow, I'll provide the most critical piece that you appear to need and that is the bit of code that actually submits the scale operation to vRA. This code can scale-in OR scale-out a deployment - the differentiating factor is what is provided for the inputs.
var myvCACCAFELiteralMap = new vCACCAFELiteralMap()
myvCACCAFELiteralMap.put("_cluster", new vCACCAFEIntegerLiteral(clusterNodeCount));
typeFilter = BlueprintId + "*" + componentId;
var myvCACCAFEComplexLiteral = new vCACCAFEComplexLiteral(
componentTypeId,
null,
classId,
typeFilter,
myvCACCAFELiteralMap);
props = new Properties();
props.put(("provider-" + componentId), myvCACCAFEComplexLiteral);
1st Screenshot: Bindings for Prepare Properties scriptable task
2nd Screenshot: Bindings for requestResourceAction action
3rd Screenshot: Inputs to Submit to vRA workflow
Input notes:
(In my hints above, the virtualMachineProperties object is a properties object that was created using the getVirtualMachineProperties action from one of the dailyhypervisor.com packages.)
Your overall workflow should gather the necessary inputs to provide to this one. The one bit that I haven't figured out (due to lack of motivation and/or need) is how to find (via API of course) the Min/Max instances of a Component in the Blueprint.
Wondering if i am not clear with my question. Many views but no responses. Any ideas will be much appreciated.
Folks, anybody has ever coded vro call vra to scale-in/scale-out a deployment ?
I suspect the high view count vs. no reply thus far is because you have posted something many people are interested in, but very few have accomplished ... Well, I have this working in class I teach internally and to partners... While I'm not going to provide my entire workflow, I'll provide the most critical piece that you appear to need and that is the bit of code that actually submits the scale operation to vRA. This code can scale-in OR scale-out a deployment - the differentiating factor is what is provided for the inputs.
var myvCACCAFELiteralMap = new vCACCAFELiteralMap()
myvCACCAFELiteralMap.put("_cluster", new vCACCAFEIntegerLiteral(clusterNodeCount));
typeFilter = BlueprintId + "*" + componentId;
var myvCACCAFEComplexLiteral = new vCACCAFEComplexLiteral(
componentTypeId,
null,
classId,
typeFilter,
myvCACCAFELiteralMap);
props = new Properties();
props.put(("provider-" + componentId), myvCACCAFEComplexLiteral);
1st Screenshot: Bindings for Prepare Properties scriptable task
2nd Screenshot: Bindings for requestResourceAction action
3rd Screenshot: Inputs to Submit to vRA workflow
Input notes:
(In my hints above, the virtualMachineProperties object is a properties object that was created using the getVirtualMachineProperties action from one of the dailyhypervisor.com packages.)
Your overall workflow should gather the necessary inputs to provide to this one. The one bit that I haven't figured out (due to lack of motivation and/or need) is how to find (via API of course) the Min/Max instances of a Component in the Blueprint.
Thank you , it looks great and i appreciate your response.
Wonder in the docs where you managed to find it .. but i will try that now and let you know.
thanks much
One of my colleagues just posted a step-by-step blog article on the topic of Auto-Scaling - I suspect the code I shared here is likely to be part of the workflow package he includes in the article: Auto-Scale VMware vRA Workloads with NSX, vRO and vRealize Automation
Thank you , but your colleague did not post any code. He just posted the idea; which is the same thing i am trying to solve.
Thank you again and it seems the code should be working..
here is what i have now. (see below) on the first run it fails .. it can not get the "propsin.machine.properties"
directly from ebs.. however, if i execute the workflow again, it works fine. So i assume code is good, just not
able to get propsin right away. Wonder if it's a bug or something else.
instanceNumber--;
System.log(" Scaling in to " + instanceNumber + " VMs");
var myvCACCAFELiteralMap = new vCACCAFELiteralMap();
myvCACCAFELiteralMap.put("_cluster", new vCACCAFEIntegerLiteral(instanceNumber));
sleep (10);
System.log ("Trying to get the BluePrint ID");
var blueprintId = propsin.machine.properties['VirtualMachine.Cafe.Blueprint.Id'];
System.log("BlueprintID: " + blueprintId);
typeFilter = blueprintId + "*" + propsin.componentId;
System.log("TypeFilter: " + typeFilter);
var myvCACCAFEComplexLiteral = new vCACCAFEComplexLiteral(
propsin.componentTypeId,
null,
'Blueprint.Node',
typeFilter,
myvCACCAFELiteralMap);
props = new Properties();
props.put(("provider-" + propsin.componentId), myvCACCAFEComplexLiteral);
awesome job . it works great ! thank you