SoftLayer管理block devices而不是虛擬訪客服務器的硬盤驅動器,您可以通過在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. <[email protected]>
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
問候,