We would like to find out how many VMs are already in a subnet, and what the leftover capacity is. What Softlayer APIs shall we use to achieve this?
问题:
回答1:
Try the following rest request:
https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Network_Subnet/$SubnetID/getIpAddresses?objectMask=mask[ id, isBroadcast, isGateway, isNetwork, isReserved, subnetId, hardware, virtualGuest, guestNetworkComponentBinding, ipAddress, note, publicNetworkGateway,privateNetworkGateway, virtualLicenseCount, applicationDeliveryController]
Ok lets see, the request above will return all your ip and their assigments to hardware (bare metal server) or virtual guest. Now the first thing you need to look is the value of the properties:
isBroadcast isGateway isNetwork isReserved
If any of those values is true so the IP is reserved and also they are going to help you to know what kind the IP is (e.g. gateway etc.)
Then you need to look the "guestNetworkComponentBinding" if this property is differnt of null so the IP is in use (in the control portal you will see in the description of this IP "Primary IP").
Then you need to look at the "hardware" property if this value is differnt from null the IP is being used for a Baremetal server the "hardware" property will give you more information about the server.
Then you need to look at the "virtualGuest" property this is the same as the "hardware" property but applied for virtual guests.
then you need to look at "applicationDeliveryController" property this is used for netscalers, again if this property is not null the IP is being used for a device.
For the cases that all the values above are null the IP should not be in use (in control portal I saw as description reserved for future Primary IP address)
Well those are the cases that I was able to see, if you still getting issues let me know
Regards