1
00:00:05,060 --> 00:00:05,300
Okay.

2
00:00:05,300 --> 00:00:08,720
So I'm tired of using Python on the box now.

3
00:00:08,750 --> 00:00:15,950
What I'm going to do is start an Ubuntu VM on my local mac.

4
00:00:16,650 --> 00:00:18,390
Now I'm using Linux.

5
00:00:18,690 --> 00:00:22,620
I strongly suggest just like Python that you learn Linux.

6
00:00:22,830 --> 00:00:24,450
Linux is one of those core skills.

7
00:00:24,450 --> 00:00:27,210
You're going to use it everywhere, so make sure that you learn Linux.

8
00:00:27,810 --> 00:00:30,750
So here I'm going to open up a terminal.

9
00:00:33,540 --> 00:00:34,890
This is on my local computer.

10
00:00:34,890 --> 00:00:35,700
It's not in.

11
00:00:36,210 --> 00:00:37,230
This is local.

12
00:00:37,560 --> 00:00:44,280
And what I'm going to do is install python three and net mico.

13
00:00:45,390 --> 00:00:52,620
Basically what we're doing is we installing Python three on the Ubuntu PC and we installing net MICO,

14
00:00:52,620 --> 00:00:56,160
which is a great way to connect to network devices.

15
00:00:56,430 --> 00:01:03,320
Rather than you writing all the low level code to SSH to a network device and then send commands to

16
00:01:03,320 --> 00:01:05,710
a network device and then interpret the output.

17
00:01:05,730 --> 00:01:12,270
Net Mico is your first step in automation because the developer of Net Mika has done a lot of the hard

18
00:01:12,270 --> 00:01:16,270
work already and you can just leverage that code in your Python scripts.

19
00:01:16,290 --> 00:01:21,930
One of the advantages of Python is there are a whole bunch of libraries available, including Net MICO,

20
00:01:21,930 --> 00:01:28,260
including apps, including Narnia that make our lives as network engineers a lot simpler.

21
00:01:28,380 --> 00:01:35,190
Don't reinvent the wheel, use the code and the hard work that others have done, and import those libraries

22
00:01:35,190 --> 00:01:36,980
into your code and just leverage them.

23
00:01:36,990 --> 00:01:38,430
Don't reinvent the wheel.

24
00:01:38,710 --> 00:01:44,850
Now I've already installed these commands on my Ubuntu PC, but I'll paste them here just to show you

25
00:01:44,850 --> 00:01:45,870
the process.

26
00:01:45,870 --> 00:01:48,630
So sudo apt install python three.

27
00:01:48,630 --> 00:01:53,640
Pip basically allows me to install python three on the ubuntu computer.

28
00:01:54,550 --> 00:01:56,770
And then I'm going to install net mico.

29
00:01:57,850 --> 00:02:05,890
Once again, I have previously installed the software, so it should all be good.

30
00:02:08,860 --> 00:02:14,200
Just in case you want to know what release I'm using, I'm using ubuntu.

31
00:02:15,980 --> 00:02:16,520
18.

32
00:02:16,580 --> 00:02:18,670
04.3 ELTs.

33
00:02:18,770 --> 00:02:25,940
So this command LSB released a shows me the version of a Punto that I'm using, so I'm just using one

34
00:02:25,940 --> 00:02:27,850
of the later releases of Ubuntu.

35
00:02:28,070 --> 00:02:29,120
So I'll clear the screen.

36
00:02:31,730 --> 00:02:33,560
And now let's create a script.

37
00:02:33,980 --> 00:02:35,360
So here's my script.

38
00:02:35,360 --> 00:02:41,300
I'm going to copy it into that Ubuntu computer and then I'll show you how to use it.

39
00:02:41,780 --> 00:02:44,970
I'm going to create a script called Python one point p.

40
00:02:45,080 --> 00:02:51,860
Not a good name, but it's okay for this demonstration and I'm going to paste that code in.

41
00:02:52,070 --> 00:03:00,110
This is importing the library net MICO So I'm going to basically leverage the power of net mico to connect

42
00:03:00,110 --> 00:03:01,910
to my Nexus device.

43
00:03:01,940 --> 00:03:05,330
Here's the username, here's the password, here's the port.

44
00:03:05,420 --> 00:03:09,050
Now I know a lot of people are going to complain, so I'll just say it right now.

45
00:03:09,050 --> 00:03:12,350
You don't have to store the credentials in your script.

46
00:03:12,350 --> 00:03:14,320
You could prompt for them if you wanted to.

47
00:03:14,330 --> 00:03:16,210
I'm just going to store it yet to keep it simple.

48
00:03:16,220 --> 00:03:18,380
It's a lab anyway, so it doesn't matter.

49
00:03:18,650 --> 00:03:23,870
I just want to show you how simple it is to extract information from a remote router.

50
00:03:23,900 --> 00:03:26,060
This route is running probably in the States somewhere.

51
00:03:26,060 --> 00:03:26,780
I don't know.

52
00:03:26,990 --> 00:03:34,190
It's hosted by Dev Net and I'm going to pull back the show IP interface, brief output and display it

53
00:03:34,190 --> 00:03:35,240
on my computer.

54
00:03:35,720 --> 00:03:36,470
So.

55
00:03:37,670 --> 00:03:41,390
This is an example of a dictionary in Python.

56
00:03:41,420 --> 00:03:42,710
Notice the formatting.

57
00:03:42,740 --> 00:03:44,720
Does that look familiar?

58
00:03:44,960 --> 00:03:51,770
Hopefully that looks familiar, but it's a little bit different here to JSON because in JSON formatting,

59
00:03:51,770 --> 00:03:53,930
we don't use single inverted commas.

60
00:03:54,230 --> 00:03:59,390
Basically, this is a dictionary storing the information that we need to connect to the router.

61
00:03:59,930 --> 00:04:06,820
This command allows me to connect to the router and then this allows me to send a command to the router.

62
00:04:06,830 --> 00:04:09,080
In this case, show IP interface brief.

63
00:04:09,110 --> 00:04:12,830
We store that in a variable and then we print the results out.

64
00:04:12,830 --> 00:04:14,870
So I'll save that script.

65
00:04:15,440 --> 00:04:19,010
I'm going to use Python three to run that script.

66
00:04:20,000 --> 00:04:21,019
Okay, I'm getting an error.

67
00:04:21,019 --> 00:04:24,980
And this is one of the things you need to be careful with using PowerPoint.

68
00:04:25,010 --> 00:04:28,250
Notice the difference between that and this.

69
00:04:29,090 --> 00:04:31,070
Don't use PowerPoint.

70
00:04:31,100 --> 00:04:33,710
Use a text editor.

71
00:04:33,890 --> 00:04:39,590
I typically use sublime text or Visual Studio code.

72
00:04:39,740 --> 00:04:42,920
Notice that's gone green now, so that looks better.

73
00:04:43,700 --> 00:04:45,050
I'll save that script.

74
00:04:45,950 --> 00:04:47,330
Python three.

75
00:04:47,330 --> 00:04:48,170
Python one.

76
00:04:48,320 --> 00:04:51,030
P y script seems to be working now.

77
00:04:51,050 --> 00:04:58,490
So this is a switching to that device and then running the command and then hopefully we'll display

78
00:04:58,490 --> 00:04:58,940
the output.

79
00:04:58,940 --> 00:04:59,720
And there you go.

80
00:05:00,110 --> 00:05:06,590
We can see the output on that remote nexus device on my ubuntu computer.

81
00:05:07,160 --> 00:05:11,090
On the succession to the nexus show ip interface brief.

82
00:05:11,360 --> 00:05:15,110
There's the output of my direct ssh session.

83
00:05:15,380 --> 00:05:18,260
And here's the output using my python script.

84
00:05:19,240 --> 00:05:19,450
Okay.

85
00:05:19,810 --> 00:05:24,550
So once again, I could simply type python three, Python one at P.

86
00:05:24,550 --> 00:05:25,030
Why?

87
00:05:25,060 --> 00:05:27,870
Python three means I'm using Python three.

88
00:05:27,880 --> 00:05:31,240
Python one is the name of my script and I can see the output.

89
00:05:31,780 --> 00:05:35,950
It's as simple as that to retrieve that data from that Nexus device.

90
00:05:35,950 --> 00:05:39,340
But let's try and do something more intelligent with the data.

