Simple little code snippet that you might find handy to use in vCenter Orchestrator. Â I am working on a workflow that needs to clone a VM and the name should increment by 1 for example, we want to clone appweb1 (but we already have appweb2, 3, 4) so we want the new VM to be appweb5.
Inside a new Scriptable task create an output parameter called newvmname and make it’s source itself. Â Then use this bit ‘o code:
1 2 3 4 |
var vms = System.getModule("com.vmware.library.vc.vm").getAllVMsMatchingRegexp("appweb[0-9]"); for (var i=0; i System.debug("Counting VMs:" + i); } var newvmname = "appweb" + i; |
1 |
<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">If anyone has a better way to do this I'd love to hear it, I know you should be able to use the getAllVMsMatchingRegexp as an action inside the Schema but it seemed clunky to do that then pass to a Scriptable task when you can do it all in one object.</span> |