350-401 ENCOR – Cisco CCIE Enterprise – 6.0 Automation part 2
January 27, 2023

5. Construct Valid JSON

Next topic, we have to construct a valid JSON encoded file. Now, JSON is nothing but Java script object notation. It’s very much like the text file. Here we can see the example as well. This is the format of JSON. But obviously in next example you will get a little bit complex program where you’ll find that inside my program I want output in JSON format. So not only that, I can use the input input in JSON, but I can do the output in JSON as well. Both ways it is working. It’s very easy to read, it’s understand and where we are using JSON. So JSON we are using when we are running any API. And maybe you have seen this in our earlier SDWAN API call where we can get the output. Or we are getting output in the JSON format, easy to read and then it is used, or it may be called inside Python program.

 You can see import JSON inside the Python program and in between Python and non Python applications as well. So now here you can see that in the link below. You can go and read more about the Python and JSON interaction with Python. I’m going to show you one import JSON example here in the next video you will find that how we can export in JSON as well. So, what you have to do, you have to go and use import JSON. And then I’ll create one file where I want to put certain values. For example, the name and then name is say tom once we define the name. And again you can see it’s very easy to read in double quotation. And then I’ll go and define the age. Because these are these strings, these are the characters. So that’s why we are putting inside the double quote. But if it is a number, we can use like this and then finally say address. And then we can go and give place. So we don’t know what place. I’ll go and give ABCD is the address. Alright. What we can do now that we can go and close this. So next that we can go and load the JSON. So JSON loads x and then I can go and print the output in a dictionary format. So here I can go and give print cy. And then I want to print the age. For example, let me close the box. All right. So some mistake is there.

 You can see in the printer statement if you click should close this and we should correct this print age. So this should be inside here. You can see if you have any type of mistake, you’ll get the error like this. All right. So apart from that, if you want to print the address, you can go and print the name. That’s the power. Actually we have the once we have the program, we can have different type of output as well. So let’s just stop here. And in this section, you’ll find that we can create a complex program and use JSON as the output.

6. Local Destination in JSON format

In this section I’m going to run one lab where you can see that how we can store the output over JSON format inside the local destination. For this you can go and refer the link below say local underscore action. This is the shorthand syntax for executed task on a local machine where the ansible laybook instead of the target device. So let me show you this in the lab so you can understand more about this. For reference you can go and check this link. Once we collect that output in JSON format, then how we can see that output. So what we are going to do that we are going to create one playbook where in that playbook I am going to store Vlantin interface details. Okay, so let me log into ansible and show you this particular lab task. We are here in the ansible.

I can go and create the program program maybe say local output in JSON format. All right. So let’s create this program. Let’s create this playbook and the name I can give name as a so let me give the name of this playbook. Say playbook for getting the VLAN ten interface details in JSON format. All right, let’s start. So the same thing that we used to do host is all then gather fax gather fax is no and then we can start the task. So let’s start the task. What I want here, let me start the label under task, get the interface details. If I want I can put one comment that VLAN ten interface details. So interface details store in JSON format. All right. Then inside this name, obviously we have to give Nxos command. So this time I’m going to use a command, what command I’m using? The command that I am using is say commands, simple CLI command like show IP, enter, face vlanten like that.

 This is the command that I’m going to use. All right. Then you can see here that if I give a space because this is a programming thing so here also I should give a space. Otherwise if I’m not giving any space, then I should not give space to the other place as well. Same label. What I want to do transport is Nxapi. Now I am going to use register and that’s the thing that you can go and refer the URL. So what is the register here? Register is interface facts.

Now I want to give this to the local destination, this particular output. So this output like that I can give the comment and here also if I am maintaining the label. So here also I can maintain the label, no problem. Now we’ll move next and give the destination. So I am here now and let’s start with the label. This label will be the same, otherwise it will throw an error. So let’s do this. All right, local action copy the content. So what is the content? We have content equal to interface facts that we have here. All right, and what’s the destination? So the destination equal to name, what is the inventory host name? And that’s it. We are almost done. The format that we are using is JSON. We’re done. So let’s save this program and try to run in the playbook.

This is the local output and inventory. So now we can see that this program execution is successful. Playbook for getting the wheel and interface detail, get the interface detail copy, task copy. So we have two tasks. You can see task one and task two. And now if I want to see the output, I can go and check the interface. You can see this is the output in our program. So let me show you the output format as well. The output format is destination is interface then hostname is nxos v one. Just like that, correct. So we’ll go back here and if you want to see the output, I can see like this. Now this output, you can see that this is in the JSON format for that particular VLAN ten interface.

 You can see the IP address and all those stuff for VLAN ten. But again, this particular format is not that much helpful while we are reading this because this is not in certain structure. Obviously if I copy this and if I try to import or try to convert this output in other formats, it’s okay. But this is still not in that way that we can read it. So that’s why we are going to convert this JSON format to other format as well. So let’s stop here, this JSON JSON and the export that we have done for this particular task. So the agenda was to show you that how we can give the local JSON destination in the next upcoming lapse we’ll see that how we can convert the formats in the other format.

7. YANG

In six dot three we have to learn about Yang, yet another next generation. Now, before understanding Yang, you can see that we have a different type of data format. We have XML JSON and YAML XML JSON JSON we have discussed earlier. So what I have done that I have given one example related to XML as well. In upcoming video you’ll find one lab related to XML basically in XML Language what is happening that in this Markup Language you have to start and you have to end like this. You have tag value tag so you can create the header and footer and subheaders and sub footers, et cetera. And then inside that closed box you have to write your program. It’s useful for RESTCONF and Linux API.

 Likewise, we have a study about JSON. It’s a very easy format to understand and it is used by Restconfan NX API again. Then next we have yet another Markup language that is heavily used inside ansible but we have to go and learn about new type of formats again, here you have the example but for XML just to understand XML I have one lab for Jason also we have done the lab you can go and refer those videos. That what the JSON format looks like. How you can call inside actually the description of the scenario was something like you have to call the JSON as per the curriculum. But we have seen and we have done one lab related to how we can export in JSON format.

 Basically you can export in XML and JSON format both whatever looks good, we can export on those formats. Again. Yet another Markup language. Now, if you see the display, one thing is common that all three language overall it’s very easy to understand. So even you can think that we are writing some sort of code or program like that high level program and it’s very much like human readable format. We are doing some configuration in Cisco via CLI it will look like that these programs now when we are talking about yet another next generation what I have done that one of the product in Cisco called NSO Network Service orchestrations or orchestrated they are using this young model heavily.

So what is happening in NSO model that irrespective of what device you have like Juniper or F five or Aruba or Cisco et cetera, the same model or the same model driven program, you can go and implement on those devices. So related to that, in upcoming section you’ll find first of all I’ll go and define what is NSOF one video and then subsequent you have three videos, one video related to XML, one related to young and again you can see the format of Yang that you have the list and then you have to define the key. Then you have to go and define the Leaf type. Again you have Leaf and type.

So it’s something like a format where you have to put the data. And those data you can go and take from here you can see in the diagram, let’s say Young model, you can take the data and you can have the output in XML. Or you can go and take the data and you may have the output in JSON or XML format. So yeah, you’re going to see a complete program how you can write, although maybe you don’t know NSO at this point of time. So you can think that okay, we’re writing one program, just our understanding and knowledge and at least to understand the format of Young and then XML. That’s how the program looks like. And once you exclude the program, you can go actually and exclude the program and how the result looks like, if you are willing to see the result in XML or in the JSON format. So here you can see this model driven programming.

Young it’s very much human readable. You define the list and then the leaf and the type. Leaf and the type. So one time leaf is just the name of the route distinguisher. So here you can see that you have the VRF. This leaf is actually the name of the VRF. And here you can see the CLI. So I have a VRF called Red and then the Rd. Again, you can see that in CLI. How easy it is. Go. Define Ipvr and Rd. And in program you have to write these many number of codes. But the great thing about programs are that you can reuse the code again here you don’t need to give the value because those values will come as an input, correct? So you have the program, you are giving the value as an input and then you are getting the result for that. So what is the key here? Go define the list. Leaf and type. Leaf and type.

 And that’s it. It will work. Young model supported inside Cisco iOS Xi suppose in certain image, maybe some old iOS Xi. If the module support is not there, then you can go to GitHub and you can download and you can upgrade the patch or update the patch cisco is supporting in the iOS XE XR plus Cisco NSO product. And then you have the standard body as well, like IETF, open config, open daylight and it play, etc. All right, so this is the basic introduction of Young. What is Yang, how the format looks like now in upcoming four sections, at least three is for Lab and one is for understanding of NSO. You can understand about this.

8. What is NSO ?

Let us discuss about what is NSO, this Cisco Network service orchestrator. Actually this product is evolution of NCS and that NCS was actually the product of telev that has been acquired by Cisco at 2014. Now, with the help of this NCS or with help of this NSO, what we can achieve that we can abstract either physical or the virtual devices and then with help of some programming language, say some model driven programming language, we can assign the services or we can deploy the services. Once we are doing that, then we are bringing the services means we are applying the services quicker than the normal operational dispute that we have. We are improving the service agility and hence we have this new option or we have the revenue opportunities to enhance or to increase that.

 Obviously it will increase the operational efficiency. In this particular course, you will find that not many commands I’m going to use in terms of NCS, like NCS, NCS Net, Seam, NCS CLI, because by the end of the day the programming or the operating system was developed by NCS network control systems. So that’s the reason. Let me go to the next slide and let me show you the architecture of NSO. This is the architecture of NSO. You can see what are the key components here. Obviously we have two major key components here. One is the service manager, the second one is the device manager. And apart from that, obviously we can do programming, say in terms of Restful or in terms of northbound APIs like RESTCONF, NETCONF, Java, Python and other options we have.

 Now, this portion is something my entity network element drivers, all my network devices are sitting here, either physical or virtual, say with help of NETCONF and Young. If I have to deploy a service, I can deploy it within few seconds or within a few minutes. Because by the end of day what I have to do, you can say that I have to extract my package or I have to go inside my package and then I have to enforce or then I have to run a script. So once I run that script, my services will be enabled. Okay, let us discuss little bit about the service manager and device manager. As name suggest. The device manager, they are something there to manage all the devices, manage different devices in a uniform generic way and irrespective of Cisco or Juniper or any other vendor, they have that uniformity in the uniform way. This device manager managing all the devices, the device manager uses device models written in Yang. That is again very important because here the concept is that we are using model driven approach and we have the network element drivers where we can unpack the instances or unpack the device models like Cisco, Dell, F Five, Juniper, whatever the device manager is there that will maintain the uniformity of all the devices, of all the snapshots of the devices. Then we have service manager now service manager. So here we know that with help of NSO, the target of NSO is that inside the devices you have to push the services. Okay, let me change the color. So I’m pushing the services inside my device. For that reason I have two manager.

One is the device manager who is managing the uniformity of the devices with help of young. Even the service manager they are also doing the same thing means they are also maintaining the uniformity with respect to say F Five, Dell, Cisco, Juniper but they are putting some services, some services like say L two VPN, l three VPN like that. Each service app is a package and that’s again very important. The services are package. Even everything is a part of package. You have to unpack the package and you have to push inside either physical or the virtual environment. Okay, one important thing here to note that the service managers support the full lifecycle of a service like creating, deleting, editing, et cetera. This comes with a patented built in algorithm. So this is some patented algorithm fastmap and it is used to create, delete, edit all the services inside the NAD.

So the goal of NSU service is to map the service model parameter to the device that we know we are mapping the services to the devices. Okay? Finally let us discuss about package because this package can come a lot in this section. What is package? Services application and LEDs are examples of package. So either my services or my network executable drivers they are form of package, okay? The package consists of young modules that’s again, this is a model driven approach written in Python or Java or any type of XML template. Package are loaded by NSO at the startup. So this package loading and not unloading, but this package loading you will see in the upcoming sessions where I will load the package. Then I will add some actually I’m going to add two Cisco device like two CC Zero and C one. So at that time we’ll come to know more about these packages. Okay? A package is a controlled way of managed loading and versioning of a custom applications.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!