-->

API :create a VSI with a public subnet fail with e

2019-09-07 17:49发布

问题:

Try to create a VSI with a public subnet fail with error " The subnet specified #1217371 (169.44.xxx.0/27) does not currently have available slots", but the subnet id should have enought ips

here is question

1 what's concept for slot ?
2 how to check slot infor for public subnet by API
3 how to apply slot

here is log

 >>> templateObject = {'domain': 'rccmlk.com', 'localDiskFlag': True, 'maxMemory': 1024, 'networkComponents': [{'maxSpeed': 1000}],'primaryBackendNetworkComponent': {'networkVlan': {'primarySubnetId': 821332}}, 'primaryNetworkComponent': {'networkVlan': {'primarySubnetId': 1217371}}, 'datacenter': {'name': 'dal09'}, 'hourlyBillingFlag': True, 'hostname': 'WDSPARKtest', 'startCpus': 1, 'operatingSystemReferenceCode': 'CENTOS_LATEST_64', 'sshKeys': [{'id': '756355'}]}
    >>> vsi = client['SoftLayer_Virtual_Guest'].createObject(templateObject)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 392, in call_handler
    return self(name, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 360, in call
    return self.client.call(self.name, name, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 263, in call
    return self.transport(request)
    File "/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py", line 195, in __call__
    raise _ex(ex.faultCode, ex.faultString)
    SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Public): The subnet specified #1217371 (169.44.xxx.xxx/27) does not currently have available slots. Free up space or remove the subnet specification.


    here is subnet infor
    {'addressSpace': 'PUBLIC',
    'broadcastAddress': '169.44.xxx.xxx',
    'cidr': 27,
    'datacenter': {'id': xxxxxx,
    'longName': 'Dallas 9',
    'name': 'xxxxxx',
    'statusId': 2},
    'gateway': '169.44.xxx.xxx',
    'hardware': [],
    'id': 1217371,<<<<<<<<<<<<<<<<<
    'ipAddressCount': 32,
    'isCustomerOwned': False,
    'isCustomerRoutable': False,
    'modifyDate': '2016-05-16T20:43:19-07:00',
    'netmask': '255.255.255.224',
    'networkIdentifier': '169.44.109.0',
    'networkVlan': {'id': 835113, 'networkSpace': 'PUBLIC'},
    'networkVlanId': 835113,
    'sortOrder': '2',
    'subnetType': 'SECONDARY_ON_VLAN',
    'totalIpAddresses': '32',<<<<<<<<<<<<<<<<<<
    'usableIpAddressCount': '29',
    'version': 4,
    'virtualGuests': []},<<<<<<<<<<<<<<<<<<<<<<
    Update 1

回答1:

Well first of all you need to make sure that you can order a VSI with that subnet using the control portal this is because the error displayed by the API is not quite accurate about the real error, so if you can use the subnet in control portal so it may be an issue with the Softlayer's Python client.

Jus in case you cannot use any subnet to order a VSI see more information about that here https://knowledgelayer.softlayer.com/learning/utilizing-subnets-and-ips practically you only can use the primary subnet.

The slots are free IP address in the subnet you can get the ip address of the subnet using this method

http://sldn.softlayer.com/reference/services/SoftLayer_Network_Subnet/getIpAddresses

Then you need to check the status of the if it is reservaded or not in case all the IP are reservaded so there is not free slots.

here you can see a related forum question about the free slots:

SoftLayer API to know and total and available IPs in a VLAN

I hope it helps you

Regards