første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / uio / lib / ad / get_project.workflow.xml
CommitLineData
d8fdd35b
SA
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="item1" object-name="workflow:name=generic" id="a5c7285f-1b6c-45e6-a4cb-3b2881b54cb0" version="0.0.8" api-version="3.1.0" allowed-operations="fve" restartMode="1" resumeFromFailedMode="0">
3 <display-name>get_project</display-name>
4
5 <description>Small flow used to get ldapPath for AD object. Also returns project name.</description>
6
7 <position x="100.0" y="50.0"/>
8
9 <input>
10 <param name="computerName" type="string"/>
11 </input>
12
13 <output>
14 <param name="project" type="string"/>
15 <param name="ldapPath" type="string"/>
16 </output>
17
18 <attrib name="errorCode" type="string" read-only="false">
19 <value encoded="n">Computer not defined in correct AD path</value>
20 </attrib>
21
22 <workflow-item name="item0" type="end" end-mode="0">
23 <position x="384.5" y="45.40909090909091"/>
24 </workflow-item>
25
26 <workflow-item name="item1" out-name="item0" throw-bind-name="errorCode" type="task">
27 <display-name>Scriptable task</display-name>
28
29 <script encoded="false">
30var vmname=computerName.replace(/\..*/,"");
31
32function get_computers (vmname) {
33 var computers = ActiveDirectory.getComputerADRecursively(vmname);
34
35 for each (var mpc in computers){
36 //System.log("Checking computer: "+pc.name);
37
38 if (vmname.toLowerCase() == mpc.name.toLowerCase()){
39 System.log("Found Computer: "+mpc.name);
40 var ff=mpc.allAttributes;
41 return mpc;
42 }
43 }
44}
45
46computer=get_computers(vmname);
47if (!computer) {
48 System.log("Not able to find "+computerName+" in AD");
49 System.throw("Error");
50}
51
52ldapPath=computer.distinguishedName;
53
54var ous=ldapPath.split(',');
55ous.shift();
56ldapPath=ous.toString();
57
58if (ous[1] == "OU=lost and found hosts") {
59 System.trow("VM er i lost and found");
60}
61
62var reverse=ous.reverse();
63//System.log(reverse);
64
65if (reverse[3] != "OU=projects") {
66 if (reverse[3] == "OU=usit") {
67 System.log(reverse[4]);
68 project="usit";
69 } else {
70 project="autoprovisioned";
71 }
72} else {
73 project=reverse[4].split('=')[1];
74}
75 </script>
76
77 <in-binding>
78 <bind name="computerName" type="string" export-name="computerName"/>
79 </in-binding>
80
81 <out-binding>
82 <bind name="project" type="string" export-name="project"/>
83 <bind name="ldapPath" type="string" export-name="ldapPath"/>
84 </out-binding>
85
86 <position x="204.5" y="55.40909090909091"/>
87 </workflow-item>
88
89 <presentation>
90 <p-param name="computerName">
91 <desc>computerName</desc>
92 </p-param>
93 </presentation>
94</workflow>