2017-04-03 85 views
0

檢索硬件機器的硬盤空間很簡單。我可以調用getHardware並遍歷「hardDrives [capacity]」值的數組。我想從getVirtualGuests調用中獲得相同的信息,但我無法解決如何執行此操作。我使用以下頁面作爲可用信息的參考: https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_GuestSoftLayer API(Ruby):無法獲取虛擬目錄的存儲空間

有人可以幫助指出在哪裏獲得virtual_guest的存儲容量嗎?

回答

1

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 

問候,