første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / uio / lib / tools / copy_files_to_vm.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="0d2ce070-c285-4a7f-9ec0-71f769d07114" version="1.0.0" api-version="3.1.0" allowed-operations="fve" restartMode="1" resumeFromFailedMode="0">
3     <display-name>copy_files_to_vm</display-name>
4
5     <description>Create directories, and copy scripts to the new VM</description>
6
7     <position x="100.0" y="50.0"/>
8
9     <input>
10         <param name="vm" type="VC:VirtualMachine">
11             <description>Virtual machine</description>
12         </param>
13         <param name="directories" type="Array/string"/>
14         <param name="dos_path" type="string"/>
15         <param name="dos_files" type="Array/string"/>
16         <param name="vco_path" type="string"/>
17         <param name="vmUsername" type="string">
18             <description>Username for the virtual machine</description>
19         </param>
20         <param name="vmPassword" type="SecureString">
21             <description>Password for the virtual machine</description>
22         </param>
23     </input>
24
25     <output>
26         <param name="var" type="Array/boolean"/>
27     </output>
28
29     <attrib name="errorCode" type="string" read-only="false">
30         <value encoded="n"/>
31     </attrib>
32     <attrib name="createParents" type="boolean" read-only="false">
33         <value encoded="n">true</value>
34         <description>Create parent directories if missing</description>
35     </attrib>
36
37     <workflow-item name="item0" type="end" end-mode="0">
38         <position x="684.5" y="45.40909090909091"/>
39     </workflow-item>
40
41     <workflow-item name="item5" out-name="item0" throw-bind-name="errorCode" type="task">
42         <display-name>Upload files to vm</display-name>
43
44         <script encoded="false">
45 var host = vm.sdkConnection;
46
47 var guestOperationsManager = host.guestOperationsManager;
48 var guestAuth = new VcNamePasswordAuthentication();
49
50
51 guestAuth.username = vmUsername;
52 guestAuth.password = vmPassword;
53
54 var fileManager = guestOperationsManager.fileManager;
55 result = false;
56
57 for each (var script in dos_files) {
58         var attr = new VcGuestFileAttributes();
59         var srcFile = new File(vco_path+'/'+script);
60
61         if (vm.config.guestFullName.match(/Linux/)) {
62                 var posix = new VcGuestPosixFileAttributes() ;
63                 posix.permissions=0700;
64                 var uri = fileManager.initiateFileTransferToGuest(vm , guestAuth ,dos_path+'/'+script, posix, srcFile.length, 1);               
65         } else {
66                 var uri = fileManager.initiateFileTransferToGuest(vm , guestAuth ,dos_path+'\\'+script, attr, srcFile.length, 1);
67         }
68         result = fileManager.putFile(vco_path+'/'+script, uri);
69 }
70         </script>
71
72         <in-binding>
73             <bind name="dos_files" type="Array/string" export-name="dos_files"/>
74             <bind name="vco_path" type="string" export-name="vco_path"/>
75             <bind name="dos_path" type="string" export-name="dos_path"/>
76             <bind name="vmUsername" type="string" export-name="vmUsername">
77                 <description>Username for the virtual machine</description>
78             </bind>
79             <bind name="vmPassword" type="SecureString" export-name="vmPassword">
80                 <description>Password for the virtual machine</description>
81             </bind>
82             <bind name="vm" type="VC:VirtualMachine" export-name="vm">
83                 <description>Virtual machine</description>
84             </bind>
85         </in-binding>
86
87         <out-binding/>
88
89         <position x="504.5" y="55.40909090909091"/>
90     </workflow-item>
91
92     <workflow-item name="item2" out-name="item5" throw-bind-name="errorCode" type="foreach">
93         <display-name>Foreach (Create directory in guest)</display-name>
94
95         <in-binding>
96             <bind name="vmUsername" type="string" export-name="vmUsername">
97                 <description>Username for the virtual machine</description>
98             </bind>
99             <bind name="vmPassword" type="SecureString" export-name="vmPassword">
100                 <description>Password for the virtual machine</description>
101             </bind>
102             <bind name="vm" type="VC:VirtualMachine" export-name="vm">
103                 <description>Virtual machine</description>
104             </bind>
105             <bind name="dirPath" type="Array/string" export-name="*directories">
106                 <description>Guest path</description>
107             </bind>
108             <bind name="createParents" type="boolean" export-name="createParents">
109                 <description>Create parent directories if missing</description>
110             </bind>
111         </in-binding>
112
113         <out-binding>
114             <bind name="result" type="Array/boolean" export-name="*var"/>
115         </out-binding>
116         <reference type="Workflow" id="C88080808080808080808080808080809880808001322751030482b80adf61e7c"/>
117         <iteration-catch-block>
118             <script encoded="false">
119 System.log(dirPath[$index]+" Finnes fra før");
120             </script>
121         </iteration-catch-block>
122
123         <description>Create a directory in a guest virtual machine.</description>
124
125         <position x="285.0" y="55.90909090909091"/>
126     </workflow-item>
127
128     <presentation>
129         <p-param name="vm">
130             <desc>Virtual machine</desc>
131             <p-qual kind="static" name="mandatory" type="boolean">true</p-qual>
132         </p-param>
133         <p-param name="directories">
134             <desc>directories</desc>
135         </p-param>
136         <p-param name="dos_path">
137             <desc>dos_path</desc>
138         </p-param>
139         <p-param name="dos_files">
140             <desc>dos_files</desc>
141         </p-param>
142         <p-param name="vco_path">
143             <desc>vco_path</desc>
144         </p-param>
145         <p-param name="vmUsername">
146             <desc>Username for the virtual machine</desc>
147         </p-param>
148         <p-param name="vmPassword">
149             <desc>Password for the virtual machine</desc>
150         </p-param>
151     </presentation>
152 </workflow>