første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / uio / lib / bofh / host_add.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="7f97fbb6-daf1-41dc-ae0c-a24388a77fa4" version="2.0.3" api-version="3.1.0" allowed-operations="fve" icon-id="419c9a2c-8915-4c26-8b59-fbb5931eb502" restartMode="1" resumeFromFailedMode="0">
3     <display-name>host_add</display-name>
4
5     <description>
6 Add VM to Cererbrum and request an IP
7
8 virtprov@esx-mgmt:/site/lib/Ovc/host_add
9     </description>
10
11     <position x="100.0" y="50.0"/>
12
13     <input>
14         <param name="vm" type="VC:VirtualMachine">
15             <description>Virtual Machine</description>
16         </param>
17         <param name="kort_beskrivelse" type="string">
18             <description>Kort beskrivelse av ny VM</description>
19         </param>
20         <param name="epostliste" type="string">
21             <description>Mail alias for ny VM</description>
22         </param>
23     </input>
24
25     <output>
26         <param name="outputText1" type="string">
27             <description>Result of running the SSH command</description>
28         </param>
29     </output>
30
31     <attrib name="hostNameOrIP" type="string" read-only="false">
32         <value encoded="n">esx-mgmt.uio.no</value>
33         <description>Hostname or IP address of the SSH host</description>
34     </attrib>
35     <attrib name="username" type="string" read-only="false">
36         <value encoded="n">virtprov</value>
37         <description>Username</description>
38     </attrib>
39     <attrib name="passwordAuthentication" type="boolean" read-only="false">
40         <value encoded="n">false</value>
41         <description>Sets authentication to password or key file</description>
42     </attrib>
43     <attrib name="passphrase" type="SecureString" read-only="false">
44         <value encoded="n"/>
45         <description>Private key pass-phrase</description>
46     </attrib>
47     <attrib name="password" type="SecureString" read-only="false">
48         <value encoded="n"/>
49         <description>Password</description>
50     </attrib>
51     <attrib name="cmd" type="string" read-only="false">
52         <value encoded="n">uptime</value>
53         <description>The SSH command to run</description>
54     </attrib>
55     <attrib name="outputText" type="string" read-only="false">
56         <value encoded="n"/>
57         <description>Result of running the SSH command</description>
58     </attrib>
59     <attrib name="errorText" type="string" read-only="false">
60         <value encoded="n"/>
61         <description>Error text, if any</description>
62     </attrib>
63     <attrib name="path" type="Path" read-only="false">
64         <value encoded="n">../conf/vco_key</value>
65         <description>Path to the private key</description>
66     </attrib>
67     <attrib name="nicNumber" type="number" read-only="false">
68         <value encoded="n">1.0</value>
69         <description>1 to 4: the nic number</description>
70     </attrib>
71     <attrib name="nic" type="VC:Network" read-only="false">
72         <value encoded="n">__NULL__</value>
73     </attrib>
74     <attrib name="vlanid" type="string" read-only="false">
75         <value encoded="n"/>
76     </attrib>
77     <attrib name="database" type="SQL:Database" read-only="false">
78         <value encoded="n">__NULL__</value>
79         <description>The database to use for the query</description>
80     </attrib>
81     <attrib name="query_vlan" type="string" read-only="false">
82         <value encoded="n"/>
83         <description>The query to execute</description>
84     </attrib>
85     <attrib name="networkName" type="Array/SQL:ActiveRecord" read-only="false">
86         <value encoded="n">__NULL__</value>
87         <description>An array of ActiveRecord objects corresponding to the query.</description>
88     </attrib>
89     <attrib name="macAddress" type="string" read-only="false">
90         <value encoded="n"/>
91     </attrib>
92     <attrib name="result" type="number" read-only="false">
93         <value encoded="n">__NULL__</value>
94         <description>0 = OK, Negative = Error, Positive = Number of values returned, after error text</description>
95     </attrib>
96
97     <workflow-item name="item1" out-name="item4" catch-name="item5" throw-bind-name="errorText" type="link" linked-workflow-id="90808080808080808080808080808080D28080800120523434428525559a3425f">
98         <display-name>Add host to bofh</display-name>
99
100         <in-binding>
101             <bind name="hostNameOrIP" type="string" export-name="hostNameOrIP">
102                 <description>Hostname or IP address of the SSH host</description>
103             </bind>
104             <bind name="username" type="string" export-name="username">
105                 <description>Username</description>
106             </bind>
107             <bind name="password" type="SecureString" export-name="password">
108                 <description>Password</description>
109             </bind>
110             <bind name="cmd" type="string" export-name="cmd">
111                 <description>The SSH command to run</description>
112             </bind>
113             <bind name="passwordAuthentication" type="boolean" export-name="passwordAuthentication">
114                 <description>Sets authentication to password or key file</description>
115             </bind>
116             <bind name="path" type="Path" export-name="path">
117                 <description>Path to the private key</description>
118             </bind>
119             <bind name="passphrase" type="SecureString" export-name="passphrase">
120                 <description>Private key pass-phrase</description>
121             </bind>
122         </in-binding>
123
124         <out-binding>
125             <bind name="result" type="number" export-name="result">
126                 <description>0 = OK, Negative = Error, Positive = Number of values returned, after error text</description>
127             </bind>
128             <bind name="errorText" type="string" export-name="errorText">
129                 <description>Error text, if any</description>
130             </bind>
131             <bind name="outputText" type="string" export-name="outputText1">
132                 <description>Result of running the SSH command</description>
133             </bind>
134         </out-binding>
135
136         <description>Runs an SSH command.</description>
137
138         <position x="864.5" y="55.40909090909091"/>
139     </workflow-item>
140
141     <workflow-item name="item2" out-name="item3" throw-bind-name="outputText" type="task" script-module="com.vmware.library.vc.vm.network/getNetworkForGivenNic">
142         <display-name>getNetworkForGivenNic</display-name>
143
144         <script encoded="false">
145 //Auto generated script, cannot be modified !
146 actionResult = System.getModule("com.vmware.library.vc.vm.network").getNetworkForGivenNic(vm,nicNumber) ;
147         </script>
148
149         <in-binding>
150             <bind name="vm" type="VC:VirtualMachine" export-name="vm">
151                 <description>VM to get the first network</description>
152             </bind>
153             <bind name="nicNumber" type="number" export-name="nicNumber">
154                 <description>1 to 4: the nic number</description>
155             </bind>
156         </in-binding>
157
158         <out-binding>
159             <bind name="actionResult" type="VC:Network" export-name="nic"/>
160         </out-binding>
161
162         <description>Retrun the network for a given VM nic</description>
163
164         <position x="344.5" y="55.40909090909091"/>
165     </workflow-item>
166
167     <workflow-item name="item3" out-name="item6" type="task">
168         <display-name>Get VLAN id</display-name>
169
170         <script encoded="false">
171 var index ;
172 var macAddress;
173 var dev=vm.config.hardware.device;
174 for (index = 0; index &lt; dev.length; ++index) {
175         if (dev[index].macAddress) {
176                 macAddress=dev[index].macAddress;
177         }
178 }
179
180 if (macAddress) {
181         System.log("MAC =&gt; "+macAddress);
182 }
183
184 vlanid = nic.config.defaultPortConfig.vlan.vlanId;
185
186 query_vlan="select network from all_networks where vlanid = " + vlanid + ";";
187         </script>
188
189         <in-binding>
190             <bind name="nic" type="VC:Network" export-name="nic"/>
191             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
192             <bind name="macAddress" type="string" export-name="macAddress"/>
193         </in-binding>
194
195         <out-binding>
196             <bind name="vlanid" type="string" export-name="vlanid"/>
197             <bind name="query_vlan" type="string" export-name="query_vlan">
198                 <description>The query to execute</description>
199             </bind>
200             <bind name="macAddress" type="string" export-name="macAddress"/>
201         </out-binding>
202
203         <position x="484.5" y="55.40909090909091"/>
204     </workflow-item>
205
206     <workflow-item name="item6" out-name="item7" type="link" linked-workflow-id="048080808080808080808080808080808F808080013264596926189e8150e1493">
207         <display-name>Network name from SQL</display-name>
208
209         <in-binding>
210             <bind name="database" type="SQL:Database" export-name="database">
211                 <description>The database to use for the query</description>
212             </bind>
213             <bind name="query" type="string" export-name="query_vlan">
214                 <description>The query to execute</description>
215             </bind>
216         </in-binding>
217
218         <out-binding>
219             <bind name="resultRecords" type="Array/SQL:ActiveRecord" export-name="networkName">
220                 <description>An array of ActiveRecord objects corresponding to the query.</description>
221             </bind>
222         </out-binding>
223
224         <description>Do a select network from all_networks where vlanid = vlan of current VM</description>
225
226         <position x="584.5" y="55.40909090909091"/>
227     </workflow-item>
228
229     <workflow-item name="item7" out-name="item1" catch-name="item5" throw-bind-name="errorText" type="task">
230         <display-name>preapare bofh cmd</display-name>
231
232         <script encoded="false">
233 var netName=networkName[0].getProperty("network");
234 System.log("Network name =&gt; " + netName);
235
236
237 var osname=vm.config.guestFullName;
238 System.log("OS = "+osname);
239
240 if (osname.search(/linux/i) != -1) {
241         var os = 'linux';
242 } else if (osname.search(/windows/i) != -1) {
243         var os = 'win';
244 } else {
245         //trow.error("Not a supported OS");
246         
247         throw("The VM "+vm+" is defined with an unsupported OS");
248                 
249 }
250
251 var email = epostliste;
252 var description = kort_beskrivelse+' #headless server#';
253 cmd="/site/lib/Ovc/host_add "+vm.name+" "+netName+" "+macAddress+" "+os+" "+email+' "'+description+'"';
254         </script>
255
256         <in-binding>
257             <bind name="epostliste" type="string" export-name="epostliste"/>
258             <bind name="kort_beskrivelse" type="string" export-name="kort_beskrivelse"/>
259             <bind name="macAddress" type="string" export-name="macAddress"/>
260             <bind name="networkName" type="Array/SQL:ActiveRecord" export-name="networkName">
261                 <description>An array of ActiveRecord objects corresponding to the query.</description>
262             </bind>
263             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
264         </in-binding>
265
266         <out-binding>
267             <bind name="cmd" type="string" export-name="cmd">
268                 <description>The SSH command to run</description>
269             </bind>
270         </out-binding>
271
272         <description>Prepare a BOFH add_host commandline for sending to esx-mgmt</description>
273
274         <position x="744.5" y="55.40909090909091"/>
275     </workflow-item>
276
277     <workflow-item name="item8" type="end" end-mode="0">
278         <position x="1144.5" y="109.04545454545453"/>
279     </workflow-item>
280
281     <workflow-item name="item0" throw-bind-name="errorText" type="end" end-mode="0">
282         <position x="1184.5" y="45.40909090909091"/>
283     </workflow-item>
284
285     <workflow-item name="item4" out-name="item0" type="link" linked-workflow-id="25832524-da3e-407e-a64a-d4418bcb3174">
286         <display-name>info</display-name>
287
288         <in-binding>
289             <bind name="message" type="string" export-name="outputText"/>
290         </in-binding>
291
292         <out-binding/>
293
294         <position x="1004.5" y="55.40909090909091"/>
295     </workflow-item>
296
297     <workflow-item name="item5" out-name="item8" type="link" linked-workflow-id="2cdac1c6-1c4b-4fd4-aa62-a2736a71f7e7">
298         <display-name>error</display-name>
299
300         <in-binding>
301             <bind name="message" type="string" export-name="errorText"/>
302         </in-binding>
303
304         <out-binding/>
305
306         <position x="864.5" y="119.04545454545453"/>
307     </workflow-item>
308
309     <workflow-item name="item9" out-name="item2" type="link" linked-workflow-id="1f0fc470-006c-4c15-a3b9-95e2e7540f22">
310         <display-name>global_parameters</display-name>
311
312         <in-binding/>
313
314         <out-binding>
315             <bind name="mailto" type="string">
316                 <description>Default mailto parameter</description>
317             </bind>
318             <bind name="smtp_server" type="string">
319                 <description>Default SMTP server</description>
320             </bind>
321             <bind name="smtp_port" type="string">
322                 <description>Default SMTP port</description>
323             </bind>
324             <bind name="database" type="SQL:Database" export-name="database">
325                 <description>Default database</description>
326             </bind>
327             <bind name="vmPassword" type="SecureString"/>
328             <bind name="ou" type="string"/>
329             <bind name="ad_controll" type="boolean">
330                 <description>if yes, manipulate AD, if no, use uioadd with dynamic password</description>
331             </bind>
332             <bind name="ssh_shell_server" type="string" export-name="hostNameOrIP"/>
333             <bind name="ad_domain_user" type="string" explicitly-not-bound="true">
334                 <description>Ad join user</description>
335             </bind>
336             <bind name="domain_name" type="string"/>
337             <bind name="manage_cpu_ram" type="boolean">
338                 <description>If yes, define CPU when creating new VM, not using templated default</description>
339             </bind>
340         </out-binding>
341
342         <position x="204.5" y="55.40909090909091"/>
343     </workflow-item>
344
345     <presentation>
346         <p-param name="vm">
347             <desc>Virtual Machine</desc>
348         </p-param>
349         <p-param name="kort_beskrivelse">
350             <desc>Kort beskrivelse av ny VM</desc>
351         </p-param>
352         <p-param name="epostliste">
353             <desc>Mail alias for ny VM</desc>
354         </p-param>
355     </presentation>
356 </workflow>