我如何确定裸机设备具有GPU以及哪种类型的GPU?

问题描述 投票:0回答:1

我正在尝试确定我的IBM Cloud帐户中具有GPU的Bare Metal设备的数量,GPU的数量以及GPU的类型。使用REST API如何做到这一点?谢谢。

ibm-cloud-infrastructure
1个回答
0
投票
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))
© www.soinside.com 2019 - 2024. All rights reserved.