February 16, 2017


Subnets and Bandwidth Pools
An example of getting information on portable subnets and servers in a bandwidth pool.

import SoftLayer
from pprint import pprint as pp

class example():

    def __init__(self):

        self.client = SoftLayer.Client()

    def getPublicSubnets(self):
        """
        subnet types
        SECONDARY_ON_VLAN = Portable IPs
        PRIMARY
        SUBNET_ON_VLAN = static subnets
        PRIMARY_6
        STATIC_IP_ROUTED
        GLOBAL_IP
        ADDITIONAL_PRIMARY
        """
        object_filter = {
            'publicSubnets' : {
                'subnetType' : {
                    'operation': 'SECONDARY_ON_VLAN'
                }
            }
        }

        subnets = self.client['Account'].getPublicSubnets(filter=object_filter)
        pp(subnets)

    def getBandwidthPools(self):
        """
        bareMetalInstances and privateNetworkOnlyHardware
        may need to be included in the mask if applicable. 
        """
        mask = "mask[hardware,virtualGuests]"
        pool = self.client['Account'].getVirtualDedicatedRacks(mask=mask)
        pp(pool)


if __name__ == "__main__":
    main = example()
    main.getBandwidthPools()
    main.getPublicSubnets()

Feedback?

We would love to hear it
Open an issue

/python/bandwidthPoolsAndSubnets/