November 23, 2017


ListDedicatedHost.py

ListDedicatedHost.py
"""
List the dedicated hosts in the account.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getDedicatedHosts
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_DedicatedHost

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer
import json

USERNAME = 'setme'
API_KEY = 'setme'

client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
accountService = client['SoftLayer_Account']

try:
    response = accountService.getDedicatedHosts()
    print(json.dumps(response, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to list the dedicated hosts. 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