WEBVTT

1
00:00.000 --> 00:04.550
Now so far we have seen how we can use get requests to ultimately retrieve

2
00:04.550 --> 00:05.520
information about

3
00:05.520 --> 00:10.130
our devices. What we now want to do though is to actually make configuration

4
00:10.130 --> 00:11.040
changes okay.

5
00:11.040 --> 00:15.280
So if we want to be making configuration changes the types of methods we want

6
00:15.280 --> 00:16.320
to look at are things

7
00:16.320 --> 00:20.680
like a post request for creating something brand new or potentially we can just

8
00:20.680 --> 00:21.920
create a put request

9
00:21.920 --> 00:28.740
to update something. Now here is the difficulty in managing configurations with

10
00:28.740 --> 00:29.200
Yang.

11
00:29.200 --> 00:33.120
Remember when we happen to send a get request we got this information coming
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:29.200 --> 00:33.120
Remember when we happen to send a get request we got this information coming

12
00:33.120 --> 00:34.320
back to us in this

13
00:34.320 --> 00:38.490
Yang model type way. Well any similar sense when it comes to making

14
00:38.490 --> 00:40.160
configurations we actually

15
00:40.160 --> 00:45.010
have to send the data that we want to update the device with also in this Yang

16
00:45.010 --> 00:45.920
based structure.

17
00:45.920 --> 00:49.040
So this might present some difficulty because as you know you might be looking

18
00:49.040 --> 00:49.440
at this in

19
00:49.440 --> 00:54.510
gun roll. How do I begin building this configuration not like your regular

20
00:54.510 --> 00:56.080
Cisco CLI but instead

21
00:56.080 --> 01:01.120
as this weird and wonderful Yang type data. So there are different ways in
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

21
00:56.080 --> 01:01.120
as this weird and wonderful Yang type data. So there are different ways in

22
01:01.120 --> 01:02.320
which you can do this

23
01:02.320 --> 01:07.450
task but quite embarrassingly I have to admit that even today it seems like the

24
01:07.450 --> 01:08.640
best utility that we

25
01:08.640 --> 01:12.990
have to do this is to actually use the old school CLI and what can you imagine

26
01:12.990 --> 01:14.400
what is this all about.

27
01:14.400 --> 01:18.480
Now now what I will say is we're not just using the CLI we're using the CLI in

28
01:18.480 --> 01:19.680
conjunction with

29
01:19.680 --> 01:24.550
some restcon for requests. So what on earth am I even blabbing about okay so

30
01:24.550 --> 01:25.360
let's go with a fairly

31
01:25.360 --> 01:30.180
simple example. Let's imagine we're going to configure a look back on our
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

31
01:25.360 --> 01:30.180
simple example. Let's imagine we're going to configure a look back on our

32
01:30.180 --> 01:31.680
device. Now a look back

33
01:31.680 --> 01:35.750
is a form of interface after all. So what we could do is we could go and

34
01:35.750 --> 01:37.200
consult the Yang model.

35
01:37.200 --> 01:40.570
You know just as we did we went through Pi Yang and we could see all the

36
01:40.570 --> 01:41.760
different keys.

37
01:41.760 --> 01:45.100
So we could use Pi Yang and we can see the structures see which keys belong to

38
01:45.100 --> 01:45.920
which try to fix

39
01:45.920 --> 01:50.000
the indentation so on so forth but quite honestly this is a bit of a headache.

40
01:50.000 --> 01:50.720
If we want to just

41
01:50.720 --> 01:55.170
configure a look back with restcon let's first configure a look back on the

42
01:55.170 --> 01:56.560
device to make sure one

43
01:56.560 --> 01:59.900
actually exists. So what I'm going to first do is I will just log into the

44
01:59.900 --> 02:01.040
machine itself and all
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

44
01:59.900 --> 02:01.040
machine itself and all

45
02:01.040 --> 02:04.880
I will do is say configure terminal and let's just say interface look back and

46
02:04.880 --> 02:05.920
let's just go with

47
02:05.920 --> 02:09.120
look back one two three okay and let's just add in things we would like to

48
02:09.120 --> 02:10.080
configure so let's add

49
02:10.080 --> 02:15.070
any description for example this is a test look back let's also add an IPv4

50
02:15.070 --> 02:17.040
address also IP address

51
02:17.040 --> 02:21.810
I'm just do one into one six eights I don't know one two three dot one and we

52
02:21.810 --> 02:22.560
'll give it a slash

53
02:22.560 --> 02:26.960
24 mask okay so pretty much let's imagine this is what we want to configure via

54
02:26.960 --> 02:27.760
restcon but we just

55
02:27.760 --> 02:31.440
don't know how to structure the data but the cool thing is we have this now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

55
02:27.760 --> 02:31.440
don't know how to structure the data but the cool thing is we have this now

56
02:31.440 --> 02:32.800
configured on the device

57
02:32.800 --> 02:37.040
with all the details that we need such as the description and an IPv4 address

58
02:37.040 --> 02:38.080
so what I propose

59
02:38.080 --> 02:43.440
we do is we now send a get request over restcon which will actually pull back

60
02:43.440 --> 02:44.160
this information

61
02:44.160 --> 02:48.000
and we can just see the structure that restcon returns this data and then

62
02:48.000 --> 02:49.520
effectively we will use

63
02:49.520 --> 02:53.500
this as a template which we can modify for creating lookbacks in the future

64
02:53.500 --> 02:54.800
okay so let's go and

65
02:54.800 --> 02:58.890
try this then okay so what I will do right now is I will copy over script

66
02:58.890 --> 03:00.400
number two and I'll create
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

66
02:58.890 --> 03:00.400
number two and I'll create

67
03:00.400 --> 03:04.950
one called script4.py so if we just go and open this one up as we recall this

68
03:04.950 --> 03:05.920
particular script

69
03:05.920 --> 03:10.440
is going to return interface information modeled via the ietf style so let me

70
03:10.440 --> 03:11.680
just delete this

71
03:11.680 --> 03:16.050
portion right here and just get a JSON response back so let's save this clear

72
03:16.050 --> 03:17.360
the screen and we'll run

73
03:17.360 --> 03:21.050
script number four okay though because let's scroll on up now here is the thing

74
03:21.050 --> 03:22.320
what I want to do

75
03:22.320 --> 03:27.060
is I want to just target one particular interface but right now all I'm getting

76
03:27.060 --> 03:28.640
back is the model data

77
03:28.640 --> 03:32.580
for all of the interfaces this is no good for my template if I just want to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

77
03:28.640 --> 03:32.580
for all of the interfaces this is no good for my template if I just want to

78
03:32.580 --> 03:34.160
make a modification to

79
03:34.160 --> 03:38.640
one of them so what I will do is I will filter the actual data now notice here

80
03:38.640 --> 03:40.000
we have this interface

81
03:40.000 --> 03:44.320
key and inside of it is not actually a key this happens to be a list object now

82
03:44.320 --> 03:45.120
the way we actually

83
03:45.120 --> 03:49.970
target an element within the list via url and we're going to combine this

84
03:49.970 --> 03:51.440
particular key and then

85
03:51.440 --> 03:55.380
associate it with the actual interface that we want to return so to say for

86
03:55.380 --> 03:56.960
example in my case here

87
03:56.960 --> 04:01.670
we go down to this one here look back one two three what I can do here is this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

87
03:56.960 --> 04:01.670
we go down to this one here look back one two three what I can do here is this

88
04:01.670 --> 04:02.640
I can grab that key

89
04:02.640 --> 04:07.420
interface which is like I say what we see right here and now because we have a

90
04:07.420 --> 04:08.480
list object I'm

91
04:08.480 --> 04:12.220
going to use the equal sign and then just specify the name of the interface

92
04:12.220 --> 04:13.120
that I want to actually

93
04:13.120 --> 04:17.360
return so for example if I wanted to get gigabit ethernet one I would just copy

94
04:17.360 --> 04:18.880
this paste you in save

95
04:18.880 --> 04:23.330
this run the script again and now we just get the information for ethernet one

96
04:23.330 --> 04:24.160
similarly if I

97
04:24.160 --> 04:27.120
wanted to get the information for the look back which has got all of the

98
04:27.120 --> 04:28.480
information that we are

99
04:28.480 --> 04:33.200
interested in all I will do is change the interface to equal look back one two
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

99
04:28.480 --> 04:33.200
interested in all I will do is change the interface to equal look back one two

100
04:33.200 --> 04:34.320
three so if I save

101
04:34.320 --> 04:39.370
this now clearly screen and run it this here is all of the information that we

102
04:39.370 --> 04:40.480
wanted to configure

103
04:40.480 --> 04:44.220
such as the description the IP address but the handy thing is we've got the

104
04:44.220 --> 04:45.600
exact structure we need

105
04:45.600 --> 04:49.350
in order to send off these types of requests so if I just happen to copy this

106
04:49.350 --> 04:50.160
here and let me just

107
04:50.160 --> 04:54.470
copy script four and I'll create one called script five dot py so what I'm

108
04:54.470 --> 04:55.600
going to do is make some

109
04:55.600 --> 04:59.210
modifications to this particular script under the headers let me just go and

110
04:59.210 --> 05:00.720
create a little payloads
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

110
04:59.210 --> 05:00.720
create a little payloads

111
05:00.720 --> 05:03.560
and I'll say it's equal to and all I'm going to do is paste in the

112
05:03.560 --> 05:05.200
configuration that we just saw

113
05:05.200 --> 05:09.690
there okay so essentially we've just got this little dictionary with all of the

114
05:09.690 --> 05:10.720
data so what I can do

115
05:10.720 --> 05:15.270
here is let's maybe say I wanted to update the description as well as the

116
05:15.270 --> 05:16.880
actual IP address let's

117
05:16.880 --> 05:20.780
just change this to be updated so we know it's actually changed and maybe let's

118
05:20.780 --> 05:21.280
make this

119
05:21.280 --> 05:27.150
address to be 192168123.123 okay and maybe in fact let's give it a slash 32

120
05:27.150 --> 05:28.320
mask so I've modified

121
05:28.320 --> 05:32.300
this now what we're going to do here is if you recall when it comes to arrest
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

121
05:28.320 --> 05:32.300
this now what we're going to do here is if you recall when it comes to arrest

122
05:32.300 --> 05:33.440
apis we're going to have

123
05:33.440 --> 05:38.890
particular headers we are sending a payload to the actual device so I want to

124
05:38.890 --> 05:40.240
tell the device which

125
05:40.240 --> 05:43.890
type of data I'm going to be sending also the header is going to be content

126
05:43.890 --> 05:45.360
type is application

127
05:45.360 --> 05:49.630
yang data JSON so what I'm actually specifying here in the URL is that I'm

128
05:49.630 --> 05:50.720
targeting you very

129
05:50.720 --> 05:55.460
particular resource I want to be targeting look back 123 but I want to be

130
05:55.460 --> 05:56.960
sending this particular

131
05:56.960 --> 06:01.580
payload along with my actual request now the problem is right now is my request
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

131
05:56.960 --> 06:01.580
payload along with my actual request now the problem is right now is my request

132
06:01.580 --> 06:02.480
currently happened

133
06:02.480 --> 06:07.100
to be a get request but as it stands I actually want to update look back 123

134
06:07.100 --> 06:08.480
with this information

135
06:08.480 --> 06:13.300
so instead what I will do is I will change this to a put request to update and

136
06:13.300 --> 06:14.400
right now here I will

137
06:14.400 --> 06:18.130
just print out the response and what I need to do is to add one more thing to

138
06:18.130 --> 06:19.200
the actual request

139
06:19.200 --> 06:22.730
I'm making I'm going to also have to pass in the payload I'll be sending over

140
06:22.730 --> 06:24.080
some JSON data

141
06:24.080 --> 06:26.970
and that's going to be equal to the payload dictionary that I've just defined

142
06:26.970 --> 06:28.080
above okay see this

143
06:28.080 --> 06:32.680
right here we're now passing it in so if I save this and I run the script now
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

143
06:28.080 --> 06:32.680
right here we're now passing it in so if I save this and I run the script now

144
06:32.680 --> 06:33.920
we get a 204 this is

145
06:33.920 --> 06:38.520
actually indicating that we have a success so if I now log into the device and

146
06:38.520 --> 06:39.440
I do a show run

147
06:39.440 --> 06:42.390
if I scroll all the way down to the look back look at this right here we can

148
06:42.390 --> 06:43.120
see it has been

149
06:43.120 --> 06:47.790
updated it now has the new IP address and it also has the new subnet mask and

150
06:47.790 --> 06:48.720
again if I actually

151
06:48.720 --> 06:53.040
just go back exit if I run script number four which actually retrieves the

152
06:53.040 --> 06:53.760
information for that

153
06:53.760 --> 06:58.050
particular look back indeed we can see here as part of a risk on request this

154
06:58.050 --> 06:59.040
information has

155
06:59.040 --> 07:02.220
clearly been updated so we'll see how to get data we'll see how to make
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

155
06:59.040 --> 07:02.220
clearly been updated so we'll see how to get data we'll see how to make

156
07:02.220 --> 07:03.520
configuration changes let's

157
07:03.520 --> 07:07.740
imagine we wanted to delete this particular look back well what we'll do is

158
07:07.740 --> 07:09.120
just copy script number 5

159
07:09.120 --> 07:13.400
over create script number six let's open you in this case here we actually don

160
07:13.400 --> 07:14.560
't need any headers

161
07:14.560 --> 07:19.060
and we'll delete the payload so I can remove these two options from my actual

162
07:19.060 --> 07:20.000
request and all I'm

163
07:20.000 --> 07:24.640
going to do is I'm going to target this very particular interface look back 123

164
07:24.640 --> 07:26.320
as pair the actual URL

165
07:26.320 --> 07:30.120
remember the URL correlates to the resource and all I'm going to do this time
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

165
07:26.320 --> 07:30.120
remember the URL correlates to the resource and all I'm going to do this time

166
07:30.120 --> 07:30.960
is I'm going to send a

167
07:30.960 --> 07:36.070
get request I'm going to use the HTTP delete method so if I happen to save this

168
07:36.070 --> 07:36.960
I clear the screen

169
07:36.960 --> 07:42.180
if I now run script number six I answer we have a 204 this indicates a success

170
07:42.180 --> 07:43.040
so now if I log into

171
07:43.040 --> 07:47.390
the machine one more time and I do a show run if I scroll on down notice look

172
07:47.390 --> 07:49.120
back 123 is nowhere to

173
07:49.120 --> 07:52.950
be found it actually has been deleted so I know Yang can certainly be pretty

174
07:52.950 --> 07:54.240
confusing especially if

175
07:54.240 --> 07:57.940
you're not familiar with it we have to understand how to configure payloads in

176
07:57.940 --> 07:59.280
this particular structure

177
07:59.280 --> 08:02.960
but if we just configure the information that we want via the CLI and then
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

177
07:59.280 --> 08:02.960
but if we just configure the information that we want via the CLI and then

178
08:02.960 --> 08:04.320
craft the necessary get

179
08:04.320 --> 08:09.210
request with the correct URL then we do have a good template to ultimately send

180
08:09.210 --> 08:10.560
off future payloads

181
08:10.560 --> 08:12.160
and then make modifications
