første xml update
[virt-orchestrator.git] / vFLOWER / content / Actions / com.vmware.library.vc.vm.network / getNetworkForGivenNic.action.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <dunes-script-module name="getNetworkForGivenNic" result-type="VC:Network" api-version="3.1.0" id="43191800-13b2-4ec6-814f-3de5f07252d6" version="0.3.1" allowed-operations="fv">
3     <description>Retrun the network for a given VM nic</description>
4
5     <param n="vm" t="VC:VirtualMachine">VM to get the first network</param>
6
7     <param n="nicNumber" t="number">1 to 4: the nic number</param>
8
9     <script encoded="false">
10 var devices = vm.config.hardware.device;
11
12 for (var i in devices) {
13         if (System.getModule("com.vmware.library.vc.vm.network").isSupportedNic(devices[i])) {
14                 if (--nicNumber == 0) {
15                         if (devices[i].backing instanceof VcVirtualEthernetCardNetworkBackingInfo) {
16                                 return VcPlugin.convertToVimManagedObject(vm ,devices[i].backing.network);
17                         } else if (devices[i].backing instanceof VcVirtualEthernetCardDistributedVirtualPortBackingInfo) {
18                                 var moRef = new VcManagedObjectReference();
19                                 moRef.type = "DistributedVirtualPortgroup";
20                                 moRef.value = devices[i].backing.port.portgroupKey;
21                                 return VcPlugin.convertToVimManagedObject(vm ,moRef);
22                         } else {
23                                 return null;
24                         }
25                 }
26         }
27 }
28 return null;
29     </script>
30 </dunes-script-module>