første xml update
[virt-orchestrator.git] / vFLOWER / content / Workflows / Library / vCenter / Virtual Machine management / Device Management / Add disk.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="item4" object-name="Workflow:name=generic" id="BD8080808080808080808080808080801BC280800122528313869552e41805bb1" version="0.2.0" api-version="3.1.0" allowed-operations="fv" restartMode="1" resumeFromFailedMode="0">
3     <display-name>Add disk</display-name>
4
5     <description>Adds a virtual disk to a virtual machine.</description>
6     <ref-types>(VC:VirtualMachine)</ref-types>
7
8     <position x="140.0" y="0.0"/>
9
10     <input>
11         <param name="vm" type="VC:VirtualMachine">
12             <description>Virtual machine to which to add the disk</description>
13         </param>
14         <param name="datastore" type="VC:Datastore">
15             <description>Datastore in which to put the virtual disk file</description>
16         </param>
17         <param name="diskIndex" type="number">
18             <description>Disk index</description>
19         </param>
20         <param name="diskSize" type="number">
21             <description>Disk size (in GB)</description>
22         </param>
23         <param name="diskMode" type="VC:VirtualDiskMode">
24             <description>Disk persistence mode</description>
25         </param>
26         <param name="scsiBusNumber" type="number">
27             <description>SCSI controller bus number</description>
28         </param>
29         <param name="thinProvisioned" type="boolean">
30             <description>Use thin provisioning?</description>
31         </param>
32     </input>
33
34     <attrib name="scsiControllerKey" type="number" read-only="false">
35         <value encoded="n">0</value>
36         <description>LSI or Bus Logic SCSI controller key</description>
37     </attrib>
38     <attrib name="task" type="VC:Task" read-only="false">
39         <value encoded="n">__NULL__</value>
40         <description>Task to await</description>
41     </attrib>
42     <attrib name="progress" type="boolean" read-only="false">
43         <value encoded="n">false</value>
44         <description>Log progress while waiting for the task to complete</description>
45     </attrib>
46     <attrib name="pollRate" type="number" read-only="false">
47         <value encoded="n">1.0</value>
48         <description>Polling rate for the task state, in seconds</description>
49     </attrib>
50     <attrib name="noContollerError" type="string" read-only="false">
51         <value encoded="n">Error: No controller found</value>
52         <description>Error if virtual machine has no IDE controller</description>
53     </attrib>
54
55     <workflow-item name="item0" out-name="item1" type="task">
56         <display-name>Add disk</display-name>
57
58         <script encoded="false">
59 var configSpec = new VcVirtualMachineConfigSpec();
60 var deviceConfigSpecs = new Array();
61 var deviceConfigSpec;
62
63 // Add/Create the disk
64 deviceConfigSpec = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualDiskFlatVer2ConfigSpec(
65         diskSize, datastore, scsiControllerKey, diskIndex, VcVirtualDiskMode.fromString(diskMode.name), thinProvisioned );
66 deviceConfigSpecs[0] = deviceConfigSpec;
67
68 // List of devices
69 configSpec.deviceChange = deviceConfigSpecs;
70
71 // Launch the reconfigVM task
72 task = vm.reconfigVM_Task( configSpec );
73         </script>
74
75         <in-binding>
76             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
77             <bind name="scsiControllerKey" type="number" export-name="scsiControllerKey"/>
78             <bind name="diskSize" type="number" export-name="diskSize"/>
79             <bind name="diskMode" type="VC:VirtualDiskMode" export-name="diskMode"/>
80             <bind name="diskIndex" type="number" export-name="diskIndex"/>
81             <bind name="datastore" type="VC:Datastore" export-name="datastore"/>
82             <bind name="thinProvisioned" type="boolean" export-name="thinProvisioned"/>
83         </in-binding>
84
85         <out-binding>
86             <bind name="task" type="VC:Task" export-name="task"/>
87         </out-binding>
88
89         <position x="100.0" y="220.0"/>
90     </workflow-item>
91
92     <workflow-item name="item5" out-name="item6" type="task">
93         <display-name>Retrieve Scsi controller found ?</display-name>
94
95         <script encoded="false">
96 scsiControllerKey = -1;
97 var devices = vm.config.hardware.device;
98 var isScsiBusNumberInvalid = true;
99 if(scsiBusNumber==null || scsiBusNumber&lt;0)
100         scsiBusNumber=0;
101 if ( devices != null )  {
102         for ( device in devices )  {
103                 if ( devices[device] instanceof VcVirtualBusLogicController || devices[device] instanceof VcVirtualLsiLogicController 
104                 || devices[device] instanceof VcParaVirtualSCSIController || devices[device] instanceof VcVirtualLsiLogicSASController )  {
105                         if(scsiBusNumber==devices[device].busNumber){
106                                 scsiControllerKey = devices[device].key;
107                                 isScsiBusNumberInvalid = false;
108                                 System.log( "SCSI controller found. (Key: " + scsiControllerKey + ")" );
109                                 break;
110                         }
111                 }
112         }
113 }
114 if(isScsiBusNumberInvalid){
115         System.log( "SCSI controller not found. The bus number entered is invalid" );
116 }
117         </script>
118
119         <in-binding>
120             <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
121             <bind name="scsiBusNumber" type="number" export-name="scsiBusNumber"/>
122         </in-binding>
123
124         <out-binding>
125             <bind name="scsiControllerKey" type="number" export-name="scsiControllerKey"/>
126         </out-binding>
127
128         <position x="100.0" y="100.0"/>
129     </workflow-item>
130
131     <workflow-item name="item6" out-name="item0" type="condition" alt-out-name="item2" comparator="0">
132         <display-name>Scsi controller found ?</display-name>
133
134         <script encoded="false">
135 //Generated by the system, cannot be edited
136 return (scsiControllerKey &gt;= 0.0) ;
137         </script>
138
139         <in-binding>
140             <bind name="scsiControllerKey" type="number" export-name="scsiControllerKey"/>
141         </in-binding>
142         <condition name="scsiControllerKey" type="number" comparator="5" label="null">0.0</condition>
143
144         <position x="100.0" y="150.0"/>
145     </workflow-item>
146
147     <workflow-item name="item1" out-name="item3" type="task" script-module="com.vmware.library.vc.basic/vim3WaitTaskEnd">
148         <display-name>vim3WaitTaskEnd</display-name>
149
150         <script encoded="false">
151 //Auto generated script, cannot be modified !
152 actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,progress,pollRate) ;
153         </script>
154
155         <in-binding>
156             <bind name="task" type="VC:Task" export-name="task">
157                 <description>Task to Wait for</description>
158             </bind>
159             <bind name="progress" type="boolean" export-name="progress">
160                 <description>Log progess while waiting for the task</description>
161             </bind>
162             <bind name="pollRate" type="number" export-name="pollRate">
163                 <description>Polling rate for the task state [seconds]</description>
164             </bind>
165         </in-binding>
166
167         <out-binding>
168             <bind name="actionResult" type="Any" explicitly-not-bound="true" export-name="NULL"/>
169         </out-binding>
170
171         <description>
172 Wait a VIM 3 Task to end.
173 When task ended, return the
174         </description>
175
176         <position x="100.0" y="280.0"/>
177     </workflow-item>
178
179     <workflow-item name="item2" throw-bind-name="noContollerError" type="end" end-mode="1">
180         <position x="260.0" y="150.0"/>
181     </workflow-item>
182
183     <workflow-item name="item3" type="end" end-mode="0">
184         <position x="140.0" y="330.0"/>
185     </workflow-item>
186
187     <workflow-item name="item4" out-name="item5" type="task">
188         <display-name>check Params</display-name>
189
190         <script encoded="false">
191 if (diskSize &lt; 0.01 ) {
192         throw ("Error, invalid parameter. Disk size should be no less than 0.01 ");
193 }
194         </script>
195
196         <in-binding>
197             <bind name="diskSize" type="number" export-name="diskSize"/>
198         </in-binding>
199
200         <out-binding/>
201
202         <position x="100.0" y="60.0"/>
203     </workflow-item>
204
205     <presentation>
206         <p-step>
207             <title>VM</title>
208             <p-param name="vm">
209                 <desc>Virtual machine to which to add the disk</desc>
210                 <p-qual name="mandatory">true</p-qual>
211                 <p-qual name="show-select-as">list</p-qual>
212                 <p-qual name="contextualParameter"/>
213             </p-param>
214         </p-step>
215         <p-step>
216             <title>Disk</title>
217             <p-group>
218                 <title>Disk information</title>
219                 <desc>'Disk index' must be between 0 and 15 (and not 7 as it's reserved by spec)</desc>
220                 <p-param name="datastore">
221                     <desc>Datastore in which to put the virtual disk file</desc>
222                     <p-qual name="mandatory">true</p-qual>
223                     <p-qual name="show-select-as">list</p-qual>
224                 </p-param>
225                 <p-param name="diskMode">
226                     <desc>Disk persistence mode</desc>
227                     <p-qual kind="static" name="mandatory" type="boolean">true</p-qual>
228                 </p-param>
229                 <p-param name="diskIndex">
230                     <desc>Disk index</desc>
231                     <p-qual kind="static" name="numberFormat" type="String">#</p-qual>
232                     <p-qual kind="static" name="minNumberValue" type="Number">0.0</p-qual>
233                     <p-qual kind="static" name="maxNumberValue" type="Number">15.0</p-qual>
234                     <p-qual name="mandatory">true</p-qual>
235                     <p-qual kind="ognl" name="ognlValidator" type="String">(#diskIndex != 7 ? "": "7 is not valid" )</p-qual>
236                 </p-param>
237                 <p-param name="diskSize">
238                     <desc>Disk size (in GB)</desc>
239                     <p-qual name="mandatory">true</p-qual>
240                     <p-qual kind="static" name="minNumberValue" type="Number">0.01</p-qual>
241                 </p-param>
242                 <p-param name="scsiBusNumber">
243                     <desc>SCSI controller bus number</desc>
244                     <p-qual kind="static" name="numberFormat" type="String">#</p-qual>
245                     <p-qual kind="static" name="minNumberValue" type="Number">0</p-qual>
246                 </p-param>
247                 <p-param name="thinProvisioned">
248                     <desc>Use thin provisioning?</desc>
249                 </p-param>
250             </p-group>
251         </p-step>
252     </presentation>
253 </workflow>