første endring registrert
[virt-orchestrator.git] / vFLOWER / content / Workflows / Library / vCenter / Virtual Machine management / Basic / Wait for task and answer virtual machine question.workflow.xml
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>
4
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>
6
7     <position x="180.0" y="10.0"/>
8
9     <input>
10         <param name="vm" type="VC:VirtualMachine">
11             <description>Virtual machine for which the task runs</description>
12         </param>
13         <param name="task" type="VC:Task">
14             <description>Task to await</description>
15         </param>
16     </input>
17
18     <attrib name="questionText" type="string" read-only="false">
19         <value encoded="n"/>
20         <description>Text of the question asked by the virtual machine</description>
21     </attrib>
22     <attrib name="questionAnswer" type="string" read-only="false">
23         <value encoded="n"/>
24         <description>Selected answer</description>
25     </attrib>
26     <attrib name="questionText2" type="string" read-only="false">
27         <value encoded="n"/>
28         <description>Text to prompt user choice</description>
29     </attrib>
30     <attrib name="answerList" type="Array/string" read-only="false">
31         <value encoded="n">__NULL__</value>
32         <description>List of possible answers</description>
33     </attrib>
34     <attrib name="questionId" type="string" read-only="false">
35         <value encoded="n"/>
36         <description>Identifier of the question asked</description>
37     </attrib>
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>
41     </attrib>
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>
45     </attrib>
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>
49     </attrib>
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>
53     </attrib>
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>
57     </attrib>
58     <workflow-note x="500.0" y="50.0" w="360.0" h="260.0">
59         <description>
60 VM requires answer
61         </description>
62     </workflow-note>
63
64     <workflow-item name="item2" type="end" end-mode="0">
65         <position x="380.0" y="250.0"/>
66     </workflow-item>
67
68     <workflow-item name="item4" out-name="item5" type="input">
69         <display-name>Reply to VM</display-name>
70
71         <in-binding>
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>
74             </bind>
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>
77             </bind>
78             <bind name="questionText" type="string" export-name="questionText"/>
79             <bind name="questionText2" type="string" export-name="questionText2"/>
80         </in-binding>
81
82         <out-binding>
83             <bind name="questionAnswer" type="string" export-name="questionAnswer"/>
84         </out-binding>
85
86         <presentation>
87             <desc>${questionText}</desc>
88             <p-param name="questionAnswer">
89                 <desc>
90 ${questionText2}
91                 </desc>
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>
94             </p-param>
95         </presentation>
96
97         <position x="540.0" y="140.0"/>
98     </workflow-item>
99
100     <workflow-item name="item5" out-name="item3" type="task">
101         <display-name>Send answer to VM</display-name>
102
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 
105 var theAnswer;
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 + ")");
110                 break;
111         }
112 }
113
114 vm.answerVM(questionId , theAnswer);
115         </script>
116
117         <in-binding>
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"/>
123         </in-binding>
124
125         <out-binding/>
126
127         <position x="540.0" y="200.0"/>
128     </workflow-item>
129
130     <workflow-item name="item6" out-name="item4" type="task">
131         <display-name>Set question text</display-name>
132
133         <script encoded="false">
134 // Set text to display in user interaction
135 var question = vm.runtime.question;
136
137 questionId = question.id;
138
139 questionText = question.text;
140 questionText2 = "Please choose: " + "\n";
141
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);
148 }
149         </script>
150
151         <in-binding>
152             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
153         </in-binding>
154
155         <out-binding>
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"/>
161         </out-binding>
162
163         <position x="540.0" y="80.0"/>
164     </workflow-item>
165
166     <workflow-item name="item0" out-name="item1" type="task" script-module="com.vmware.library.vc.basic/WaitTaskEndOrVMQuestion">
167         <display-name>WaitTaskEndOrVMQuestion</display-name>
168
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) ;
172         </script>
173
174         <in-binding>
175             <bind name="task" type="VC:Task" export-name="task">
176                 <description>Task to Wait for</description>
177             </bind>
178             <bind name="progress" type="boolean" export-name="progress">
179                 <description>Log progess while waiting for the task</description>
180             </bind>
181             <bind name="pollRate" type="number" export-name="pollRate">
182                 <description>Polling rate for the task state [seconds]</description>
183             </bind>
184             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
185         </in-binding>
186
187         <out-binding>
188             <bind name="actionResult" type="Any" export-name="taskActionResult"/>
189         </out-binding>
190
191         <description>
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.
194         </description>
195
196         <position x="140.0" y="80.0"/>
197     </workflow-item>
198
199     <workflow-item name="item1" out-name="item6" type="custom-condition" alt-out-name="item2">
200         <display-name>VM Question?</display-name>
201
202         <script encoded="false">
203 if (taskActionResult instanceof VcVirtualMachineQuestionInfo){
204         return true;
205 }
206 else {
207         return false;
208 }
209         </script>
210
211         <in-binding>
212             <bind name="taskActionResult" type="Any" export-name="taskActionResult"/>
213         </in-binding>
214
215         <position x="340.0" y="70.0"/>
216     </workflow-item>
217
218     <workflow-item name="item3" out-name="item2" type="task" script-module="com.vmware.library.vc.basic/vim3WaitTaskEnd">
219         <display-name>vim3WaitTaskEnd</display-name>
220
221         <script encoded="false">
222 //Auto generated script, cannot be modified !
223 actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,progress,pollRate) ;
224         </script>
225
226         <in-binding>
227             <bind name="task" type="VC:Task" export-name="task">
228                 <description>Task to Wait for</description>
229             </bind>
230             <bind name="progress" type="boolean" export-name="progress">
231                 <description>Log progess while waiting for the task</description>
232             </bind>
233             <bind name="pollRate" type="number" export-name="pollRate">
234                 <description>Polling rate for the task state [seconds]</description>
235             </bind>
236         </in-binding>
237
238         <out-binding>
239             <bind name="actionResult" type="Any" export-name="taskActionResult"/>
240         </out-binding>
241
242         <description>
243 Wait for a VC Task to end.
244 When task ended, return the task result if any.
245         </description>
246
247         <position x="540.0" y="260.0"/>
248     </workflow-item>
249
250     <presentation>
251         <p-param name="vm">
252             <desc>Virtual machine for which the task runs</desc>
253         </p-param>
254         <p-param name="task">
255             <desc>Task to await</desc>
256         </p-param>
257     </presentation>
258 </workflow>