Resume a Job
Scenario Overview
This guide shows how to resume suspended CNC server jobs, enabling continuity and efficiency in network tasks.
Prerequisites
Before running, obtain an access token ('Getting Started'), configure cnc-api-common.sh
, and verify input/output directories.
Retrieve Devices with a Specific Collection Status
Run the resume_job.sh
script from the example directory to resume a specific inventory job. Provide the job name and job type in the required format (for example, jobName:jobType) during the script execution.
cd cnc-inventory-api-examples;./resume_job.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
resume_job() {
# Assuming the CNC JWT has already been obtained by running the get-cnc-jwt.sh script.
# Read from JWT file and export it as AUTH_TOKEN_HDR
export_jwt
# STEP 1 : Retrieve all the job specifications on the server
# STEP 2 : At the input prompt, enter the job name and job type (in the format jobName:jobType) for the job you want to resume.
# STEP 3 : Trigger resumeJob api
# STEP 4 : Wait for 10 seconds, retrieve the updated job specifications, and copy them to a file.
echo -e "\n\nGet details of all the jobs on the server: \n"
retrieve_job_specifications
echo -e "\nPlease enter the job you want to resume in the format jobName:jobType (Ex. Switch Inventory:Inventory):"
read job_name
CNC_API_INPUT="$PRJ/input/resume_job.json"
echo "$job_name" > $CNC_API_INPUT
CNC_API_URL=$CNC_INVENTORY_JOB_API_CTX/resumeJob
CNC_API_OUTPUT="$PRJ/output/resume_job.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
echo -e "\n Waiting 10sec.."
sleep 10
retrieve_job_specifications
echo -e "\n\nUpdated Job Specifications copied to $JOB_SPECS_OUTPUT\n"
}
resume_job