November 23, 2017


is_pingable.rb

is_pingable.rb
# Issues a ping command and returns the success (true) or failure (false) of the ping command.
#
# Important manual pages:
# http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/isPingable
#
# License: http://sldn.softlayer.com/article/License
# Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>

require 'rubygems'
require 'softlayer_api'
require 'awesome_print'

virtual_guest_id = 6032256

SL_API_USERNAME = 'set me'
SL_API_KEY = 'set me'

client = SoftLayer::Client.new(username: SL_API_USERNAME,
                               api_key: SL_API_KEY)

virtual_guest_service = client['SoftLayer_Virtual_Guest']

begin
  pingable = virtual_guest_service.object_with_id(virtual_guest_id)
                                  .isPingable
  ap pingable
rescue StandardError => e
  p 'Error when executing the script...'
  $stdout.print(e.inspect)
end

Feedback?

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