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="item7" object-name="Workflow:name=generic" id="13f152b9-bdfe-43ca-9399-47e61cb74022" version="2.0.22" api-version="3.1.0" allowed-operations="fve" restartMode="1" resumeFromFailedMode="0">
3 <display-name>clone VM from DB + linux 2.0</display-name>
6 This workflow is suposed to be scheduled to run every 5 minutes. It will look for new requests where provisioning type is defined as clone. (!= pxe).
8 As its possible to run more than one instance of this workflow, we will look for the first row with a distincts search. When the flow returns from builing an vm it will look in the db for aditional requests. If none exists it will terminate.
11 Look for DB entries with status = 5.
18 <position x="25.0" y="209.04545454545453"/>
20 <attrib name="allVMs" type="Array/SQL:ActiveRecord" read-only="false">
21 <value encoded="n">__NULL__</value>
22 <description>Array of virtual machines</description>
24 <attrib name="vmCount" type="number" read-only="false">
25 <value encoded="n">0</value>
26 <description>Number of virtual machines in the resource pool</description>
28 <attrib name="currentVM" type="number" read-only="false">
29 <value encoded="n">0</value>
30 <description>Index of the virtual machine in the array of virtual machines</description>
32 <attrib name="activeVM" type="string" read-only="false">
34 <description>Virtual machine currently being processed</description>
36 <attrib name="errorCode" type="string" read-only="false">
38 <description>Error code</description>
40 <attrib name="status" type="number" read-only="false">
41 <value encoded="n">5.0</value>
42 <description>Status in database. Staus 5 = bulk</description>
44 <attrib name="vmGuestOs" type="VC:VirtualMachineGuestOsIdentifier" read-only="false">
45 <value encoded="n">__NULL__</value>
46 <description>Guest operating system to use with the virtual machine</description>
48 <attrib name="vmFolder" type="VC:VmFolder" read-only="false">
49 <value encoded="n">dunes://service.dunes.ch/CustomSDKObject?id='vcsa-test01.uio.no/group-v22'&dunesName='VC:VmFolder'</value>
50 <description>Virtual machine folder</description>
52 <attrib name="vmResourcePool" type="VC:ResourcePool" read-only="false">
53 <value encoded="n">__NULL__</value>
54 <description>Resource pool in which to create the virtual machine</description>
56 <attrib name="vmHost" type="VC:HostSystem" read-only="false">
57 <value encoded="n">__NULL__</value>
58 <description>Host on which to create the virtual machine</description>
60 <attrib name="vmDiskSize" type="number" read-only="false">
61 <value encoded="n">60.0</value>
62 <description>Size of virtual disk in GB</description>
64 <attrib name="vmMemorySize" type="number" read-only="false">
65 <value encoded="n">4096.0</value>
66 <description>Virtual machine's memory size in MB</description>
68 <attrib name="vmNbOfCpus" type="number" read-only="false">
69 <value encoded="n">1.0</value>
70 <description>Number of virtual processors</description>
72 <attrib name="vmNetwork" type="VC:DistributedVirtualPortgroup" read-only="false">
73 <value encoded="n">dunes://service.dunes.ch/CustomSDKObject?id='vcsa-test01.uio.no/dvportgroup-37'&dunesName='VC:DistributedVirtualPortgroup'</value>
74 <description>The network to connect to</description>
76 <attrib name="kort_beskrivelse" type="string" read-only="false">
78 <description>Kort beskrivelse av ny VM</description>
80 <attrib name="epostliste" type="string" read-only="false">
82 <description>Mail alias for ny VM</description>
84 <attrib name="database" type="SQL:Database" read-only="false">
85 <value encoded="n">__NULL__</value>
86 <description>Pointer to database</description>
88 <attrib name="mailto1" type="string" read-only="false">
90 <description>Default mailto parameter</description>
92 <attrib name="smtp_server1" type="string" read-only="false">
94 <description>Default SMTP server</description>
96 <attrib name="smtp_port1" type="string" read-only="false">
98 <description>Default SMTP port</description>
100 <attrib name="viktighet" type="number" read-only="false">
101 <value encoded="n">__NULL__</value>
102 <description>Resource group to add VM into</description>
104 <attrib name="folder" type="string" read-only="false">
106 <description>Folder to store the new VM</description>
108 <attrib name="VIM" type="VC:SdkConnection" read-only="false">
109 <value encoded="n">dunes://service.dunes.ch/CustomSDKObject?id='vcsa-test01.uio.no'&dunesName='VC:SdkConnection'</value>
110 <description>Pointer to Vcenter object</description>
112 <attrib name="template" type="VC:VirtualMachine" read-only="false">
113 <value encoded="n">dunes://service.dunes.ch/CustomSDKObject?id='vcsa-test01.uio.no/vm-125'&dunesName='VC:VirtualMachine'</value>
114 <description>Virtual machine to clone</description>
116 <attrib name="datastore" type="VC:Datastore" read-only="false">
117 <value encoded="n">__NULL__</value>
118 <description>Datastore in which to store the virtual machine. If not specified, the current datastore is used</description>
120 <attrib name="dnsServerList" type="Array/string" read-only="false">
121 <value encoded="n">#{#string#129.240.2.27#;#string#129.240.2.40#;#string#129.240.2.3#}#</value>
122 <description>(Optional) List of DNS servers for a virtual network adapter with a static IP address</description>
124 <attrib name="dnsDomain" type="string" read-only="false">
125 <value encoded="n">uio.no</value>
126 <description>(Optional) DNS domain suffix such as vmware.com</description>
128 <attrib name="gateway" type="Array/string" read-only="false">
129 <value encoded="n">#{#string#129.240.255.193#}#</value>
130 <description>(Optional) List of gateways, in order of preference</description>
132 <attrib name="ipAddress" type="string" read-only="false">
133 <value encoded="n">129.240.255.215</value>
134 <description>Fixed valid IP address</description>
136 <attrib name="subnetMask" type="string" read-only="false">
137 <value encoded="n">255.255.255.224</value>
138 <description>(Optional) Subnet mask for this virtual network adapter</description>
140 <attrib name="fullName" type="string" read-only="false">
141 <value encoded="n">Universitetet i Oslo</value>
142 <description>User's full name</description>
144 <attrib name="orgName" type="string" read-only="false">
145 <value encoded="n">UiO</value>
146 <description>Organization name</description>
148 <attrib name="computerName" type="string" read-only="false">
150 <description>Name of the new VM</description>
152 <attrib name="macAddress" type="string" read-only="false">
153 <value encoded="n">false</value>
154 <description>Dersom undef, så defineres ikke macAddress</description>
156 <attrib name="osname" type="string" read-only="false">
158 <description>Navn på OS</description>
160 <attrib name="environment" type="Array/string" read-only="false">
161 <value encoded="n">__NULL__</value>
162 <description>An array of environment variables, specified in the guest OS notation (eg PATH=c:\bin;c:\windows\system32 or LD_LIBRARY_PATH=/usr/lib:/lib), to be set for the program being run. Note that these are not additions to the default environment variables; they define the complete set available to the program. If none are specified the values are guest dependent.</description>
164 <attrib name="windows_roles" type="Array/string" read-only="false">
165 <value encoded="n">__NULL__</value>
166 <description>Windows roles. Other workflow fetches roles from database</description>
168 <attrib name="vlan_name" type="string" read-only="false">
170 <description>Vlan descriptive name</description>
172 <attrib name="ad_domain_id" type="number" read-only="false">
173 <value encoded="n">__NULL__</value>
174 <description>Ad omain id from database. If > 0 add vm in AD</description>
176 <attrib name="ad_domain_name" type="string" read-only="false">
178 <description>Ad domain to join</description>
180 <attrib name="vlan_id" type="number" read-only="false">
181 <value encoded="n">__NULL__</value>
182 <description>vlanid</description>
184 <attrib name="cluster" type="string" read-only="false">
187 <attrib name="errorStatus" type="number" read-only="false">
188 <value encoded="n">13.0</value>
189 <description>VM status. Default 4 or 999 for deleted</description>
191 <attrib name="newVM" type="VC:VirtualMachine" read-only="false">
192 <value encoded="n">__NULL__</value>
193 <description>The newly created virtual machine</description>
195 <attrib name="datacenter" type="string" read-only="false">
198 <attrib name="os_full_name" type="string" read-only="false">
201 <attrib name="status_start_cloning" type="number" read-only="false">
202 <value encoded="n">10.0</value>
203 <description>VM status. Default 4 or 999 for deleted</description>
205 <attrib name="message_start_cloning" type="string" read-only="false">
206 <value encoded="n">Starting to clone VM</value>
207 <description>Message to log to info or error</description>
209 <attrib name="template_name" type="string" read-only="false">
212 <attrib name="status_finished" type="number" read-only="false">
213 <value encoded="n">4.0</value>
214 <description>VM status. Default 4 or 999 for deleted</description>
216 <attrib name="vmPassword" type="SecureString" read-only="false">
217 <value encoded="n">12AE4ED65E7787216FD6F074931532633734F3534A85DE3EBD93C7671CDC2A140DF056C8810B8C79FD2C985F605987495D9</value>
219 <attrib name="powerOn" type="boolean" read-only="false">
220 <value encoded="n">true</value>
221 <description>Specifies whether or not the new virtual machine should be powered on after creation</description>
223 <attrib name="doSysprep" type="boolean" read-only="false">
224 <value encoded="n">true</value>
225 <description>Run the Sysprep operations and wait for the task to complete. Not used if the virtual machine is marked as template</description>
227 <attrib name="dhcp" type="boolean" read-only="false">
228 <value encoded="n">false</value>
229 <description>Use a DHCP server to configure the virtual network adapter</description>
231 <attrib name="macAddress1" type="string" read-only="false">
233 <description>(Optional) The MAC address of a network adapter being customized. If it is not included, the customization process maps the settings from the virtual machine's network adapters, in PCI slot order</description>
235 <attrib name="diskIndex" type="number" read-only="false">
236 <value encoded="n">1.0</value>
237 <description>Disk index</description>
239 <attrib name="diskMode" type="VC:VirtualDiskMode" read-only="false">
240 <value encoded="n">dunes://service.dunes.ch/CustomSDKObject?id='persistent'&dunesName='VC:VirtualDiskMode'</value>
241 <description>Disk persistence mode</description>
243 <attrib name="scsiBusNumber" type="number" read-only="false">
244 <value encoded="n">0.0</value>
245 <description>SCSI controller bus number</description>
247 <attrib name="thinProvisioned" type="boolean" read-only="false">
248 <value encoded="n">false</value>
249 <description>Use thin provisioning?</description>
251 <attrib name="allocate_disk_space" type="number" read-only="false">
252 <value encoded="n">__NULL__</value>
253 <description>Size of virtual disk in GB</description>
255 <attrib name="linux_roles" type="Array/string" read-only="false">
256 <value encoded="n">__NULL__</value>
258 <attrib name="project_folder" type="string" read-only="false">
261 <attrib name="ipv6gateway" type="string" read-only="false">
264 <attrib name="ipv6dnsServerList" type="Array/string" read-only="false">
265 <value encoded="n">__NULL__</value>
267 <attrib name="ipv6address" type="string" read-only="false">
270 <attrib name="ipv6Prefixlen" type="number" read-only="false">
271 <value encoded="n">__NULL__</value>
273 <attrib name="vimCL" type="VC:ClusterComputeResource" read-only="false">
274 <value encoded="n">__NULL__</value>
276 <attrib name="vimDC" type="VC:Datacenter" read-only="false">
277 <value encoded="n">__NULL__</value>
279 <attrib name="vm" type="SQL:ActiveRecord" read-only="false">
280 <value encoded="n">__NULL__</value>
282 <attrib name="vmProperties" type="Properties" read-only="false">
283 <value encoded="n">__NULL__</value>
285 <attrib name="pxe" type="boolean" read-only="false">
286 <value encoded="n">false</value>
288 <attrib name="test" type="Array/string" read-only="false">
289 <value encoded="n">__NULL__</value>
292 <workflow-item name="item0" out-name="item1" type="task">
293 <display-name>Initialize</display-name>
295 <script encoded="false">
296 System.log('select * from server_view where statusid = 5;');
297 allVMs = database.readCustomQuery('select distinct on (status) * from server_view where statusid = 5;');
300 vmCount = allVMs.length;
305 <bind name="database" type="SQL:Database" export-name="database"/>
306 <bind name="status" type="number" export-name="status">
307 <description>Status in database. Staus 5 = bulk</description>
309 <bind name="VIM" type="VC:SdkConnection" export-name="VIM"/>
313 <bind name="vmCount" type="number" export-name="vmCount"/>
314 <bind name="currentVM" type="number" export-name="currentVM"/>
315 <bind name="allVMs" type="Array/SQL:ActiveRecord" export-name="allVMs">
316 <description>Array of virtual machines</description>
318 <bind name="newVM" type="VC:VirtualMachine" export-name="newVM">
319 <description>The newly created virtual machine</description>
321 <bind name="vlan_id" type="number" export-name="vlan_id">
322 <description>vlanid</description>
324 <bind name="template" type="VC:VirtualMachine" export-name="template">
325 <description>Virtual machine to clone</description>
327 <bind name="cluster" type="string" export-name="cluster"/>
328 <bind name="ad_domain_name" type="string" export-name="ad_domain_name">
329 <description>Ad domain to join</description>
331 <bind name="datacenter" type="string" export-name="datacenter"/>
332 <bind name="vlan_name" type="string" export-name="vlan_name">
333 <description>Vlan descriptive name</description>
335 <bind name="ad_domain_id" type="number" export-name="ad_domain_id">
336 <description>Ad omain id from database. If > 0 add vm in AD</description>
338 <bind name="vmNetwork" type="VC:DistributedVirtualPortgroup" export-name="vmNetwork">
339 <description>The network to connect to</description>
341 <bind name="status" type="number" export-name="status">
342 <description>Status in database. Staus 5 = bulk</description>
346 <position x="124.5" y="155.4090909090909"/>
349 <workflow-item name="item1" out-name="item17" type="custom-condition" alt-out-name="item2">
350 <display-name>VMs to Process?</display-name>
352 <script encoded="false">
353 if(allVMs.length > 0){
361 <bind name="allVMs" type="Array/SQL:ActiveRecord" export-name="allVMs"/>
364 <position x="124.5" y="318.1363636363636"/>
367 <workflow-item name="item2" out-name="item3" type="task">
368 <display-name>Scriptable task</display-name>
370 <script encoded="false">
371 System.log("No VM's to process at the moment");
378 <position x="124.5" y="400.8636363636363"/>
381 <workflow-item name="item3" type="end" end-mode="0">
382 <position x="164.5" y="454.49999999999994"/>
385 <workflow-item name="item6" out-name="item5" catch-name="item10" throw-bind-name="errorCode" type="task">
386 <display-name>Get resources</display-name>
388 <script encoded="false">
389 System.log("VM = > "+activeVM);
392 if (vmDiskSize == -1) {
393 allocate_disk_space=60;
396 for each (vmHost in vimCL.host) {
397 System.log("HOSTNAME "+vmHost.name);
398 for each (vlan in vmHost.network) {
401 if(vlan.config.defaultPortConfig.vlan instanceof VcVmwareDistributedVirtualSwitchVlanIdSpec){
402 //System.log('NAME => '+vlan.config.name);
403 //System.log('VLAN Ting '+vlan.config.defaultPortConfig.vlan.vlanId);
404 if (vlan_name == vlan.config.name) {
406 var pools = System.getModule("com.vmware.library.vc.resourcePool").getValidResourcePoolForNetwork(vmNetwork);
407 for each (pool in pools) {
408 if (pool.name == "sydr-kat"+viktighet) {
410 System.log("Ressurs poool = "+pool.name);
425 <bind name="activeVM" type="string" export-name="activeVM">
426 <description>Virtual machine currently being processed</description>
428 <bind name="allVMs" type="Array/SQL:ActiveRecord" export-name="allVMs"/>
429 <bind name="VIM" type="VC:SdkConnection" export-name="VIM">
430 <description>Virtual Senter Server</description>
432 <bind name="vlan_id" type="number" export-name="vlan_id"/>
433 <bind name="vmResourcePool" type="VC:ResourcePool" export-name="vmResourcePool">
434 <description>Resource pool in which to create the virtual machine</description>
436 <bind name="vlan_name" type="string" export-name="vlan_name">
437 <description>Vlan descriptive name</description>
439 <bind name="vimCL" type="VC:ClusterComputeResource" export-name="vimCL"/>
440 <bind name="viktighet" type="number" export-name="viktighet"/>
441 <bind name="vmDiskSize" type="number" export-name="vmDiskSize"/>
445 <bind name="vmGuestOs" type="VC:VirtualMachineGuestOsIdentifier" export-name="vmGuestOs">
446 <description>Guest operating system to use with the virtual machine</description>
448 <bind name="vmFolder" type="VC:VmFolder" export-name="vmFolder">
449 <description>Virtual machine folder</description>
451 <bind name="allocate_disk_space" type="number" export-name="allocate_disk_space"/>
452 <bind name="vmResourcePool" type="VC:ResourcePool" export-name="vmResourcePool">
453 <description>Resource pool in which to create the virtual machine</description>
455 <bind name="vmNetwork" type="VC:DistributedVirtualPortgroup" export-name="vmNetwork">
456 <description>The network to connect to</description>
458 <bind name="vmHost" type="VC:HostSystem" export-name="vmHost">
459 <description>Host on which to create the virtual machine</description>
463 <description>Get and find resources for our new VM</description>
465 <position x="964.5" y="328.1363636363636"/>
468 <workflow-item name="item7" out-name="item0" type="link" linked-workflow-id="1f0fc470-006c-4c15-a3b9-95e2e7540f22">
469 <display-name>global_parameters</display-name>
474 <bind name="mailto" type="string" export-name="mailto1"/>
475 <bind name="smtp_server" type="string" export-name="smtp_server1"/>
476 <bind name="smtp_port" type="string" export-name="smtp_port1"/>
477 <bind name="database" type="SQL:Database" export-name="database"/>
478 <bind name="vmPassword" type="SecureString" export-name="vmPassword"/>
481 <position x="65.0" y="219.04545454545453"/>
484 <workflow-item name="item11" out-name="item18" catch-name="item10" throw-bind-name="activeVM" type="task">
485 <display-name>GetVmAttrfromDB</display-name>
487 <script encoded="false">
489 * Get variables from Database
493 var guestid = vm.getProperty("guestid");
495 System.log("Active VM => "+activeVM);
497 var computer=activeVM.split(".");
498 computerName=computer[0];
499 vlan_id = vm.getProperty("vlanid");
500 vlan_name = vm.getProperty("vlan");
501 var date = new Date();
506 viktighet = vm.getProperty("viktighet");
507 folder = vm.getProperty("folder");
508 vlanName = vm.getProperty("vlanid");
510 System.log("VLAN = "+vlanName);
512 vmGuestOs = VcVirtualMachineGuestOsIdentifier.fromString(vm.getProperty("guestid"));
513 vmDiskSize = vm.getProperty("disksize");
514 vmMemorySize = vm.getProperty("memory")*1024;
515 vmNbOfCpus = vm.getProperty("num_cpus");
516 epostliste = vm.getProperty("epostliste");
517 kort_beskrivelse = vm.getProperty("kort_beskrivelse");
518 osname = vm.getProperty("guestid");
519 ad_domain_id=vm.getProperty("ad_domain_id");
520 ad_domain_name=vm.getProperty("ad_domain_name");
521 cluster=vm.getProperty("cluster");
522 datacenter=vm.getProperty("datacenter");
523 os_full_name=vm.getProperty("os");
524 template_name=vm.getProperty("template");
526 if (template_name == "pxe") {
530 Get Windows roles from DB
532 var serverid = vm.getProperty("serverid");
533 var db_roles=database.readCustomQuery(""
534 +"select windows_roles.info from windows_roles, win_server_roles "
535 +"where windows_roles.id = win_server_roles.id and serverid = "+serverid+";");
538 for each (role in db_roles) {
539 System.log(role.getProperty("info"));
540 var rname=role.getProperty("info");
541 windows_roles.push(rname);
545 Get Linux Roles from DB
548 var db_cfroles=database.readCustomQuery(""
549 +"select cf_roles.name from cf_server_roles, cf_roles "
550 +"where cf_roles.cfid = cf_server_roles.cfid and cf_server_roles.serverid=" + serverid + ";");
554 for each (cfrole in db_cfroles) {
555 System.log(cfrole.getProperty("name"));
556 var rname=cfrole.getProperty("name");
557 linux_roles.push(rname);
563 guestid : vm.getProperty("guestid"),
564 computerName : activeVM.split(".")[0],
565 vlan_id : vm.getProperty("vlanid"),
566 vlan_name : vm.getProperty("vlan"),
567 viktighet : vm.getProperty("viktighet"),
568 folder : vm.getProperty("folder"),
569 vlanName : vm.getProperty("vlanid"),
570 vmGuestOs : VcVirtualMachineGuestOsIdentifier.fromString(vm.getProperty("guestid")),
571 vmDiskSize : vm.getProperty("disksize"),
572 vmMemorySize : vm.getProperty("memory"),
573 vmNbOfCpus : vm.getProperty("num_cpus"),
574 epostliste : vm.getProperty("epostliste"),
575 kort_beskrivelse: vm.getProperty("kort_beskrivelse"),
576 osname : vm.getProperty("guestid"),
577 ad_domain_id : vm.getProperty("ad_domain_id"),
578 ad_domain_name : vm.getProperty("ad_domain_name"),
579 cluster : vm.getProperty("cluster"),
580 datacenter : vm.getProperty("datacenter"),
581 os_full_name : vm.getProperty("os"),
582 template_name : vm.getProperty("template"),
583 serverid : vm.getProperty("serverid"),
584 windows_roles : windows_roles,
585 linux_roles : linux_roles,
590 //vmCount = allVMs.length;
595 <bind name="currentVM" type="number" export-name="currentVM">
596 <description>Index of the virtual machine in the array of virtual machines</description>
598 <bind name="database" type="SQL:Database" export-name="database"/>
599 <bind name="activeVM" type="string" export-name="activeVM"/>
600 <bind name="vm" type="SQL:ActiveRecord" export-name="vm"/>
604 <bind name="viktighet" type="number" export-name="viktighet"/>
605 <bind name="folder" type="string" export-name="folder"/>
606 <bind name="vmGuestOs" type="VC:VirtualMachineGuestOsIdentifier" export-name="vmGuestOs"/>
607 <bind name="vmDiskSize" type="number" export-name="vmDiskSize"/>
608 <bind name="vmMemorySize" type="number" export-name="vmMemorySize"/>
609 <bind name="vmNbOfCpus" type="number" export-name="vmNbOfCpus"/>
610 <bind name="epostliste" type="string" export-name="epostliste"/>
611 <bind name="kort_beskrivelse" type="string" export-name="kort_beskrivelse"/>
612 <bind name="osname" type="string" export-name="osname">
613 <description>Navn på OS</description>
615 <bind name="environment" type="Array/string" export-name="environment">
616 <description>An array of environment variables, specified in the guest OS notation (eg PATH=c:\bin;c:\windows\system32 or LD_LIBRARY_PATH=/usr/lib:/lib), to be set for the program being run. Note that these are not additions to the default environment variables; they define the complete set available to the program. If none are specified the values are guest dependent.</description>
618 <bind name="windows_roles" type="Array/string" export-name="windows_roles">
619 <description>Windows roles. Other workflow fetches roles from database</description>
621 <bind name="ad_domain_id" type="number" export-name="ad_domain_id"/>
622 <bind name="ad_domain_name" type="string" export-name="ad_domain_name"/>
623 <bind name="computerName" type="string" export-name="computerName"/>
624 <bind name="activeVM" type="string" export-name="activeVM">
625 <description>Virtual machine currently being processed</description>
627 <bind name="vlan_id" type="number" export-name="vlan_id"/>
628 <bind name="vlan_name" type="string" export-name="vlan_name"/>
629 <bind name="cluster" type="string" export-name="cluster"/>
630 <bind name="datacenter" type="string" export-name="datacenter"/>
631 <bind name="os_full_name" type="string" export-name="os_full_name"/>
632 <bind name="template_name" type="string" export-name="template_name"/>
633 <bind name="linux_roles" type="Array/string" export-name="linux_roles"/>
634 <bind name="vmProperties" type="Properties" export-name="vmProperties"/>
635 <bind name="pxe" type="boolean" export-name="pxe"/>
638 <description>Get VM attributes from database</description>
640 <position x="544.5" y="328.1363636363636"/>
643 <workflow-item name="item8" out-name="item12" catch-name="item10" throw-bind-name="errorCode" type="link" linked-workflow-id="d37cd9f5-2d4a-4ec1-ae1f-d2df8496c5b4">
644 <display-name>host_add_nonvm</display-name>
647 <bind name="vm" type="string" export-name="activeVM">
648 <description>Virtual Machine</description>
650 <bind name="kort_beskrivelse" type="string" export-name="kort_beskrivelse">
651 <description>Kort beskrivelse av ny VM</description>
653 <bind name="epostliste" type="string" export-name="epostliste">
654 <description>Mail alias for ny VM</description>
656 <bind name="osname" type="string" export-name="osname">
657 <description>Navn på OS</description>
659 <bind name="macAddress" type="string" export-name="macAddress">
660 <description>Dersom undef, så defineres ikke macAddress</description>
662 <bind name="vlanName" type="number" export-name="vlan_id"/>
666 <bind name="gateway" type="Array/string" export-name="gateway"/>
667 <bind name="netmask" type="string" export-name="subnetMask"/>
668 <bind name="ipAddress" type="string" export-name="ipAddress"/>
671 <description>Registrer en ny enhet i bofh før opprettelse av VM</description>
673 <position x="964.5" y="155.4090909090909"/>
676 <workflow-item name="item14" out-name="item8" catch-name="item10" throw-bind-name="errorCode" type="link" linked-workflow-id="1f459776-8603-4336-ae18-85672d369909">
677 <display-name>get_optimal_datastore</display-name>
680 <bind name="vmNetwork" type="VC:DistributedVirtualPortgroup" export-name="vmNetwork"/>
681 <bind name="diskspace" type="number" export-name="allocate_disk_space"/>
685 <bind name="datastore1" type="VC:Datastore" export-name="datastore"/>
689 Find datastore with most free disk, and space for the VMs disk
691 Input parameter is network object, and GB of required space
694 <position x="964.5" y="200.86363636363635"/>
697 <workflow-item name="item10" out-name="item0" type="link" linked-workflow-id="fac19258-528f-4e75-a341-6242a16246b6">
698 <display-name>set_db_state</display-name>
701 <bind name="vm" type="string" export-name="activeVM">
702 <description>Navn på vm som skal ha oppdatert status</description>
704 <bind name="status" type="number" export-name="errorStatus">
705 <description>VM status. Default 4 or 999 for deleted</description>
707 <bind name="message" type="string" export-name="errorCode">
708 <description>Message to log to info or error</description>
710 <bind name="virtualMachine" type="VC:VirtualMachine" export-name="newVM"/>
711 <bind name="project_folder" type="string" export-name="project_folder"/>
712 <bind name="datacenter" type="VC:Datacenter" export-name="vimDC"/>
717 <description>Set a new state for VM in database</description>
719 <position x="504.5" y="155.4090909090909"/>
722 <workflow-item name="item15" out-name="item0" type="link" linked-workflow-id="e8ecbc5e-964e-4811-84d6-76ff12d69d72">
723 <display-name>vm_ready_email</display-name>
726 <bind name="vm" type="VC:VirtualMachine" export-name="newVM"/>
727 <bind name="viktighet" type="number" export-name="viktighet"/>
728 <bind name="datacenter" type="string" export-name="datacenter"/>
729 <bind name="cluster" type="string" export-name="cluster"/>
730 <bind name="disksize" type="number" export-name="vmDiskSize"/>
731 <bind name="num_cpus" type="number" export-name="vmNbOfCpus"/>
732 <bind name="memory" type="number" export-name="vmMemorySize"/>
733 <bind name="osname" type="string" export-name="os_full_name"/>
734 <bind name="epostliste" type="string" export-name="epostliste"/>
735 <bind name="datacenter1" type="VC:Datacenter" export-name="vimDC"/>
740 <description>Logger hendelser som skjer til databasen. Også mulig å logge til email dersom variablen enable_mail settes til true</description>
742 <position x="124.5" y="28.136363636363633"/>
745 <workflow-item name="item16" out-name="item6" type="link" linked-workflow-id="fac19258-528f-4e75-a341-6242a16246b6">
746 <display-name>Set status = 10</display-name>
749 <bind name="vm" type="string" export-name="activeVM">
750 <description>Navn på vm som skal ha oppdatert status</description>
752 <bind name="status" type="number" export-name="status_start_cloning">
753 <description>VM status. Default 4 or 999 for deleted</description>
755 <bind name="message" type="string" export-name="message_start_cloning">
756 <description>Message to log to info or error</description>
758 <bind name="virtualMachine" type="VC:VirtualMachine" export-name="newVM"/>
759 <bind name="project_folder" type="string" export-name="project_folder"/>
760 <bind name="datacenter" type="VC:Datacenter" export-name="vimDC"/>
765 <description>Set a new state for VM in database</description>
767 <position x="824.5" y="328.1363636363636"/>
770 <workflow-item name="item4" out-name="item15" type="link" linked-workflow-id="fac19258-528f-4e75-a341-6242a16246b6">
771 <display-name>Set status = 4</display-name>
774 <bind name="vm" type="string" export-name="activeVM">
775 <description>Navn på vm som skal ha oppdatert status</description>
777 <bind name="status" type="number" export-name="status_finished">
778 <description>VM status. Default 4 or 999 for deleted</description>
780 <bind name="message" type="string" export-name="message_start_cloning">
781 <description>Message to log to info or error</description>
783 <bind name="virtualMachine" type="VC:VirtualMachine" export-name="newVM"/>
784 <bind name="project_folder" type="string" export-name="epostliste"/>
785 <bind name="datacenter" type="VC:Datacenter" export-name="vimDC"/>
790 <description>Set a new state for VM in database</description>
792 <position x="404.5" y="28.136363636363633"/>
795 <workflow-item name="item5" out-name="item14" type="link" linked-workflow-id="bb56f2b9-97b8-4c32-829f-b92a9a0fd53e">
796 <display-name>get_template</display-name>
799 <bind name="vmName" type="string" export-name="template_name"/>
800 <bind name="vmHost" type="VC:HostSystem" export-name="vmHost"/>
801 <bind name="currState" type="number" export-name="status_start_cloning"/>
805 <bind name="autoFolder" type="VC:VmFolder" export-name="vmFolder"/>
806 <bind name="template" type="VC:VirtualMachine" export-name="template"/>
807 <bind name="osname" type="string" explicitly-not-bound="true"/>
810 <position x="964.5" y="264.5"/>
813 <workflow-item name="item9" out-name="item4" catch-name="item10" throw-bind-name="errorCode" type="link" linked-workflow-id="eb00c75d-3403-4fb9-a3ae-a07e45c20bf0">
814 <display-name>clone_lin_win</display-name>
817 <bind name="folder" type="VC:VmFolder" export-name="vmFolder">
818 <description>Virtual machine folder</description>
820 <bind name="name" type="string" export-name="activeVM">
821 <description>New virtual machine name</description>
823 <bind name="vm" type="VC:VirtualMachine" export-name="template">
824 <description>Virtual machine to clone</description>
826 <bind name="powerOn" type="boolean" export-name="powerOn">
827 <description>Specifies whether or not the new virtual machine should be powered on after creation</description>
829 <bind name="datastore" type="VC:Datastore" export-name="datastore">
830 <description>Datastore in which to store the virtual machine. If not specified, the current datastore is used</description>
832 <bind name="host" type="VC:HostSystem" export-name="vmHost">
833 <description>(Optional) Host on which to create the virtual machine</description>
835 <bind name="pool" type="VC:ResourcePool" export-name="vmResourcePool">
836 <description>(Optional) Resource pool in which to create the virtual machine</description>
838 <bind name="doSysprep" type="boolean" export-name="doSysprep">
839 <description>Run the Sysprep operations and wait for the task to complete. Not used if the virtual machine is marked as template</description>
841 <bind name="clientName" type="string" export-name="computerName">
842 <description>Name or prefix name of the Linux client</description>
844 <bind name="network" type="VC:DistributedVirtualPortgroup" export-name="vmNetwork">
845 <description>Network on which to attach the virtual network interface</description>
847 <bind name="dnsServerList" type="Array/string" export-name="dnsServerList">
848 <description>(Optional) List of DNS servers for a virtual network adapter with a static IP address</description>
850 <bind name="dnsDomain" type="string" export-name="dnsDomain">
851 <description>(Optional) DNS domain suffix such as vmware.com</description>
853 <bind name="dhcp" type="boolean" export-name="dhcp">
854 <description>Use a DHCP server to configure the virtual network adapter</description>
856 <bind name="gateway" type="Array/string" export-name="gateway">
857 <description>(Optional) List of gateways, in order of preference</description>
859 <bind name="ipAddress" type="string" export-name="ipAddress">
860 <description>Fixed, valid IP address</description>
862 <bind name="macAddress" type="string" export-name="macAddress1">
863 <description>(Optional) The MAC address of a network adapter being customized. If it is not included, the customization process maps the settings from the virtual machine's network adapters, in PCI slot order</description>
865 <bind name="subnetMask" type="string" export-name="subnetMask">
866 <description>[Optional] Subnet mask for this virtual network adapter</description>
868 <bind name="diskIndex" type="number" export-name="diskIndex">
869 <description>Disk index</description>
871 <bind name="diskSize" type="number" export-name="vmDiskSize">
872 <description>Disk size (in GB)</description>
874 <bind name="diskMode" type="VC:VirtualDiskMode" export-name="diskMode">
875 <description>Disk persistence mode</description>
877 <bind name="scsiBusNumber" type="number" export-name="scsiBusNumber">
878 <description>SCSI controller bus number</description>
880 <bind name="thinProvisioned" type="boolean" export-name="thinProvisioned">
881 <description>Use thin provisioning?</description>
883 <bind name="fullName" type="string" export-name="fullName">
884 <description>User's full name</description>
886 <bind name="orgName" type="string" export-name="orgName">
887 <description>Organization name</description>
889 <bind name="windows_roles" type="Array/string" export-name="windows_roles">
890 <description>Windows roles. Other workflow fetches roles from database</description>
892 <bind name="vlan_name" type="string" export-name="vlan_name">
893 <description>Vlan descriptive name</description>
895 <bind name="ad_domain_id" type="number" export-name="ad_domain_id"/>
896 <bind name="ad_domain_name" type="string" export-name="ad_domain_name"/>
897 <bind name="vmPassword" type="SecureString" export-name="vmPassword"/>
898 <bind name="osname" type="string" export-name="osname"/>
899 <bind name="ipv6gateway" type="string" export-name="ipv6gateway"/>
900 <bind name="ipv6dnsServerList" type="Array/string" export-name="ipv6dnsServerList"/>
901 <bind name="memory" type="number" export-name="vmMemorySize"/>
902 <bind name="vcpu" type="number" export-name="vmNbOfCpus"/>
903 <bind name="ipv6address" type="string" export-name="ipv6address"/>
904 <bind name="ipv6Prefixlen" type="number" export-name="ipv6Prefixlen"/>
905 <bind name="pxe" type="boolean" export-name="pxe"/>
906 <bind name="epostliste" type="string" export-name="epostliste"/>
907 <bind name="kort_beskrivelse" type="string" export-name="kort_beskrivelse"/>
911 <bind name="newVM1" type="VC:VirtualMachine" export-name="newVM"/>
914 <position x="964.5" y="28.136363636363633"/>
917 <workflow-item name="item12" out-name="item9" type="link" linked-workflow-id="1877a3a5-e5cc-45fe-b752-677bf91a6e7f">
918 <display-name>host_roles</display-name>
921 <bind name="vm" type="string" export-name="activeVM">
922 <description>Virtual Machine</description>
924 <bind name="osname" type="string" export-name="osname">
925 <description>Navn på OS</description>
927 <bind name="linux_roles" type="Array/string" export-name="linux_roles"/>
928 <bind name="vmobject" type="VC:VirtualMachine" explicitly-not-bound="true"/>
933 <description>Add cfengine roles to bofh</description>
935 <position x="964.5" y="91.77272727272727"/>
938 <workflow-item name="item13" out-name="item11" type="custom-condition" alt-out-name="item10">
939 <display-name>Finnes vm fra før ?</display-name>
941 <script encoded="false">
942 var VMs = System.getModule("com.vmware.library.vc.vm").getAllVMsMatchingRegexp(activeVM);
947 if (VMs.length > 0) {
948 System.log("Det finnes allerde en VM med navn "+activeVM);
956 <bind name="activeVM" type="string" export-name="activeVM"/>
957 <bind name="vimCL" type="VC:ClusterComputeResource" export-name="vimCL"/>
958 <bind name="status" type="number" export-name="status"/>
961 <position x="404.5" y="318.1363636363636"/>
964 <workflow-item name="item17" out-name="item13" catch-name="item10" throw-bind-name="errorCode" type="task">
965 <display-name>Get VIM, datacenter and cluster</display-name>
967 <script encoded="false">
968 vm = allVMs[currentVM];
971 var url = vm.getProperty('url');
972 var cluster = vm.getProperty('cluster');
973 var datacenter = vm.getProperty('datacenter');
975 for each (var vim in VcPlugin.allSdkConnections) {
976 var vimname=vim.name.replace(":443","");
977 if (url == vimname+"/vimService") {
978 System.log("VIMNAME = "+vim.name);
983 var dcsearch = "xpath:name[matches(.,'" + datacenter +"')]";
984 var datacenters = VIM.getAllDatacenters(['name'],dcsearch);
986 for each (var dcid in datacenters) {
988 System.log("Datacenter "+dcid.name);
991 var search = "xpath:name[matches(.,'" + cluster +"')]";
992 var clusters = VIM.getAllClusterComputeResources(['name'],search);
993 for each (var c in clusters) {
994 var dcname=System.getModule("com.vmware.library.vc.basic").getDatacenterForVimObject(c).name;
995 if (datacenter == dcname) {
997 System.log("Cluster "+c.name);
1003 System.error("Not able to find datacenter"+activeVM);
1009 <bind name="currentVM" type="number" export-name="currentVM"/>
1010 <bind name="allVMs" type="Array/SQL:ActiveRecord" export-name="allVMs"/>
1011 <bind name="vmPassword" type="SecureString" export-name="vmPassword"/>
1015 <bind name="activeVM" type="string" export-name="activeVM"/>
1016 <bind name="VIM" type="VC:SdkConnection" export-name="VIM">
1017 <description>Pointer to Vcenter object</description>
1019 <bind name="vimCL" type="VC:ClusterComputeResource" export-name="vimCL"/>
1020 <bind name="vimDC" type="VC:Datacenter" export-name="vimDC"/>
1021 <bind name="vm" type="SQL:ActiveRecord" export-name="vm"/>
1022 <bind name="status" type="number" export-name="status"/>
1025 <position x="264.5" y="328.1363636363636"/>
1028 <workflow-item name="item18" out-name="item16" type="task">
1029 <display-name>Test params</display-name>
1031 <script encoded="false">
1032 //var ff = vmProperties.g()
1033 //var f = vmProperties.get("osname");
1034 //ystem.log(ff.name);
1037 for each (var r in f) {
1038 System.log("role = "+r);
1044 <bind name="vmProperties" type="Properties" export-name="vmProperties"/>
1045 <bind name="test" type="Array/string" export-name="test"/>
1050 <position x="685.0" y="328.1363636363636"/>