1 <?xml version="1.0" encoding="UTF-8"?>
2 <workflow xmlns="http://vmware.com/vco/workflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://vmware.com/vco/workflow http://vmware.com/vco/workflow/Workflow-v4.xsd" root-name="item0" object-name="Workflow:name=generic" id="B8808080808080808080808080808080C480808001231146624761b79546544c2" version="0.1.0" api-version="3.1.0" allowed-operations="fv" restartMode="1" resumeFromFailedMode="0">
3 <display-name>Wait for task and answer virtual machine question</display-name>
5 <description>Waits for a vCenter Server task to complete or for the virtual machine to ask a question. If the virtual machine requires an answer, accepts user input and answers the question.</description>
7 <position x="180.0" y="10.0"/>
10 <param name="vm" type="VC:VirtualMachine">
11 <description>Virtual machine for which the task runs</description>
13 <param name="task" type="VC:Task">
14 <description>Task to await</description>
18 <attrib name="questionText" type="string" read-only="false">
20 <description>Text of the question asked by the virtual machine</description>
22 <attrib name="questionAnswer" type="string" read-only="false">
24 <description>Selected answer</description>
26 <attrib name="questionText2" type="string" read-only="false">
28 <description>Text to prompt user choice</description>
30 <attrib name="answerList" type="Array/string" read-only="false">
31 <value encoded="n">__NULL__</value>
32 <description>List of possible answers</description>
34 <attrib name="questionId" type="string" read-only="false">
36 <description>Identifier of the question asked</description>
38 <attrib name="choiceList" type="Array/Any" read-only="false">
39 <value encoded="n">__NULL__</value>
40 <description>List of answer elements (IDs and texts)</description>
42 <attrib name="taskActionResult" type="Any" read-only="false">
43 <value encoded="n">__NULL__</value>
44 <description>Result of the task to await action</description>
46 <attrib name="progress" type="boolean" read-only="false">
47 <value encoded="n">true</value>
48 <description>Log progress while waiting for the task to complete</description>
50 <attrib name="pollRate" type="number" read-only="false">
51 <value encoded="n">1.0</value>
52 <description>Polling rate for the task state, in seconds</description>
54 <attrib name="timeoutDate" type="Date" read-only="false">
55 <value encoded="n">__NULL__</value>
56 <description>If not set to null, this input item waits until the specified date and continues the workflow run</description>
58 <workflow-note x="500.0" y="50.0" w="360.0" h="260.0">
64 <workflow-item name="item2" type="end" end-mode="0">
65 <position x="380.0" y="250.0"/>
68 <workflow-item name="item4" out-name="item5" type="input">
69 <display-name>Reply to VM</display-name>
72 <bind name="security.group" type="LdapGroup" explicitly-not-bound="true" export-name="NULL">
73 <description>Any user member of this security group will be authorized to answer this 'Input'</description>
75 <bind name="timeout.date" type="Date" export-name="timeoutDate">
76 <description>If not null, this input item will wait until date and will continue workflow execution.</description>
78 <bind name="questionText" type="string" export-name="questionText"/>
79 <bind name="questionText2" type="string" export-name="questionText2"/>
83 <bind name="questionAnswer" type="string" export-name="questionAnswer"/>
87 <desc>${questionText}</desc>
88 <p-param name="questionAnswer">
92 <p-qual kind="ognl" name="linkedEnumeration" type="Array/string">#answerList</p-qual>
93 <p-qual kind="static" name="mandatory" type="boolean">true</p-qual>
97 <position x="540.0" y="140.0"/>
100 <workflow-item name="item5" out-name="item3" type="task">
101 <display-name>Send answer to VM</display-name>
103 <script encoded="false">
104 // 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
106 for (i in choiceList) {
107 if (choiceList[i].label == questionAnswer){
108 theAnswer = choiceList[i].key;
109 System.log("Answer selected: " + choiceList[i].key + " (The text the user selected was: " + questionAnswer + ")");
114 vm.answerVM(questionId , theAnswer);
118 <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
119 <bind name="questionAnswer" type="string" export-name="questionAnswer"/>
120 <bind name="questionId" type="string" export-name="questionId"/>
121 <bind name="choiceList" type="Array/Any" export-name="choiceList"/>
122 <bind name="pollRate" type="number" export-name="pollRate"/>
127 <position x="540.0" y="200.0"/>
130 <workflow-item name="item6" out-name="item4" type="task">
131 <display-name>Set question text</display-name>
133 <script encoded="false">
134 // Set text to display in user interaction
135 var question = vm.runtime.question;
137 questionId = question.id;
139 questionText = question.text;
140 questionText2 = "Please choose: " + "\n";
142 // Set array of valid answers
143 choiceList=question.choice.choiceInfo;
144 // Set array of texts to display in presentation allowing user to choose response
145 answerList = new Array();
146 for (i in choiceList) {
147 answerList.push(choiceList[i].label);
152 <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
156 <bind name="questionText" type="string" export-name="questionText"/>
157 <bind name="questionText2" type="string" export-name="questionText2"/>
158 <bind name="answerList" type="Array/string" export-name="answerList"/>
159 <bind name="questionId" type="string" export-name="questionId"/>
160 <bind name="choiceList" type="Array/Any" export-name="choiceList"/>
163 <position x="540.0" y="80.0"/>
166 <workflow-item name="item0" out-name="item1" type="task" script-module="com.vmware.library.vc.basic/WaitTaskEndOrVMQuestion">
167 <display-name>WaitTaskEndOrVMQuestion</display-name>
169 <script encoded="false">
170 //Auto generated script, cannot be modified !
171 actionResult = System.getModule("com.vmware.library.vc.basic").WaitTaskEndOrVMQuestion(task,progress,pollRate,vm) ;
175 <bind name="task" type="VC:Task" export-name="task">
176 <description>Task to Wait for</description>
178 <bind name="progress" type="boolean" export-name="progress">
179 <description>Log progess while waiting for the task</description>
181 <bind name="pollRate" type="number" export-name="pollRate">
182 <description>Polling rate for the task state [seconds]</description>
184 <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
188 <bind name="actionResult" type="Any" export-name="taskActionResult"/>
192 Wait for a VC Task to end or for the VM to ask a question.
193 Return the task result or the question asked.
196 <position x="140.0" y="80.0"/>
199 <workflow-item name="item1" out-name="item6" type="custom-condition" alt-out-name="item2">
200 <display-name>VM Question?</display-name>
202 <script encoded="false">
203 if (taskActionResult instanceof VcVirtualMachineQuestionInfo){
212 <bind name="taskActionResult" type="Any" export-name="taskActionResult"/>
215 <position x="340.0" y="70.0"/>
218 <workflow-item name="item3" out-name="item2" type="task" script-module="com.vmware.library.vc.basic/vim3WaitTaskEnd">
219 <display-name>vim3WaitTaskEnd</display-name>
221 <script encoded="false">
222 //Auto generated script, cannot be modified !
223 actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,progress,pollRate) ;
227 <bind name="task" type="VC:Task" export-name="task">
228 <description>Task to Wait for</description>
230 <bind name="progress" type="boolean" export-name="progress">
231 <description>Log progess while waiting for the task</description>
233 <bind name="pollRate" type="number" export-name="pollRate">
234 <description>Polling rate for the task state [seconds]</description>
239 <bind name="actionResult" type="Any" export-name="taskActionResult"/>
243 Wait for a VC Task to end.
244 When task ended, return the task result if any.
247 <position x="540.0" y="260.0"/>
252 <desc>Virtual machine for which the task runs</desc>
254 <p-param name="task">
255 <desc>Task to await</desc>