System information

import json
import requests
# Define Satellite location and login details
SAT_API = "https://localhost/api/v2/"
POST_HEADERS = {'content-type': 'application/json'}
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 post_json(location, json_data):
"""
Performs a POST and passes the data to the URL location
"""
result = requests.post(
location,
data=json_data,
auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY,
headers=POST_HEADERS)
return result.json()
def delete_json(location):
"""
Performs a DELETE and passes the id to the URL location
"""
result = requests.delete(
location,
auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY)
return result.json()
def main():
# List all users within the Satellite
users = get_json(SAT_API + "users/")
#print json.dumps(users, indent=4)
print "Users known are:"
for login in users['results']:
print login['login']
# Look for user example and if found, delete the user
for delete in users['results']:
if delete['login'] == 'example':
id = delete ['id']
Red Hat Sat ellit e 6 .0 T ransit ion G uid e
4 8