SoftLayer API (Ruby):无法为 virtual_guest 获取存储 space

SoftLayer API (Ruby): Unable to get storage space for a virtual_guest

检索硬件机器的硬盘 space 很简单。我可以调用 getHardware 并遍历 "hardDrives[capacity]" 值的数组。我想从 getVirtualGuests 调用中获得相同的信息,但我无法弄清楚如何执行此操作。我使用以下页面作为可用信息的参考: https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest

有人可以帮忙指出从哪里获得 virtual_guest 的存储容量吗?

SoftLayer 管理 block devices instead of hard drives for Virtual Guest servers, you can know their space capacity by using the following mask over the SoftLayer_Account::getVirtualGuests 方法。

blockDevices[diskImage[capacity]]

以下代码示例显示如何获取块设备的容量。

# List all VSIs in your account.
#
# Important manual pages:
# https://sldn.softlayer.com/reference/services/SoftLayer_Account
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest
#
# @license <http://sldn.softlayer.com/article/License>
# @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'softlayer_api'
require 'pp'

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

# Create a SoftLayer API client object
client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
account_service = client['SoftLayer_Account']

# We will retrieve the additional information for each VSI:
mask = 'mask[id,blockDevices[id,mountType,diskImage[capacity]]]'
begin
  # getVirtualGuests() will get all the VSIs that an account has.
  result = account_service.object_mask(mask).getVirtualGuests
  pp result
rescue StandardError => exception
  puts "Unable to  get the VSIs: #{exception}"
end

此致,