VMware Cloud Community
vSteveR
Contributor
Contributor

waittaskendorvmquestion

Hi, I'm looking for some help with a workflow. It's simple enough, adding a VM to the inventory and powering on. The machine is a replica though so there's a user interaction presented when the workflow runs (copied below). Either the "Wait for task and answer virtual machine question" element or the "waittaskendorvmquestion" action should do it but I could do with some help setting them up please (the task specifically). Has anyone used these before or created a simliar WF that could provide some advice please?

Thanks and regards

Steve

pastedImage_0.png

0 Kudos
3 Replies
qc4vmware
Virtuoso
Virtuoso

There are a couple of ways you can deal with this.  You can either change a setting in the template which will force cloned vm's to always create or change the uuid or you can modify the workflow to remove the user interaction and just make what you want to do an input or just force the behavior you want.  Here is some code that would do it.

var uuidAction = "change"; // this will either be set to "change" or "keep" depending on what you want to do

var configSpec = new VcVirtualMachineConfigSpec();

var extraConfig = vm.config.extraConfig;

var newConfig = new Array();

var addIt = true;

System.log("\nScanning Extra Config:");

for each (var config in extraConfig) {

System.log("\t" + config.key + ":" + config.value + ":" + config.required);

if (config.key == "uuid.action") {

System.log("Found uuid.action setting: " + config.value + ". Will update key");

config.value = uuidAction;

addIt = false;

}

newConfig.push(config);

}

if (addIt) {

System.log("uuid.action config not detected.  Adding...");

var uuidConfig = extraConfig[0];

uuidConfig.key = "uuid.action";

uuidConfig.value = uuidAction;

newConfig.push(uuidConfig);

}

configSpec.extraConfig = newConfig;

System.log("Reconfiguring VM...");

var reconfigTask = vm.reconfigVM_Task(configSpec);

System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(reconfigTask,1,10);

System.log("Reconfig complete!");

vSteveR
Contributor
Contributor

Hi and thanks for the response, apologies for the delay in getting back to you. I would prefer to remove the user interaction and force the setting. I'll do some more testing with this later and update.

Thanks again

Steve

0 Kudos
vSteveR
Contributor
Contributor

I was able to achieve my desired result by removing the user interaction and setting the answer manually. I kept the "set question" scriptable task, removed the user interaction and modified the code in the "Send answer to VM". I used the code below for anyone interested:

// The user has selected a response, now we need to convert it back from the label to the key because the answerVM requires the key

var theAnswer;

        theAnswer = choiceList[1].key;

        System.log("Answer selected: "  + choiceList[1].key + " (The text the user selected was: " + theAnswer + ")");

vm.answerVM(questionId , theAnswer);

0 Kudos