データセンターの値を取得するには、オブジェクト マスクを使用する必要があります
例:
mask[serviceResource[datacenter[name]]]
また、次の Ruby スクリプトを試して、そのような情報を取得することもできます。
# Get Network Storage
#
# This script retrieves an account's associated storage volumes.
#
# Important manual pages
# http://sldn.softlayer.com/reference/services/SoftLayer_Account/getNetworkStorage
# http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Storage
#
# @License: http://sldn.softlayer.com/article/License
# @Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'rubygems'
require 'softlayer_api'
require 'pp'
# Declare your SoftLayer username and apiKey
SL_API_USERNAME = 'set me'
SL_API_KEY = 'set me'
# Create the client
client = SoftLayer::Client.new(username: SL_API_USERNAME, api_key: SL_API_KEY)
# Define an object mask to get datacenter name
object_mask = 'mask[serviceResource[datacenter[name]]]'
begin
storages = client['SoftLayer_Account'].object_mask(object_mask).getNetworkStorage
print "+------------+---------------------------+------------+-----------------------+\n"
print "| ID | Datacenter | Size | Username |\n"
print "+------------+---------------------------+------------+-----------------------+\n"
storages.each do |storage|
printf('| %-10s ', storage['id'])
if storage['serviceResource'].has_key?('datacenter')
datacenter = storage['serviceResource']['datacenter']['name']
else
datacenter = 'None'
end
printf('| %-25s ', datacenter)
printf('| %-10s ', storage['capacityGb'])
printf("| %-21s | \n", storage['username'])
end
rescue StandardError => exception
puts "Error. : #{exception}"
end
参考文献: