første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / uio / lib / tools / mk_kickstart.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="item2" object-name="workflow:name=generic" id="f9934087-646a-4a21-97ab-032a2663c0eb" version="0.0.11" api-version="3.1.0" allowed-operations="vfe" restartMode="1" resumeFromFailedMode="0">
3     <display-name>mk_kickstart</display-name>
4
5     <description>Opprett kickstart konfig for VM</description>
6
7     <position x="100.0" y="50.0"/>
8
9     <input>
10         <param name="siteadmin" type="string"/>
11         <param name="vm" type="VC:VirtualMachine"/>
12         <param name="ssh_shell_server" type="string"/>
13         <param name="server" type="boolean">
14             <description>
15 Dersom "true" bygg server os.
16 Dersom "false" bygg klient os.
17             </description>
18         </param>
19         <param name="guestos" type="string"/>
20     </input>
21
22     <workflow-item name="item0" type="end" end-mode="0">
23         <position x="524.5" y="45.40909090909091"/>
24     </workflow-item>
25
26     <workflow-item name="item1" out-name="item0" type="task">
27         <display-name>Scriptable task</display-name>
28
29         <script encoded="false">
30 /*
31         Create tftpboot config for new VM
32 */
33
34 var ssh = new SSHSession(ssh_shell_server,'virtprov');
35 ssh.connectWithIdentity('../conf/vco_key','');
36
37
38 var vm=newVirtualMachine.name;
39 if (os) {
40 } else {
41         os=newVirtualMachine.config.guestId;
42 }
43 var dev=newVirtualMachine.config.hardware.device;
44 for (index = 0; index &lt; dev.length; ++index) {
45         if (dev[index].macAddress) {
46                 macAddress=dev[index].macAddress;
47         }
48 }
49 System.log("OS ="+os);
50 var pxe_link='/tftpboot/pxelinux.cfg/01-'+macAddress.split(":").join("-");
51 if (server) {
52         type="server";
53 } else {
54         type="client"
55 }
56
57 var version;
58 if (os.match(/rhel.*64/)) {
59         os_s=os.replace(/_64.*/,"");
60         version=os_s;
61         System.log(os);
62         rev=version+"-latest-"+type+"-64"
63 } else if (os.match(/rhel.*Guest/)) {
64         os_s=os.replace("Guest","");
65         version=os_s;
66         System.log(os);
67         rev=version+"-latest-"+type+"-32"
68 } else if (os.match(/fedora/)) {
69         System.log(os);
70         rev="fedora-latest";
71         //version="NA";
72         type='client';
73         ssh.executeCommand('ssh pxe ls -l /var/lib/tftpboot/images/linux/fedora-latest | sed "s/.*fedora[01]*//"',true) ;
74         var version = "f"+ssh.getOutput();
75         version=version.trim();
76 }
77
78
79 if (type == 'server') {
80         var append="append initrd=images/linux/"+rev+"/initrd.img "
81                 +"ks=http://yum.uio.no/cgi-bin/ks.pl?"
82                 +"type="+type
83                 +"&amp;headless=yes"
84                 +"&amp;os="+version+" "
85                 +"ksdevice=bootif "
86                 +"nicdelay=60 "
87                 +"cmdline "
88                 +"siteadmin="+siteadmin+" "
89                 +"name="+vm+" ";
90 } else {
91         var append="APPEND initrd=images/linux/"+rev+"/initrd.img vconsole.keymap=no "
92                 +"ks=http://yum.uio.no/cgi-bin/ks.pl?"
93                 +"os="+version+"&amp;type="+type+" "
94                 +"siteadmin="+siteadmin+" "
95                 +"name="+vm+" "
96                 +"primaryuser=root "
97                 +"confirm=no "
98                 +"ks.device=bootif ";
99 }
100 cmd="echo -e 'IPAPPEND 2\n"
101 +"default images/linux/"+rev+"/vmlinuz\n"
102 +append
103 +"' &gt;"+pxe_link
104
105 ssh.executeCommand('ssh pxe "'+cmd+'"',true) ;
106 var output = ssh.getOutput();
107 System.log("Output: '"+output+"'");
108
109
110 errorText = ssh.getError();
111 var exitCode = ssh.exitCode;
112
113
114 System.log("Error: '"+errorText+"'");
115 System.log("Exit code: '"+exitCode+"'");
116
117 ssh.disconnect();
118
119 if (exitCode == 1) {
120         trow (errorText);
121 }
122         </script>
123
124         <in-binding>
125             <bind name="newVirtualMachine" type="VC:VirtualMachine" export-name="vm"/>
126             <bind name="ssh_shell_server" type="string" export-name="ssh_shell_server"/>
127             <bind name="siteadmin" type="string" export-name="siteadmin"/>
128             <bind name="server" type="boolean" export-name="server"/>
129             <bind name="os" type="string" export-name="guestos"/>
130         </in-binding>
131
132         <out-binding/>
133
134         <position x="344.5" y="55.40909090909091"/>
135     </workflow-item>
136
137     <workflow-item name="item2" out-name="item1" type="link" linked-workflow-id="1f0fc470-006c-4c15-a3b9-95e2e7540f22">
138         <display-name>global_parameters</display-name>
139
140         <in-binding/>
141
142         <out-binding>
143             <bind name="mailto" type="string">
144                 <description>Default mailto parameter</description>
145             </bind>
146             <bind name="smtp_server" type="string">
147                 <description>Default SMTP server</description>
148             </bind>
149             <bind name="smtp_port" type="string">
150                 <description>Default SMTP port</description>
151             </bind>
152             <bind name="database" type="SQL:Database">
153                 <description>Default database</description>
154             </bind>
155             <bind name="vmPassword" type="SecureString"/>
156             <bind name="ou" type="string"/>
157             <bind name="ad_controll" type="boolean">
158                 <description>if yes, manipulate AD, if no, use uioadd with dynamic password</description>
159             </bind>
160             <bind name="ssh_shell_server" type="string"/>
161             <bind name="ad_domain_user" type="string">
162                 <description>Ad join user</description>
163             </bind>
164             <bind name="domain_name" type="string"/>
165             <bind name="manage_cpu_ram" type="boolean">
166                 <description>If yes, define CPU when creating new VM, not using templated default</description>
167             </bind>
168         </out-binding>
169
170         <position x="205.0" y="55.90909090909091"/>
171     </workflow-item>
172
173     <presentation>
174         <p-param name="siteadmin">
175             <desc>siteadmin</desc>
176         </p-param>
177         <p-param name="vm">
178             <desc>vm</desc>
179         </p-param>
180         <p-param name="ssh_shell_server">
181             <desc>ssh_shell_server</desc>
182         </p-param>
183         <p-param name="server">
184             <desc>
185 Dersom "true" bygg server os.
186 Dersom "false" bygg klient os.
187             </desc>
188         </p-param>
189         <p-param name="guestos">
190             <desc>guestos</desc>
191         </p-param>
192     </presentation>
193 </workflow>