første xml update
[virt-orchestrator.git] / vFLOWER / content / Actions / com.vmware.library.vc.vm.power / shutdownVM.action.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <dunes-script-module name="shutdownVM" result-type="void" api-version="3.1.0" id="cf810eef-158a-49bd-8ee9-7f9616b7519b" version="0.2.0" allowed-operations="fv">
3     <description>Shutdown the VM guest and wait for a given time before throwing an error if the VM is still not powered off. If timeout is set to 0, the action don't wait</description>
4
5     <param n="vm" t="VC:VirtualMachine"/>
6
7     <param n="timeout" t="number">Timeout in minutes [min]</param>
8
9     <param n="polling" t="number">Polling rate in seconds [s]</param>
10
11     <script encoded="false">
12 if (timeout == null || timeout &lt; 0) {
13         timeout = 0
14 }
15 timeout = timeout * 60;
16 var status = vm.runtime.powerState.value;
17 vm.shutdownGuest() ;
18 while(timeout &gt; 0){
19         var status = vm.runtime.powerState.value;
20         if(status == "poweredOff"){
21                 break;
22         }
23         timeout -= polling;
24         if (timeout &lt;= 0) {
25                 throw "Timeout: VM " + vm.name + "is still power on";
26         }
27         System.sleep(polling * 1000);
28 }
29     </script>
30 </dunes-script-module>