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>
5 <description>Adds a virtual disk to a virtual machine.</description>
6 <ref-types>(VC:VirtualMachine)</ref-types>
8 <position x="140.0" y="0.0"/>
11 <param name="vm" type="VC:VirtualMachine">
12 <description>Virtual machine to which to add the disk</description>
14 <param name="datastore" type="VC:Datastore">
15 <description>Datastore in which to put the virtual disk file</description>
17 <param name="diskIndex" type="number">
18 <description>Disk index</description>
20 <param name="diskSize" type="number">
21 <description>Disk size (in GB)</description>
23 <param name="diskMode" type="VC:VirtualDiskMode">
24 <description>Disk persistence mode</description>
26 <param name="scsiBusNumber" type="number">
27 <description>SCSI controller bus number</description>
29 <param name="thinProvisioned" type="boolean">
30 <description>Use thin provisioning?</description>
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>
38 <attrib name="task" type="VC:Task" read-only="false">
39 <value encoded="n">__NULL__</value>
40 <description>Task to await</description>
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>
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>
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>
55 <workflow-item name="item0" out-name="item1" type="task">
56 <display-name>Add disk</display-name>
58 <script encoded="false">
59 var configSpec = new VcVirtualMachineConfigSpec();
60 var deviceConfigSpecs = new Array();
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;
69 configSpec.deviceChange = deviceConfigSpecs;
71 // Launch the reconfigVM task
72 task = vm.reconfigVM_Task( configSpec );
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"/>
86 <bind name="task" type="VC:Task" export-name="task"/>
89 <position x="100.0" y="220.0"/>
92 <workflow-item name="item5" out-name="item6" type="task">
93 <display-name>Retrieve Scsi controller found ?</display-name>
95 <script encoded="false">
96 scsiControllerKey = -1;
97 var devices = vm.config.hardware.device;
98 var isScsiBusNumberInvalid = true;
99 if(scsiBusNumber==null || 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 + ")" );
114 if(isScsiBusNumberInvalid){
115 System.log( "SCSI controller not found. The bus number entered is invalid" );
120 <bind name="vm" type="VC:VirtualMachine" export-name="vm"/>
121 <bind name="scsiBusNumber" type="number" export-name="scsiBusNumber"/>
125 <bind name="scsiControllerKey" type="number" export-name="scsiControllerKey"/>
128 <position x="100.0" y="100.0"/>
131 <workflow-item name="item6" out-name="item0" type="condition" alt-out-name="item2" comparator="0">
132 <display-name>Scsi controller found ?</display-name>
134 <script encoded="false">
135 //Generated by the system, cannot be edited
136 return (scsiControllerKey >= 0.0) ;
140 <bind name="scsiControllerKey" type="number" export-name="scsiControllerKey"/>
142 <condition name="scsiControllerKey" type="number" comparator="5" label="null">0.0</condition>
144 <position x="100.0" y="150.0"/>
147 <workflow-item name="item1" out-name="item3" type="task" script-module="com.vmware.library.vc.basic/vim3WaitTaskEnd">
148 <display-name>vim3WaitTaskEnd</display-name>
150 <script encoded="false">
151 //Auto generated script, cannot be modified !
152 actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,progress,pollRate) ;
156 <bind name="task" type="VC:Task" export-name="task">
157 <description>Task to Wait for</description>
159 <bind name="progress" type="boolean" export-name="progress">
160 <description>Log progess while waiting for the task</description>
162 <bind name="pollRate" type="number" export-name="pollRate">
163 <description>Polling rate for the task state [seconds]</description>
168 <bind name="actionResult" type="Any" explicitly-not-bound="true" export-name="NULL"/>
172 Wait a VIM 3 Task to end.
173 When task ended, return the
176 <position x="100.0" y="280.0"/>
179 <workflow-item name="item2" throw-bind-name="noContollerError" type="end" end-mode="1">
180 <position x="260.0" y="150.0"/>
183 <workflow-item name="item3" type="end" end-mode="0">
184 <position x="140.0" y="330.0"/>
187 <workflow-item name="item4" out-name="item5" type="task">
188 <display-name>check Params</display-name>
190 <script encoded="false">
191 if (diskSize < 0.01 ) {
192 throw ("Error, invalid parameter. Disk size should be no less than 0.01 ");
197 <bind name="diskSize" type="number" export-name="diskSize"/>
202 <position x="100.0" y="60.0"/>
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"/>
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>
225 <p-param name="diskMode">
226 <desc>Disk persistence mode</desc>
227 <p-qual kind="static" name="mandatory" type="boolean">true</p-qual>
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>
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>
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>
247 <p-param name="thinProvisioned">
248 <desc>Use thin provisioning?</desc>