System information

Usin g Pyt h o n t o List Available H o st s on Sat ellit e 6
This example uses a Python script to connect to Satellite 6, authenticate, and retrieve a list of
available hosts.
#!/usr/bin/python
import json
import requests
# Define Satellite location and login details
SAT_API = "https://localhost/api/v2/"
USERNAME = "admin"
PASSWORD = "changeme"
SSL_VERIFY = False
def get_json(location):
"""
Performs a GET using the passed URL location
"""
r = requests.get(location, auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY)
return r.json()
def main():
# List all hosts available to the user
hosts = get_json(SAT_API + "hosts/")
# Pretty Print the returned JSON of Hosts
print json.dumps(hosts, sort_keys=True, indent=4)
if __name__ == "__main__":
main()
Usin g Rub y t o List Available Hosts on Sat ellite 6
This example uses a Ruby script to connect to Satellite 6, authenticate, and retrieve a list of available
hosts.
#!/usr/bin/ruby193-ruby
require 'json'
require 'rest-client'
url = 'https://localhost/api/v2/'
$username = 'admin'
$password = 'changeme'
def get_json(location)
response = RestClient::Request.new(
:method => :get,
:url => location,
:user => $username,
Chapt er 4 . Advanced T ransit ioning
4 5