November 23, 2017


# Get the recurring cost of a single server or all servers on your account.
# Get a list of servers on a SoftLayer account along with their recurring
# monthly costs. We can get that by calling getHardware() in the
# SoftLayer_Account API service with an object mask to retrieve cost.
# Important manual pages
# License:
# Author: SoftLayer Technologies, Inc. <>
require 'softlayer_api'
require 'pp'

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

# Declaring the object mask to get information about cost of the bare metal server
object_mask = 'mask(SoftLayer_Hardware_Server).cost'

# Declare the API client
client = USERNAME, api_ke: API_KEY)
hardware_account = client['SoftLayer_Account']

  # Retrieve our account's hardware records.
  servers = hardware_account.object_mask(object_mask).getHardware
  print servers
rescue StandardError => exception
  puts "Unable to retrieve the VSIs. : #{exception}"


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue