通过 API 重新创建带宽池详细信息屏幕
re-creating bandwidth pool detail screen via API
我正在尝试从带宽池中以编程方式转储每台计算机的带宽使用情况。
我已经创建了可以使用 API 添加和删除我的服务器的代码,但我还没有设法找到正确的机制来获取每台机器的使用详细信息。
看起来像:
是正确的 api 调用,调用它会给我一个分配详细信息列表,但我无法计算出正确的掩码来获取我需要的所有详细信息。
到目前为止,我已经尝试了以下掩码:
"allocation.amount;allocation.billingItem.hostname;bandwidthAllotment.amount;bandwidthAllotment.billingItem.hostname;bandwidthUsage.amount;bandwidthUsage.billingItem.hostname"
但这并没有让我获得我需要的详细信息,而且似乎引入了大量不在过滤器中的额外字段,使调用需要很长时间才能完成。
有谁知道如何构建正确的过滤器?
要了解移入带宽池机架的所有硬件服务器的带宽使用情况,您必须使用服务的方法 getHardware SoftLayer_Account,因为它是控制门户使用的方法和服务。
使用此剩余 api 获取硬件服务器的带宽使用信息:
方法:获取
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware?objectMask=mask[id,primaryIpAddress,datacenter[longName,groups[id]],bandwidthAllocation,outboundPublicBandwidthUsage,billingItem[nextBillDate],virtualRackId,bareMetalInstanceFlag]&objectFilter={"hardware":{"virtualRackId":{"operation":11111}}}
更改 virtualRackId:11111 为您的 virtualRackId,这是您正在使用的带宽池 ID。
您在控制门户中找到的当前使用情况,您将在此处找到具有“outboundPublicBandwidthUsage”属性的响应。
在硬件服务器中没有“projectedPublicBandwidthUsage”属性,但在虚拟服务器中您会找到该选项。
参考:
https://softlayer.github.io/reference/datatypes/SoftLayer_Hardware/
与带宽池关联的虚拟服务器也是如此,但在这种情况下,您将获得属性“projectedPublicBandwidthUsage”,即控制门户中的“PROJECTED USAGE”。
为虚拟服务器使用其余 api:
方法:获取
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,primaryIpAddress,datacenter[longName,groups[id]],bandwidthAllocation,outboundPublicBandwidthUsage,billingItem[nextBillDate],virtualRackId,projectedPublicBandwidthUsage]&objectFilter={"virtualGuests":{"virtualRackId":{"operation":11111}}}
与上面相同,将 virtualRackId 更改为您的带宽池 ID。
参考:
https://softlayer.github.io/reference/datatypes/SoftLayer_Virtual_Guest/
我正在尝试从带宽池中以编程方式转储每台计算机的带宽使用情况。
我已经创建了可以使用 API 添加和删除我的服务器的代码,但我还没有设法找到正确的机制来获取每台机器的使用详细信息。
看起来像:
是正确的 api 调用,调用它会给我一个分配详细信息列表,但我无法计算出正确的掩码来获取我需要的所有详细信息。
到目前为止,我已经尝试了以下掩码:
"allocation.amount;allocation.billingItem.hostname;bandwidthAllotment.amount;bandwidthAllotment.billingItem.hostname;bandwidthUsage.amount;bandwidthUsage.billingItem.hostname"
但这并没有让我获得我需要的详细信息,而且似乎引入了大量不在过滤器中的额外字段,使调用需要很长时间才能完成。
有谁知道如何构建正确的过滤器?
要了解移入带宽池机架的所有硬件服务器的带宽使用情况,您必须使用服务的方法 getHardware SoftLayer_Account,因为它是控制门户使用的方法和服务。
使用此剩余 api 获取硬件服务器的带宽使用信息:
方法:获取
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware?objectMask=mask[id,primaryIpAddress,datacenter[longName,groups[id]],bandwidthAllocation,outboundPublicBandwidthUsage,billingItem[nextBillDate],virtualRackId,bareMetalInstanceFlag]&objectFilter={"hardware":{"virtualRackId":{"operation":11111}}}
更改 virtualRackId:11111 为您的 virtualRackId,这是您正在使用的带宽池 ID。
您在控制门户中找到的当前使用情况,您将在此处找到具有“outboundPublicBandwidthUsage”属性的响应。
在硬件服务器中没有“projectedPublicBandwidthUsage”属性,但在虚拟服务器中您会找到该选项。
参考:
https://softlayer.github.io/reference/datatypes/SoftLayer_Hardware/
与带宽池关联的虚拟服务器也是如此,但在这种情况下,您将获得属性“projectedPublicBandwidthUsage”,即控制门户中的“PROJECTED USAGE”。
为虚拟服务器使用其余 api:
方法:获取
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,primaryIpAddress,datacenter[longName,groups[id]],bandwidthAllocation,outboundPublicBandwidthUsage,billingItem[nextBillDate],virtualRackId,projectedPublicBandwidthUsage]&objectFilter={"virtualGuests":{"virtualRackId":{"operation":11111}}}
与上面相同,将 virtualRackId 更改为您的带宽池 ID。
参考:
https://softlayer.github.io/reference/datatypes/SoftLayer_Virtual_Guest/