WEBVTT

1
00:00.000 --> 00:05.120
Alright friends, let's try and demystify these URLs. So like I said, the URL is

2
00:05.120 --> 00:06.080
directly tied

3
00:06.080 --> 00:10.060
to the Yang model and we know that we have different types of Yang models

4
00:10.060 --> 00:11.760
available, we have ITF,

5
00:11.760 --> 00:15.700
we have Cisco or other native models which include Cisco, Juniper, so on, so

6
00:15.700 --> 00:16.880
forth, as well as

7
00:16.880 --> 00:21.290
the Open Config models. So what I propose we do is we go to a website called

8
00:21.290 --> 00:22.640
GetUp, whereby all of

9
00:22.640 --> 00:26.490
these models are actually uploaded and we can download a copy of all of the

10
00:26.490 --> 00:27.680
available models and

11
00:27.680 --> 00:32.180
then we can begin inspecting them and from that point we can derive what our
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:27.680 --> 00:32.180
then we can begin inspecting them and from that point we can derive what our

12
00:32.180 --> 00:33.600
URL should actually be.

13
00:33.600 --> 00:38.400
So let me go and go to my browser here, so if you happen to search for Yang

14
00:38.400 --> 00:39.520
models GetUp,

15
00:39.520 --> 00:42.950
let's click this link here. Now what I'm going to do is I'm going to download a

16
00:42.950 --> 00:43.920
copy of everything

17
00:43.920 --> 00:47.640
that is in all of these folders, okay. So because I'm downloading from GetUp, I

18
00:47.640 --> 00:48.240
'm going to use

19
00:48.240 --> 00:51.620
a utility called GetSaults. They get clone and then paste in the address that I

20
00:51.620 --> 00:52.480
just saw there and

21
00:52.480 --> 00:57.040
if I enter we're going to begin downloading all of these files, okay. Now just

22
00:57.040 --> 00:57.520
whilst that

23
00:57.520 --> 01:01.230
downloads, if I go back to my browser, what we can actually see here is we have
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

23
00:57.520 --> 01:01.230
downloads, if I go back to my browser, what we can actually see here is we have

24
01:01.230 --> 01:01.920
a whole bunch of

25
01:01.920 --> 01:06.260
different folders, okay. So if I just go into say, for example, the standard

26
01:06.260 --> 01:07.360
folder, I can get down

27
01:07.360 --> 01:11.830
and go into IETF for the IETF models, if I go into RFC for the request for

28
01:11.830 --> 01:13.360
comments, what we actually

29
01:13.360 --> 01:17.260
see here are tons and tons and tons of these models. So we have IETF models for

30
01:17.260 --> 01:18.800
things like IPv4,

31
01:18.800 --> 01:22.660
Unicast routing, so if you've got some type of routing configuration, the

32
01:22.660 --> 01:23.440
information you would

33
01:23.440 --> 01:26.970
find would be in this model, whereas if you want to get, say for example, some

34
01:26.970 --> 01:28.240
interface information,

35
01:28.240 --> 01:33.350
if we scroll on up, what we can see here is the IETF interfaces yang model. Now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:28.240 --> 01:33.350
if we scroll on up, what we can see here is the IETF interfaces yang model. Now

36
01:33.350 --> 01:33.760
one thing you'll

37
01:33.760 --> 01:37.180
notice is if we happen to just look at this right here and if you scroll

38
01:37.180 --> 01:38.400
through all of this,

39
01:38.400 --> 01:42.320
you are beginning to see that this looks kind of confusing, it's pretty complex

40
01:42.320 --> 01:43.040
and it really is

41
01:43.040 --> 01:46.890
very, very long. I can just keep scrolling and scrolling and scrolling. This is

42
01:46.890 --> 01:47.920
really, really hard

43
01:47.920 --> 01:52.560
to just look at this way and because of that, what I'm going to suggest we do

44
01:52.560 --> 01:53.120
is we use

45
01:53.120 --> 01:56.480
the utility that is going to transform this data into something that is at

46
01:56.480 --> 01:57.760
least a little bit more

47
01:57.760 --> 02:01.110
readable. So the utility that I'm going to use right now is something called pi
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

47
01:57.760 --> 02:01.110
readable. So the utility that I'm going to use right now is something called pi

48
02:01.110 --> 02:02.080
yang. It's basically

49
02:02.080 --> 02:06.090
a Python program that is going to, well, ingest these models. So I'll say pip3

50
02:06.090 --> 02:07.360
installed pi yang

51
02:07.360 --> 02:10.810
and to enter and then we begin installation. So now we're that done because I

52
02:10.810 --> 02:12.000
have downloaded the

53
02:12.000 --> 02:15.960
yang models, it's been downloaded into a directory called yang, which we can

54
02:15.960 --> 02:17.280
see right here. So if I

55
02:17.280 --> 02:21.410
just go into this folder and I do a listing, we actually see all of the same

56
02:21.410 --> 02:22.480
information that we

57
02:22.480 --> 02:25.730
saw on the website right there. We can go into the standard folder, we can go

58
02:25.730 --> 02:26.640
into vendor models,

59
02:26.640 --> 02:30.300
so on, so forth. So if I just go into the standard folder like we just saw
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

59
02:26.640 --> 02:30.300
so on, so forth. So if I just go into the standard folder like we just saw

60
02:30.300 --> 02:31.840
before and I do a listing

61
02:31.840 --> 02:36.100
and I go into the ITF folder and do a listing and again, our FC, we can see

62
02:36.100 --> 02:37.040
this is the exact same

63
02:37.040 --> 02:40.680
structure. So inside this folder, do a listing, we're going to see all of these

64
02:40.680 --> 02:41.760
models. So again,

65
02:41.760 --> 02:45.760
scrolling on up, we can see models for SNMP, segment routing, tons and tons and

66
02:45.760 --> 02:46.720
tons of stuff.

67
02:46.720 --> 02:51.220
But for now, let's go and grab the ITF interfaces model, okay? So if I just

68
02:51.220 --> 02:52.400
copy this right here,

69
02:52.400 --> 02:57.670
and grab you, what I will do is use my tool and say, pi yang dash f for the

70
02:57.670 --> 02:58.960
format, say I want to see

71
02:58.960 --> 03:02.060
this in a tree like format and then just paste in the model that we want to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

71
02:58.960 --> 03:02.060
this in a tree like format and then just paste in the model that we want to

72
03:02.060 --> 03:03.440
inspect. If I hit enter,

73
03:03.440 --> 03:06.730
we now see this tree like structure. So let's go up to the very top, okay? So

74
03:06.730 --> 03:07.760
at the very top,

75
03:07.760 --> 03:12.080
we actually see the name of the module, okay? And then inside that, we have all

76
03:12.080 --> 03:13.120
of the model data,

77
03:13.120 --> 03:16.650
okay? So again, I know this is pretty confusing to look at. But honestly, we

78
03:16.650 --> 03:17.600
don't have to get too

79
03:17.600 --> 03:21.960
deep in the way to this, okay? So don't be discouraged. Try to follow along. So

80
03:21.960 --> 03:23.280
basically we have this top

81
03:23.280 --> 03:27.270
level container here called interfaces. And we can see it's actually out-dented

82
03:27.270 --> 03:28.560
here a little bit.

83
03:28.560 --> 03:32.530
And then everything within, this is all within that particular container, see
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

83
03:28.560 --> 03:32.530
And then everything within, this is all within that particular container, see

84
03:32.530 --> 03:34.080
that? Now I will say it

85
03:34.080 --> 03:37.890
gets more detailed than this. But for a good starting point, what we're going

86
03:37.890 --> 03:39.520
to do is to make a note

87
03:39.520 --> 03:44.520
of the module here, okay? And then we're going to make a note of the top level

88
03:44.520 --> 03:45.920
container. Okay,

89
03:45.920 --> 03:49.610
so just take those two pieces of information that we see right now, okay? And I

90
03:49.610 --> 03:50.400
'm going to basically

91
03:50.400 --> 03:54.480
combine them now, pause for a moment. These two values might actually be

92
03:54.480 --> 03:55.760
familiar. If you go back

93
03:55.760 --> 03:59.460
to our script, look at what we actually see here. This is the way we build our

94
03:59.460 --> 04:01.280
URL. We have the target
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

94
03:59.460 --> 04:01.280
URL. We have the target

95
04:01.280 --> 04:04.830
we're trying to reach and the port and then we say forward slash, rest corn

96
04:04.830 --> 04:05.920
forward slash data.

97
04:05.920 --> 04:10.240
That's a standard. After that, we now specify the information that we want to

98
04:10.240 --> 04:11.600
receive from the

99
04:11.600 --> 04:16.400
browser rather than the browser from the router. So the first portion here,

100
04:16.400 --> 04:17.840
this is me telling what

101
04:17.840 --> 04:21.400
yang model I want to be retrieving. Okay? And remember that's just what you saw

102
04:21.400 --> 04:22.480
right there. Okay?

103
04:22.480 --> 04:27.330
See it. This is the module name right here for all of this information. And

104
04:27.330 --> 04:28.800
then immediately after,

105
04:28.800 --> 04:32.850
what I have is a little colon separator, which we can see. And then right after
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

105
04:28.800 --> 04:32.850
what I have is a little colon separator, which we can see. And then right after

106
04:32.850 --> 04:33.840
we have that top

107
04:33.840 --> 04:37.870
level container. So think about it like this. If I wanted to get a different

108
04:37.870 --> 04:39.120
piece of information,

109
04:39.120 --> 04:42.390
how would I do that? But I would go through another yang model. I could then

110
04:42.390 --> 04:43.520
use pie yang. And from

111
04:43.520 --> 04:47.060
that point, I would quickly look at the module and then get the top level

112
04:47.060 --> 04:48.320
container. So here's the

113
04:48.320 --> 04:51.880
thing. If you go back into our yang folder here, and this time we go into the

114
04:51.880 --> 04:52.960
vendor folder. And now

115
04:52.960 --> 04:57.000
I go in and look for Cisco. And then I'm on a Cisco iOS XE device. So I'll go

116
04:57.000 --> 04:58.320
into this particular

117
04:58.320 --> 05:01.560
folder and all I have here are all of these revision numbers. So let's grab the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

117
04:58.320 --> 05:01.560
folder and all I have here are all of these revision numbers. So let's grab the

118
05:01.560 --> 05:02.320
latest revision.

119
05:02.320 --> 05:06.660
So this one right here, going here. If I do a listing, we see all of these

120
05:06.660 --> 05:07.760
models. Okay?

121
05:07.760 --> 05:11.520
If I just grab the model that says native, this is essentially going to give me

122
05:11.520 --> 05:12.400
all of my running

123
05:12.400 --> 05:17.120
configuration. So let's just copy this here. And I'll say pie yang f dream. And

124
05:17.120 --> 05:17.840
I'll paste in the

125
05:17.840 --> 05:21.110
model once again, if I enter. So because this can model the entire

126
05:21.110 --> 05:22.640
configuration, this is an

127
05:22.640 --> 05:26.530
absolutely massive file. But if I go to the very top, what can we see here? I

128
05:26.530 --> 05:27.280
can see the name of

129
05:27.280 --> 05:31.790
the module, which is this right here. And then the top level container is this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

129
05:27.280 --> 05:31.790
the module, which is this right here. And then the top level container is this

130
05:31.790 --> 05:32.720
one right here.

131
05:32.720 --> 05:37.200
Okay? So let's try to follow the same principles and return this data. So let

132
05:37.200 --> 05:37.440
me just

133
05:37.440 --> 05:41.040
copy this right here. Okay? And all I will do is I will copy it over the

134
05:41.040 --> 05:42.880
previous script. And I'll

135
05:42.880 --> 05:47.460
create one called script free dot py. So if I open this up, go in here and what

136
05:47.460 --> 05:48.960
I'm going to do here,

137
05:48.960 --> 05:54.110
if I just remove all of this. And I'll go and modify the actual path. Okay? So

138
05:54.110 --> 05:55.360
let's just take the URL,

139
05:55.360 --> 05:59.130
delete this, paste in the name of the module. Then we'll have a colon and then

140
05:59.130 --> 06:00.240
we'll use the top
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

140
05:59.130 --> 06:00.240
we'll use the top

141
06:00.240 --> 06:03.700
level container, which is native. Open in fact, before I do this, let me put my

142
06:03.700 --> 06:04.720
parentheses back in

143
06:04.720 --> 06:09.660
right here. And now I will say, Python 3 script 3 dot py and to enter. And now

144
06:09.660 --> 06:10.640
look at this, we get a

145
06:10.640 --> 06:14.080
whole bunch of different information we're seeing effectively. The running

146
06:14.080 --> 06:15.280
configuration, your show

147
06:15.280 --> 06:19.580
runs of the speak in this Yang model type data. So scrolling all the way up to

148
06:19.580 --> 06:20.400
the very top,

149
06:20.400 --> 06:24.080
we can actually see the information that we have here is the outer key and

150
06:24.080 --> 06:24.880
instead of that,

151
06:24.880 --> 06:28.460
we have our version, which returns the version number. If you want to scroll on

152
06:28.460 --> 06:28.880
down,

153
06:28.880 --> 06:32.600
we have a host name key, which tells me the name of the host. We also have a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

153
06:28.880 --> 06:32.600
we have a host name key, which tells me the name of the host. We also have a

154
06:32.600 --> 06:34.080
router key. And instead

155
06:34.080 --> 06:37.540
of here, we can see that happens to be OSPF configured on this particular

156
06:37.540 --> 06:38.880
device. So there's two ways

157
06:38.880 --> 06:42.710
to actually approach this. We can just get this data very generally and get all

158
06:42.710 --> 06:43.920
this information back

159
06:43.920 --> 06:47.240
and then we can begin parsing it directly with Python. So say, for example,

160
06:47.240 --> 06:48.640
what I could do is

161
06:48.640 --> 06:52.260
copy the key right here. And then when I retrieve the data, I can paste in the

162
06:52.260 --> 06:53.600
key. So if I save this,

163
06:53.600 --> 06:57.520
clear the screen, read around the script, if I scroll all the way up to the

164
06:57.520 --> 06:58.880
very top once again.

165
06:58.880 --> 07:01.920
Now we can see we have removed that outer key. So I can now grab more
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

165
06:58.880 --> 07:01.920
Now we can see we have removed that outer key. So I can now grab more

166
07:01.920 --> 07:03.280
information. Let's try the

167
07:03.280 --> 07:07.140
version key right here. Okay. So again, paste your in. If I run it one more

168
07:07.140 --> 07:08.400
time, now we're just receiving

169
07:08.400 --> 07:12.260
back the version key. Here's what's happening here. I've got my Linux machine

170
07:12.260 --> 07:12.960
and I've got my

171
07:12.960 --> 07:17.740
REST CONF configured catalyst switch here. So right now, I'm sending an 80DP

172
07:17.740 --> 07:19.200
request to ultimately get

173
07:19.200 --> 07:23.890
back all of the native configuration. Okay. And this is actually sending back a

174
07:23.890 --> 07:24.960
ton of information

175
07:24.960 --> 07:29.100
back to my machine right here over the network. And at this point on my machine

176
07:29.100 --> 07:30.320
, I'm just effectively
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

176
07:29.100 --> 07:30.320
, I'm just effectively

177
07:30.320 --> 07:34.440
filtering all of that data locally right here to return this particular piece

178
07:34.440 --> 07:35.360
of information.

179
07:35.360 --> 07:39.780
As opposed to me sending a request just to target the native data and pull back

180
07:39.780 --> 07:40.400
tons and tons

181
07:40.400 --> 07:44.370
of that information being sent over the wire and filter it here. What I can

182
07:44.370 --> 07:45.760
actually do is I can just

183
07:45.760 --> 07:50.380
send a more specific URL to the actual server itself. And this will just send

184
07:50.380 --> 07:51.840
me over the very specific

185
07:51.840 --> 07:55.240
data that I want. So pretty much the filtering is happening over here, meaning

186
07:55.240 --> 07:56.240
that we're not having

187
07:56.240 --> 08:00.830
to send tons and tons of data over the network unnecessarily just to filter it
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

187
07:56.240 --> 08:00.830
to send tons and tons of data over the network unnecessarily just to filter it

188
08:00.830 --> 08:01.840
out locally.

189
08:01.840 --> 08:06.110
So as opposed to filtering it out with Python, let's actually filter it out

190
08:06.110 --> 08:06.960
directly from the server

191
08:06.960 --> 08:10.610
by specifying a more specific URL. So here's what I will do. I will delete the

192
08:10.610 --> 08:11.920
part of the time filtering

193
08:11.920 --> 08:15.960
just so I can see all the data one more time, run the script. And if I scroll

194
08:15.960 --> 08:17.120
on up to the very top,

195
08:17.120 --> 08:21.370
what if I just try to add the version directly within the URL itself? Okay. So

196
08:21.370 --> 08:21.920
check this out. What

197
08:21.920 --> 08:27.450
we'll do here is go back in this time. I will just say forward slash version

198
08:27.450 --> 08:28.480
and save you if I

199
08:28.480 --> 08:31.520
clear the screen and run the script. Look at this. The formatting might look a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

199
08:28.480 --> 08:31.520
clear the screen and run the script. Look at this. The formatting might look a

200
08:31.520 --> 08:32.560
little bit different,

201
08:32.560 --> 08:36.000
but we're actually getting back the correct value in this time. We've only had

202
08:36.000 --> 08:37.200
the server send over

203
08:37.200 --> 08:41.190
a very tiny amount of data, just the specific details that we want. So

204
08:41.190 --> 08:42.880
similarly, why could do

205
08:42.880 --> 08:46.330
is go back again? Let's just remove this to get the more general information.

206
08:46.330 --> 08:46.880
Save you.

207
08:46.880 --> 08:50.640
Arrow up try again. Say for example, I wanted to get this banner information.

208
08:50.640 --> 08:51.520
Okay. Well, you'll

209
08:51.520 --> 08:55.970
notice that this banner is actually indented within this key. And this key is

210
08:55.970 --> 08:57.360
also indented within.

211
08:57.360 --> 09:00.890
This key. Okay. So this has been a beginning to get a little bit confusing. So
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

211
08:57.360 --> 09:00.890
This key. Okay. So this has been a beginning to get a little bit confusing. So

212
09:00.890 --> 09:02.000
we'll reference this key

213
09:02.000 --> 09:06.180
first. The most outer key. So if I just say forward slash banner, save you.

214
09:06.180 --> 09:07.440
Clear the screen,

215
09:07.440 --> 09:11.120
try again. Now we're getting the more banner specific information. So again,

216
09:11.120 --> 09:12.880
let's get the MOTD key.

217
09:12.880 --> 09:17.670
So I'll just say forward slash MOTD, save you. Run it again. Now we have the

218
09:17.670 --> 09:18.720
banner key right here.

219
09:18.720 --> 09:23.050
So if I just say forward slash banner one more time and run the script, here we

220
09:23.050 --> 09:23.680
can now see we're

221
09:23.680 --> 09:27.500
parsing at the actual banner within the device itself. And again, if I just log

222
09:27.500 --> 09:29.040
in and say SSH and

223
09:29.040 --> 09:34.340
just give the sandbox address. If I log in, indeed we can see here, this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

223
09:29.040 --> 09:34.340
just give the sandbox address. If I log in, indeed we can see here, this

224
09:34.340 --> 09:35.440
actually is the banner that

225
09:35.440 --> 09:38.500
we're seeing. See that. So no doubt if this is the first time you're seeing

226
09:38.500 --> 09:39.840
this in action,

227
09:39.840 --> 09:44.410
risk on and Yang can be pretty confusing due to these URLs. But really as a

228
09:44.410 --> 09:45.600
recap, all we have to do

229
09:45.600 --> 09:49.770
is to download the models. We then choose the model that we want to use, say

230
09:49.770 --> 09:51.200
for example, an interface

231
09:51.200 --> 09:55.970
model. And then we can make a note of the module name and also specify the top

232
09:55.970 --> 09:57.200
level container.

233
09:57.200 --> 10:01.680
We then take this information, put it into a URL and then make a request to the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

233
09:57.200 --> 10:01.680
We then take this information, put it into a URL and then make a request to the

234
10:01.680 --> 10:02.240
device. And this

235
10:02.240 --> 10:06.850
will return the information about that particular model. And from that point on

236
10:06.850 --> 10:07.920
, we can either work with

237
10:07.920 --> 10:12.080
the data programmatically via Python, which is going to include us sending,

238
10:12.080 --> 10:13.200
perhaps maybe a lot more

239
10:13.200 --> 10:16.970
information over the network. Or if we wish we can request that the server

240
10:16.970 --> 10:17.920
itself filters the

241
10:17.920 --> 10:21.430
information being sent back. But ultimately, walking through the data and just

242
10:21.430 --> 10:24.000
specifying more specific URLs.
