haunm
haunm

Reputation: 39

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

Retrieving the hard disk space for a Hardware machine is straightforward. I can call getHardware and loop over the array of "hardDrives[capacity]" values. I'd like to get the same information from the getVirtualGuests call but I am having trouble figuring out how to do this. I'm using the following page as a reference on what information is available: https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest

Can someone help point to where to get the storage capacity for a virtual_guest?

Upvotes: 0

Views: 42

Answers (1)

Albert Camacho
Albert Camacho

Reputation: 1104

SoftLayer manage 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 method.

blockDevices[diskImage[capacity]]

Following code example shows how to get the capacity of block devices.

# 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

Regards,

Upvotes: 1

Related Questions