Howdy out there in automation land!!! I hope everyone is having a nice ramp down to the school year and is getting ready for summer. I know we are :) I hope plenty of you folks are heading to Cisco Live in San Diego in a few weeks too!!!! I plan to be there, so feel free to hit me up on email or look me up in the NOC. I would love to meet some of the readers and viewers and have automation chats. So what do I have for you this time? This time we are going to look at workflow creation... basic workflow creation.
Now what movie poster would this be you say? Well I like to think of new workflows as a "New Hope" for automation... so how about this?
This might be a bit of a replication of some of the *really* old CPO stuff, but Action Orchestrator is a *NEW* product. It is the NextGen, but is net new as well. So I want you guys to treat this as such. On top of that, know that (unless otherwise) most of my blog going forward will be centered around AO. So get excited!
I will give you guys some steps to follow here... but of course there is a video below as well :)
Now, for this, something you can do first is create the users and targets. In the recording I already had them and talked to creating them on the fly, but you might find it easier to create them first... for this "lab" we need a web target(http) and an email server.
Create a category under Admin->Categories and use your CEC ID as the category.
Create a runtime user under Account Keys. Click NEW ACCOUNT KEY, select HTTP Basic Authentication and fill out the information. The actual information does not matter. You can use test/test if you like. Click SUBMIT.
Create a target under Targets. Click NEW TARGET, select HTTP Endpoint and fill out the information. Set DEFAULT ACCOUNT KEYS to your user from #2. Select HTTPS protocol. Set the HOST/IPADDRESS to jsonplaceholder.typicode.com. Set the PORT to 443 and select DISABLE SERVER CERTIFICATE VALIDATION. Click SUBMIT.
Create another target under Targets. Click NEW TARGET, select SMTP Target and fill out the information. Under DEFAULT ACCOUNT KEYS click the Add New option and use your CEC email/CEC Password. Then select that user. Set the SMTP SERVER to outbound.cisco.com and set the SMTP PORT to 25.
Let's Create a Basic Workflow
Create a new workflow under Workflows. Click NEW WORKFLOW. Go down the right side and select your category under the CATEGORY drop down.
Under Variables click ADD VARIABLE.
For the first variable Select Data Type as String. Display Name as path and SCOPE as Input. Set the value or default as users. Click SAVE.
Click ADD VARIABLE again. Select Data Type as String. Display Name as output json and SCOPE as Output. Click SAVE.
Continue down to Target. Select Execute On This Target and then select HTTP Endpoint under the TARGET TYPE drop down and then select your target under the TARGET drop down.
Search for http in your toolbox and drag and drop the HTTP Request activity. This is the basic activity to make any API call.
Click on the HTTP Request activity. Change the DISPLAY NAME to GET JSONPATH.
Scroll down to RELATIVE URL. Click the puzzle-piece icon(or insert variable reference) and a new dialog should appear called Browse Variables.
Click Workflow, then Input, then you should see your path variable. Click it and then click SAVE. You should now see a VARIABLE REFERENCE showing in your RELATIVE URL field.
Set METHOD to GET. Scroll down and set the CONTENT TYPE to JSON.
Search for the Set Variables activity. Drag and down it BELOW your GET JSONPATH activity. Change the DISPLAY NAME to Set Output. Click ADD. For VARIABLE TO UPDATE, click the insert variable reference icon, and browse to your output variable. Workflow->Output->output json. Click SAVE.
For VARIABLE VALUE NEW, click the insert variable reference icon. Now browse to Activities, then your activity GET JSONPATH, then select Body. Click SAVE.
Create a new variable of type Integer and call it Status Code. It should be an output scope.
Add your new variable to the Set Output activity. Click ADD below your first entry and set your Status Code Variable to the value in Activities->GET JSONPATH->Status code. Validate the workflow and run it. See what your variables are set to.
Let's get it running in layered!!!
Exit your current workflow and create a new one called "Master" or similar
Scroll down and select Execute On This Target. Select HTTP ENDPOINT as the TARGET TYPE and then select your JSONPATH holder target in the TARGET select.
Drag and drop your workflow to your canvas. It should look a little different.
Add an input variable call name of type string.
Find the JSONPath Query activity. Drag and drop it below your atomic workflow in the MASTER workflow.
On the JSONPath Query activity, click insert variable reference and point it to the output of your previous activity. This should be Activites->Your Activity->output json. Click SAVE.
Scroll down and click ADD below JSONPATH QUERIES. Leave the PROPERTY TYPE as String. Make the PROPERTY NAME be name and make the JSONPATH QUERY be $.[?(@.username==“<input name>)].
Select the checkbox for CONTINUE WORKFLOW EXECUTION ON FAILURE
Go the middle icon in your toolbox, this is the Program Logic or Flow Control area.
Find the Condition Block and drag and drop it below your JSONPath Query.
Click the Condition Block in your canvas and change the Display Name to If found name.
Click on the left most CONDITION BRANCH and you should see the conditional dialog.
Under CONDITION, title it THEN, then select the insert variable reference icon for the first field and map it to Activity->JSONPath Query->Succeeded. This is a boolean value that tells us if the activity succeeded or not. Select Equals in the second field and then type true into the last field.
Click on the other CONDITION BRANCH, and do the same as #5, but set the last field to false. Title this block ELSE. This will work because the JSONPath query activity will error if it does not find what you are looking for.
Search for the EMAIL activity. Drag and drop it into the left CONDITION BRANCH blocks.
On the email activity, go to Target and select Override Workflow Target. Select your SMTP server from above. Scroll down and input your email into the TO field. Input something into the SUBJECT line and something into the MESSAGE field. Something like We found them!
On your email block, click the ... and select duplicate. Drag the duplicate over to the other CONDITION BRANCH. (Your else branch)
Change the SUBJECT and MESSAGE to reflect not finding the person.
Validate and run the workflow. Search for bill. Did it email you? Now run again and search for Bret.
This is a great lab that I adapted from some things I built before but I hope you were able to get through it!!! If you run into issues or have questions, please post below. As always, I have a VOD to go along with this of course :) .... now....
Thanks as always to all my wonderful readers and those who continue to stick with and use CPO and now those learning AO! I have always wanted to find good questions, scenarios, stories, etc... if you have a question, please ask, if you want to see more, please ask... if you have topic ideas that you want me to blog on, Please ask! I am happy to cater to the readers and make this the best blog you will find :)
AUTOMATION BLOG DISCLAIMER: As always, this is a blog and my (Shaun Roberts) thoughts on CPO, AO, CCS, orchestration, and automation, my thoughts on best practices, and my experiences with the products and customers. The above views are in no way representative of Cisco or any of it's partners, etc. None of these views, etc are supported and this is not a place to find standard product support. If you need standard product support please do so via the current call in numbers on Cisco.com or email email@example.com
We currently have a 6506-E with a fan tray, 2 3000W power supplies, 3 X6748-SFP line cards and a SUP720 running IOS 12.2 IP Services, which works. We would like to upgrade to the SUP 6T which is running 15.3 IOS IP Services, but when we tried it denies po...
I've been struggling to find a clean comparison between these two switch models, I suspect that the OR model does not support 10G-baseT but I haven't been able to find a data sheet to confirm. Anybody know what the OR designation represents (li...
I am looking for the battery information required for shipping a Cisco 9500 switch. If it contains a battery, I need to know the type (Lithium rechargeable or non-rechargeable, NiMh, Wet, NiCd, Alkaline or Button Cell).
I'm new to ACI so please forgive me. I have multiple BD EPGs that are connected and have subnets. Inside the subnets I can ping everyone. But I would like to have EPG 1 reach EPG 2. They are in the same VRF. Typical routing is placing stat...
I upgraded my ACI from 4.2 to 5.1.one leaf decided to drop an epg. all ports that connect to Repg are out of service. if i changed the port to other epg it come up and work. as soon as i put back to its original epg it become unusable.when I run sho...