0

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 Answers1

0

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

  • Thanks for the reply. I can use the API to get a list of IPs in the subnet, and trying to understand how to determine the status. I do not see the "status" and "description" fields as described in the link you mentioned. Here is what I saw in "guestNetworkComponentBinding":{"ipAddressId":61768639,"port":null,"type":"PRIMARY"}. Does it mean that as long as the "guestNetworkComponentBinding" tag is there, that IP is being used, and if the tag is not there, that IP is still available? – Little Fish Oct 29 '16 at 02:04
  • Hi, I have been using the SL API from your reply to get information about the subnet, and check the tag "guestNetworkComponentBinding" to determine whether the IP is available or not. However, there were cases that the tag was not there for the IP, which means that the IP should be available. But when I went to SL portal, it showed that the IP was in use. Is it good enough to use the tag to determine whether the IP is available or not? Any hole with this logic? – Little Fish Mar 30 '17 at 03:21
  • what cases? can you explain better the cases in order to look into that? – Nelson Raul Cabero Mendoza Mar 30 '17 at 12:40
  • Basically when I used the API you gave, there is no "guestNetworkComponentBinding" listed for the IP. For example, I got something like this: – Little Fish Mar 30 '17 at 13:58
  • Basically when I used the API you gave, there is no "guestNetworkComponentBinding" listed for the IP. For example, I got something like this: {"id": 12345678, "ipAddress": "1.2.3.4", "isBroadcast": false, "isGateway": false, "isNetwork": false, "isReserved": false, "subnetId": 10123456, "subnet":null}. But when I go to Softlayer Portal, and under Network->IP Management->VLANs, find the VLAN, and then look at the details of the subnet, the same IP shows "in use", and has hostname associated with it. – Little Fish Mar 30 '17 at 14:04
  • I updated the answer let me know if this now achieves your goals regards – Nelson Raul Cabero Mendoza Mar 30 '17 at 14:57
  • I tried the updated API call, and all it returned for the given IP is { "id": 40xxxxxx, "ipAddress": "x.x.x.x", "isBroadcast": false, "isGateway": false, "isNetwork": false, "isReserved": false, "subnetId": 10xxxx }, but the SL Portal indicates the same IP is "In Use". – Little Fish Mar 30 '17 at 18:11
  • can you give me the id of the subnet? I will see what is happening. just in case did it not say reserved for future primary IP address? – Nelson Raul Cabero Mendoza Mar 30 '17 at 18:14
  • Just in case if you subnet is primary you will see in the portal the status reservaded and the description "Primary IP for future server only" for non-used ips, those IPs only can be used for new bare metal servers or virtual guests and you should be able to use that subnet in a new order – Nelson Raul Cabero Mendoza Mar 30 '17 at 18:22
  • I am seeing everthing fine man your subnet is primary so as I told you you see some IPs as reserved and in the description "Primary IP for future server only" that's okay that means that IP only can be used for softlayer for future servers and as I told you before you can use that subnet in your orders because it is still having free IPs (The Primary IP for future servers onl;y ones) – Nelson Raul Cabero Mendoza Mar 30 '17 at 18:41
  • Again, when I used API to pull information from that subnet, all of the IPs are free. However, when I looked at SL portal, the ip x.x.x.36 is "In Use", which is not consistent with the value returned from the API. – Little Fish Mar 30 '17 at 19:00
  • your IP has attached a hardware, that is returned by the request that I provided you in my answer ,so the IP is in use as I explained in my answer, so I do not undertand what is wrong bro. – Nelson Raul Cabero Mendoza Mar 30 '17 at 19:13
  • The problem is that I do not see anything about hardware or virtualGuest is being returned for that IP. – Little Fish Mar 30 '17 at 19:54
  • try with the master users I was able to see it with the request that I passed you for your subnet, perhaps your user does not have enough permissions – Nelson Raul Cabero Mendoza Mar 30 '17 at 20:02
  • Yes, I was also thinking whether my id has the permission to see it. I tried with two ids I have, and they returned the same result. I do not have other master user that I can try. If I need to request more permission for the id I am using, what permission shall I ask? – Little Fish Mar 30 '17 at 20:09
  • BTW, I do see virtualGuest for other subnets where there is such occurrence. Not sure what extra permission I need to see hardware related information. – Little Fish Mar 30 '17 at 20:10
  • Me neither, are you usng the same user for both the control portal and Api request? – Nelson Raul Cabero Mendoza Mar 30 '17 at 22:39
  • Ok I verified that you need the device access granted and the permission to view the details of the server or virtual guest if you do not have both permissions the API will not display the value of the property – Nelson Raul Cabero Mendoza Mar 31 '17 at 13:06