VMware Cloud Community
Subnet88
Enthusiast
Enthusiast
Jump to solution

Modify vApp startup order

I am able to retrieve a vApp's startup order using the following code, but am at a loss on how to set the startup info. Any guidance would be greatly appeciated

var ID = new Array();
var order= new Array();
var StartAction = new Array();
var StartDelay = new Array();
var StopAction = new Array();
var StopDelay = new Array();
var WaitForTools= new Array();
var StartupSection = vApp.getStartUpSection();
ItemList = StartupSection.item.enumerate();
for (var i in ItemList) {
vm = ItemList[i]
for (var k in vm) {
}
ID.push(vm.id)
order.push(vm.order)
StartAction.push(vm.startAction)
StartDelay.push(vm.startDelay)
StopAction.push(vm.stopAction)
StopDelay.push(vm.stopDelay)
WaitForTools.push(vm.waitingForGuest)
}

0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

None if wavemaker abstract the gui part. If it was web views then entering values for different type of inputs in an array is not user friendly.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

0 Kudos
9 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Here is a sample code.

vApp.updateInternalState();

var startupSection = vApp.getStartUpSection();

for each (var item in startupSection.item) {
    System.log("Checking startup configuration for vApp " + vApp.name  + ", VM " + item.id);

    if (startAction != null && startAction !="" && item.startAction != startAction) {
        System.log("Configuration change on vApp " + vApp.name + ", VM " + item.id + " - Changing start action from " + item.startAction + " to " + startAction);
        Server.log("Configuration change on vApp " + vApp.name + ", VM " + item.id , "Changing start action from " + item.startAction + " to " + startAction);
        item.startAction = startAction;
    }

    if (startDelay != null && item.startDelay != startDelay) {
        System.log("Configuration change on vApp " + vApp.name + ", VM " + item.id + " - Changing start delay from " + item.startDelay+ " seconds to " + startDelay + " seconds");
        Server.log("Configuration change on vApp " + vApp.name + ", VM " + item.id , "Changing start delay from " + item.startDelay + " seconds to " + startDelay + " seconds");
        item.startDelay = startDelay;
    }

    if (stopAction != null && stopAction !="" && item.stopAction != stopAction) {
        System.log("Configuration change on vApp " + vApp.name + ", VM " + item.id + " - Changing stop action from " + item.stopAction + " to " + stopAction);
        Server.log("Configuration change on vApp " + vApp.name + ", VM " + item.id , "Changing stop action from " + item.stopAction + " to " + stopAction);
        item.stopAction = stopAction;
    }
       
    if (stopDelay != null && item.stopDelay != stopDelay) {
        System.log("Configuration change on vApp " + vApp.name + ", VM " + item.id + " - Changing stop delay from " + item.stopDelay + " seconds to " + stopDelay + " seconds");
        Server.log("Configuration change on vApp " + vApp.name + ", VM " + item.id , "Changing stop delay from " + item.stopDelay + " seconds to " + stopDelay + " seconds");
        item.stopDelay = stopDelay;
    }

    if (item.waitingForGuest != waitingForGuest) {
        System.log("Configuration change on vApp " + vApp.name + ", VM " + item.id + " - Changing waitForGuest from " + item.waitingForGuest + " to " + waitingForGuest );
        Server.log("Configuration change on vApp " + vApp.name + ", VM " + item.id , "Changing waitForGuest from " + item.waitingForGuest + " to " + waitingForGuest);
        item.waitingForGuest = waitingForGuest;
    }               
}

vApp.updateSection(startupSection);

startAction is a strings ("powerOn", "none")

stopAction is a strings ("guestShutdown", "powerOff").

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I have just realized this was for the 1.0 relaese of the plug-in. You may need to use

startupSection.item.enumerate();

As you did.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

The example you have provided is fine if I want to set all vms to the same values, but what if I want to change the startup order?  This would have to be an input for each vm, with an undetermined amount of vms in the vapp.

Which is where I have no idea how to proceed.

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Then you must have a rule to determine in which order to start them depending on name / attribute right ?

Or is the goal to have as many inputs as vms ?

In this case since vCO does not support dynamic presentations you will need to create as many input fields as the vApp may contain and show hide them based on the number of VMs in the vApp (you will need to create an action for that). You may also need to call an action getting the name of the VM in place of the presentation label (then I would need to provide you the syntax to call the action within the presentation - I do not have an example at hand ATM).

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

Would it work to create an array of strings as the input, with each item in th array containing all of the info for the specific vm that it will be modifying?

then performing a split(,) on the array item, and building the Object Map from that?

ie:

array[0]=vm,2,powerOn,0.0,powerOff,0.0,true

array[1]=testvm,1,powerOn,0.0,powerOff,0.0,true

where vm=name, 2=Startup Order, PowerOn = StartupAction, 0.0 = Startupdelay, powerOff = StopAction, 0.0 = Stopdelay. true = WaitforTools

vApp.updateInternalState();
var StartupSection = vApp.getStartUpSection();
ItemList = StartupSection.item.enumerate();
System.log("There are "+ItemList.length+" Items in the var ItemList")
for (var i in ItemList) {
vm = ItemList[i]
System.log("There are "+Array.length+" items in the input Array")
for (var m in Array){
ArrayLine = Array[m];
CurrentArray = ArrayLine.split(",");  // Split the array into smaller arrays line by line
System.log(CurrentArray[0])
if(CurrentArray[0] = vm.id) {  //This is because vm.id == the vm Name in vcd
System.log("Virtual Machine "+CurrentArray[0]+" Found. Modifying startup parameters");
System.log("Setting Startup Order of Virtual Machine "+CurrentArray[0]+" to "+CurrentArray[1]);
vm.order = CurrentArray[1];
System.log("Setting Startup Action of Virtual Machine "+CurrentArray[0]+" to "+CurrentArray[2]);
vm.startAction= CurrentArray[2]
System.log("Setting Startup Delay of Virtual Machine "+CurrentArray[0]+" to "+CurrentArray[3]);
vm.startDelay =CurrentArray[3]
System.log("Setting Stop Action of Virtual Machine "+CurrentArray[0]+" to "+CurrentArray[4]);
vm.stopAction = CurrentArray[4]
System.log("Setting Stop Delay of Virtual Machine "+CurrentArray[0]+" to "+CurrentArray[5]);
vm.stopDelay = CurrentArray[5]
System.log("Setting Wai For vmware Tools property of Virtual Machine "+CurrentArray[0]+" to "+CurrentArray[6]);
if (CurrentArray[6] == "true") {
vm.waitingForGuest = true;
}
else if(CurrentArray[6] == "false") {
vm.waitingForGuest = false;
}
}
}
}
vApp.updateSection(StartupSection);

Updated with mostly working code

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

It would work but is this a end user facing workflow or not ?

If so this cause some usability issues.

If not you may want to use a Properties() as input instead of an array. The properties object gives you a list of key value so it is easier to manipulate than the array.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

This will be for an end user facing workflow, abstracted by a Wavemaker GUI. What usability issues do you foresee?

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

None if wavemaker abstract the gui part. If it was web views then entering values for different type of inputs in an array is not user friendly.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

The code above works almost perfectly, however the waitingForGuest property does not change.   Any ideas?

0 Kudos