Cisco CCNA 200-301 – Network Automation and Programmability Part 2

  • By
  • March 8, 2023
0 Comment

3. Python, Git, GitHub and CI-CD

Cisco don’t expect you to be a developer who can write your own code for the CCNA exam, but they do expect you to know some of the basic terminology around development and the way that developers work. So I’m going to cover those in this short lecture here. First up is about Python. And Python is typically the language of choice for network programmability for several reasons. It’s relatively easy to learn, and there’s many different training resources available. The Python scripting language is human readable, and it’s easy by reading through it to see what’s going on. It’s free, open source, it can be installed in all popular operating systems.

It’s actually built into Linux and Mac by default, and it’s easy to find network automation code samples, so you don’t have to start from a blank page all the time for anything that you want to do. You can typically find a code sample where somebody’s already done that, and then you maybe just need to modify it slightly for your particular environment.

Next thing is git. Git is a version control system which tracks changes in source code and files. It’s typically used for software development, but it can also provide version control for any type of files with most client server version control systems. So other version control systems do exist. But Get is by far the most popular one these days. With a client server version control system, the code has to be checked out and can only be worked on by one developer at a time.

So we get the benefits that you get. You get the version control there, so it keeps track of the changes that have been made, and it’s very easy to roll back to a previous version. It’s also very useful when you’re working as part of a team where multiple people can work on the code at the same time. If you’ve got a client server version, that’s where there’s one master copy of it, and only one person can work on the code at a time. Get is different. It’s a distributed version control system. So with it being a distributed version control system, every git directory on every computer is a fully fledged repository with complete history and full version tracking abilities.

So when you’ve got multiple developers working on the same project, they can all have their own separate copy of the project, and they can start their own branches from there. And it’s very easy to merge everything into the same code. Organizations do typically designate one repository as the master copy just for ease of management. But the architecture of git is it’s distributed. Every separate repository is a complete separate copy of the repository. Okay, so that was git. That gives you your version control.

It makes it easy to work on code when you’re working as part of a team. There’s also Git Hub. Now, git and GitHub are two different things. So Get is the version control software GitHub is a git repository hosting service which adds many of its own features. Repository, by the way, is just a place that you can keep things. So if you’ve got a source code repository, it’s where you’re keeping all the files that are making up that source code. Repositories in GitHub can be private or they can be publicly shared. They can be easily copied between users and task management tools that are available which make it easier when you’re working as part of a team and control mechanisms provide security and resolve conflicts.

As I mentioned earlier, with get it’s distributed and you can have multiple people working on it at the same time. So rather, when you’ve only got one single master copy, which one person can work on at a time because it’s distributed, it is possible that conflicts where it can arise, where you’ve got people that have made changes to the same part of the code and it’s different changes. There are tools within git and GitHub to help you resolve that. Okay, the last thing to talk about here is CI CD. CI stands for continuous integration and CD is continuous delivery or continuous deployment. You can use either one of those terms.

They’re both CD. CI CD is a set of operating principles and practices that enable application development teams to deliver code changes more frequently and reliable. So CI CD, it’s not a thing that you can touch, it’s not like a piece of software. It is really best practices for how software development teams work out. With software development teams producing code, frequent changes are more efficient than rolling them up into large change windows. So when the code is written and it’s ready to be put into production, it seems a best practice.

Now that you do that frequently, it’s better to have frequent changes when rolling up all your changes into a huge bundle and then doing that infrequently, I mean, putting it into production. Automation of building testing and deployment allows you to make those frequent changes and still having them being quality changes without causing problems. And the implementation when you’re doing this, it’s known as your CI CD pipeline. Software tools such as Jenkins and Travis CI can aid management of the pipeline in your environment. Okay, so that was all the basic information around development required for the CCNA that I needed to talk about here. I’ll see you in the next lecture.

4. Data Serialization Formats: XML, JSON and YAML

In this lecture, you’ll learn about the data serialization formats XML, JSON, and YAML to give you the definition. Data serialization is the process of converting structured data to a standardized format that allows sharing or storage of that data in a form that allows recovery of its original structure. So basically what that means is that it allows transfer of the data between different systems, applications and programming languages because it’s storing the data in a standardized format. And three of the available format types are XML, JSON, and YAML. Obviously they have to be machine readable for the data to be shared between machines. They’re also designed to be human readable as well, though, to make it easier for us to work with them. And they’re plain text data encoding formats. The data formats are mostly interchangeable, meaning normally you can use any of them, it just depends what is supported on the particular system you’re working on at the time. Often you’ll be able to choose between multiple different data formats.

For example, if you’re working with Python programming, it’s capable of reading and writing with all three of those formats. So the one to use depends on the support in the system it’s being used with and which one is easiest for you. I’ll talk about which ones are easier than the others as we go through this lecture. So starting off with JSON, we’ll start here because this is the one that you’re most likely to be tested on in the CCNA exam. One of the requirements is that you’re able to read JSON formatting. So JSON. It stands for JavaScript Object Notation. This was first standardized in 2013, and it’s easier for humans to read and work with than XML. XML has been around for a longer time than JSON, and one of the reasons for JSON being developed was to have an easier format to read. JSON can be imported directly into JavaScript, which is commonly used on the Internet, and with JSON, white space in the text has got no special meaning. Restful APIs often use JSON.

We’ll be talking about Restful APIs later in this section. So the different data types in JSON. So I’m going to break down the syntax in the format of how JSON works now. And first off, I need to tell you what the different data types are. I’ll be explaining each of these as we go through the following slides. So the different data types are object, array, string number, boolean, and null. So let’s start off with Object. An object is an unordered collection of key value pairs which describe the thing. Whatever the object is, when the object is written in JSON format, it is surrounded by curly braces. So we’ve got the key value pairs which describe the object. The keys must be strings, meaning a set of characters, and the values must be a valid JSON data type. So those earlier, but the six types of string, number, object, array, boolean, or null. The keys and values are separated by a colon when they’re written. And each key value pair is separated by a comma until we get to the last one there. So, having a look at an example here, you can see we’ve got our JSON object. We can tell that because it opens and closes with curly brackets. And then in here we’ve got that unordered collection of key value pairs which describe it. So we’re looking at the description for an interface.

Here. You can see here is the key is the name, and then the value is gigabit ethernet one. And then we’ve got the next key, which is description and the value internet link. And then we’ve got the key enabled and the value of two. So you can see there, we’ve got three key value pairs. We’ve got the key first, then the value, and they’re separated by a colon. Okay, moving on. The next one is array. And where an object is an unordered list and array is an ordered list of values. And where an object is surrounded by curly brackets, the array is surrounded by square brackets. That’s how you can tell them apart with our arrays. Values must be a valid JSON data type. Again, string number, object, array, boolean or no. So you can see here that the value for an array could be another array or it could be an object. And going back a slide, it’s the same for our objects. That can include an object or an array as well. So we can nest our values, we can have objects within objects, we can have arrays within arrays and we can have them within each other as well.

You’ll see some examples of the nesting as I go through this lecture. So an example of an array. In fact, you can see here that we are nesting an array inside an object. We’ve got the object here, we can see that from the curly brackets on the object. We’ve got the key values there of the name is John and his age is 25. And then we’ve got the key value where the key is girlfriends, and the value is an array. And we can see with the array there, which is opened and closed with the square brackets. And we’ve got the list there of John’s girlfriends are Zoe, Eve and Emma.

And you can see here on our object that each of the key value pairs there. We’ve got a comma after each one apart from the last one. And it’s the same in the array as well, where they are separated by commas, but we don’t have a comma after the last one there. Okay, and more example of nesting here. You can see here that we’ve got an object. So we’re opening and then closing the object. And then in there we have got an array. And in the array we’ve got two objects nested in the array. We’ve got our first IP address and subnet mask and then our second IP address and subnet mask.

Okay, moving on to the other JSON data types apart from object and Array are a string. So a string is an alphanumeric string of characters and with our strings they are always shown enclosed in quotes. So the key is always a string. So that’s why the key is always within quotes. And then we’ve got the coupon to separate from the value. And then you can see this is a string. We can tell it’s a string because that is in quotes as well. The next data type is a number. The example here the key is input errors and then the value there is three.

When we’re specifying a data type which is not a string, we don’t put it in quotes. So we can see here it’s not in quotes and it’s a number. So the data type is number boolean is either going to be true or false. So here we’re describing the state of the interface in this example. Is it enabled or not? That’s a Boolean value, either it’s true or false on whether the interface is enabled. And finally we can have a null value as well. Null can be written explicitly as null, or you could just have a blank value there. It depends on the particular application you’re working with at the time. If there are a null value, you should say null or leave it blank. Okay, so that is the format of JSON. I’ve got another final example here as well, and this gives you an example of where it would be used for network programmability, where we have got the object opened at the top and then closed down at the bottom here. And then we’ve got multiple objects and arrays inside there describing our interfaces.

So we’ve got two different interfaces. So that’s why we’ve got an array opened here and then closed down here for our different interfaces. We’ve got an object inside the array, the first object is Interface Gigabit ethernet one, and we’ve also got Interface Gigabit ethernet two as well. We’ve also got nested arrays for the IP addresses in there. So you can see here we’ve got nested arrays because you can have multiple interfaces on the device. You can also have multiple IP addresses on the interfaces as well. And this is how it would be written in JSON format if you wanted to have a description of your two interfaces on your device and the IP addresses on there.

Okay, so that was the syntax of the JSON data format. Moving on, the next one is XMLs. XML was standardized in 90 98. It’s been around a lot longer than JSON. It’s widely used across the Internet and similar with Htmls, XML was designed to describe and transfer data. While HTML is focused on how to display the data with your web pages on the Internet, white space has no special meaning in XML. The same as it is in JSON. And again we’ve got our list here of our key value pairs and that they are contained within object tags. You can see an example of a tag here and we open it with the word inside our arrows here and then we close it. We repeat the word again, but we put a slash in front of it. So let’s have a look at an example of XML. Same kind of information that we were looking at earlier about our interfaces. So earlier on you saw how similar information here would be written in JSON. This is how we would write it in XML. So you can see here we’ve got our gigabit ethernet, one interface and to open that tag we’ve got name inside our arrows and then close it, we say name again as well, again inside our arrows and we put a slash there in front of the name.

We do the same thing for Internet link. We’ve got opening and closing the description, opening and closing, that is true, et cetera. So that is the XML format. It’s been around for a long time, there’s very wide support for it. It’s not quite as easy to work with and read as JSON is. So developers will typically prefer to use JSON over XML if it is available to use that with whatever they’re working on. The last one is YAML and this stands for YAML aint Markup Language. A bit of geek humor for you there. YAML is often used in python, pearl and Ansible. Again like JSON designed to be easily read by humans. With YAML the white space of the indentation is important. It’s a big difference between YAML and XML and JSON. Anything at a common indentation level in YAML is considered to be related at that same level. With our YAML files they always start with three dashes.

That is how it indicates that it is a YAML file. Again it uses key value representation the same as the other formats. And inside our YAML file a dash indicates a list. I mentioned it’s often used with Ansible, your ancient playbooks use YAML. We’ll be having a look at how Ansible works in a lot more detail later on and you’ll see YAML being used then. For now, here is an example of the YAML syntax and format. You can see it starts with the three dashes and then we’ve got again similar information we’re looking at here. We’ve got IETF interfaces interface, then we’ve got our key value pairs which again are separated by a colon. And you can see here that the name description enabled and IETF If are all at the same level. So normally you’ll use two spaces for each indentation.

So I’ve got two spaces in front of each of these to indicate that they’re at a lower level than the top level. And then when we get down to the sub information which is the address on that interface, we’ve got that indented another two spaces as well because we can have multiple addresses on our interfaces. We then got a list below that. And again, we’ve got that indented too. Okay, so that was what our data serialization is the common format of XML, JSON and YAML and how they are written. See you in the next lecture.

Comments
* The most recent comment are at the top

Interesting posts

Everything ENNA: Cisco’s New Network Assurance Specialist Certification

The landscape of networking is constantly evolving, driven by rapid technological advancements and growing business demands. For IT professionals, staying ahead in this dynamic environment requires an ongoing commitment to developing and refining their skills. Recognizing the critical need for specialized expertise in network assurance, Cisco has introduced the Cisco Enterprise Network Assurance (ENNA) v1.0… Read More »

Best Networking Certifications to Earn in 2024

The internet is a wondrous invention that connects us to information and entertainment at lightning speed, except when it doesn’t. Honestly, grappling with network slowdowns and untangling those troubleshooting puzzles can drive just about anyone to the brink of frustration. But what if you could become the master of your own digital destiny? Enter the… Read More »

Navigating Vendor-Neutral vs Vendor-Specific Certifications: In-depth Analysis Of The Pros And Cons, With Guidance On Choosing The Right Type For Your Career Goals

Hey, tech folks! Today, we’re slicing through the fog around a classic dilemma in the IT certification world: vendor-neutral vs vendor-specific certifications. Whether you’re a fresh-faced newbie or a seasoned geek, picking the right cert can feel like trying to choose your favorite ice cream flavor at a new parlor – exciting but kinda overwhelming.… Read More »

Achieving Your ISO Certification Made Simple

So, you’ve decided to step up your game and snag that ISO certification, huh? Good on you! Whether it’s to polish your company’s reputation, meet supplier requirements, or enhance operational efficiency, getting ISO certified is like telling the world, “Hey, we really know what we’re doing!” But, like with any worthwhile endeavor, the road to… Read More »

What is Replacing Microsoft MCSA Certification?

Hey there! If you’ve been around the IT block for a while, you might fondly remember when bagging a Microsoft Certified Solutions Associate (MCSA) certification was almost a rite of passage for IT pros. This badge of honor was crucial for those who wanted to master Microsoft platforms and prove their mettle in a competitive… Read More »

5 Easiest Ways to Get CRISC Certification

CRISC Certification – Steps to Triumph Are you ready to stand out in the ever-evolving fields of risk management and information security? Achieving a Certified in Risk and Information Systems Control (CRISC) certification is more than just adding a prestigious title next to your name — it’s a powerful statement about your expertise in safeguarding… Read More »

img