Hello everyone,
We are currently working to automate our VM deployment process using vRealize Automation (VRA). We see that we cannot do this using the Orion SDK, or a VRA Plugin, though both are being worked on.
A contractor developed the SQL queries below, that we would like to use to get IPs. I was hoping for a second set of eyes to review these and verify that we are not missing anything.
I have tested everything with select queries in SQL Studio (not update), and all looks well. One question I have is: do we need to manually update the reserved count and percent used columns, or will they get updated automatically?
--Get first 'Available' IP (starting after 10) based on Address and CIDR:
SELECT Top (1) IPAddress FROM IPAM_Node AS a INNER JOIN IPAM_Group as b ON a.SubnetId=b.GroupId WHERE b.Address = 'xxx.xxx.xxx.xxx' AND b.CIDR = 'xx' AND a.Status=2 AND IPOrdinal > 10
--Update the IP Status to 'Used':
UPDATE IPAM_Node SET Status=4, StatusBy=9, Comments='Automated allocation from vRealize', LastSync=NULL WHERE IPAddress='xxx.xxx.xxx.xxx'
--Update reserved count after allocation:
UPDATE IPAM_Group SET ReservedCount = ReservedCount + 1 WHERE Address = 'xxx.xxx.xxx.xxx' AND CIDR = 'xx' AND GroupId IN (SELECT SubnetID From IPAM_Node)
--Update percent used:
DECLARE @PercentUsed decimal(19,5)
SET @PercentUsed =
(SELECT cast(cast(a.used as float) / cast(a.AvailableCount as float) as decimal(19,5))
FROM (SELECT UsedCount + ReservedCount AS used, AvailableCount
FROM IPAM_Group
WHERE Address = 'xxx.xxx.xxx.xxx' AND CIDR = 'xx' AND GroupId IN (SELECT SubnetID From IPAM_Node))
a)
UPDATE IPAM_Group SET PercentUsed=@PercentUsed WHERE Address = 'xxx.xxx.xxx.xxx' AND CIDR = 'xx' AND GroupId IN (SELECT SubnetID From IPAM_Node)
Thanks,
Tanner