Using the Satellite REST API Red Hat Satellite 6.16 Develop custom applications or integrations by using the Satellite REST API Red Hat Satellite Documentation Team satellite-doc-list@redhat.com

Commands:
https:// satellite.example.com /apidoc/v2.html
HTTP_METHOD API_ROUTE
curl --request HTTP_METHOD \ 1 --insecure \ 2 --user My_User_Name : My_Password \ 3 --data @ input_file .json \ 4 --header "Accept:application/json" \ 5 --header "Content-Type:application/json" \ 6 --output output_file 7 API_ROUTE \ 8 | python3 -m json.tool 9
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/hosts | python3 -m json.tool
{ "total": 2, "subtotal": 2, "page": 1, "per_page": 20, "search": null, "sort": { "by": null, "order": null }, "results": output truncated
organization_id: 1
name: TestKey
description: Just for testing
curl --header "Accept:application/json" --header "Content-Type:application/json" --request POST --user My_User_Name : My_Password --data @activation-key.json https:// satellite.example.com /katello/api/activation_keys | python3 -m json.tool
{ "id": 2, "name": "TestKey", "description": "Just for testing", "unlimited_hosts": true, "auto_attach": true, "content_view_id": null, "environment_id": null, "usage_count": 0, "user_id": 3, "max_hosts": null, "release_version": null, "service_level": null, "content_overrides": [ ], "organization": { "name": "Default Organization", "label": "Default_Organization", "id": 1 }, "created_at": "2017-02-16 12:37:47 UTC", "updated_at": "2017-02-16 12:37:48 UTC", "content_view": null, "environment": null, "products": null, "host_collections": [ ], "permissions": { "view_activation_keys": true, "edit_activation_keys": true, "destroy_activation_keys": true } }
organization_id: 1
name: TestKey
description: Just for testing
max_hosts: 10
curl --request PUT --header "Accept:application/json" --header "Content-Type:application/json" --user My_User_Name : My_Password --data @activation-key.json https:// satellite.example.com /katello/api/activation_keys/2 | python3 -m json.tool
{ "id": 2, "name": "TestKey", "description": "Just for testing", "unlimited_hosts": false, "auto_attach": true, "content_view_id": null, "environment_id": null, "usage_count": 0, "user_id": 3, "max_hosts": 10, "release_version": null, "service_level": null, "content_overrides": [ ], "organization": { "name": "Default Organization", "label": "Default_Organization", "id": 1 }, "created_at": "2017-02-16 12:37:47 UTC", "updated_at": "2017-02-16 12:46:17 UTC", "content_view": null, "environment": null, "products": null, "host_collections": [ ], "permissions": { "view_activation_keys": true, "edit_activation_keys": true, "destroy_activation_keys": true } }
curl --header "Accept:application/json" --header "Content-Type:application/json" --request DELETE --user My_User_Name : My_Password https:// satellite.example.com /katello/api/activation_keys/2 | python3 -m json.tool
output omitted "started_at": "2017-02-16 12:58:17 UTC", "ended_at": "2017-02-16 12:58:18 UTC", "state": "stopped", "result": "success", "progress": 1.0, "input": { "activation_key": { "id": 2, "name": "TestKey" output truncated
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/domains/23 | python3 -m json.tool
id: 23
name: qa.lab.example.com
fullname: QA
dns_id: 10
created_at: 2024-08-13T09:02:31Z
updated_at: 2024-08-13T09:02:31Z
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/domains | python3 -m json.tool
{ "total": 3, "subtotal": 3, "page": 1, "per_page": 20, "search": null, "sort": { "by": null, "order": null }, "results": [ { "id": 23, "name": "qa.lab.example.com", "fullname": "QA", "dns_id": 10, "created_at": "2024-08-13T09:02:31Z", "updated_at": "2024-08-13T09:02:31Z" }, { "id": 25, "name": "dev.lab.example.com", "fullname": "DEVEL", "dns_id": 8, "created_at": "2024-08-13T08:32:48Z", "updated_at": "2024-08-14T07:04:03Z" }, { "id": 32, "name": "hr.lab.example.com", "fullname": "HR", "dns_id": 8, "created_at": "2024-08-16T08:32:48Z", "updated_at": "2024-08-16T07:04:03Z" } ] }
Nested_Resource . Attribute_Name
Resource [ Nested_Resource_attributes ][ Attribute_Name_id ]
curl -o /etc/pki/ca-trust/source/anchors/ satellite.example.com -katello-server-ca.crt http://satellite.example.com/pub/katello-server-ca.crt
cp /var/www/html/pub/katello-server-ca.crt /etc/pki/ca-trust/source/anchors/ satellite.example.com -katello-server-ca.crt
update-ca-trust extract
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts
curl https:// satellite.example.com /api/status --user My_Username : My_Personal_Access_Token
satellite_version: 6.16.0
result: ok
status: 200
version: 3.5.1.10
api_version: 2
curl https:// satellite.example.com /api/status --user My_Username : My_Personal_Access_Token
{ "error": {"message":"Unable to authenticate user My_Username "} }
satellite-installer --full-help | grep oauth
satellite-installer --foreman-oauth-map-users true
--header 'FOREMAN-USER: My_User_Name ' --header 'Authorization: OAuth oauth_version="1.0",oauth_consumer_key=" secretkey ",oauth_signature_method="hmac-sha1",oauth_timestamp= timestamp ,oauth_signature= signature '
curl 'https:// satellite.example.com /api/architectures' --header 'Content-Type: application/json' --header 'Accept:application/json' --header 'FOREMAN-USER: My_User_Name ' --header 'Authorization: OAuth oauth_version="1.0",oauth_consumer_key=" secretkey ",oauth_signature_method="hmac-sha1",oauth_timestamp= 1321473112 ,oauth_signature= Il8hR8/ogj/XVuOqMPB9qNjSy6E= '
--header "Accept:application/json" --header "Content-Type:application/json"
--data {"id":44, "smart_class_parameter":{"override":"true", "parameter_type":"json", "default_value":"{\"GRUB_CMDLINE_LINUX\": {\"audit\":\"1\",\"crashkernel\":\"true\"}}"}}
--data @ file .json
json_verify < file .json
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/users | python3 -m json.tool
{ "page": 1, "per_page": 20, "results": [ { "admin": false, "auth_source_id": 1, "auth_source_name": "Internal", "created_at": "2018-09-21 08:59:22 UTC", "default_location": null, "default_organization": null, "description": "", "effective_admin": false, "firstname": "", "id": 5, "last_login_on": "2018-09-21 09:03:25 UTC", "lastname": "", "locale": null, "locations": [], "login": "test", "mail": "example@domain.com", "organizations": [ { "id": 1, "name": "Default Organization" } ], "ssh_keys": [], "timezone": null, "updated_at": "2018-09-21 09:04:45 UTC" }, { "admin": true, "auth_source_id": 1, "auth_source_name": "Internal", "created_at": "2018-09-20 07:09:41 UTC", "default_location": null, "default_organization": { "description": null, "id": 1, "name": "Default Organization", "title": "Default Organization" }, "description": "", "effective_admin": true, "firstname": "Admin", "id": 4, "last_login_on": "2018-12-07 07:31:09 UTC", "lastname": "User", "locale": null, "locations": [ { "id": 2, "name": "Default Location" } ], "login": "admin", "mail": "root@example.com", "organizations": [ { "id": 1, "name": "Default Organization" } ], "ssh_keys": [], "timezone": null, "updated_at": "2018-11-14 08:19:46 UTC" } ], "search": null, "sort": { "by": null, "order": null }, "subtotal": 2, "total": 2 }
curl --header "Accept:application/json" --header "Content-Type:application/json" --request POST --user My_User_Name : My_Password --data "{\"firstname\":\" Test Name \",\"mail\":\" test@example.com \",\"login\":\" test_user \",\"password\":\" password123 \",\"auth_source_id\": 1 }" https:// satellite.example.com /api/users | python3 -m json.tool
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data "{\"firstname\":\" New Test Name \",\"mail\":\" test@example.com \",\"login\":\" new_test_user \",\"password\":\" password123 \",\"auth_source_id\": 1 }" https:// satellite.example.com /api/users/ 8 | python3 -m json.tool
#!/usr/bin/ruby require 'rest-client' require 'json' url = 'https://satellite.example.com/api/v2/' katello_url = "#{url}/katello/api/v2/" USDusername = 'admin' USDpassword = 'changeme' org_name = "MyOrg" environments = [ "Development", "Testing", "Production" ] Performs a GET by using the passed URL location def get_json(location) response = RestClient::Request.new( :method => :get, :url => location, :user => USDusername, :password => USDpassword, :headers => { :accept => :json, :content_type => :json } ).execute JSON.parse(response.to_str) end Performs a POST and passes the data to the URL location def post_json(location, json_data) response = RestClient::Request.new( :method => :post, :url => location, :user => USDusername, :password => USDpassword, :headers => { :accept => :json, :content_type => :json}, :payload => json_data ).execute JSON.parse(response.to_str) end Creates a hash with ids mapping to names for an array of records def id_name_map(records) records.inject({}) do |map, record| map.update(record['id'] => record['name']) end end Get list of existing organizations orgs = get_json("#{katello_url}/organizations") org_list = id_name_map(orgs['results']) if !org_list.has_value?(org_name) # If our organization is not found, create it puts "Creating organization: \t#{org_name}" org_id = post_json("#{katello_url}/organizations", JSON.generate({"name"=> org_name}))["id"] else # Our organization exists, so let's grab it org_id = org_list.key(org_name) puts "Organization \"#{org_name}\" exists" end Get list of organization's lifecycle environments envs = get_json("#{katello_url}/organizations/#{org_id}/environments") env_list = id_name_map(envs['results']) prior_env_id = env_list.key("Library") Exit the script if at least one life cycle environment already exists environments.each do |e| if env_list.has_value?(e) puts "ERROR: One of the Environments is not unique to organization" exit end end # Create life cycle environments environments.each do |environment| puts "Creating environment: \t#{environment}" prior_env_id = post_json("#{katello_url}/organizations/#{org_id}/environments", JSON.generate({"name" => environment, "organization_id" => org_id, "prior_id" => prior_env_id}))["id"] end
#!/usr/bin/ruby require 'apipie-bindings' org_name = "MyOrg" environments = [ "Development", "Testing", "Production" ] Create an instance of apipie bindings @api = ApipieBindings::API.new({ :uri => 'https://satellite.example.com/', :username => 'admin', :password => 'changeme', :api_version => 2 }) Performs an API call with default options def call_api(resource_name, action_name, params = {}) http_headers = {} apipie_options = { :skip_validation => true } @api.resource(resource_name).call(action_name, params, http_headers, apipie_options) end Creates a hash with IDs mapping to names for an array of records def id_name_map(records) records.inject({}) do |map, record| map.update(record['id'] => record['name']) end end Get list of existing organizations orgs = call_api(:organizations, :index) org_list = id_name_map(orgs['results']) if !org_list.has_value?(org_name) # If our organization is not found, create it puts "Creating organization: \t#{org_name}" org_id = call_api(:organizations, :create, {'organization' => { :name => org_name }})['id'] else # Our organization exists, so let's grab it org_id = org_list.key(org_name) puts "Organization \"#{org_name}\" exists" end Get list of organization's life cycle environments envs = call_api(:lifecycle_environments, :index, {'organization_id' => org_id}) env_list = id_name_map(envs['results']) prior_env_id = env_list.key("Library") Exit the script if at least one life cycle environment already exists environments.each do |e| if env_list.has_value?(e) puts "ERROR: One of the Environments is not unique to organization" exit end end # Create life cycle environments environments.each do |environment| puts "Creating environment: \t#{environment}" prior_env_id = call_api(:lifecycle_environments, :create, {"name" => environment, "organization_id" => org_id, "prior_id" => prior_env_id })['id'] end
#!/usr/bin/python3 import json import sys try: import requests except ImportError: print("Please install the python-requests module.") sys.exit(-1) URL to your Satellite Server URL = "https://satellite.example.com" FOREMAN_API = f"{URL}/api/" KATELLO_API = f"{URL}/katello/api/" POST_HEADERS = {'content-type': 'application/json'} Default credentials to login to Satellite 6 USERNAME = "admin" PASSWORD = "changeme" Ignore SSL for now SSL_VERIFY = False Name of the organization to be either created or used ORG_NAME = "MyOrg" Name for life cycle environments to be either created or used ENVIRONMENTS = ["Development", "Testing", "Production"] def get_json(location): """ Performs a GET by 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 main(): """ Main routine that creates or re-uses an organization and life cycle environments. If life cycle environments already exist, exit out. """ # Check if our organization already exists org = get_json(f"{FOREMAN_API}/organizations/{ORG_NAME}") # If our organization is not found, create it if org.get('error', None): org_id = post_json( f"{FOREMAN_API}/organizations/", json.dumps({"name": ORG_NAME}) )["id"] print("Creating organization:\t" + ORG_NAME) else: # Our organization exists, so let's grab it org_id = org['id'] print(f"Organization '{ORG_NAME}' exists.") # Now, let's fetch all available life cycle environments for this org envs = get_json( f"{KATELLO_API}/organizations/{org_id}/environments/" ) # ...and add them to a dictionary, with respective 'Prior' environment prior_env_id = 0 env_list = {} for env in envs['results']: env_list[env['id']] = env['name'] prior_env_id = env['id'] if env['name'] == "Library" else prior_env_id # Exit the script if at least one life cycle environment already exists if all(environment in env_list.values() for environment in ENVIRONMENTS): print("ERROR: One of the Environments is not unique to organization") sys.exit(-1) # Create life cycle environments for environment in ENVIRONMENTS: new_env_id = post_json( f"{KATELLO_API}/organizations/{org_id}/environments/", json.dumps({ "name": environment, "organization_id": org_id, "prior": prior_env_id }) )["id"] print("Creating environment:\t" + environment) prior_env_id = new_env_id if __name__ == "__main__": main()
#!/usr/bin/env python3 import json import sys try: import requests except ImportError: print("Please install the python-requests module.") sys.exit(-1) HOSTNAME = "satellite.example.com" URL for the API to your Satellite Server FOREMAN_API = f"https://{HOSTNAME}/api/" KATELLO_API = f"https://{HOSTNAME}/katello/api/v2/" POST_HEADERS = {'content-type': 'application/json'} Default credentials to login to Satellite 6 USERNAME = "admin" PASSWORD = "password" Ignore SSL for now SSL_VERIFY = False #SSL_VERIFY = "./path/to/CA-certificate.crt" # Put the path to your CA certificate here to allow SSL_VERIFY def get_json(url): # Performs a GET by using the passed URL location r = requests.get(url, auth=(USERNAME, PASSWORD), verify=SSL_VERIFY) return r.json() def get_results(url): jsn = get_json(url) if jsn.get('error'): print("Error: " + jsn['error']['message']) else: if jsn.get('results'): return jsn['results'] elif 'results' not in jsn: return jsn else: print("No results found") return None def display_all_results(url): results = get_results(url) if results: print(json.dumps(results, indent=4, sort_keys=True)) def display_info_for_hosts(url): hosts = get_results(url) if hosts: print(f"{'ID':10}{'Name':40}{'IP':30}{'Operating System':30}") for host in hosts: print(f"{str(host['id']):10}{host['name']:40}{str(host['ip']):30}{str(host['operatingsystem_name']):30}") def display_info_for_subs(url): subs = get_results(url) if subs: print(f"{'ID':10}{'Name':90}{'Start Date':30}") for sub in subs: print(f"{str(sub['id']):10}{sub['name']:90}{str(sub['start_date']):30}") def main(): host = HOSTNAME print(f"Displaying all info for host {host} ...") display_all_results(FOREMAN_API + 'hosts/' + host) print(f"Displaying all facts for host {host} ...") display_all_results(FOREMAN_API + f'hosts/{host}/facts') host_pattern = 'example' print(f"Displaying basic info for hosts matching pattern '{host_pattern}'...") display_info_for_hosts(FOREMAN_API + 'hosts?per_page=1&search=name~' + host_pattern) print(f"Displaying basic info for subscriptions") display_info_for_subs(KATELLO_API + 'subscriptions') environment = 'production' print(f"Displaying basic info for hosts in environment {environment}...") display_info_for_hosts(FOREMAN_API + 'hosts?search=environment=' + environment) if __name__ == "__main__": main()
url = 'https:// satellite.example.com /api/v2/' katello_url = 'https:// satellite.example.com /katello/api/v2/'
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts | python3 -m json.tool
{ "total" => 2, "subtotal" => 2, "page" => 1, "per_page" => 1000, "search" => nil, "sort" => { "by" => nil, "order" => nil }, "results" => [ }
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts/ satellite.example.com | python3 -m json.tool
{ "all_puppetclasses": [], "architecture_id": 1, "architecture_name": "x86_64", "build": false, "capabilities": [ "build" ], "certname": " satellite.example.com ", "comment": null, "compute_profile_id": null, }
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts/ satellite.example.com /facts | python3 -m json.tool
{ "results": { " satellite.example.com ": { "augeasversion": "1.0.0", "bios_release_date": "01/01/2007", "bios_version": "0.5.1", "blockdevice_sr0_size": "1073741312", "facterversion": "1.7.6", }
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts?search=example | python3 -m json.tool
{ "results": [ { "name": " satellite.example.com ", } ], "search": "example", }
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts?search=environment=production | python3 -m json.tool
{ "results": [ { "environment_name": "production", "name": " satellite.example.com ", } ], "search": "environment=production", }
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts?search=model=\"RHV+Hypervisor\" | python3 -m json.tool
{ "results": [ { "model_id": 1, "model_name": "RHV Hypervisor", "name": " satellite.example.com ", } ], "search": "model=\"RHV Hypervisor\"", }
curl --request DELETE --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts/ host1.example.com | python3 -m json.tool
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/bootdisk/hosts/ host_ID ?full=true --output image .iso
curl --header "Accept:application/json" --header "Content-Type:application/json" --request GET --user My_User_Name : My_Password https:// satellite.example.com /katello/api/organizations/1/environments | python3 -m json.tool`
output omitted "description": null, "id": 1, "label": "Library", "library": true, "name": "Library", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": false, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": null, "successor": null, output truncated
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /katello/api/environments/1 | python3 -m json.tool
output omitted "id": 1, "label": "Library", output omitted "prior": null, "successor": null, output truncated
organization_id: 1
label: api-dev
name: API Development
prior: 1
curl --header "Accept:application/json" --header "Content-Type:application/json" --request POST --user My_User_Name : My_Password --data @life-cycle.json https:// satellite.example.com /katello/api/environments | python3 -m json.tool
output omitted "description": null, "id": 2, "label": "api-dev", "library": false, "name": "API Development", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 1, "name": "Library" }, output truncated
organization_id: 1
label: api-qa
name: API QA
prior: 2
curl --header "Accept:application/json" --header "Content-Type:application/json" --request POST --user My_User_Name : My_Password --data @life-cycle.json https:// satellite.example.com /katello/api/environments | python3 -m json.tool
output omitted "description": null, "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, "successor": null, output truncated
curl --header "Accept:application/json" --header "Content-Type:application/json" --request POST --user My_User_Name : My_Password --data '{"description":"Quality Acceptance Testing"}' https:// satellite.example.com /katello/api/environments/3 | python3 -m json.tool
output omitted "description": "Quality Acceptance Testing", "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, output truncated
curl --request DELETE --user My_User_Name : My_Password https:// satellite.example.com /katello/api/environments/ :id
export name=jq-1.6-2.el7.x86_64.rpm
export checksum=USD(sha256sum USDname|cut -c 1-65)
export size=USD(du -bs USDname|cut -f 1)
curl -H 'Content-Type: application/json' -X POST -k -u My_User_Name : My_Password -d "{\"size\": \"USDsize\", \"checksum\":\"USDchecksum\"}" https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads
upload_id: 37eb5900-597e-4ac3-9bc5-2250c302fdc4
export upload_id=37eb5900-597e-4ac3-9bc5-2250c302fdc4
export path=/root/jq/jq-1.6-2.el7.x86_64.rpm
curl -u My_User_Name : My_Password -H Accept:application/json -H Content-Type:multipart/form-data --request PUT --data-urlencode size=USDsize --data-urlencode offset=0 --data-urlencode content@USD{path} https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id
curl -H "Content-Type:application/json" -X PUT -u My_User_Name : My_Password -k -d "{\"uploads\":[{\"id\": \"USDupload_id\", \"name\": \"USDname\", \"checksum\": \"USDchecksum\" }]}" https:// satellite.example.com /katello/api/v2/repositories/76/import_uploads
curl -H 'Content-Type: application/json' -X DELETE -k -u My_User_Name : My_Password -d "{}" https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id
export name=bpftool-3.10.0-1160.2.1.el7.centos.plus.x86_64.rpm
export checksum=USD(sha256sum USDname|cut -c 1-65)
export size=USD(du -bs USDname|cut -f 1)
curl -H 'Content-Type: application/json' -X POST -k -u My_User_Name : My_Password -d "{\"size\": \"USDsize\", \"checksum\":\"USDchecksum\"}" https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads
upload_id: 37eb5900-597e-4ac3-9bc5-2250c302fdc4
export upload_id=37eb5900-597e-4ac3-9bc5-2250c302fdc4
split --bytes 2MB --numeric-suffixes --suffix-length=1 bpftool-3.10.0-1160.2.1.el7.centos.plus.x86_64.rpm bpftool
ls bpftool[0-9] -l -rw-r--r--. 1 root root 2000000 Mar 31 14:15 bpftool0 -rw-r--r--. 1 root root 2000000 Mar 31 14:15 bpftool1 -rw-r--r--. 1 root root 2000000 Mar 31 14:15 bpftool2 -rw-r--r--. 1 root root 2000000 Mar 31 14:15 bpftool3 -rw-r--r--. 1 root root 868648 Mar 31 14:15 bpftool4
export path=/root/tmp/bpftool
curl -u My_User_Name : My_Password -H Accept:application/json -H Content-Type:multipart/form-data -X PUT --data-urlencode size=USDsize --data-urlencode offset=0 --data-urlencode content@USD{path}0 https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id curl -u My_User_Name : My_Password -H Accept:application/json -H Content-Type:multipart/form-data -X PUT --data-urlencode size=USDsize --data-urlencode offset=2000000 --data-urlencode content@USD{path}1 https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id curl -u My_User_Name : My_Password -H Accept:application/json -H Content-Type:multipart/form-data -X PUT --data-urlencode size=USDsize --data-urlencode offset=4000000 --data-urlencode content@USD{path}2 https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id USDcurl -u My_User_Name : My_Password -H Accept:application/json -H Content-Type:multipart/form-data -X PUT --data-urlencode size=USDsize --data-urlencode offset=6000000 --data-urlencode content@USD{path}3 https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id curl -u My_User_Name : My_Password -H Accept:application/json -H Content-Type:multipart/form-data -X PUT --data-urlencode size=USDsize --data-urlencode offset=8000000 --data-urlencode content@USD{path}4 https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id
curl -H "Content-Type:application/json" -X PUT -u My_User_Name : My_Password -k -d "{\"uploads\":[{\"id\": \"USDupload_id\", \"name\": \"USDname\", \"checksum\": \"USDchecksum\" }]}" https:// satellite.example.com /katello/api/v2/repositories/76/import_uploads
curl -H 'Content-Type: application/json' -X DELETE -k -u My_User_Name : My_Password -d "{}" https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads/USDupload_id
curl -H 'Content-Type: application/json' -X POST -k -u My_User_Name : My_Password -d "{\"size\": \"USDsize\", \"checksum\":\"USDchecksum\"}" https:// satellite.example.com /katello/api/v2/repositories/76/content_uploads
content_unit_href: /pulp/api/v3/content/file/files/c1bcdfb8-d840-4604-845e-86e82454c747/
curl -H "Content-Type:application/json" -X PUT -u My_User_Name : My_Password -k \-d "{\"uploads\":[{\"content_unit_id\": \"/pulp/api/v3/content/file/files/c1bcdfb8-d840-4604-845e-86e82454c747/\", \"name\": \"USDname\", \ \"checksum\": \"USDchecksum\" }]}" https:// satellite.example.com /katello/api/v2/repositories/76/import_uploads
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data My_JSON_Formatted_Data https:// satellite.example.com
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data "{\"organization_id\":1,\"included\":{\"search\":\" my-host \"},\"content_type\":\"errata\",\"content\":[\" RHBA-2016:1981 \"]}" https:// satellite.example.com /api/v2/hosts/bulk/install_content
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data "{\"organization_id\":1,\"included\":{\"search\":\"host_collection=\\\" my-collection \\\"\"},\"content_type\":\"errata\",\"content\":[\" RHBA-2016:1981 \"]}" https:// satellite.example.com /api/v2/hosts/bulk/install_content
curl --user My_User_Name : My_Password https:// satellite.example.com /api/v2/hosts?search=os_title=\"RedHat+7.7\",model=\"PowerEdge+R330\" | python3 -m json.tool
{ "results": [ { "model_id": 1, "model_name": "PowerEdge R330", "name": " satellite.example.com ", "operatingsystem_id": 1, "operatingsystem_name": "RedHat 7.7", } ], "search": "os_title=\"RedHat 7.7\",model=\"PowerEdge R330\"", "subtotal": 1, "total": 11 }
curl --request GET --user My_User_Name : My_Password https://satellite.example.com/katello/api/content_views?per_page=10&amp;page=3
curl --request GET --user My_User_Name : My_Password https://satellite.example.com/katello/api/activation_keys?organization_id=1&amp;per_page=30&amp;page=2
for i in seq 1 3 ; do curl --request GET --user My_User_Name : My_Password https://satellite.example.com/katello/api/content_views?per_page=5&amp;page=USDi; done
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/smart_class_parameters
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/puppetclasses/5/smart_class_parameters
curl --request GET --user My_User_Name : My_Password --data 'search=puppetclass_name = access_insights_client and key = authmethod' https:// satellite.example.com /api/smart_class_parameters
curl --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/smart_class_parameters/ 63
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data '{"smart_class_parameter":{"override":true}}' https:// satellite.example.com /api/smart_class_parameters/63
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data '{"smart_class_parameter":{"override_value":{"match":"hostgroup=Test","value":"2.4.6"}}}' https:// satellite.example.com /api/smart_class_parameters/63
curl --request DELETE --user My_User_Name : My_Password https:// satellite.example.com /api/smart_class_parameters/63/override_values/3
curl --header "Accept:application/json" --header "Content-Type:application/json" --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/smart_class_parameters?search=puppetclass_name=motd | python3 -m json.tool
{ "avoid_duplicates": false, "created_at": "2017-02-06 12:37:48 UTC", # Remove this line. "default_value": "", # Add a new value here. "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": false, # Set the override value to true . "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values": [], # Remove this line. "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "updated_at": "2017-02-07 11:56:55 UTC", # Remove this line. "use_puppet_default": false, "validator_rule": null, "validator_type": "" }
curl --header "Accept:application/json" --header "Content-Type:application/json" --request GET --user My_User_Name : My_Password https:// satellite.example.com /api/smart_class_parameters/3 | python3 -m json.tool > output_file.json
cp output_file.json changed_file.json
{ "avoid_duplicates": false, "created_at": "2017-02-06 12:37:48 UTC", # Remove this line. "default_value": "", # Add a new value here. "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": false, # Set the override value to true . "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values": [], # Remove this line. "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "updated_at": "2017-02-07 11:56:55 UTC", # Remove this line. "use_puppet_default": false, "validator_rule": null, "validator_type": "" }
{ "avoid_duplicates": false, "default_value": " No Unauthorized Access Allowed ", "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": true, "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "use_puppet_default": false, "validator_rule": null, "validator_type": "" }
curl --header "Accept:application/json" --header "Content-Type:application/json" --request PUT --user My_User_Name : My_Password --data @changed_file.json https:// satellite.example.com /api/smart_class_parameters/3
curl --user My_User_Name : My_Password https:// satellite.example.com /api/v2/compliance/arf_reports/ | python3 -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3252 0 3252 0 0 4319 0 --:--:-- --:--:-- --:--:-- 4318 { "page": 1, "per_page": 20, "results": [ { "created_at": "2017-05-16 13:27:09 UTC", "failed": 0, "host": " host1.example.com ", "id": 404, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:27:09 UTC" }, { "created_at": "2017-05-16 13:26:07 UTC", "failed": 0, "host": " host2.example.com , "id": 405, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:26:07 UTC" }, { "created_at": "2017-05-16 13:25:07 UTC", "failed": 0, "host": " host3.example.com ", "id": 406, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:25:07 UTC" }, { "created_at": "2017-05-16 13:24:07 UTC", "failed": 0, "host": " host4.example.com ", "id": 407, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:24:07 UTC" }, ], "search": null, "sort": { "by": null, "order": null }, "subtotal": 29, "total": 29
curl --user My_User_Name : My_Password --header "Content-Type: application/json" --request DELETE https:// satellite.example.com /api/v2/compliance/arf_reports/405
HTTP/1.1 200 OK Date: Thu, 18 May 2017 07:14:36 GMT Server: Apache/2.4.6 (Red Hat Enterprise Linux) X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Foreman_version: 1.11.0.76 Foreman_api_version: 2 Apipie-Checksum: 2d39dc59aed19120d2359f7515e10d76 Cache-Control: max-age=0, private, must-revalidate X-Request-Id: f47eb877-35c7-41fe-b866-34274b56c506 X-Runtime: 0.661831 X-Powered-By: Phusion Passenger 4.0.18 Set-Cookie: request_method=DELETE; path=/ Set-Cookie: _session_id=d58fe2649e6788b87f46eabf8a461edd; path=/; secure; HttpOnly ETag: "2574955fc0afc47cb5394ce95553f428" Status: 200 OK Vary: Accept-Encoding Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8
#!/bin/bash #this script removes all the ARF reports from your Satellite Server #settings USER= username PASS= password URI=https:// satellite.example.com #check amount of reports while [ USD(curl --user USDUSER:USDPASS USDURI/api/v2/compliance/arf_reports/ | python3 -m json.tool | grep \"\total\": | cut --fields=2 --delimiter":" | cut --fields=1 --delimiter"," | sed "s/ //g") -gt 0 ]; do #fetch reports for i in USD(curl --user USDUSER:USDPASS USDURI/api/v2/compliance/arf_reports/ | python3 -m json.tool | grep \"\id\": | cut --fields=2 --delimiter":" | cut --fields=1 --delimiter"," | sed "s/ //g") #delete reports do curl --user USDUSER:USDPASS --header "Content-Type: application/json" --request DELETE USDURI/api/v2/compliance/arf_reports/USDi done done
foreman-rake console
f = File.open('/tmp/table.html', 'w') result = Foreman::AccessControl.permissions {|a,b| a.security_block <=> b.security_block}.collect do |p| actions = p.actions.collect { |a| "<li>#{a}</li>" } "<tr><td>#{p.name}</td><td><ul>#{actions.join('')}</ul></td><td>#{p.resource_type}</td></tr>" end.join("\n") f.write(result)
<table border="1"><tr><td>Permission name</td><td>Actions</td><td>Resource type</td></tr>
</table>