November 23, 2017

Classes SoftLayer_Account
Tags vlans

get_vlan_for_account.py

get_vlan_for_account.py
"""
Example to get the VLANS in an account

The example retrieves a list of all VLANs in the account.
It makes a single call to the SoftLayer_Account::getPublicNetworkVlans
method. For more information please see below.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getPublicNetworkVlans
http://sldn.softlayer.com/reference/services/SoftLayer_Account/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
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)

# Declaring an object mask to get more information about the VLANs
objectMask = "primaryRouter[datacenter], dedicatedFirewallFlag, firewallNetworkComponentCount, firewallGuestNetworkComponentCount, firewallInterfaces, highAvailabilityFirewallFlag, networkVlanFirewall"

try:
    # Getting the VLANs
    result = client['SoftLayer_Account'].getPublicNetworkVlans(mask=objectMask)
    print(result)
except SoftLayer.SoftLayerAPIError as e:
    """
    If there was an error returned from the SoftLayer API then bomb out with the
    error message.
    """
    print("Unable to get Vlans. faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))

Feedback?

If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue