første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / uio / lib / ad / get_ad_passwd.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="item10" object-name="workflow:name=generic" id="21827d8d-4e4b-4094-a41f-f2c5b8a3375e" version="0.0.17" api-version="3.1.0" allowed-operations="fve" restartMode="1" resumeFromFailedMode="0">
3     <display-name>get_ad_passwd</display-name>
4
5     <description>Define and set new password for tsdadd user.</description>
6
7     <position x="105.0" y="127.72727272727272"/>
8
9     <output>
10         <param name="ad_passwd" type="SecureString"/>
11     </output>
12
13     <attrib name="flow" type="Workflow" read-only="false">
14         <value encoded="n">dunes://service.dunes.ch/Workflow?id='21827d8d-4e4b-4094-a41f-f2c5b8a3375e'&amp;dunesName='Workflow'</value>
15     </attrib>
16     <attrib name="tagValue" type="string" read-only="false">
17         <value encoded="n">test</value>
18         <description>Tag value</description>
19     </attrib>
20     <attrib name="isGlobal" type="boolean" read-only="false">
21         <value encoded="n">false</value>
22         <description>Create global or private tag</description>
23     </attrib>
24     <attrib name="vm" type="VC:VirtualMachine" read-only="false">
25         <value encoded="n">__NULL__</value>
26     </attrib>
27     <attrib name="fromRest" type="Workflow" read-only="false">
28         <value encoded="n">dunes://service.dunes.ch/Workflow?id='e7764fb3-d858-4336-af95-2295aca15ce8'&amp;dunesName='Workflow'</value>
29     </attrib>
30     <attrib name="fixPasswd" type="boolean" read-only="false">
31         <value encoded="n">false</value>
32     </attrib>
33     <attrib name="execution" type="string" read-only="false">
34         <value encoded="n">executing</value>
35         <description>Tag name</description>
36     </attrib>
37     <attrib name="isGlobal1" type="boolean" read-only="false">
38         <value encoded="n">false</value>
39         <description>Is global tag</description>
40     </attrib>
41     <attrib name="sleepTime" type="number" read-only="false">
42         <value encoded="n">10.0</value>
43         <description>Time to sleep in seconds</description>
44     </attrib>
45     <attrib name="errorCode" type="string" read-only="false">
46         <value encoded="n"/>
47     </attrib>
48     <attrib name="tsdadd" type="AD:User" read-only="false">
49         <value encoded="n">__NULL__</value>
50         <description>The user which password will be changed</description>
51     </attrib>
52     <attrib name="password" type="string" read-only="false">
53         <value encoded="n">C0wb0yB33B00P2014!</value>
54         <description>The new password to set</description>
55     </attrib>
56     <attrib name="out_passwd" type="string" read-only="false">
57         <value encoded="n">Badroot12345</value>
58     </attrib>
59     <attrib name="change_passwd" type="boolean" read-only="false">
60         <value encoded="n">false</value>
61         <description>Define as yes, if you want to automaticly assign a new passwd for this user</description>
62     </attrib>
63     <attrib name="ad_controll" type="boolean" read-only="false">
64         <value encoded="n">false</value>
65         <description>if yes, manipulate AD, if no, use uioadd with dynamic password</description>
66     </attrib>
67
68     <workflow-item name="item0" type="end" end-mode="0">
69         <position x="1504.5" y="54.5"/>
70     </workflow-item>
71
72     <workflow-item name="item1" out-name="item2" type="task">
73         <display-name>Scriptable task</display-name>
74
75         <script encoded="false">
76 var inuse=false;
77 var running=false;
78 var inuseby;
79 tagValue=vm.name;
80
81 function chkTag() {
82         var tags = Server.findTagsForObject(flow);
83         for (t in tags) {
84                 if (t == "executing") {
85                         if (vm.name != tags[t]) {
86                                 inuse=true;
87                                 inuseby=tags[t];
88                                 System.log(vm.name+" "+tags[t]);
89                         } 
90                 }
91         }
92 }
93
94 chkTag();
95
96 if (inuse == false) {   
97         fixPasswd=true;
98 } else {  // ta en titt om vi finner en kjøring som bruker denne jobben
99         for each (var exec in fromRest.executions) {
100                 if (exec.state == "running") {
101                         var pp=exec.getInputParameters();
102                         System.log(pp.name);
103                         if (pp.name == inuseby) {
104                                 running=true;
105                                 fixPasswd=false;
106                         }
107                 }
108         }
109         if (running == false) {
110                 fixPasswd=true;
111         }
112 }
113         </script>
114
115         <in-binding>
116             <bind name="flow" type="Workflow" export-name="flow"/>
117             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
118             <bind name="fromRest" type="Workflow" export-name="fromRest"/>
119             <bind name="executing" type="string" export-name="execution"/>
120         </in-binding>
121
122         <out-binding>
123             <bind name="fixPasswd" type="boolean" export-name="fixPasswd"/>
124             <bind name="tagValue" type="string" export-name="tagValue">
125                 <description>Tag value</description>
126             </bind>
127         </out-binding>
128
129         <position x="484.5" y="137.22727272727272"/>
130     </workflow-item>
131
132     <workflow-item name="item2" out-name="item6" type="condition" alt-out-name="item7" comparator="0">
133         <display-name>Decision</display-name>
134
135         <script encoded="false">
136 //Generated by the system, cannot be edited
137 return (fixPasswd == true) ;
138         </script>
139
140         <in-binding>
141             <bind name="fixPasswd" type="boolean" export-name="fixPasswd"/>
142         </in-binding>
143         <condition name="fixPasswd" type="boolean" comparator="0" label="null">false</condition>
144
145         <position x="624.5" y="127.22727272727272"/>
146     </workflow-item>
147
148     <workflow-item name="item5" out-name="item9" catch-name="item3" throw-bind-name="errorCode" type="link" linked-workflow-id="0ef918a9-8fc7-4efd-b556-59a32f96bae5">
149         <display-name>Tag workflow</display-name>
150
151         <in-binding>
152             <bind name="taggedWorkflow" type="Workflow" export-name="flow">
153                 <description>Tagged object</description>
154             </bind>
155             <bind name="tagName" type="string" export-name="execution">
156                 <description>Tag name</description>
157             </bind>
158             <bind name="tagValue" type="string" export-name="tagValue">
159                 <description>Tag value</description>
160             </bind>
161             <bind name="isGlobal" type="boolean" export-name="isGlobal">
162                 <description>Create global or private tag</description>
163             </bind>
164         </in-binding>
165
166         <out-binding/>
167
168         <description>Assigns a tag to a workflow. You must specify the workflow you want to tag and the tag name and value.</description>
169
170         <position x="904.5" y="55.40909090909091"/>
171     </workflow-item>
172
173     <workflow-item name="item6" out-name="item5" type="link" linked-workflow-id="5a067901-2ced-47ef-8973-ea49ceb60d5d">
174         <display-name>Untag workflow</display-name>
175
176         <in-binding>
177             <bind name="taggedObject" type="Workflow" export-name="flow">
178                 <description>Workflow to untag</description>
179             </bind>
180             <bind name="tagName" type="string" export-name="execution">
181                 <description>Tag name</description>
182             </bind>
183             <bind name="isGlobal" type="boolean" export-name="isGlobal1">
184                 <description>Is global tag</description>
185             </bind>
186         </in-binding>
187
188         <out-binding/>
189
190         <description>Removes a tag from a workflow. You must specify the workflow you want to untag and the tag you want to remove from the specified workflow.</description>
191
192         <position x="764.5" y="137.22727272727272"/>
193     </workflow-item>
194
195     <workflow-item name="item7" prototype-id="sleep" out-name="item1" content-mode="x" type="task">
196         <display-name>Sleep</display-name>
197
198         <script encoded="false">
199 //Auto-generated script
200 if ( sleepTime != null )  {
201         System.sleep(sleepTime*1000);
202 }
203 else  {
204         throw "'sleepTime' is NULL";
205 }
206         </script>
207
208         <in-binding>
209             <bind name="sleepTime" type="number" export-name="sleepTime">
210                 <description>Time to sleep in seconds</description>
211             </bind>
212         </in-binding>
213
214         <out-binding/>
215
216         <description>Sleep a given number of seconds</description>
217
218         <position x="584.5" y="219.04545454545453"/>
219     </workflow-item>
220
221     <workflow-item name="item3" prototype-id="sleep" out-name="item1" content-mode="x" type="task">
222         <display-name>Sleep</display-name>
223
224         <script encoded="false">
225 //Auto-generated script
226 if ( sleepTime != null )  {
227         System.sleep(sleepTime*1000);
228 }
229 else  {
230         throw "'sleepTime' is NULL";
231 }
232         </script>
233
234         <in-binding>
235             <bind name="sleepTime" type="number" export-name="sleepTime">
236                 <description>Time to sleep in seconds</description>
237             </bind>
238         </in-binding>
239
240         <out-binding/>
241
242         <description>Sleep a given number of seconds</description>
243
244         <position x="704.5" y="91.77272727272727"/>
245     </workflow-item>
246
247     <workflow-item name="item4" out-name="item8" throw-bind-name="errorCode" type="task">
248         <display-name>Generate and set password</display-name>
249
250         <script encoded="false">
251 function password_generator( len ) {
252             var length = (len)?(len):(10);
253             var string = "abcdefghijklnopqrstuvwxyz"; //to upper 
254             var numeric = '0123456789';
255             var punctuation = '!@#$%^&amp;*()_+~`|}{[]\:;?&gt;&lt;,./-=';
256             var passwd = "";
257             var character = "";
258             var crunch = true;
259             while( passwd.length&lt;length ) {
260                 entity1 = Math.ceil(string.length * Math.random()*Math.random());
261                 entity2 = Math.ceil(numeric.length * Math.random()*Math.random());
262                 entity3 = Math.ceil(punctuation.length * Math.random()*Math.random());
263                 hold = string.charAt( entity1 );
264                 hold = (entity1%2==0)?(hold.toUpperCase()):(hold);
265                 character += hold;
266                 character += numeric.charAt( entity2 );
267                 character += punctuation.charAt( entity3 );
268                 passwd = character;
269             }
270             return passwd;
271         }
272
273 var passwd=password_generator(16);
274 System.log('PASSWD_generated ='+passwd);
275 System.log('PASSWD ='+password);
276 if (change_passwd == true) {
277         tsdadd.setPassword(password);
278 }
279         </script>
280
281         <in-binding>
282             <bind name="tsdadd" type="AD:User" export-name="tsdadd">
283                 <description>The user which password will be changed</description>
284             </bind>
285             <bind name="password" type="string" export-name="password">
286                 <description>The new password to set</description>
287             </bind>
288             <bind name="out_passwd" type="string" export-name="out_passwd"/>
289             <bind name="change_passwd" type="boolean" export-name="change_passwd"/>
290         </in-binding>
291
292         <out-binding>
293             <bind name="out_passwd" type="SecureString" export-name="ad_passwd"/>
294         </out-binding>
295
296         <position x="1184.5" y="37.22727272727273"/>
297     </workflow-item>
298
299     <workflow-item name="item9" out-name="item4" type="task" script-module="com.vmware.pso.cryptojs/base64Encode">
300         <display-name>base64Encode</display-name>
301
302         <script encoded="false">
303 //Auto generated script, cannot be modified !
304 actionResult = System.getModule("com.vmware.pso.cryptojs").base64Encode(input) ;
305         </script>
306
307         <in-binding>
308             <bind name="input" type="string" export-name="password">
309                 <description>Message to encode with Base64</description>
310             </bind>
311         </in-binding>
312
313         <out-binding>
314             <bind name="actionResult" type="string" export-name="password"/>
315         </out-binding>
316
317         <description>
318 Encodes a message with Base64
319
320 Pure Javascript and self contained.  Uses code.google.com/p/crypto-js version 3.1.2
321         </description>
322
323         <position x="1024.5" y="55.40909090909091"/>
324     </workflow-item>
325
326     <workflow-item name="item8" out-name="item0" type="link" linked-workflow-id="958080808080808080808080808080803881808001175609873343b6bbd2e3eea">
327         <display-name>Enable a user</display-name>
328
329         <in-binding>
330             <bind name="user" type="AD:User" export-name="tsdadd">
331                 <description>User to enable</description>
332             </bind>
333         </in-binding>
334
335         <out-binding/>
336
337         <description>Enables a user in an Active Directory instance.</description>
338
339         <position x="1324.5" y="46.31818181818181"/>
340     </workflow-item>
341
342     <workflow-item name="item10" out-name="item11" type="link" linked-workflow-id="1f0fc470-006c-4c15-a3b9-95e2e7540f22">
343         <display-name>global_parameters</display-name>
344
345         <in-binding/>
346
347         <out-binding>
348             <bind name="mailto" type="string"/>
349             <bind name="smtp_server" type="string"/>
350             <bind name="smtp_port" type="string"/>
351             <bind name="database" type="SQL:Database"/>
352             <bind name="vmPassword" type="SecureString"/>
353             <bind name="ou" type="string"/>
354             <bind name="ad_controll" type="boolean" export-name="ad_controll"/>
355         </out-binding>
356
357         <position x="204.5" y="137.22727272727272"/>
358     </workflow-item>
359
360     <workflow-item name="item11" out-name="item1" type="condition" alt-out-name="item13" comparator="0">
361         <display-name>Decision</display-name>
362
363         <script encoded="false">
364 //Generated by the system, cannot be edited
365 return (ad_controll == true) ;
366         </script>
367
368         <in-binding>
369             <bind name="ad_controll" type="boolean" export-name="ad_controll"/>
370         </in-binding>
371         <condition name="ad_controll" type="boolean" comparator="0" label="null">false</condition>
372
373         <position x="344.5" y="127.22727272727272"/>
374     </workflow-item>
375
376     <workflow-item name="item12" type="end" end-mode="0">
377         <position x="384.5" y="254.5"/>
378     </workflow-item>
379
380     <workflow-item name="item13" out-name="item12" type="link" linked-workflow-id="2b5cccb5-e2f5-4d3b-8a05-c0d3fdc61e3c">
381         <display-name>get_ad_password</display-name>
382
383         <in-binding/>
384
385         <out-binding>
386             <bind name="outputText1" type="string">
387                 <description>Result of running the SSH command</description>
388             </bind>
389             <bind name="secure_password" type="SecureString" export-name="ad_passwd"/>
390         </out-binding>
391
392         <description>
393 Request a dynamic AD password for the user uioadd. This password is valid for 30 minutes. PS the request might take up to two minutes as the script ensures that the requested password is valid for at least two minutes after the request. 
394
395 Script name: virtprov@esx-mgmt:/site/lib/Ovc/get_ad_password
396         </description>
397
398         <position x="345.0" y="200.86363636363635"/>
399     </workflow-item>
400
401     <presentation/>
402 </workflow>