Overview
Join John McGovern as he walks through the basics of Python.
Recommended Experience
- At least six months of Python programming experience is recommended, but not required
- An understanding of concepts taught in Cisco CCNA is recommended, but not required
Related Job Functions
- Network engineer
- DevOps engineer
John McGovern has been a CBT Nuggets trainer since 2020. His areas of expertise include Python, networking, network automation, and cybersecurity.
Introduction to Network Automation
Join John as he introduces you to this skill and the benefits of automation within the world of networking.
Python & Programming
Python is one of the most popular programming languages in the world. Learn why and how you can benefit from learning how to use it.
Knowledge Check
This course will be focused around Python2. True or false?
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Linux Setup
Learn how to set up your programming environment within a Linux operating system.
Knowledge Check
Which of the following commands was used to install Visual Studio Code?
- Asudo snap install --classic code
- Bsudo snap install --vs code
- Csudo apt install vscode
- Dsudo apt install classic code
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
macOS Setup
Learn how to set up your programming environment within a macOS operating system.
Knowledge Check
Which version of Python was installed in this Nugget?
- Apython 3.9.6
- Bpython 3.8.5
- Cpython 2.8.3
- Dpython 2.9.6
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Windows Setup
Learn how to set up your programming environment within a Windows operating system.
Knowledge Check
Which command was used to install an SSH server on the Ubuntu virtual machine?
- Asudo apt install openssh-server
- Bsudo apt install ssh-server
- Csudo apt install openssh
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Useful Extensions
Extensions allow you to speed up the development of your scripts and programs and help you minimize errors. Learn all about them in this video.
Knowledge Check
All Visual Studio Code extensions must be purchased prior to installation. True or false?
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Cloning Code from Github
Github allows you, or anyone else, to store code in an accessible place so that anyone in the world can download your code and use it in their own projects.
Knowledge Check
Which of the following commands will allow a user to download and copy a remote repository?
- Agit clone <URL>
- Bgit copy <URL>
- Cgit download <URL>
- Dgit source <URL>
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Cisco DevNet Sandboxes
Note: This section is specifically designed for those preparing for a Cisco exam or planning to work with Cisco products. If you're focusing on general Python skills or network automation concepts outside the Cisco ecosystem, you may skip this section without missing any key content.
Learn how you can gain practical, hands-on experience by using Cisco DevNet sandboxes.
Knowledge Check
The Cisco DevNet Always-On sandboxes must be booked prior to use and accessed via a VPN. True or false?
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Running Our First Script
Learn how to run a script on your machine.
Knowledge Check
Which of the following commands would execute a python script?
- Apython3 <scriptname>
- Bpython3 execute <scriptname>
- Cpython3 run <scriptname>
- Dpython3 program <scriptname>
Verify your team's readiness — Request a Demo to verify practice assessments, completion reporting, and CSV / SCORM exports on the Team plan.
Conclusion
I hope this has been informative for you and I would like to thank you for consuming.
View Transcript
Introduction to Network Automation
0:12Hey, guys, and welcome to the CBT Nuggets course
0:15on learning Python for network engineers.
0:18So first, let's start by addressing who exactly
0:22is this course designed for.
0:24Well, the clue is in the name.
0:26It's designed for you, the network engineer.
0:29But why would you as a network engineer, the type of person
0:32who deals with access control lists, who configures routing
0:35protocols and VLANs, why exactly would someone
0:38like you want to learn a programming
0:42language like Python?
0:43Well, I'm sure you've already been keeping up
0:45with the latest news.
0:46Without doubt, the biggest buzz within the networking industry
0:50is the concept of network automation.
0:53Network automation is absolutely everywhere.
0:56And the significance of this change
0:58was really hammered home when Cisco announced its DevNet
1:02certifications.
1:03When this happened, people really
1:05started to take notice and realize that this was not
1:08a fad, it was not just hype, and it was not going away.
1:11Now, quite understandably, many within the networking industry
1:15were a little bit uncertain about this news.
1:18Networking is a really hard profession.
1:20It's not easy, as you know.
1:22How on Earth are you going to remember
1:24all of that crucial networking information,
1:26and then squeeze in a whole new profession?
1:29Do you have to be a developer now?
1:31A developer and a network engineer?
1:33Well, that's two separate professions.
1:35How much time in the day does someone really have, honestly?
1:38Well, here is the good news when it comes to network automation.
1:42Network engineers can learn the Python programming language
1:46to effectively do their network engineering
1:49job more efficiently.
1:51So the focus still is the network.
1:53Your network and information doesn't just go out the window.
1:56It doesn't just become antiquated and old hat.
1:59Certainly not at all.
2:00This is still going to be of primary importance.
2:03But what about this Python stuff.
2:05How much do we really need to learn?
2:06Do we have to become experts in programming?
2:09Well, again, this is the good news.
2:11You really don't have to learn an awful lot of Python
2:14to get a lot of mileage within the realm of network
2:19automation.
2:20So pretty much if you're just starting your career
2:23as a network automation engineer and you have some programming
2:26experience, well, this course certainly
2:29should help you solidify this information,
2:31and maybe help build upon this knowledge,
2:34and help give you ideas how to apply
2:36this knowledge to the network.
2:38But here's the thing.
2:39Even if you have no knowledge of programming whatsoever, i.e.
2:44zip, nada, none, then my goal for this course
2:47is to be able to help you get from ground zero
2:50up to learning the fundamentals of Python.
2:53And like I say, even a small amount of Python
2:56can go a long way in the network automation space.
2:59So ultimately, throughout this course,
3:01we're going to be discussing Python concepts such as lists,
3:04and dictionaries, and loops, and a whole lot more.
3:08But what my goal here as a network engineer primarily
3:12is to try to teach these concepts,
3:14not from the traditional programming point of view,
3:17my goal is to help you understand these concepts
3:20and see how they can be applicable to the network.
3:23Because it was only when I saw how
3:25it could be applied to the network,
3:27that was when my enthusiasm for the programming language
3:30really accelerated.
3:31Suddenly it felt like I had this big new superpower
3:35to be able to manage the network.
3:37And let's be honest, that sounds like fun.
3:39Now quite frankly, some concepts can't really
3:41be taught from a network-centric point of view.
3:44Sometimes we will fall back into more classical programming
3:48examples, but ultimately, we're always
3:50going to be trying to tie that information up and bring it
3:53back into the networking world where
3:55we can so you can really get a sense of the applicability
3:58here.
3:59So that is the rough goal for this course.
4:01But what about network automation generally.
4:03Why did this take off?
4:04Why is it such a big deal?
4:06Why can't you go on Twitter or LinkedIn
4:09without hearing a constant buzz about network automation
4:12from your colleagues?
4:14Well, at a glance, being able to program your networks
4:17is going to make your efficiency skyrocket.
4:20You know those mundane tasks you hate to do, perhaps
4:23maybe like documenting the network, how many devices do
4:26we have, and what are the serial numbers, and what
4:28are the IP addresses.
4:29And gather them all together and put them
4:31into an Excel spreadsheet.
4:32Wouldn't it be cool if you could just write a little program
4:35and then within 10 minutes, sit back, enjoy a coffee,
4:39and have a computer go and gather all that information
4:42all at once, put it into a spreadsheet,
4:44and send it off to your boss.
4:45Well, by learning Python, this is exactly the type of thing
4:48you will be able to do, no problem at all.
4:51And related to an increase in efficiency,
4:54we're also going to see an increase in speed.
4:57So it's not just about you being able to put your feet up
4:59and maybe go do another task at the same time
5:02as your program is executing.
5:03Simply put, what may take you three weeks to do manually,
5:07a program may be able to do within 10 minutes.
5:09Similarly, if you happen to make a mistake within the network,
5:13you can reverse those changes much faster as well.
5:16And if you know-- as a network engineer
5:18if you melt down that network, it
5:21can be a pretty stressful event.
5:23So if you can have an undo button, which
5:24can go out and pull the network back to a safe state,
5:28well, that's probably a good thing for your blood pressure.
5:30So tying in with that concept as well is we're
5:33going to see an increase in reliability.
5:36Teams that implement automation have much more stable networks.
5:40They have less downtime.
5:42And quite honestly, it really does encourage
5:45network development and growth.
5:46What do I mean when I say that?
5:48Many networking teams almost adopt a posture of fear.
5:52They don't want to make a change because if a change goes wrong,
5:54well, it might be hard to recover and re-converge
5:57the network.
5:58However, with automation, being able to make these changes much
6:01more reliably as well as having the option to easily roll back
6:06upon misconfiguration, it gives you a lot more freedom
6:09to try to optimize the network as opposed to just leaving it
6:12in a still stagnant state that you know
6:14is pretty safe, but not really optimal or efficient.
6:18And again, how much Python do you
6:19need to know to be able to do these types of things?
6:21Well, the good news again, I say, really not that much.
6:25And now lastly, almost selfishly,
6:27it's going to be really good for your career.
6:30Programming skills are really in demands,
6:33and the ability to be able to apply these skills to automate
6:36out networks so that they can be deployed faster, rolled
6:39back easier, more stable, save the company money,
6:42all of these things make you a valuable employee
6:45because if you can leverage the power of Python
6:48to be able to do the workload of 10,
6:5120, 30 regular network engineers, then
6:53you can imagine that companies will pay you a lot of money
6:56to be able to do that.
6:57So I really do think this is going
6:59to be a great journey for you to embark on.
7:01There is so much upside and it really is a lot of fun.
7:04Now, if you are like me and you come from a networking
7:07background and you know nothing about Python, then just like me
7:10I expect you to find some of the concepts
7:12a little difficult at first.
7:14This is plenty normal.
7:15It's no different than when you first learned how to subnet.
7:18The key here really is just simply practice.
7:21So throughout this course, I'm really
7:23going to try to make it as hands-on as possible for you,
7:26so that you're getting your hands dirty,
7:28you're typing up code, and you're
7:29beginning to see the applicability
7:31of what you're doing and how it actually
7:33pertains to the network.
7:35So suffice to say I'm really excited to get going with you.
7:37And I hope this has been informative for you,
7:39and I'd like to thank you for viewing.
Python & Programming
0:12Hey, guys and welcome back.
0:14So, let's talk about this strange concept
0:17known as programming.
0:19When I first heard about programming, in my head
0:22I had this image of a lot of green text on a black terminal,
0:26and a lot of ones and zeros flying around and just
0:28a lot of magic happening.
0:30It just seems so esoteric and just so strange.
0:33But once you understand the concepts behind programming,
0:37everything becomes a lot clearer.
0:39Now, the first thing that you will
0:41notice when you began programming
0:43is that computers are pretty stupid
0:45and they are very, very literal.
0:47You know the way we as humans communicate with each other?
0:50This is not the way that programming works.
0:53You might hear a good song and say it's kick-[garbled],
0:55but to a computer, kick-[garbled] is committing an assault
0:57on someone's backside.
0:59Same way if you say a song is pure fire.
1:02Pure fire to a computer would be an emergency.
1:05That would be something is actually burning down.
1:07Computers are really, really literal.
1:09So, if I had to ask you, how do you make a cup of coffee?
1:13And I asked you to write down the steps of what you do.
1:15So, you might say, you know, you boil water.
1:18And then you say you put coffee in the cup.
1:20And then you pour boiled water into the cup.
1:24And then maybe you add some milk because you
1:26don't like it too hot.
1:27And then you add sugar, maybe, if you've
1:29got a sweet tooth like me.
1:30And then you drink the coffee.
1:33Now these are perfectly reasonable instructions
1:35you could give to a friend who doesn't really drink coffee,
1:38and they could take these instructions,
1:39go into your kitchen and probably
1:41make a pretty decent cup of coffee.
1:43OK, maybe not decent, but still a cup of coffee.
1:45But if you gave these types of instructions to a computer,
1:48you would have to be way more explicit.
1:51The computer would want to know where is the water coming from?
1:54How were you going to boil the water?
1:56What are you going to use?
1:58How are you going to get the water into the kettle?
2:00How can you tell if the water is boiled or not?
2:02Where did you get the coffee from?
2:04How do you know it's coffee and not tea?
2:06How do you know that the water has boiled?
2:08Add milk to cup.
2:09Add milk to which cup?
2:11The same as the coffee's in?
2:13Add sugar.
2:13Add sugar where?
2:15To the cup?
2:15To the table?
2:16Drink?
2:17Who's the drinker?
2:18And how do you drink it?
2:19What does it even mean to drink?
2:20Now, this all may sound a little crazy because you
2:24as a human don't think this way, but honestly, it's
2:27this type of literalism that you really
2:30have to kind of adapt to when you're dealing with programs.
2:33Again, the good news is, is that this is something
2:36you can definitely get used to and it really
2:38is quite fun to learn.
2:39So, that is a more broad overview
2:42of programming in general.
2:43But what about this language right here, Python?
2:46Well, some brief details about Python
2:48is that it is what's called an interpreted language.
2:51And you'll get to see what this means as we progress
2:54throughout this course.
2:55It's also called a high-level programming language.
2:59What does this mean?
3:00Well, is good news for me and you.
3:02It makes our job a lot easier.
3:04There's a higher level of abstraction.
3:06Python hides away a lot of the lower-level details of what's
3:09really going on under the hood.
3:11Now, ultimately, this makes Python a very readable
3:14programming language.
3:16Now, that doesn't mean that all Python code,
3:18you can just read it like you could read a book.
3:20But in the world of programming, Python code
3:23is vastly more readable than something like say,
3:26assembly language or Java.
3:29So, this makes a really good fit for us
3:31as network engineers who maybe don't
3:33have the classical programming background.
3:36Now, another great feature about Python
3:38is that it is so, so flexible.
3:41And this is something you're going to find out hopefully
3:43within this course is that with Python, you can do an almost
3:47limitless amount of things.
3:48And one of the reasons why this is possible
3:51is number one, the way the language has been designed.
3:53And two, because Python has a huge, huge community.
3:58So, how does a community actually
4:00help us as Python programmers?
4:02Well, basically, what people do is,
4:04they write their own Python code to create Python tools
4:08and modules.
4:09Here's an example.
4:10Someone in the Python community created
4:13a module called IP addr.
4:15Now, this is very useful for us as network engineers
4:18because with this module, you can just
4:21feed it a particular sub net and this module will automatically
4:25tell you the host range, the network address, the broadcast
4:29address, and many, many more.
4:31Ultimately, what this translates to
4:33is that, people have already done
4:36so much of the heavy lifting for us,
4:38we don't have to code all this ourselves.
4:40We can just make use of the great work of the wider Python
4:44community.
4:44And like I said, the community is so large.
4:47There are so many useful modules like IP addr
4:51which is going to make your job much, much easier.
4:53And in fact, you don't have to write the tools.
4:56If you just learn how to use the tools then
4:58you can really improve your efficiency
5:01in managing your network.
5:02Now, there's an important thing to note with Python.
5:05Is that there are two main branches of Python.
5:08First one is Python 2.
5:10You might still see this.
5:11And the second one is Python 3.
5:14Crucially, within the year 2020, i.e.,
5:17last year, Python 2 has been completely deprecated.
5:21There is no longer support for this.
5:23The difference between Python 2 and Python 3
5:25is that Python 2 was an older implementation of the language.
5:29There were some slightly different rules,
5:31some of the syntax was different,
5:33but you might still see some Python 2 code out in the wild.
5:36In fact, even if you happen to install maybe Ubuntu,
5:40by default, Python may actually be used in Python 2.
5:44This is something you want to watch out
5:46for because what we are going to be focusing on
5:48is the new Python 3.
5:50And when I say, new, Python 3 has been it
5:52for many, many years.
5:54But on this day in 2021, Python 3
5:56should really be the only type of Python you are using.
5:59And it's going to be Python 3 which
6:02we are going to be exclusively focusing on within this course.
6:05But how on earth do we set up Python 3
6:08and make sure it's not Python 2?
6:09Don't worry, we'll figure that out in the very next Nugget.
6:12So, I hope this has been informative for you,
6:14and I'd like to thank you for viewing.
Linux Setup
0:00[MUSIC PLAYING]
0:12Hey, guys, and welcome back.
0:14So in this Nugget, what we're going to be discussing
0:16is how we can set up a programming environment
0:19within a Linux system.
0:21Now, I'm also going to be walking
0:23through how we can set up our environment for a Mac OS system
0:26as well as a Windows system.
0:28But I really would advise that you use a Linux system
0:31because so many of the tools with a network automation
0:34are tailored to be run on Linux.
0:36Now, Mac OS is also a Unix-based system
0:39so it's pretty close to just using Linux.
0:42So you could probably get away with using Mac OS
0:44but ultimately, if you can, I really
0:47would stress to try to use a Linux environment.
0:50So as you can probably tell from the top of the screen,
0:52this is not actually a native installation
0:55on the baremetal of my computer.
0:57Instead, this is just a Linux virtual machine.
1:01But quite frankly, this is a really great way
1:03to use your automation in my opinion, at least for lobbying,
1:07because virtual machines are easy to snapshot
1:09and roll back, so on and so forth,
1:11they're very, very to manage.
1:12And like I said, you get the benefit of a full Linux system.
1:16So what I'm going to do here is to walk you
1:18through the basic installation, which
1:20we need to do to get our Python environment up and running.
1:23So let me just log in to this Ubuntu machine.
1:26Now, this is an absolute fresh installation
1:29as virtual machines.
1:29There's nothing on this at all.
1:31OK, so we've now logged in.
1:33What I'm going to do it as just escape here.
1:35Hit on whatever that, click Next, and Next, Next
1:39and this is all done now.
1:41So the very first thing which I'm going to do
1:42is go to the bottom left of the corner here, click this.
1:45And what I'll search for is terminal and to Enter.
1:49So now we have a Linux terminal, let me just full-screen this.
1:52And what I'll do here to make us a little bit more
1:54readable is go to Preferences, I'll go to Unnamed,
1:58and then I'll go into Custom Font, click on this
2:00and it'll just increase the font size.
2:02It's a little bit easier for you to see.
2:04So I'll say 18 that's nice and large, click Select.
2:06OK.
2:07Now the version of Python that we are going to be using within
2:10this course is going to be Python 3.9 so let's get this
2:14installed on our system, so what I'm going to say is 'sudo apt -
2:19add' and I'll say 'repository' and do a space and then say
2:23'ppa : deadsnakes' which is a strange name,
2:28and then we'll do 'ppa' OK, perfect.
2:30So what I need to do is to type in my sudo password,
2:33which is my administrator password OK
2:35and I'll just hit Enter.
2:37OK, so forget that's a lot of money to install here.
2:39Now what I'm going to say is 'sudo
2:42apt install Python 3.main' and then hit Enter.
2:47Say 'Y' for yes, hit Enter again and that
2:50should now install Python 3.9.
2:52OK, so let's clear the screen.
2:54So if we say 'Python 3.9 - - version' hit Enter,
2:59you can see that we have Python 3.9 and this Python 3.9.6
3:03we've actually got here.
3:04Now what we want to do is to install something
3:06called an IDE, this is an Integrated Development
3:09Environment.
3:10Basically, this is a program designed for code development.
3:14In real terms it's like a text editor,
3:16but it's designed for codes.
3:18You'll get syntax highlighting top completion
3:21and many, many more features.
3:23Now, the IDE which I'm going to recommend,
3:25you install as one called VS code, Visual Studio code.
3:29And the way we can get this is say 'sudo snap
3:32install' and we'll say '- - classic code' hit Enter
3:36and that should begin installing.
3:39Just give this maybe a minute or so.
3:41And as simple as that, Virtual Studio
3:43code has now been installed.
3:45So what we can do here is just type the word 'code'
3:48and thus should launch Virtual Studio code within Linux.
3:51And from there if we just full-screen this
3:54and we just double click here at the site,
3:56that should open up a new file.
3:57And if we click Select Your Language, what I'm going to do
4:00is select Python so let's click Python.
4:04And down the bottom here, that's going
4:05to offer us do we want to install the recommended
4:08extensions for Python, so we'll just say Install.
4:11And you'll notice that it says here that it's installing.
4:14Now here's the thing, it says 'No Python interpreter is
4:16selected.'
4:17You need to select one.
4:18So what we'll do here is click Select Python Interpreter,
4:21and what we are going to do is select Python 3.9.6 here so
4:26click on this.
4:26And now if you just reload the window, let me just
4:29zoom in a little bit here, you can
4:31see that down the bottom left here we're actually now running
4:34Python 3.9.6.
4:36Perfect, so we now have Visual Studio code
4:39installed within Ubuntu and we have
4:42Python 3.9 running with a nut.
4:44Now the next thing that we are going to install
4:46is something called Git.
4:48You may have heard of the website called GitHub.
4:51Well, we will be using Git in conjunction
4:53with GitHub as a way to manage your code
4:55and we'll see more of that later on within our scale.
4:58But for now, I'm going to have to install Git,
5:00so I'll say 'sudo apt install' and I'll say 'git'
5:04and then hit Enter, and that's going to install.
5:06If I just see 'Y' for yes to accept,
5:08hit Enter again, perfect.
5:10And if we now say 'git - - version,' Perfect.
5:13So Git has been installed.
5:15Now, just for posterity, if you want
5:17to know what Ubuntu Image I'm actually using,
5:20let me just show you that.
5:21If we go to our browser and let's go to Google,
5:24and if I just search for download Ubuntu
5:27and click the top link here, I'll accept all.
5:30This is the version which I'm running, Ubuntu 20.04.2.0 LTS.
5:36LTS is the stable version, that's Long Term Support.
5:40So this is the version I recommend that you download,
5:43either you put it onto baremetal onto your laptop directly
5:46or your PC, or you do as I've done
5:49here is download this image and create a virtual machine.
5:52Now down here, that's going to tell you the recommended system
5:55requirements to download this operating system.
5:58The main point here is 4 Gig RAM,
6:00that's the minimum you want.
6:02That or more.
6:03And again 25 Gig of free hard drive space.
6:07Once again, you really probably want a little bit more
6:09than that given that we won't be installed
6:11until throughout this course.
6:12But ultimately, the good news is that if you
6:15can get as far as this, then you are ready to begin programming
6:19with Python and Linux Ubuntu.
6:21Let's see how we can do similar setups on different operating
6:25systems.
6:25And that's what we'll be doing next.
6:27I hope this has been informative for you,
6:28and I'd like to thank you for viewing.
macOS Setup
0:12Hey, guys, and welcome back.
0:14So in the previous Nugget, we had just
0:15walked through a very basic set up of our Linux environment
0:19using Ubuntu.
0:20In this Nugget right here, we're going
0:22to be focusing on setting up our environment for a Mac OS.
0:26So let's walk through the installation of first Python,
0:29and then we'll go through the installation of VS Code then.
0:33So what I'm going to do here is go to my Safari browser
0:35down here and just open this.
0:37And let me just fullscreen this.
0:39So what I'll search for is download Python 3.9 Mac OS.
0:44So if I click on this top line here, download Python.
0:47So clearly here, we can see the link for download Python 3.9.6.
0:52Now depending on when you're watching us,
0:54this might not be the latest link.
0:56So if you want, you can just scroll on down a little
0:58bit here.
0:59And you can look for a specific release.
1:01So we had 3.9.6, so there is 3.9.6, and we've also got say,
1:04for example, 3.9.5.
1:05But as long as you've got 3.9, you should be pretty OK.
1:09OK, so we can get down to 3.9.6.
1:11If I click Download here and scroll on down--
1:14OK, so I'm going to choose Mac OS 64-bit Intel
1:18installer, because I have an Intel machine.
1:20Let me just click this.
1:21Do I want to allow downloads?
1:22I'll say allow.
1:23And it's just going to download at the top right,
1:25you can see up here.
1:26Perfect.
1:26So if I click on this link here and I just right click and Show
1:30In Finder.
1:31Now that's going to open this up here.
1:34So all I'm going to do here is double click this,
1:36and it tells me it's going to install
1:38Python 3.9.6 for Mac OS.
1:40Let me just click Continue here.
1:42Now you want to read through all of the stuff, wink wink,
1:45that nobody actually ever does, and just click
1:47Continue OK, history and license, same again.
1:50Click Continue.
1:52And I'm going to click Agree.
1:54So finally, again, you can choose the installation
1:57location if you want to.
1:58I'm just going to leave it at the default, and click Install.
2:01So now I need to enter my password,
2:03so I'll just pop this in.
2:04And I'll choose Install Software.
2:07So now it's preparing to install.
2:08It's going to access my files and my downloads folder,
2:11I'll say OK.
2:12Now it's going to write these files.
2:14And you should give this maybe a minute or two just
2:16to finalize and complete.
2:18OK, perfect.
2:19So if we just click on this Python launcher here,
2:22it's going to show us where our actual interpreter is.
2:25So it's in user local bin Python 3.
2:28So now what we want to do is to install VS Code.
2:31So again, let's go back to Safari.
2:33Let's go to Google.
2:34And we'll search and download VS Code for Mac.
2:37So if we click this top link up here
2:39and I choose this link here for Mac, course.
2:42We'll say Allow.
2:43Again, at the top right here, we can
2:45see that we are downloading.
2:46So again, give this a little minute just to finalize.
2:49OK.
2:50So if I click Show Downloads, again,
2:52let's right click this here.
2:54And Show In Finder.
2:55OK, so let's just double click on this to unzip it.
2:57That's going to expand this out.
2:59Give it a little second.
3:00So if I just right click this and choose Open,
3:03that should now launch VS Code.
3:06OK, so it's going to verify.
3:07We're going to say Open.
3:09And now we have VS Code installed.
3:11Let me just fullscreen this temporarily.
3:13I'll just zoom in a little bit.
3:15OK, so I'll just double click up here to open up a file.
3:17And again, I'll choose Select A Language.
3:20I'm going to search for Python once again.
3:23Now again, it's going to say, do you
3:24want to install the recommended extensions for Python?
3:27We're going to say install here.
3:28So that's now installed.
3:30Now it's going to prompt you to install these command line
3:33developer tools.
3:35Now, I'm actually using a virtual machine.
3:37This is not a native installation of Mac OS.
3:40When I try to install these tools,
3:42it's just giving me an error.
3:43You should not have the same type of problem.
3:45So if you go on and just choose Install,
3:47there should install just fine.
3:49But for now, what I'm going to focus on
3:51is selecting the Python interpreter.
3:53So let me go over here and select this.
3:55I'll just cancel you.
3:56So this is the path which I want to select here.
3:59That's the path that we saw earlier, user local bin Python
4:013.
4:02That's just going to be a Python that we want.
4:04And we can see it in the bottom left here,
4:06we have Python 3.9.6.
4:08Perfect, so let's just close this down.
4:10Now, like I say, because I'm actually
4:12operating on a virtual environment,
4:14I'm a little bit limited in what I can demonstrate here.
4:16I'm trying my best.
4:17But ultimately, if you have a regular Mac OS system,
4:21then you shouldn't be experiencing the issues I have.
4:23Effectively, if you want to be able to install Git,
4:26you should be able to install Git view brew, the brew package
4:29manager.
4:29So if you just type in brew install git and hit Enter,
4:33that should run through the installation.
4:35And hopefully, you should all Git up and running.
4:38But again, I do stress that I recommend everyone instead uses
4:42an Ubuntu machine, either a regular machine
4:45or a virtual machine, since that's really
4:46what'll give us parity across what I'm doing on the lesson
4:50and what you're doing watching at home.
4:51But nevertheless, if you want to use a Mac machine,
4:54this is how you can get Python installed, VS code.
4:57And like I say, by using brew, you
4:58should be able to install Git just as well.
5:01Okeydoke, so I hope this has been informative for you,
5:03and I'd like to thank you for viewing.
Windows Setup
0:00[MUSIC PLAYING]
0:12Hey, guys and welcome back.
0:14So in the previous Nuggets, we had
0:15seen how we could install our environment within a Linux
0:18environment, as well as within Mac OS.
0:22And this Nugget right here, we're
0:23going to be focusing on using Windows.
0:25Now, I will say, off the bat, is that Windows as the operating
0:29system which I use--
0:30I have Windows 10.
0:31But here's the thing, I'm really going to strongly recommend
0:34that you don't use Windows for your network automation.
0:38Simply put, there are just far too
0:40many network automation libraries that are just
0:42not going to work on Windows.
0:43You're going to have to use a Mac or a Linux environment.
0:46But here's the thing-- you can actually
0:48set up your environment in such a way
0:50that you're kind of using Windows, but logging remotely
0:53into a Ubuntu virtual machine.
0:56Now this is the setup that I actually use myself.
0:59So I want to walk you through it,
1:00because I do think [INAUDIBLE] needs compromise.
1:02So the plan is here is we're going to create an Ubuntu VM.
1:06And from our host machine, we are
1:07going to be able to log in remotely
1:09and manage it from our Windows system.
1:12Now, like I say, this is the preferred method in which I
1:15use, but just be aware that actually there's
1:17another solution that you could use called
1:19Windows Subsystem for Linux, otherwise known as WSL.
1:24This effectively does a similar thing.
1:27It gives you an Ubuntu terminal within your Windows machine.
1:30Now, the reason why I'm not recommending you
1:32do this type of installation is not necessarily
1:36because it's bad--
1:37in fact, it's really good.
1:38The issue is that once the newer version, WSL2,
1:41because if you want to use nested virtualization
1:44within VMware--
1:46say, for example, you want to automate topologies using
1:48Cisco's CMLP, which is their virtualization product allowing
1:53you to create virtual networks, well, you
1:55can't run VMware with nested virtualization
1:57at the same time as WSL2, because WSL2 requires Hyper-V.
2:02Now you can find workarounds.
2:03That's where you can use the old version of WSL, just WSL1.
2:07But honestly, I find that the cleanest way to do this
2:10is just to install the Ubuntu VM, and log in remotely.
2:14That way we're going to have no problems at all running VMware
2:17with any type of nested virtualization within that,
2:20whether we're using GNS3, whether we're using EVE-NG,
2:23whether we're using CMLP.
2:25These are all technologies that we
2:27can use to create virtual topologies, topologies which
2:30we can practice automating.
2:31So let me just walk you through the actual set
2:34up that I have within my environment here.
2:36OK, so the first thing we're going to do,
2:38as you can see here, is go to Google.
2:40And we'll search for download Ubuntu, as we've seen before.
2:43Let's actually walk through this installation then.
2:45OK, so let's Accept All and visit site.
2:47And what I'm going to do is to download this version here,
2:5020.04.2.0.
2:52We're looking for, long-term support.
2:54That is a stable build.
2:55So download this, and just click Save,
2:58and now that should begin downloading
3:00for you-- that's ISO file.
3:01OK, so that is now completed downloading,
3:03I'm going to right-click, and then
3:05choose Open Containing Folder.
3:07And here's SSMH here.
3:08So I'll just cut out, and I'm going to go to my D drive.
3:12And I've created this folder called Example-Ubuntu.
3:15Let me just paste this image in here
3:16so it's nice and clear of what it is.
3:18OK, perfect.
3:18So now let's go to VMware.
3:21And what I'll do is create a new virtual machine here.
3:24Now, where do I want to install?
3:25Let me browse to this location.
3:27So I'll go into example-Ubuntu.
3:29Click this image here that I've just downloaded
3:31and choose Open.
3:32Next what I'll choose is Next.
3:34And then I'll just fill in some details.
3:36So I'll just say my name as ipvzero.
3:39Username, just keep it as ipvzero.
3:41And the password will be super secure.
3:43It'll be password123.
3:45So again, confirm-- password123.
3:48And choose Next.
3:49Now it's going to tell me the location where it's going
3:51to save this virtual machine.
3:53By default it's going to install on the C drive,
3:56though my C drive happens to be running a little bit low so I'm
3:59going to move it to the D drive.
4:01So I'll Browse here, go into my D drive,
4:03and I'll just go down to my Example-Ubuntu.
4:06So the same folder where my actual ISO resides.
4:09So choose OK, and then I'll say Next.
4:11In fact, I'll go back and I'll just
4:12change the name of the machine.
4:13I'll just call this Example Ubuntu Machine.
4:16I'll choose Next.
4:18Maximum desk size, let's make it 30.
4:20And we'll leave it as split virtual desk
4:22into multiple files.
4:23And we'll choose Next.
4:24If you want to add in more things, like, say, for example,
4:27crank the RAM up.
4:28You can customize the hardware, and you can maybe move the RAM
4:31up to whatever you want.
4:32I'll move it up to six.
4:33Network adapter is going to be NAT.
4:35Processors, I'm going to leave at two.
4:37So that will do us.
4:38So what I'm going to do now here is just click Finish,
4:41and this is going to run through the installation pretty much
4:44itself.
4:45If you give it maybe, say, 10, 15, 20 minutes,
4:47depending on how fast your machine is,
4:49this virtual machine should pretty much be set up for you.
4:52So what I'll do right now is pause the video
4:54and come back when we're ready to rock.
4:56OK, so now Ubuntu should be installed for you.
4:59What we're going to do now is to install
5:01VS Code within our Windows host machine.
5:04So let's just minimize this.
5:05Let's go back to Google, and we'll just
5:07search for Virtual Studio Code.
5:09OK, so let's click on Download here,
5:11and we'll choose Windows this time.
5:13So let's save this.
5:14So the setup is now installed.
5:16Let's just open this.
5:17Double-click it.
5:17And we're going to accept the agreement.
5:19Click Next.
5:20And again, choose the installation
5:22of where you want the program to be installed, or just leave it
5:24at the default. Click Next.
5:25We'll leave the folder as Virtual Studio Code.
5:28Click Next once again.
5:29And what I'll also do is create a desktop icon,
5:32and let's select these "Open with Code"
5:34actions, and just click Next.
5:36And then just choose Install.
5:37So that should begin extracting the files,
5:39and the installation should complete pretty shortly.
5:42OK, so we'll make sure at launch Virtual Studio Code has
5:45been ticked, and click Finish.
5:47OK, so my Visual Studio Code installation
5:49is going to look a little bit different from yours.
5:51That's because my old settings have actually been cached.
5:54So when I reinstall Visual Studio Code,
5:56my old settings just come back to me just like that.
5:59But really, that is not a problem at all.
6:01What you're going to do here is we'll
6:02go to File, then Preferences, and then Extensions.
6:06Now, as you can see, I've already
6:07got some things installed.
6:08So if I clicked Python and click on this here,
6:11you can see that has already been installed.
6:13But if it hasn't for you, just click the Install button.
6:16My option here is Uninstall.
6:18So you would just choose this, but the thing
6:20I really want to point out to you
6:22is something called Remote SSH.
6:24So let's just choose this, and it tells us right here
6:27we can open any folder on a remote machine using SSH
6:31and take advantage of VS Code's full feature set.
6:34That means that we can just run our development environment
6:38live on our Windows machine.
6:40So this is a Windows installation of VS Code,
6:43and we can use this Windows VS Code installation to log
6:47in to a remote machine, i.e.
6:49the Ubuntu VM that we had just created.
6:52And we can do this using SSH.
6:54So like I say, it already says I have mine installed here
6:57because I don't have the installation option.
6:59I've only got Disable and Uninstall.
7:01If you haven't already installed this, then one of these buttons
7:04will say Install.
7:05All we need to do is just click that button
7:08and wait a little second, and Remote SSH
7:11will be available for you.
7:12OK, so let me show you how we can use this Windows
7:16installation of VS Code to connect to this remote Ubuntu
7:19machine then.
7:20So let's go to our Ubuntu machine.
7:21OK, so I'll just log in here with my password, which
7:24was password123 I believe--
7:26again, super secure as per usual.
7:29OK, now just like we saw with the Linux installation,
7:32let's just skip through this part here.
7:33So what we're going to do is go to our terminal.
7:36OK, now unlike the Linux installation,
7:38we're not going to be installing VS Code on this machine,
7:41but what we do need to have is to have SSH enabled,
7:44so let's just make sure we can log in via SSH.
7:47So what I'm going to say first is sudo apt updates,
7:49then I'll type in my password, password123.
7:52Hit Enter.
7:53OK, now what I want to say is sudo apt install ssh-server.
7:59Hit Enter.
8:00Oh, and that's a mistake.
8:01I should actually say openssh-server.
8:04Apologies about that.
8:05Try again.
8:06That was a little bit better.
8:08Push Y. Hit Enter.
8:10And just give this a minute or so just to install.
8:12OK, so now that we have SSH enabled
8:15on the VM, what we want to be able to do
8:17is to log in to this machine, so we need
8:19the IP address of this machine.
8:20So we'll say ip addr.
8:22And hit Enter.
8:23And we can see the IP address right here.
8:26So it's 192-168-31-146.
8:30And my username is ipvzero.
8:32So we want to login as ipvzero to this address,
8:36and we want to do that from the Windows
8:38installation of VS Code.
8:40So let's go back to our Visual Studio Code then.
8:42Now what I'm going to do is on the left-hand side here,
8:45we have this option here saying Remote Explorer.
8:47Let's click on this.
8:48Now again, I already have these cached connections
8:51because of my old installation.
8:53It's just came back to me, effectively.
8:55What you want to do here is go up to Remote Explorer,
8:58and we're going to choose SSH targets.
9:00Now again, I've got some previous targets saved.
9:03You won't have them; don't worry about it at all.
9:05What we're going to do is click the plus sign here,
9:07and we're going to add in your new host.
9:10So I'm going to say it as SSH and then the name of the user.
9:14So my username on the Ubuntu machine was ipvzero,
9:18and the IP address we found out was 192-168-31-146.
9:24So we'll hit Enter.
9:25OK, select the configuration file.
9:26Just choose this one here.
9:28So now the host has been added.
9:30Let's right-click this and Connect to Host in New Window
9:34here.
9:34So let's open this up, and it's going
9:36to say select the platform.
9:37We're going to choose Linux.
9:39It's telling us the fingerprint up here.
9:41We'll just accept this by saying Continue.
9:44Now we need to enter the password,
9:45and my password for that VM was password123.
9:48Hit Enter.
9:50And at the bottom right, it says setting up host.
9:52It's installing VS Code server.
9:54OK, great, so this looks good.
9:56So if we look down here--
9:58let me just move this over and drag this-- down in the bottom,
10:01we actually have a terminal here.
10:02And this is the terminal we've effectively logged in.
10:05What's happened right now is we're working
10:07within our Windows environment.
10:08This is the Windows installation of VS Code.
10:11But we also have access to this terminal of that VM,
10:15of that Ubuntu machine.
10:16So say, for example, if I just create a folder just saying
10:19Testfolder, and I cd into this test folder.
10:23And I create a file just called thisisatestfile.txt.
10:29And I just nano this, and I just say, just
10:32testing that this works.
10:34Push control autosave, Control X.
10:37So now if I actually minimize this,
10:38and I go to my actual VM--
10:40look at this, let me clear the screen.
10:42If I do an ls, see that?
10:44We now have this new test folder that's
10:45been created remotely from the Windows machine.
10:48So we can see the end to this, ls.
10:50There's that file, and we can cat this file, and there we go.
10:54So this means that we can work within our Windows machine.
10:57Just open up VS Code as per normal,
11:00and we can remotely install things and activate things
11:03and run code from within this Ubuntu virtual machine.
11:06We don't have to worry about any type
11:08of clashing between Windows and these new network
11:12automation tools.
11:13We're going to bypass that completely.
11:15Everything is going to be installed, even though we
11:17are effectively operating from a Windows environment-- super,
11:20super cool, super, super handy.
11:22So this is the actual setup, which I use personally.
11:25It's what I'm going to recommend that you use.
11:27And for the record, you could do the exact same thing on Mac OS.
11:31You could just create a virtual machine
11:33within Mac OS using VirtualBox or VMware.
11:36Install VS Code within your Mac.
11:38And again, use that remote SSH extension to just log in
11:42to the Ubuntu VM.
11:44This means that you and I are using the exact same operating
11:47system.
11:47It's going to minimize any type of clash
11:49and any type of weird little errors or issues.
11:51This will make things as easy as possible, in my opinion.
11:54Okey doke, so I hope this has been informative for you,
11:56and I'd like to thank you for viewing.
Useful Extensions
0:00[MUSIC PLAYING]
0:12Hey, guys, and welcome back.
0:13So in the previous Nugget, we had just
0:15walked through the installation of our Windows setup
0:18and how we're going to integrate an Ubuntu VM, a remote machine,
0:22into this Windows environment.
0:24And to do that, we installed the Remote SSH extension.
0:30Similarly, we also installed the Python extension
0:33within VS Code.
0:34This gave us access to things like Pylance,
0:37which is going to help us out with things
0:39like auto-completion.
0:40Now, because we are ultimately working towards an end
0:43goal of automating networks, what I want to do
0:46is just highlight some of just a few little extensions
0:49I use pretty regularly to help me do just that.
0:52So outside the Python extension, outside the open SSH extension,
0:57the next extension I want to get here is one for Cisco IOS.
1:02Basically, it is a way to get nice syntax highlighting, which
1:05is going to be pretty useful for us.
1:07So again, like I said in the previous Nugget,
1:09my old extensions and my old settings
1:12have already been cached.
1:13They've already been installed.
1:15You won't have them, but let me show you how you can get them.
1:17So let's go up to File here, and then choose Preferences,
1:21and then Extensions.
1:22Now, you can probably see it's already installed.
1:24But what I'm going to search for is Cisco IOS
1:27syntax and click this here.
1:30So as you can see here, it is already installed for me.
1:32I can only disable or uninstall it.
1:34If you haven't got it installed, the option
1:36will simply be to install.
1:37You just click it, and then it's going to install.
1:40Now, once you've installed this little plugin here,
1:43basically if you take any file and append it with the .ios
1:48extension, then we're going to get Cisco-specific color
1:52highlighting.
1:53That is going to be very, very useful
1:55when we're trying to create templates of our configuration.
1:58Now again, this might not make sense quite yet--
2:01how do you templatize a configuration?
2:03Again, don't worry about that at all.
2:04We'll certainly get to that in due time.
2:06Just know that this type of thing is going to make your job
2:10a little bit easier in the future when we get to it.
2:12So let me just quickly show you how this works then.
2:15OK, so what I've got here is an EVE-NG topology.
2:18This is basically a network emulator
2:21you can use to build virtual networks.
2:23Same type of thing as GNS3 or Cisco's
2:26CML-P. Again, the details of this are not too important,
2:30but right here I have a virtual router.
2:33What I'm going to do here is just click on this
2:35to open it up.
2:36And what I'm going to do here is just issue a show run.
2:39So let me just full-screen this right now,
2:41and I'll scroll up to the top here.
2:43So let me just copy all this right here and scroll
2:45right down to the bottom.
2:46OK, so let's just copy here, and let's go to VS Code.
2:50And let me create a file called, config.txt.
2:54So what I'll do is go to File, click Open File,
2:57scroll on down, and go to config.txt.
3:01So if I just paste this in here, and I go up here
3:04and click Save.
3:05So look at this, here is the configuration here.
3:07Now, it looks quite fine.
3:09But as you can see, we have no highlighting at all.
3:12This isn't inherently a problem.
3:14But you'll realize, later on, when
3:16you're trying to templatize configurations, what
3:19you want to do is to eyeball commonalities
3:21amongst configurations.
3:23Basically, we'll be comparing different types
3:26of configuration to one another.
3:27And quite honestly, using highlighting
3:30is going to make this a lot easier as opposed
3:32to just looking at black and white text.
3:34So like I said, the extension here is .txt.
3:37But now that we have Cisco IOS syntax plugin installed,
3:41if we just change this extension to .ios, watch what happens.
3:45Let's save this file as config.ios and hit Enter.
3:50And look at this.
3:51We now get nice coloration through the configuration.
3:55Now, this makes things way, way, way easier
3:57when we're trying to compare across multiple configurations
4:00to try to derive commonalities.
4:02So that is the first plugin I'm going
4:04to suggest to you, on top of, of course, Python,
4:07as well as Remote SSH.
4:09Now, the other one is going to be-- if we go to Extensions,
4:13let's go to Preferences, and again, Extensions.
4:17And again, this is already going to be installed for me,
4:19but I'm going to search for something called Better Jinja.
4:23So I'm going to click on this.
4:24Again, as you can see here, this is already installed for me.
4:28For you, you can just click the Install button.
4:30And then within maybe 10 seconds or so, Better Jinja
4:33will also be installed for you.
4:35Now, it's very reasonable that you
4:36don't have a clue what Jinja is quite just yet.
4:39That's perfectly OK.
4:40We'll certainly get to that in depth in due time.
4:43All you need to know is that this is the templating language
4:46that we are going to be using to build
4:48our templatized configurations.
4:50And again, all this plugin does is it gives us
4:52nice syntax highlighting.
4:55So say, for example, if I go and create a new file here,
4:58and let me just save it as example2,
5:01and I use the .j2 extension, then we're going to get this
5:05nice highlighting.
5:06So if I just say things like-- and again, this
5:08won't make any sense for you-- for network in networks,
5:12you can see that we're actually getting different coloration
5:15for different keywords.
5:16And again, this doesn't have to make any sense at all to you
5:20just now.
5:21Just know that this extension is going
5:22to make your life a little bit easier when we come to this.
5:25So as we are setting things up, this
5:27is definitely an extension I would
5:28recommend that you install.
5:30And for now, really, that kind of does it.
5:32I would recommend you have the Python installation, which
5:35is going to give you things like Pylance,
5:37i.e. your auto-completion.
5:38We're going to install Remote SSH so we can remotely
5:42manage our Ubuntu server.
5:44We're going to install Better Jinja, which
5:47is going to give us nice syntax highlighting for our Jinja
5:51templating language.
5:52Again, don't worry about that.
5:54We'll get to it later.
5:55And fourth, we want to get Cisco IOS Syntax.
5:58This is going to give us an easier way to save our files
6:01with the extension, .ios, and get Cisco-specific syntax
6:05highlighting, making your job of templatizing
6:08your configurations with Jinja much, much easier.
6:11So go ahead and make sure these are all installed,
6:14and you will have a pretty solid environment
6:16to go about learning how to automate
6:18your networks with Python.
6:19So I hope this has been informative for you,
6:21and I'd like to thank you for viewing.
Cloning Code from Github
0:12Hey, guys.
0:13Now remember we talked about installing Git
0:15within our environments.
0:17Now if you're unsure of what Git is, then don't worry.
0:20We'll get to this later on in more detail within this course.
0:24But what you might have heard of, probably more likely,
0:26is GitHub.
0:27This is a large website on the internet where people
0:30store a lot of their codes.
0:32And this is where I'm going to be storing
0:34a lot of the examples that you're going to be
0:36seeing throughout this course.
0:38Basically, you're going to go to my GitHub repository
0:41and then clone what is called the Repository.
0:45Now the way we can transfer the code which
0:47I've saved onto to GitHub onto the local machine
0:50is to use Git.
0:52So Git is something we are using on the command line
0:55to get the code which is stored remotely on GitHub.
0:58Now as of right now, I don't really
1:00have any kind of code saved for this course at all.
1:03What's going to be happening is that I'm
1:05going to be slowly adding to this as we
1:07progress throughout this course skill by skill.
1:10But nevertheless, let's follow the process
1:12to see how we can do this.
1:14So what I'm going to do is to go to my terminal here.
1:17Now remember, this is actually a remote session
1:20through this new Ubuntu virtual machine.
1:22Now this virtual machine doesn't actually have Git installed.
1:25So let's quickly install it.
1:26So what we'll say is sudo apt update as we saw before.
1:29And hit Enter.
1:31Type in my password of password123.
1:34Hit Enter.
1:35And the update shall begin.
1:37And now what I'm going to do is install Git.
1:39So what I'll say is, sudo apt install git.
1:42And I'll say, yes.
1:43Hit Enter.
1:44And that will just run through the installation here.
1:47OK.
1:47So we know how to have Git installed
1:49within a remote Ubuntu virtual machine.
1:52What we want to do is to use Git now
1:54to pull back the information from the remote GitHub
1:57repository where I'm going to be storing all of these examples.
2:00So what I'll do here is go to my web browser.
2:03And this is just a browser on my normal Windows machine.
2:06And what I'll search for is ipvzero GitHub.
2:08This is my own GitHub here.
2:10Now the repository we want to go to
2:12is this one here, CodeSamples.
2:14Let's click on this link.
2:15And you see this big green button here.
2:17Let's click on this.
2:18If we highlight this here and then copy it,
2:22now this link has been copied.
2:24So let's take this to our Visual Studio code then.
2:27And let me just clear the screen.
2:28Now the way we can copy this is just by saying,
2:31if I'm doing ls, what you can see, the folder structure.
2:35Now when I say Git clone, and I paste this in and just hit
2:39Enter, this is going to clone the repository.
2:42And now we're going to have a new folder called CodeSamples.
2:45If we do an ls, look at this here.
2:47We now have CodeSamples.
2:49So if we cd to go enter this directory and we do an ls,
2:53you can see a bunch of different folders.
2:55Now the folder where I'm going to be storing
2:57the examples pertaining to this course
2:59is going to be in this one here, Intro_Python_Net_Eng.
3:04So if we cd Intro, this directory here, and I do an ls,
3:07for now I've only got one Python file.
3:10So what t can do here is just open this file here.
3:13So let's go into CodeSamples.
3:15We'll go into Intro_Python_Net_Eng.
3:18And let's open hello.py.
3:20And we have a really simple Python script here.
3:23We just have two print statements here,
3:25"welcome to CBT Nuggets.
3:27And have fun automating!"
3:29Now how to use Git and GitHub more in-depth,
3:31how you can store your own code remotely on GitHub,
3:35that is something we will certainly get to a little bit
3:37later within this course.
3:39But for now, just understanding how to install Git
3:42and to pull down example code from GitHub using git clone,
3:46this is going to provide you a really easy way
3:48to access all of the scripts we're
3:50going to be writing together throughout this course.
3:52And no just one more thing, just before I forget actually,
3:56remember we were talking about installing
3:58useful plug-ins, useful extensions, should I say.
4:01If I get down to Preferences here and go to Extensions--
4:04this is certainly not mandatory, but I would recommend you
4:07install one called Monakai Pro.
4:10This is effectively the theme which I'm using.
4:13So like I said, mine is already installed.
4:15I would suggest you search for this installer
4:17and use this as your theme, the reason being,
4:20is that it's going to give you the exact same color
4:22highlighting as I have.
4:24So that's just totally optional.
4:26But it's going to make it a little bit easier for you
4:28to eyeball what you're writing on your screen
4:30and compare it to what you're seeing on my screen.
4:33So just what I remember there when I looked at that code,
4:35Monokai Pro is a really nice theme.
4:37And it probably will make your life a little bit easier just
4:40so that we have total parity.
4:41But for now, we have used Git to pull our GitHub repository
4:45down.
4:45And that is how you're going to be able to easily get
4:47copies of all the codes.
4:49And like I said, as we progress throughout this course,
4:51these examples are just going to keep growing and growing.
4:54So I hope this has been informative for you.
4:56And I'd like to thank you for viewing.
Cisco DevNet Sandboxes
0:00[MUSIC PLAYING]
0:12Hey, guys, and welcome back.
0:14So what I want to talk to you about in this Nugget
0:16is a really useful utility that you
0:19can use for free to be able to easily access Cisco devices
0:23that we can run our steps on as tests.
0:26What am I talking about?
0:27Well, I'm talking about the Cisco DevNet sandbox.
0:30Now, the really cool thing about the Cisco DevNet sandbox
0:33is that we do have two options.
0:35The first option is that we can book a topology,
0:38and this requires a VPN client to get
0:41your own private session.
0:43However, what we can also do, the second way,
0:45and this is what we are going to explore,
0:47is to check out the always-on sandboxes.
0:51Just like it sounds, these sandboxes are always on.
0:54You don't have to book them.
0:55You don't have to have a VPN.
0:57Simply put, an internet connection to access them
1:00is all you need.
1:01The only thing you have to realize here
1:03is that they are a shared resource,
1:05so there might be a little bit of limitations
1:07about what you can actually do.
1:09But generally speaking, these are
1:10going to be more than enough to give us access to some devices
1:14that we can test our Python scripts against.
1:17So let me show you how you can easily
1:18access these devices then.
1:20So if you search for "cisco devnet sandbox,"
1:24and we click this top link here--
1:26so I'm going to click Get Started with Sandbox.
1:29Now, to log in, you're going to have
1:31to use some type of account-- maybe a Google account
1:33or a Facebook account or a Cisco ID.
1:36What I'm going to do is to log in with my GitHub,
1:38so I'll just click this.
1:40So what I'm going to do is search for an IOS XE device.
1:44So if I just search for XE, if we look here,
1:47and let me just zoom in a little bit,
1:49you can see here we have an option
1:51to reserve some sandboxes.
1:53Now, when you see the Reserve button,
1:55these are the type of sandboxes you're
1:57going to have to book for a particular time,
1:59and you're going to have to log in with a VPN connection.
2:02But you can certainly explore this.
2:04If you want to have more access to a device,
2:06maybe you could have eight devices at once, but for ease
2:09of setup, what I'm going to recommend
2:11is that you just check out the always-on sandbox.
2:14How do we access this?
2:15Well, it's really quite simple.
2:17Let's check it out.
2:17Let's click on an always-on one.
2:20So down the left-hand side here, we're
2:21going to see the login details here.
2:25So here, as the login address here,
2:27this is basically the IP address.
2:28It's just like going to youtube.com.
2:31This is how we're going to access the sandbox,
2:33so if we want to access it over SSH,
2:35we're going to go over port 22.
2:37What's the user name?
2:38Developer.
2:39And the password login is going to be C1sco12345
2:43with a one for the i here.
2:45So let's actually copy these details over
2:47and try to log into a device.
2:49So again, no VPN.
2:50Just an internet access.
2:51Let's copy this here.
2:53Right click, copy here, and let's
2:55go back to Visual Studio Code.
2:57So let me clear here, and in fact, let
2:59me just move this over a bit so it's a bit clearer.
3:02So I'll just say CD to take me back to my home directory,
3:05and I'll just say SSH, and the username was developer@,
3:09and I'll paste in the address.
3:11Hit Enter.
3:12Do I want to accept this fingerprint?
3:14I'll say, yes, and now, I'm going to type in that password
3:17of C-1-S-C-O-1-2-3-4-5, as we saw on the website.
3:22Hit Enter, and look at this.
3:24We have access to a Cisco device.
3:26We can do a show run, if I can type show run.
3:29There we go.
3:30So we can also do some configuration.
3:32So let's say conf t, and I'll create a loopback of loopback,
3:36let's maybe say 56.
3:38And I'll create an IP address of 56.56.56,
3:42and I'll make it slash 32 mask.
3:45And I'll also add a description on this as a test loopback.
3:50So if I do a show run once again,
3:52you can see that we have created this loopback on this device.
3:56So what we are going to do throughout this course
3:58is to use these always-on sandboxes,
4:00and we're going to try to configure changes and pull
4:03information using Python.
4:06And like I said, all it requires is an internet connection.
4:09Now, there are more than Cisco XE devices.
4:12We also have Cisco XR devices as well as Nexus devices,
4:16and throughout this course, we'll
4:17be using all of these sandboxes.
4:20So there you have it--
4:21really easy access.
4:22Almost no setup.
4:23Just find the login details, have an internet connection,
4:26and off you go.
4:27So I hope this has been informative for you,
4:29and I'd like to thank you for viewing.
Running Our First Script
0:00[AUDIO LOGO]
0:12Hey, guys, and welcome back.
0:14So to round off the central skill
0:16of this course, how about we rate and execute
0:19our first Python script.
0:21OK, so let's create your first script then.
0:23So we'll go to File, click New File and we'll say Save As.
0:27And let's just put in our Home directory for simplicity,
0:30and let's just save this as example1.py.
0:34We want the py extension because it's going to be a Python file.
0:37And all I'm going to say is 'print'
0:39and then open my parentheses, and then
0:42within inverted commas, I'm going
0:44to say what I want to print to the screen.
0:46So if I say, "My name is John and I love Python,"
0:51so if I just save this.
0:53And now I go back to my terminal here, we do an 'ls.'
0:56we now have this new file here called example1.py.
1:00So how on earth do we execute it?
1:02Well, it's quite simple.
1:03We just say python3 and then follow up
1:06with the name of the file.
1:08So we say example1.py.
1:10If we hit Enter, bam, there you go.
1:12You've just created and executed your very first Python script.
1:16So let's add a little bit more to it.
1:19We'll say 'print' and we'll do, "...And I also love automating
1:25networks."
1:25And let's save this.
1:27Let's clear the screen, arrow up, re-run the script,
1:29hit Enter.
1:30And bam, there we go.
1:32Not so scary is it, really?
1:33Now of course, there is a lot more to Python programming
1:36than what we just saw here.
1:38But I do believe that you're going
1:39to be pleasantly surprised that it's not
1:41quite the scary subject that you might have built it
1:44up to be in your own head.
1:45I know when I first started programming with Python,
1:48I for sure was a little bit intimidated.
1:50But don't worry, we're going to be taking things step by step,
1:53nice and slowly, and we will gradually build upon our skills
1:56so that with time and a little bit of practice,
1:58we will begin to be able to automate
2:00our networks effectively.
2:01Okedoke, so I hope this has been informative for you,
2:04and I would like to thank you for viewing.
Team training path
Turn this skill into assignable team training
This free skill is a preview of the courses your team can assign, track, and report on with CBT Nuggets.
Python
PCEP
Assign the full course, track completion, and connect this skill to your team's readiness plan.
Cisco
Cisco Security Automation with Postman
Assign the full course, track completion, and connect this skill to your team's readiness plan.
Cisco
Data Center Automation
Assign the full course, track completion, and connect this skill to your team's readiness plan.
Python
Python Network Automation
Assign the full course, track completion, and connect this skill to your team's readiness plan.
For teams
Build a path around this skill
See how courses, reporting, labs, and Trainerbot fit your rollout.
$749
seat / year