Попробуйте использовать следующий пример сценария python:
import SoftLayer
from prettytable import PrettyTable
USERNAME = 'set me'
API_KEY = 'set me'
# Declare the API client
client = SoftLayer.create_client_from_env(USERNAME, API_KEY)
account_service = client['SoftLayer_Account']
x = PrettyTable()
x.field_names = ["HardwareComponentType", "Manufacturer", "Name"]
object_mask = 'mask[components]'
try:
response = account_service.getHardware(mask=object_mask)
count = 0
for hardware in response:
for component in hardware['components']:
component_type = component['hardwareComponentModel']['hardwareGenericComponentModel'][
'hardwareComponentType']['type']
if component_type == 'GPU':
gpu_type = component_type
gpu_manufacturer = component['hardwareComponentModel']['manufacturer']
gpu_name = component['hardwareComponentModel']['name']
x.add_row([gpu_type, gpu_manufacturer, gpu_name])
count = count + 1
print(x)
print("Number of Bare Metal devices in the account that have a GPU")
print(str(count))
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 the hardware information \nfaultCode= %s, \nfaultString= %s"
% (e.faultCode, e.faultString))