Howdy out there in Automation land!! Hope everyone is having a great summer. We draw into the last true month of summer and we are going to take you further on your Action Orchestrator journey. Since we are on our last "Back to the Basics", I think we will go with this movie poster...
Going a little old(er) school for you guys this time! In this blog we are going to do my most recent "advanced" workflow authoring lab. This will teach you looping, conditionals, and how to work with tables in AO. Also to go along with that, I would like to introduce the new *LOGO* for the blog and get your feedback! :)
Let me know what you folks think! Lots of pondering in that Thinker fella. Also in the video blog I will chat a bit on using git integration with your workflows. I know we already did that but a quick refresher. I will also talk, briefly, about how to get your "easier to use" API keys from CloudCenter Suite so you can use them with AO calls *outside* of AO. I know you can do them in AO via the API page, but this is from outside or if you want to call AO from itself..... *Twilight Zone Music*.
To get our API key we need to do the following...
Login to our CloudCenter Suite
Select Suite Admin
Click your login name at the top right
Select Generate API Key
The User ID it gives you is your username. The API Key is your Password
You can now use those in a Basic Authentication style header. So base 64 encode username:password and you are good to go! (Or just use anything like postman/etc that does it for you)
Now... onto the lab!! (got you there I bet... Video is coming..)
Create a new workflow called Advanced Workflow Lab
Add it to your category or any
Create some variables! A string for output called id_list. A local integer called LVC. A couple of local strings for storage. An input integer called number_of_users. A local integer called TRUE, set it to 1. The local strings can just be local_storage or whatever you like to call them
Writing an ADVANCED WORKFLOW!
You will need to re-use the JSONPath holder HTTP endpoint we made in the Back to the Basics Part 2 blog. Don't have it? Go back to that blog and watch and add it!!!
Now... back to this lab... Make a call to JSONPath Holder again accessing the /posts endpoint. It should be a GET. *You* get to fill in all the other stuff... watch the VOD here or do this first and attempt it yourself. This will help you and should not be hard if you watched the previous blog.
Now add new data type to your your workflow, click ADD VARIABLE under Variables, under Data Type click ADD NEW.
Table Type will be selected as it is the only advanced data type currently supported. Give your table a DISPLAY NAME. This table is just for show, we won't use it, and you will see in the VOD I skipped it... however I want you to do it so you get the feel of creating a table!
Go to your COLUMNS and add fields via ADD 1 MORE FIELD at the bottom. The FIELD NAME is the column name, the FIELD TITLE is what is on the UI. You can select the type for the column in FIELD TYPE and add optional parameters.
Add a few fields and make some required and some not via the REQUIRED slider. Click SAVE to save your table.
Now back to your workflow....Drag and drop a Read Table from JSON activity below your web call.
Under Read Table, set the JSON PATH to $..table[*] and check the PERSIST TABLE checkbox. If you do not check this, the data from the table will not be available to you later in the workflow.
In COLUMNS TO READ click ADD to start adding columns. They should be all type String and their names should be userId, id, title, and body. Their names must match the JSON.
Under SOURCE JSON, we need to "wrap" the web request json in some tags to make it readable, so we will put the output of the web activity into the SOURCE JSON field, but then wrap it as below
"table": <reference to web call output>
What about a LOOP and the Results?
Drag and a drop FOR EACH Loop from the Logic area in the toolbox under your Read Table from JSON activity
Click the insert variable reference icon to load in the SOURCE ARRAY. Select the output of the Read Table from JSON Activity. You can *only* feed tables into this field.
Drag and drop a CONDITION BLOCK inside the FOR EACH loop
Set the DISPLAY NAME of the conditional to If ID LIST is empty
Set the left CONDITION BRANCH to THEN and right one to ELSE (Remember we are doing that best practice of documentation! --- and all the developers gasp!)
On the left CONDITION BRANCH set the CONDITION to one of your local variables(the storage one) being empty or blank. We can do that by setting it to Equals then a blank field.
On the right CONDITION BRANCH set the CONDITION to your local TRUE variable Equals to 1. This is another way to do an ELSE statement.
In the left or empty branch, drag and drop a SET VARIABLE activity.
Set your local string variable to the current loop iterations id value. You do this via Activities->For Each Loop->Source Array->Items->id. Then click SAVE.
On the right branch, drag and drop another SET VARIABLE activity, or duplicate the other one.
Set your local string variable to itself, then a comma, and then the current loop iteration id value. This will build you a comma-delimited list of ids. This is how we do string concatenation in AO and will be *HUGE* for you going forward.
How about looking at the table where ID=2, how do we do that?
Drag and drop the Select from Table activity below your loop
Under Select, set the INPUT TABLE to the output of your Read Table From JSONPath
Then set the WHERE CLAUSE to id='2'. Persist this table as well and return all columns.
Lastly, set an output variable. Set your output id_list to your local storage.
Validate, Run your workflow and see the results!
Check out individual iterations of the loop. Check out what is at ID=2 and check out your resultant id list!
Pretty cool huh? A quick and simple lab to teach you some of the advanced things or standard flow control in AO! Now time for you to build on it more!!! Feel free to try the above or watch the video and do it at the same time...
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
Hi, I'm looking for some guidance. We have aci in network centric mode, and have began migration of services into aci using a physical and a vmm domain, these vlans are statically configured as we are trunking the vlans into aci while we migrate...
There was an attempt to DH a pair of N2K-2348 FEXs, but it was eventually decided to just ST them. With FEX 101 hooked to the 1st Nexus 9300 and FEX 102 hooked to a second Nexus 9300. However if the command "show fex" is run on 1st Nexus 9300. It displays...
Configuration for Extended Session: SPAN Configuration=========================================================Nexus(config)# interface <enter interface where you want span (dest)>Nexus(config-if)# switchportNexus(config-if)# switchport mode trunkNe...
Hello Frds , I am having 3 question regarding vxlan. 1. In 5600 when we use vpc + vxlan i.e anycast vpc so what i learned that we need to have nve peer link concept otherwise traffic going from peer link will removed vxlan encap. I need a scenar...