WEBVTT

1
00:00.000 --> 00:04.400
Alright friends, let's now use Netconv to begin sending some remote procedure

2
00:04.400 --> 00:05.680
calls to our target

3
00:05.680 --> 00:09.360
device. Now in order to get things up and running what I'm going to do is

4
00:09.360 --> 00:10.560
suggest we use the

5
00:10.560 --> 00:16.800
Cisco DevNet always on sandbox and inside of here we're going to use the Cisco

6
00:16.800 --> 00:18.560
iOS XE device which

7
00:18.560 --> 00:23.670
should be configured for Netconv. So first things first let's go to our browser

8
00:23.670 --> 00:24.640
and check this out.

9
00:24.640 --> 00:29.050
Okay so all I will do is log in to DevNet sandbox and if I choose to launch the

10
00:29.050 --> 00:29.680
sandbox,

11
00:29.680 --> 00:33.360
all that we'll do is go to the top and I'll search for XE. Now we can see here
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:29.680 --> 00:33.360
all that we'll do is go to the top and I'll search for XE. Now we can see here

12
00:33.360 --> 00:35.440
we have the cat 8KV

13
00:35.440 --> 00:38.930
always on sandbox, let's go with that so we don't have to reserve anything. Now

14
00:38.930 --> 00:39.520
what I should say

15
00:39.520 --> 00:43.240
as always is that these particular credentials may actually change so always

16
00:43.240 --> 00:44.080
check this before

17
00:44.080 --> 00:47.920
you actually go and do something. So we can see here this is the domain we use

18
00:47.920 --> 00:48.560
to connect to the

19
00:48.560 --> 00:54.550
device we have our user name of admin, the password of C1SEO12345 and crucially

20
00:54.550 --> 00:55.440
the Netconv port is

21
00:55.440 --> 01:00.230
enabled on port 830. Okay so remember those details, take a note of it. What we
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

21
00:55.440 --> 01:00.230
enabled on port 830. Okay so remember those details, take a note of it. What we

22
01:00.230 --> 01:00.960
now want to do is

23
01:00.960 --> 01:06.400
we want to use a particular utility that can effectively send these Netconv RPC

24
01:06.400 --> 01:07.360
s. So the command

25
01:07.360 --> 01:10.770
or rather the command, the utility that I'm going to recommend we use is

26
01:10.770 --> 01:12.640
something known as NC

27
01:12.640 --> 01:17.280
Client. This is the Netconv client. Essentially this is just a Python library

28
01:17.280 --> 01:18.640
that allows us to send

29
01:18.640 --> 01:23.170
these RPCs and then we can manipulate the data utilizing Python as expected. So

30
01:23.170 --> 01:23.840
with that said,

31
01:23.840 --> 01:28.650
let's go and check it out. So as we can see I have my virtual environment

32
01:28.650 --> 01:29.920
activated as we've seen

33
01:29.920 --> 01:34.530
before in previous skills all I will do now is say pit3 install NC Client and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

33
01:29.920 --> 01:34.530
before in previous skills all I will do now is say pit3 install NC Client and

34
01:34.530 --> 01:36.320
hit Enter. Now as it

35
01:36.320 --> 01:39.830
stands I already have this installed in my virtual environment but if you just

36
01:39.830 --> 01:40.800
follow along you will

37
01:40.800 --> 01:44.580
have it available. With this now done I will create a little folder let's just

38
01:44.580 --> 01:45.120
call this

39
01:45.120 --> 01:49.360
Netconv, I don't know I just say Netconv stuff and I'll just change into this

40
01:49.360 --> 01:50.480
directory okay so I've

41
01:50.480 --> 01:53.680
got a nice clean directory from which to work. So what I will do is let me just

42
01:53.680 --> 01:54.640
create a little script

43
01:54.640 --> 01:59.920
called script1.py and all I will do is open this up. Okay so first thing is

44
01:59.920 --> 02:01.280
first we're going to send
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

44
01:59.920 --> 02:01.280
first we're going to send

45
02:01.280 --> 02:05.740
a getconfig RPC okay. So what this should do is it should return all of the

46
02:05.740 --> 02:06.960
information about the

47
02:06.960 --> 02:11.150
configuration of our device. Now one thing to note here very very important

48
02:11.150 --> 02:12.160
this can be a little bit

49
02:12.160 --> 02:16.560
confusing when you first see it. Remember we have these different types of Yang

50
02:16.560 --> 02:17.920
models we can have

51
02:17.920 --> 02:22.080
the native models which are going to be Cisco specific. We're also going to

52
02:22.080 --> 02:23.040
have our vendor

53
02:23.040 --> 02:28.600
neutral model such as OpenConfig as well as IETF. Now when we happen to just

54
02:28.600 --> 02:29.680
retrieve the

55
02:29.680 --> 02:34.810
configuration of our device using a getconfig RPC we're going to see the same
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

55
02:29.680 --> 02:34.810
configuration of our device using a getconfig RPC we're going to see the same

56
02:34.810 --> 02:35.840
data modeled in

57
02:35.840 --> 02:38.840
multiple different ways we'll get to see the same information IE all the

58
02:38.840 --> 02:39.920
running configuration

59
02:39.920 --> 02:44.360
of the device modeled in the native style we'll also get to see the same

60
02:44.360 --> 02:45.760
information modeled in

61
02:45.760 --> 02:50.480
the OpenConfig style and the same information modeled in the IETF style. So

62
02:50.480 --> 02:52.320
obviously this can actually

63
02:52.320 --> 02:56.170
present a ton of information it can be really quite difficult to sift through

64
02:56.170 --> 02:57.360
visually. Tons and tons

65
02:57.360 --> 03:01.670
of XML tags this is just something that we have to get around. What I will say
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

65
02:57.360 --> 03:01.670
of XML tags this is just something that we have to get around. What I will say

66
03:01.670 --> 03:02.880
though is that as we

67
03:02.880 --> 03:06.250
progress throughout this particular skill we'll get to see how we can filter

68
03:06.250 --> 03:07.440
this information to be

69
03:07.440 --> 03:11.780
a little bit more specific but the first time we see this just be warned this

70
03:11.780 --> 03:12.720
might be a bit of a

71
03:12.720 --> 03:16.110
headache okay it's a lot of information to consume. So the first thing we want

72
03:16.110 --> 03:17.200
to do like you say is to

73
03:17.200 --> 03:22.650
use a particular utility NC clients to actually send this RPCs. So first things

74
03:22.650 --> 03:23.440
first what I will

75
03:23.440 --> 03:28.450
say at the top is from NC clients what I'm going to do is import manager now

76
03:28.450 --> 03:29.920
our manager object that

77
03:29.920 --> 03:33.910
we are importing will allow us to connect to a device and then we're going to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

77
03:29.920 --> 03:33.910
we are importing will allow us to connect to a device and then we're going to

78
03:33.910 --> 03:34.880
have particular

79
03:34.880 --> 03:39.760
methods associated to the type of RPCs we want to send does that seem confusing

80
03:39.760 --> 03:40.400
well trying

81
03:40.400 --> 03:43.710
it to whatever it will get to see an action it should become a little bit

82
03:43.710 --> 03:44.960
clearer. So what I will do

83
03:44.960 --> 03:49.100
is I will create a little dictionary here called my device. So I will have my

84
03:49.100 --> 03:50.560
currently braces here

85
03:50.560 --> 03:54.230
and all I will do is I'll populate some values so the first key is going to be

86
03:54.230 --> 03:54.960
the host key

87
03:54.960 --> 03:58.200
and then I'll specify the address that I'm going to be connecting to and

88
03:58.200 --> 03:59.600
remember this may change

89
03:59.600 --> 04:02.800
when you happen to do this yourself so just double check it but for right now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

89
03:59.600 --> 04:02.800
when you happen to do this yourself so just double check it but for right now

90
04:02.800 --> 04:03.920
this is the address

91
04:03.920 --> 04:08.200
for the XE box. So I'll do is paste in this information add my little comma and

92
04:08.200 --> 04:09.840
now add my next key.

93
04:09.840 --> 04:14.370
So I'll say the port key is going to be port 830 remember that is the netcon's

94
04:14.370 --> 04:14.960
default and as we

95
04:14.960 --> 04:19.020
can see as per the actual documentation that is the port the netcon's

96
04:19.020 --> 04:20.640
configured here we also have

97
04:20.640 --> 04:26.130
the admin username and the Cisco password of C1s012345 so let's go and add

98
04:26.130 --> 04:27.360
these two so I'll have my

99
04:27.360 --> 04:32.390
username key corresponding value as admin and the password key corresponding
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

99
04:27.360 --> 04:32.390
username key corresponding value as admin and the password key corresponding

100
04:32.390 --> 04:33.840
value like I say

101
04:33.840 --> 04:38.960
let's just add in C1s012345. Now lastly all I will say is host key underscore

102
04:38.960 --> 04:39.680
verify and I'm

103
04:39.680 --> 04:43.190
going to set that to the billion value of false basically we don't care about

104
04:43.190 --> 04:44.960
verifying the host keys

105
04:44.960 --> 04:49.820
now remember in python that is a particular way we can automatically close our

106
04:49.820 --> 04:50.480
connection after

107
04:50.480 --> 04:54.040
it's been opened and that is to use a context manager which is using the with

108
04:54.040 --> 04:55.440
statement as so

109
04:55.440 --> 04:58.650
so all I will do is I will take my manager object and I'm going to use the

110
04:58.650 --> 04:59.760
connect method and all

111
04:59.760 --> 05:04.040
I will do is I'll pass in all of the values within my dictionary here so I can
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

111
04:59.760 --> 05:04.040
I will do is I'll pass in all of the values within my dictionary here so I can

112
05:04.040 --> 05:05.280
do this recall we can

113
05:05.280 --> 05:10.100
unpack our dictionary with special syntax with two asterix and then we just use

114
05:10.100 --> 05:10.800
the name of the

115
05:10.800 --> 05:15.490
dictionary so pretty much all this information here is going to be passed into

116
05:15.490 --> 05:16.560
the connect method

117
05:16.560 --> 05:20.280
and this is what we're going to connect to utilizing the manager object so what

118
05:20.280 --> 05:21.040
I want to do is

119
05:21.040 --> 05:25.810
I want to store it as a variable called m and then indent it within what I will

120
05:25.810 --> 05:26.640
do is I'll create a

121
05:26.640 --> 05:31.980
variable just called let's maybe say results and I'll take the m object just
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

121
05:26.640 --> 05:31.980
variable just called let's maybe say results and I'll take the m object just

122
05:31.980 --> 05:33.280
created here and I'm

123
05:33.280 --> 05:40.960
going to send a get_config rpc now remember with respect to our netconv we also

124
05:40.960 --> 05:41.600
have different

125
05:41.600 --> 05:44.800
data stores we can target we have the startup data store the running data store

126
05:44.800 --> 05:45.600
and the candidate

127
05:45.600 --> 05:49.390
data store in my case I'm just going to keep things really quite simple and

128
05:49.390 --> 05:51.120
just focus in the running

129
05:51.120 --> 05:54.940
data store okay so I'm going to have to specify this so I will say the source

130
05:54.940 --> 05:56.080
that I'm targeting

131
05:56.080 --> 06:00.740
is going to be the running data store now for the moment all I will do here is
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

131
05:56.080 --> 06:00.740
is going to be the running data store now for the moment all I will do here is

132
06:00.740 --> 06:02.000
I will print out

133
06:02.000 --> 06:06.240
the results so if I just save this for the moment and I just clear the screen

134
06:06.240 --> 06:07.520
and I say Python 3

135
06:07.520 --> 06:13.950
and type in the name of the script and to enter give a moment and bam this is

136
06:13.950 --> 06:14.960
all the information

137
06:14.960 --> 06:19.300
I've been talking about look at this try to read this with human eyes this is

138
06:19.300 --> 06:20.160
why it's such a

139
06:20.160 --> 06:24.180
nightmare working with XML especially when you're working with multiple

140
06:24.180 --> 06:25.520
different yang models so

141
06:25.520 --> 06:29.350
what I'm going to do here just to try to make this a little bit more readable

142
06:29.350 --> 06:30.080
is I'm going to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

142
06:29.350 --> 06:30.080
is I'm going to

143
06:30.080 --> 06:33.570
ultimately format the response so what I'm going to do here is I'm going to say

144
06:33.570 --> 06:35.680
from xml.dom I'm going

145
06:35.680 --> 06:39.830
to import manydom now to be clear all I'm doing here is nothing to do with the

146
06:39.830 --> 06:41.440
actual netconv itself

147
06:41.440 --> 06:44.640
all I'm trying to do here is to help you read the output a little bit easier so

148
06:44.640 --> 06:45.280
it's just about

149
06:45.280 --> 06:48.920
XML formatting okay so don't get too confused about it or don't get too hung up

150
06:48.920 --> 06:49.760
about it so what I'm

151
06:49.760 --> 06:52.960
going to do here is I'm going to print and I'm going to say manydom and I'm

152
06:52.960 --> 06:54.320
going to pass string

153
06:54.320 --> 06:57.840
and I'm going to pass in the result that I just got there and then I'm going to

154
06:57.840 --> 06:58.560
say give me

155
06:58.560 --> 07:03.330
it in pretty XML okay so let's try this again clear this green to know if I rer
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

155
06:58.560 --> 07:03.330
it in pretty XML okay so let's try this again clear this green to know if I rer

156
07:03.330 --> 07:04.400
un this we now get

157
07:04.400 --> 07:08.880
a response byte now whilst this is still really quite hard to look at we have

158
07:08.880 --> 07:10.000
some ugly lane wrapping

159
07:10.000 --> 07:13.490
at least we have some form of indentation and structure in fact let me just

160
07:13.490 --> 07:14.480
zoom out a little bit

161
07:14.480 --> 07:17.560
so you can help you see it a little bit better see this right here this is all

162
07:17.560 --> 07:18.560
the information now

163
07:18.560 --> 07:21.600
we have a lot of indentation we have a ton of information so like you say if

164
07:21.600 --> 07:22.560
you happen to look

165
07:22.560 --> 07:26.240
at the output here we're seeing information related to in this case here this

166
07:26.240 --> 07:27.120
is a Cisco native

167
07:27.120 --> 07:31.080
Yang model and there's a whole bunch of that information model below okay and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

167
07:27.120 --> 07:31.080
Yang model and there's a whole bunch of that information model below okay and

168
07:31.080 --> 07:31.920
within the same

169
07:31.920 --> 07:37.420
output we can also see Yang models which are utilizing the ietf models as well

170
07:37.420 --> 07:38.400
as information

171
07:38.400 --> 07:42.430
modeled via open config as we see right here so right now all we've done is

172
07:42.430 --> 07:44.080
send a get config rpc

173
07:44.080 --> 07:47.910
without any filter ultimately getting back every possible way that the running

174
07:47.910 --> 07:48.720
configuration

175
07:48.720 --> 07:52.550
can be models so we're getting a lot of info what we now want to do is to be a

176
07:52.550 --> 07:53.360
little bit more

177
07:53.360 --> 07:57.230
precise and begin filtering that information now the first way we want to

178
07:57.230 --> 07:58.560
filter is utilizing

179
07:58.560 --> 08:03.800
something known as sub tree filtering so let's talk about that in the very next
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

179
07:58.560 --> 08:03.800
something known as sub tree filtering so let's talk about that in the very next

180
08:03.800 --> 08:04.320
video
