September 30, 2014

Server Locate

List specific physical location for virtual machines
require 'softlayer_api' # gem install softlayer_api
require 'table_print' # gem install table_print

# Credentials to the SoftLayer API are grabbed from the config file by default.
# See
SoftLayer::Client.default_client =

servers = SoftLayer::VirtualServer.find_servers(object_mask: 'mask[location.pathString]')
location_info = do |server|
  datacenter, server_room, rack, slot = server['location']['pathString'].split('.')
    server: server.fullyQualifiedDomainName,
    data_center: datacenter,
    server_room: server_room,
    rack: rack,
    slot: slot

tp location_info


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