This short post explains how to invoke UCS Director workflows via the northbound REST API. Authentication and role is controlled by the use of a secure token. Each user account within UCS Director has a unique API token, which can accessed via the GUI like so:
Firstly, from within the UCS Director GUI, click the current username at the top right of the screen. Like so:
User Information will then be presented. Select the ‘Advanced’ tab in order to reveal the API Access key for that user account.
Once retrieved, this key needs to be added as an HTTP header for all REST requests to UCS Director. The HTTP header name must be X-Cloupia-Request-Key.
Once this step is complete, the next requirement is to construct an appropriate URI for the HTTP request in order to invoke the required UCS Director workflow also supplying the required User Inputs (Inputs that would ordinarily be entered by the end user when executing the workflow manually).
UCS Director has two versions of northbound API. Version 1 uses HTTP GET requests with a JSON (Java Standard Object Notation) formatted URI. Version 2 uses HTTP POST with XML (eXtensible Markup Language) bodytext.
Workflow invocation for UCS Director uses Version 1 of the API (JSON). A typical request URL would look similar to this:
JSON formatted data consists of either dictionaries or lists. Dictionaries consist of name/value pairs that are separated by a colon. Name/value pairs are separated by a comma and dictionaries are bounded by curly braces. For example:
Lists are used in instances where a single value is insufficient. Lists are comma separated and bounded by square braces. For example:
To ease readability, it is often worth temporarily expanding the structure to see what is going on.
Now things get interesting. It is possible (And common) for dictionaries to contain lists, and for those lists to contain dictionaries rather than just elements (dog, cat, horse etc…).
With an understanding of how JSON objects are structured, we can now look at the required formatting of the URI for UCS Director. When invoking a workflow via the REST API, UCS Director must be called with three parameters, param0, param1 and param2. ‘param0’ contains the name of the workflow to be invoked. The syntax of the workflow name must match EXACTLY the name of the actual workflow. ‘param1’ contains a dictionary, which itself contains a list of dictionaries detailing each user input and value that should be inserted for that user input (As though an end user had invoked the workflow via the GUI and had entered values manually.
The structure of the UCS Director JSON URI looks like so:
So, let’s see this in action. Take the following workflow, which happens to be named ‘Infoblox Register New Host’ and has the user inputs ‘Infoblox IP:’,’Infoblox Username:’,’Infoblox Password:’,’Hostname:’,’Domain:’ and ‘Network Range:’.
The correct JSON object (Shown here in pretty form) would look like so:
Note once more, that the syntax of the input names must match EXACTLY that of the actual workflow inputs.
After removing all of the readability formatting, the full URL required in order to invoke this workflow with the ‘user’ inputs as shown above would look like this:
Now that we have our URL and authentication token HTTP header, we can simply enter this information into a web based REST client (e.g. RESTclient for Firefox or Postman for Chrome) and execute the request. Like so:
If the request is successful, then UCS Director will respond with a “serviceError” of null (No error) and the serviceResult will contain the service request ID for the newly invoked workflow:
Progress of the workflow can either be monitored by other API requests or via the UCS Director GUI:
Service request logging can also be monitored via either further API calls or via the UCS Director GUI:
Dear Experts,I understand how to pass an Output of one Task to another but i have following Scenario. Assume there are total 3 Tasks. 1st Task check existance of an object and if it exist then get the object id as a Output of this Task. 2nd Task is execut...
I need to get a list of Orgs in a newly added UCSM Account, after it has been added, to populate an output variable to be used in the next workflow task. I have been looking through the API for hours with no luck. EditI have found that the old contro...
Hola a todos, solicite su ayuda, si alguien tiene conocimiento en como puedo implementar dentro del simulador de UCS un servidor físico y así mismo generar la conexión con los dos interruptores, ya que es mi primera vez manejando esta consola y...
Hello *, for our Server Teams I have to provide the information how the network configuration for the server (connected to cisco aci fabric) looks like.My first idea was at first to create an workflow to collect the information from the fabric ...
Hi, I am looking for a function, that takes a Service Request ID as input and returns the error messages from this (failed) workflow. I found this Workflow, which is almost as I needed: https://community.cisco.com/t5/ucs-director-documents/...