VMware Cloud Community
n8watcher
Contributor
Contributor

vRO 7.6 Check IP in vCenter workflow

Hi together,

I'm stuck in creating a workflow to check if the given IP is existing in our vCenter. I've got two scriptable tasks. The first one is working but didn't fill the variables which I need for error handling, sending teams and mail notification ( yes the attributes are create in the workflow and assigned to the scriptable task ). The second script should work faster but is every time going to error also if the IP doesn't exist:

object = SdkConnection.searchIndex.findByIp(null,depIP,true);

var vm = object.Name


if (vm != null ) {

   throw IPError

} else {

  System.log("IP: "+ depIP+" not detected.");

}


System.log("Object Name: "+object.Name)

vmlist = VcPlugin.getAllVirtualMachines();


for (i = 0; i < vmlist.length; i++) {

  vm = vmlist[i];

    if(vm.guest.IpAddress == depIP) {

        System.log ("VM: "+vm.name +", IP: "+ depIP);

     Host = "VM: "+vm.name +", IP: "+ depIP + "deployment failed";

  messageTitle = "VM: "+vm.name +", IP: "+ depIP + "deployment failed";

  messageText = "VM deployment failed because of duplicate IP";

  ErrorContentFailed = messageText;

   throw "IP exist";

        }

        else {

            System.log("IP: "+ depIP+" not detected.");

            }

    }

I'm new with vRO and scripting so any help is appreciated.

Thanks guys.

Reply
0 Kudos
0 Replies