første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / uio / lib / bofh / host_roles.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="item9" object-name="workflow:name=generic" id="1877a3a5-e5cc-45fe-b752-677bf91a6e7f" version="1.0.3" api-version="3.1.0" allowed-operations="fve" icon-id="e7418220-002f-4135-a5de-2875150c1cdb" restartMode="1" resumeFromFailedMode="0">
3     <display-name>host_roles</display-name>
4
5     <description>
6 Add cfengine roles to bofh. 
7 PS : all existing roles are deleted!!!
8
9 virtprov@esx-mgmt:/site/lib/Ovc/host_roles
10     </description>
11
12     <position x="100.0" y="50.0"/>
13
14     <input>
15         <param name="vm" type="string">
16             <description>Virtual Machine</description>
17         </param>
18         <param name="osname" type="string">
19             <description>Navn på OS</description>
20         </param>
21         <param name="linux_roles" type="Array/string">
22             <description>Linux roller</description>
23         </param>
24         <param name="vmobject" type="VC:VirtualMachine">
25             <description>VM objekt</description>
26         </param>
27     </input>
28
29     <attrib name="ssh_shell_server" type="string" read-only="false">
30         <value encoded="n">esx-mgmt.uio.no</value>
31         <description>Hostname or IP address of the SSH host</description>
32     </attrib>
33     <attrib name="username" type="string" read-only="false">
34         <value encoded="n">virtprov</value>
35         <description>Username</description>
36     </attrib>
37     <attrib name="passwordAuthentication" type="boolean" read-only="false">
38         <value encoded="n">false</value>
39         <description>Sets authentication to password or key file</description>
40     </attrib>
41     <attrib name="passphrase" type="SecureString" read-only="false">
42         <value encoded="n"/>
43         <description>Private key pass-phrase</description>
44     </attrib>
45     <attrib name="password" type="SecureString" read-only="false">
46         <value encoded="n"/>
47         <description>Password</description>
48     </attrib>
49     <attrib name="cmd" type="string" read-only="false">
50         <value encoded="n">uptime</value>
51         <description>The SSH command to run</description>
52     </attrib>
53     <attrib name="outputText" type="string" read-only="false">
54         <value encoded="n"/>
55         <description>Result of running the SSH command</description>
56     </attrib>
57     <attrib name="errorText" type="string" read-only="false">
58         <value encoded="n"/>
59         <description>Error text, if any</description>
60     </attrib>
61     <attrib name="path" type="Path" read-only="false">
62         <value encoded="n">../conf/vco_key</value>
63         <description>Path to the private key</description>
64     </attrib>
65     <attrib name="result" type="number" read-only="false">
66         <value encoded="n">__NULL__</value>
67         <description>0 = OK, Negative = Error, Positive = Number of values returned, after error text</description>
68     </attrib>
69     <attrib name="ipInfo" type="string" read-only="false">
70         <value encoded="n"/>
71         <description>Result of running the SSH command</description>
72     </attrib>
73     <attrib name="database" type="SQL:Database" read-only="false">
74         <value encoded="n">__NULL__</value>
75         <description>Default database</description>
76     </attrib>
77
78     <workflow-item name="item1" out-name="item2" catch-name="item5" throw-bind-name="errorText" type="link" linked-workflow-id="90808080808080808080808080808080D28080800120523434428525559a3425f">
79         <display-name>Add host to bofh</display-name>
80
81         <in-binding>
82             <bind name="hostNameOrIP" type="string" export-name="ssh_shell_server">
83                 <description>Hostname or IP address of the SSH host</description>
84             </bind>
85             <bind name="username" type="string" export-name="username">
86                 <description>Username</description>
87             </bind>
88             <bind name="password" type="SecureString" export-name="password">
89                 <description>Password</description>
90             </bind>
91             <bind name="cmd" type="string" export-name="cmd">
92                 <description>The SSH command to run</description>
93             </bind>
94             <bind name="passwordAuthentication" type="boolean" export-name="passwordAuthentication">
95                 <description>Sets authentication to password or key file</description>
96             </bind>
97             <bind name="path" type="Path" export-name="path">
98                 <description>Path to the private key</description>
99             </bind>
100             <bind name="passphrase" type="SecureString" export-name="passphrase">
101                 <description>Private key pass-phrase</description>
102             </bind>
103         </in-binding>
104
105         <out-binding>
106             <bind name="result" type="number" export-name="result">
107                 <description>0 = OK, Negative = Error, Positive = Number of values returned, after error text</description>
108             </bind>
109             <bind name="errorText" type="string" export-name="errorText">
110                 <description>Error text, if any</description>
111             </bind>
112             <bind name="outputText" type="string" export-name="ipInfo">
113                 <description>Result of running the SSH command</description>
114             </bind>
115         </out-binding>
116
117         <description>Runs an SSH command.</description>
118
119         <position x="604.5" y="55.40909090909091"/>
120     </workflow-item>
121
122     <workflow-item name="item7" out-name="item1" catch-name="item5" throw-bind-name="errorText" type="task">
123         <display-name>preapare bofh cmd</display-name>
124
125         <script encoded="false">
126 if (!vm) {
127         vm=vmobject.name;
128 }
129
130 if (osname.search(/linux/i) != -1 || osname.search(/rhel/i) != -1 ) {
131         var os = 'linux';
132 } else if (osname.search(/windows/i) != -1) {
133         var os = 'win';
134 } else {
135         throw("The VM "+vm+" is defined with an unsupported OS");
136 }
137
138 var lib="/GIT/"+database.name+"/virt-selfservice/Server/lib";
139
140 if (!linux_roles) {
141         cmd="export PERL5LIB="+lib+";"+lib+"/Ovc/host_roles "+vm+" \"\"";
142 } else {
143         cmd="export PERL5LIB="+lib+";"+lib+"/Ovc/host_roles "+vm+" "+linux_roles.join(',')+"";
144 }
145 System.log("CMD = "+cmd);
146
147
148
149
150
151
152 /*
153 try {
154         var ssh = new SSHSession(hostNameOrIP,'virtprov');
155         ssh.connectWithIdentity('../conf/vco_key','');
156         
157         System.log("Executing '"+cmd+"'");
158         ssh.executeCommand(cmd,true) ;
159                 
160         var output = ssh.getOutput();
161         errorText = ssh.getError();
162         var exitCode = ssh.exitCode;
163         
164         System.log("Output: '"+output+"'");
165         System.log("Error: '"+errorText+"'");
166         System.log("Exit code: '"+exitCode+"'");
167
168         ssh.disconnect();
169         
170         if (exitCode == 1) {
171                 trow (errorText);
172         }
173         
174         
175         var IP = output.split(',');
176         
177         ipAddress=IP[0];
178         netmask=IP[1];
179         gateway=[IP[2]];
180 }
181
182 catch (e) {
183         throw "Unable to execute command " + e;
184 }
185
186 */
187         </script>
188
189         <in-binding>
190             <bind name="vm" type="string" export-name="vm"/>
191             <bind name="osname" type="string" export-name="osname"/>
192             <bind name="linux_roles" type="Array/string" export-name="linux_roles"/>
193             <bind name="vmobject" type="VC:VirtualMachine" export-name="vmobject">
194                 <description>VM objekt</description>
195             </bind>
196             <bind name="database" type="SQL:Database" export-name="database">
197                 <description>Default database</description>
198             </bind>
199         </in-binding>
200
201         <out-binding>
202             <bind name="cmd" type="string" export-name="cmd">
203                 <description>The SSH command to run</description>
204             </bind>
205         </out-binding>
206
207         <description>Prepare a BOFH add_host commandline for sending to esx-mgmt</description>
208
209         <position x="484.5" y="55.40909090909091"/>
210     </workflow-item>
211
212     <workflow-item name="item0" throw-bind-name="errorText" type="end" end-mode="0">
213         <position x="1064.5" y="45.40909090909091"/>
214     </workflow-item>
215
216     <workflow-item name="item4" out-name="item0" type="link" linked-workflow-id="25832524-da3e-407e-a64a-d4418bcb3174">
217         <display-name>info</display-name>
218
219         <in-binding>
220             <bind name="message" type="string" export-name="outputText"/>
221         </in-binding>
222
223         <out-binding/>
224
225         <position x="884.5" y="55.40909090909091"/>
226     </workflow-item>
227
228     <workflow-item name="item5" out-name="item8" type="link" linked-workflow-id="2cdac1c6-1c4b-4fd4-aa62-a2736a71f7e7">
229         <display-name>error</display-name>
230
231         <in-binding>
232             <bind name="message" type="string" export-name="errorText"/>
233         </in-binding>
234
235         <out-binding/>
236
237         <position x="604.5" y="119.04545454545453"/>
238     </workflow-item>
239
240     <workflow-item name="item2" out-name="item4" type="task">
241         <display-name>Scriptable task</display-name>
242
243         <script encoded="false">
244 var IP = ipInfo.split(',');
245
246 ipAddress=IP[0];
247 netmask=IP[1];
248 gateway=[IP[2]];
249         </script>
250
251         <in-binding>
252             <bind name="ipInfo" type="string" export-name="ipInfo">
253                 <description>Result of running the SSH command</description>
254             </bind>
255         </in-binding>
256
257         <out-binding/>
258
259         <position x="744.5" y="55.40909090909091"/>
260     </workflow-item>
261
262     <workflow-item name="item8" throw-bind-name="errorText" type="end" end-mode="1">
263         <position x="784.5" y="109.04545454545453"/>
264     </workflow-item>
265
266     <workflow-item name="item3" out-name="item7" type="custom-condition" alt-out-name="item6">
267         <display-name>Custom decision</display-name>
268
269         <script encoded="false">
270 if (osname != 'linux') {
271         return false;
272 }
273
274 return true;
275         </script>
276
277         <in-binding>
278             <bind name="osname" type="string" export-name="osname"/>
279             <bind name="linux_roles" type="Array/string" export-name="linux_roles"/>
280         </in-binding>
281
282         <position x="344.5" y="45.40909090909091"/>
283     </workflow-item>
284
285     <workflow-item name="item6" type="end" end-mode="0">
286         <position x="384.5" y="109.04545454545453"/>
287     </workflow-item>
288
289     <workflow-item name="item9" out-name="item3" type="link" linked-workflow-id="1f0fc470-006c-4c15-a3b9-95e2e7540f22">
290         <display-name>global_parameters</display-name>
291
292         <in-binding/>
293
294         <out-binding>
295             <bind name="mailto" type="string">
296                 <description>Default mailto parameter</description>
297             </bind>
298             <bind name="smtp_server" type="string">
299                 <description>Default SMTP server</description>
300             </bind>
301             <bind name="smtp_port" type="string">
302                 <description>Default SMTP port</description>
303             </bind>
304             <bind name="database" type="SQL:Database" export-name="database">
305                 <description>Default database</description>
306             </bind>
307             <bind name="vmPassword" type="SecureString"/>
308             <bind name="ou" type="string"/>
309             <bind name="ad_controll" type="boolean">
310                 <description>if yes, manipulate AD, if no, use uioadd with dynamic password</description>
311             </bind>
312             <bind name="ssh_shell_server" type="string" export-name="ssh_shell_server"/>
313             <bind name="ad_domain_user" type="string">
314                 <description>Ad join user</description>
315             </bind>
316             <bind name="domain_name" type="string"/>
317             <bind name="manage_cpu_ram" type="boolean">
318                 <description>If yes, define CPU when creating new VM, not using templated default</description>
319             </bind>
320         </out-binding>
321
322         <position x="204.5" y="55.40909090909091"/>
323     </workflow-item>
324
325     <presentation>
326         <p-param name="vmobject">
327             <desc>Virtual Machine</desc>
328         </p-param>
329         <p-param name="osname">
330             <desc>Navn på OS</desc>
331         </p-param>
332         <p-param name="linux_roles">
333             <desc>linux_roles</desc>
334         </p-param>
335         <p-param name="vm">
336             <desc>Virtual Machine</desc>
337         </p-param>
338     </presentation>
339 </workflow>