Patrick
Patrick

Reputation: 111

Ordering Softlayer Vlan pairs

I've done some searching on stackoverflow and looked through the API but can't seem to find an answer specifically. I'm creating some automation scripts in python and wondering if there's a way to grab the primaryNetworkComponent and the primaryBackendNetworkComponent pairs and based on location? There's the getVlans() method but not sure which vlans go together unless i go to the gui. Is there no limit to the number of machines that can be on a vlan pair? if there isn't would it just be acceptable to grab the router and just take the first 2 vlans?

Upvotes: 0

Views: 344

Answers (3)

Ruber Cuellar Valenzuela
Ruber Cuellar Valenzuela

Reputation: 2757

I have success with the following script:

"""
List Hardware

Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware
https://github.com/softlayer/softlayer-python/blob/master/SoftLayer/managers/hardware.py

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

# Declare the API client
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
mgr = SoftLayer.HardwareManager(client)

globalIdentifier = '93e99548-bb97-4a18-b728-9c8ebba6s9e3'

try:
    mask = 'id, hostname, domain, hardwareStatus, globalIdentifier, remoteManagementAccounts, primaryBackendIpAddress, primaryIpAddress'
    hardware_list = mgr.list_hardware(mask=mask)
    for hardware in hardware_list:
        if globalIdentifier == hardware['globalIdentifier']:
            print(hardware['globalIdentifier'])

except SoftLayer.SoftLayerAPIError as e:
    print("Error. "
          % (e.faultCode, e.faultString))

You are right, the global identifiers are generated in the order receipt, but they are attached to the servers until the provision proccess finish. So, it's necessary to wait until the provision process from a server finishes, to search by this.

Upvotes: 0

Patrick
Patrick

Reputation: 111

i have this code

mask = 'id, hostname, domain, hardwareStatus, globalIdentifier, remoteManagementAccounts, primaryBackendIpAddress, primaryIpAddress'
    hardware_list = mgr.list_hardware(mask=mask)
    for hardware in hardware_list:
        if "someGLobalID" == hardware['globalIdentifier']:

in which i'm trying to get the global identifier but i keep getting a key error

Do global identifiers get generated after an order is completed and in the deploy status?

I tried searching a different key like domain and it works

Upvotes: 0

Ruber Cuellar Valenzuela
Ruber Cuellar Valenzuela

Reputation: 2757

The below script can help to retrieve vlans from specific location:

"""
Retrieves vlans from specific location

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getNetworkVlans
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Vlan/
http://sldn.softlayer.com/article/object-Masks
http://sldn.softlayer.com/article/object-filters

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

# Define location
datacenter = "Seoul 1"

# Declare the API client
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)

# Declaring an object mask and object filter to get vlans from datacenter
objectMask = "mask[primaryRouter[datacenter], networkSpace]"
objectFilter = {"networkVlans": {"primaryRouter": {"datacenter": {"longName": {"operation": datacenter}}}}}

try:
    # Getting the VLANs
    vlans = client['SoftLayer_Account'].getNetworkVlans(mask=objectMask, filter=objectFilter)
    # Print vlans
    print("PRIMARY NETWORK COMPONENT")
    for vlan in vlans:
        if vlan['networkSpace'] == 'PUBLIC':
            print("Id: %s     Vlan Number: %s      Primary Router: %s" % (vlan['id'], vlan['vlanNumber'], vlan['primaryRouter']['hostname']))
    print("\nPRIMARY BACKEND NETWORK COMPONENT")
    for vlan in vlans:
        if vlan['networkSpace'] == 'PRIVATE':
            print("Id: %s     Vlan Number: %s      Primary Router: %s" % (vlan['id'], vlan['vlanNumber'], vlan['primaryRouter']['hostname']))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to get Vlans. faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))

There is no limit for number of servers in a public vlan, but it depends from the available ip addresses , the same situation for private vlan. In case of private vlan has a limit of 256 ip addresses.

If the vlan has a hardware firewall, it has a limitation of 30 servers (VSIs or BMSs).

It's not possible to retrieve the first vlans from router, because this is something restricted, you only will be able to retrieve the vlans that you purchased.

References:

Upvotes: 0

Related Questions