diff --git a/guides/common/modules/proc_calling-the-api-in-python.adoc b/guides/common/modules/proc_calling-the-api-in-python.adoc index 6eb80dfd008..5f7b086afe7 100644 --- a/guides/common/modules/proc_calling-the-api-in-python.adoc +++ b/guides/common/modules/proc_calling-the-api-in-python.adoc @@ -32,11 +32,9 @@ except ImportError: print("Please install the python-requests module.") sys.exit(-1) -# URL to your {ProjectX} server +# URL to your {ProjectServer} URL = "https://{foreman-example-com}" -# URL for the API to your deployed {ProjectX} server -{project-allcaps}_API = f"\{URL}/katello/api/v2/" -# Katello-specific API +FOREMAN_API = f"\{URL}/api/" KATELLO_API = f"\{URL}/katello/api/" POST_HEADERS = {'content-type': 'application/json'} # Default credentials to login to {ProjectX} @@ -82,12 +80,12 @@ def main(): """ # Check if our organization already exists - org = get_json(f"{{project-allcaps}_API}/organizations/\{ORG_NAME}") + 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"{{project-allcaps}_API}/organizations/", + f"\{FOREMAN_API}/organizations/", json.dumps({"name": ORG_NAME}) )["id"] print("Creating organization:\t" + ORG_NAME) @@ -98,7 +96,7 @@ def main(): # Now, let's fetch all available life cycle environments for this org... envs = get_json( - f"{{project-allcaps}_API}/organizations/\{org_id}/environments/" + f"\{KATELLO_API}/organizations/\{org_id}/environments/" ) # ...and add them to a dictionary, with respective 'Prior' environment @@ -116,7 +114,7 @@ def main(): # Create life cycle environments for environment in ENVIRONMENTS: new_env_id = post_json( - f"{{project-allcaps}_API}/organizations/\{org_id}/environments/", + f"\{KATELLO_API}/organizations/\{org_id}/environments/", json.dumps({ "name": environment, "organization_id": org_id, @@ -152,10 +150,10 @@ except ImportError: print("Please install the python-requests module.") sys.exit(-1) -SAT = "{foreman-example-com}" -# URL for the API to your deployed {ProjectX} server -{project-allcaps}_API = f"https://\{SAT}/api/" -KATELLO_API = f"https://\{SAT}/katello/api/v2/" +HOSTNAME = "{foreman-example-com}" +# URL for the API to your {ProjectServer} +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 {ProjectX} @@ -204,23 +202,23 @@ def display_info_for_subs(url): print(f"{str(sub['id']):10}{sub['name']:90}{str(sub['start_date']):30}") def main(): - host = SAT + host = HOSTNAME print(f"Displaying all info for host \{host} ...") - display_all_results({project-allcaps}_API + 'hosts/' + host) + display_all_results(FOREMAN_API + 'hosts/' + host) print(f"Displaying all facts for host \{host} ...") - display_all_results({project-allcaps}_API + f'hosts/\{host}/facts') + 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({project-allcaps}_API + 'hosts?per_page=1&search=name~' + 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({project-allcaps}_API + 'hosts?search=environment=' + environment) + display_info_for_hosts(FOREMAN_API + 'hosts?search=environment=' + environment) if __name__ == "__main__": diff --git a/guides/common/modules/proc_updating-the-details-of-multiple-operating-systems.adoc b/guides/common/modules/proc_updating-the-details-of-multiple-operating-systems.adoc index f1a0a483d42..06e16c34925 100644 --- a/guides/common/modules/proc_updating-the-details-of-multiple-operating-systems.adoc +++ b/guides/common/modules/proc_updating-the-details-of-multiple-operating-systems.adoc @@ -2,25 +2,25 @@ = Updating the details of multiple operating systems Use this procedure to update the details of multiple operating systems. -This example shows you how to assign each operating system a partition table called `Kickstart default`, a configuration template called `Kickstart default PXELinux`, and a provisioning template called `Kickstart Default`. +This example shows you how to assign each operating system a partition table called `{client-provisioning-template-type} default`, a configuration template called `{client-provisioning-template-type} default PXELinux`, and a provisioning template called `{client-provisioning-template-type} Default`. .Procedure . On {ProjectServer}, run the following Bash script: + -[source,terminal,options="nowrap" subs="+quotes"] +[source, bash, options="nowrap" subs="+quotes,verbatim,attributes"] ---- -PARTID=$(hammer --csv partition-table list | grep "Kickstart default," | cut -d, -f1) -PXEID=$(hammer --csv template list --per-page=1000 | grep "Kickstart default PXELinux" | cut -d, -f1) -SATID=$(hammer --csv template list --per-page=1000 | grep "provision" | grep ",Kickstart default" | cut -d, -f1) +PARTID=$(hammer --csv partition-table list | grep "{client-provisioning-template-type} default," | cut -d, -f1) +PXEID=$(hammer --csv template list --per-page=1000 | grep "{client-provisioning-template-type} default PXELinux" | cut -d, -f1) +{project-allcaps}_ID=$(hammer --csv template list --per-page=1000 | grep "provision" | grep ",{client-provisioning-template-type} default" | cut -d, -f1) for i in $(hammer --no-headers --csv os list | awk -F, {'print $1'}) do - hammer partition-table add-operatingsystem --id="${PARTID}" --operatingsystem-id="${i}" - hammer template add-operatingsystem --id="${PXEID}" --operatingsystem-id="${i}" - hammer os set-default-template --id="${i}" --config-template-id=${PXEID} - hammer os add-config-template --id="${i}" --config-template-id=${SATID} - hammer os set-default-template --id="${i}" --config-template-id=${SATID} + hammer partition-table add-operatingsystem --id="$\{PARTID}" --operatingsystem-id="$\{i}" + hammer template add-operatingsystem --id="$\{PXEID}" --operatingsystem-id="$\{i}" + hammer os set-default-template --id="$\{i}" --config-template-id=$\{PXEID} + hammer os add-config-template --id="$\{i}" --config-template-id=${{project-allcaps}_ID} + hammer os set-default-template --id="$\{i}" --config-template-id=${{project-allcaps}_ID} done ----