November 23, 2017
List Bare Metal servers.

The script retrieve a list of all bare metal servers in your
account. it makes a single call to the Softlayer_Account::getHardware
method for more information see below.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
import SoftLayer

# For nice debug output:
from pprint import pprint as pp

# Your SoftLayer API username and key.
API_USERNAME = 'set-me'

# Generate one at
API_KEY = 'set-me'

# Create a SoftLayer API client object
client = SoftLayer.create_client_from_env(username=API_USERNAME, api_key=API_KEY)

We will retrieve the additional information
for each server:
primaryIpAddress, primaryBackendIpAddress,
datacenter, datacenterName, serviceProvider,
object_mask = 'primaryIpAddress, primaryBackendIpAddress, datacenter,' \
              'datacenterName, serviceProvider, hardwareFunctionDescription'

    # getHardware() will get all the bare metal servers that an account has.
    hardwareList = client['SoftLayer_Account'].getHardware(mask=object_mask)
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to list the bare metal servers: \nfaultCode= %s, \nfaultString= %s"
          % (e.faultCode, e.faultString))


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