1 2 Previous Next 19 Replies Latest reply on May 2, 2019 5:41 AM by tchristin Go to original post
      • 15. Re: Can VRA be considered as IPAM?
        Dell_Technologies Novice

        I tried to populate some of the parameters with values, but still no luck.

         

        Do you know which params I should fill ?

        • 17. Re: Can VRA be considered as IPAM?
          tchristin Novice

          Hi,

           

          I was not able to use this API.

          My workaround is to use ODATA in the IaaS DB to lock or unlock IP addresses.

          • 18. Re: Can VRA be considered as IPAM?
            Dell_Technologies Novice

            Could you please explain more about your solution ?

            • 19. Re: Can VRA be considered as IPAM?
              tchristin Novice

              Of course, my piece of code:

               

              // Get VM entity (mandatory to allocate IP)

              var query = "VirtualMachineID eq guid'" + virtualMachineId + "'";

              var virtualMachineEntity = vCACEntityManager.readModelEntitiesBySystemQuery(iaasHost.id, "ManagementModelEntities.svc", "VirtualMachines", query, null, null, null, null, null)[0];

               

               

              if (virtualMachineEntity == null)

              {

                   var errorCode = "No VM found!";

                   System.error(errorCode);

                   throw errorCode;

              }

               

               

              // Get an available IP address

              var filter = "StaticIPv4AddressState eq 1"

              // Retrieve all IP addresses

              var freeIps = vCACEntityManager.readModelEntitiesBySystemQuery(iaasHost.id, modelName, "StaticIPv4Addresses", filter, null, null, null, null, null);

               

               

              if (freeIps != null)

              {

                   for each (ip in freeIps)

                   {

                        var networkProfile = ip.getLink(iaasHost, "StaticIPv4NetworkProfile");

               

                        if (networkProfile[0].getProperty("ID") == networkProfileId)

                        {

                             var ipAddress = ip

                             System.log("First available IP address is: " + ipAddress.getProperty("IPv4Address"));

                             break;

                        }

                   }

              }

               

               

              if (ip != null)

              {

                   // Allocate IP address

                   var updateProperties = new Properties();

                   var updateLinks = new Properties();

                   // Set IP address allocated (0)

                   updateProperties.put("StaticIPv4AddressState", 0);

                   // Set virtual machine ID

                   updateLinks.put("VirtualMachine", [virtualMachineEntity]);

                   System.getModule("com.vmware.library.vcac").updateVCACEntity(iaasHost.id, modelName, ipAddress.entitySetName, ipAddress.keyString,      updateProperties, updateLinks, null);

                   System.log("IP address : " + ipAddress.getProperty("IPv4Address") + " is now allocated.");

               

                   // Add properties to be updated

                   newProperties.put("VirtualMachine.Network0.Address", ipAddress.getProperty("IPv4Address"), false, false);

                   newProperties.put("VirtualMachine.Network0.DnsSearchSuffixes", dnsSearch, false, false);

                   newProperties.put("VirtualMachine.Network0.DnsSuffix", dnsSuffix, false, false);

                   newProperties.put("VirtualMachine.Network0.Gateway", gateway, false, false);

                   newProperties.put("VirtualMachine.Network0.PrimaryDns", primaryDns, false, false);

                   newProperties.put("VirtualMachine.Network0.SubnetMask", subnet, false, false);

               

                   if (secondaryDns != null)

                   {

                        newProperties.put("VirtualMachine.Network0.SecondaryDns", secondaryDns, false, false);

                   }

                   else

                   {

                        newProperties.put("VirtualMachine.Network0.SecondaryDns", "", false, false);

                   }

              }

              else

              {

                   errorCode = "IP range is exhausted !";

                   System.error(errorCode);

                   throw errorCode;

              }

               

              If you need more explanation just let me know.

              Of course you need to lock this worklow when you're working with IP allocation.

               

              Cheers,

               

              Tim.

              1 2 Previous Next