如何通过SoftLayer API判断运行中的VSI是否配备vGPU?
识别vGPU虚拟客户机的ObjectMask配置
要判断你的VSI是否配备vGPU,你需要在现有的objectMask中添加GPU组件相关的字段——这是最直接准确的方式。
需要添加的Mask字段
你需要在当前的mask里追加以下内容:
,gpuComponents[id, name, manufacturer, model, memoryCapacity, isGpuPartition]
更新后的完整Mask
把上面的内容加入你原有的mask后,最终的mask参数会是:
mask[datacenter,status,globalIdentifier,primaryIpAddress,primaryBackendIpAddress,billingItem.categoryCode,billingItem.description,billingItem.createDate,billingItem.orderItem.order.userRecord.username,billingItem.orderItem.order.userRecord.email,users.username,users.email,users.userStatus,operatingSystemReferenceCode,softwareComponents.passwords,operatingSystem,hourlyBillingFlag,localDiskFlag,managedResourceFlag,privateNetworkOnlyFlag,powerState,blockDeviceTemplateGroup.name,blockDeviceTemplateGroup.id,blockDeviceTemplateGroup.blockDevices,blockDevices.diskImage,networkVlans,activeTransactionCount,activeTransactions,consoleIpAddressRecord.type,consoleIpAddressRecord.port,consoleIpAddressRecord.ipAddress.ipAddress,userDataCount,userData,gpuComponents[id, name, manufacturer, model, memoryCapacity, isGpuPartition]]
如何判断结果
调用API后,你可以通过以下方式判断:
- 如果返回的
gpuComponents数组不为空,说明该VSI是vGPU实例; - 你还能从
gpuComponents的字段里获取详细信息:比如model查看GPU型号,memoryCapacity查看显存大小,isGpuPartition判断是否为GPU分区类型的实例。
另外,也可以辅助检查billingItem.categoryCode是否为gpu,但这个方式不如直接查看gpuComponents可靠,因为部分特殊场景下可能存在偏差。
内容的提问来源于stack exchange,提问作者Gary Sutherland
相关产品推荐
相关产品推荐

