WEBVTT

1
00:00.000 --> 00:04.560
So previously we were able to connect to a singular device by reading in data

2
00:04.560 --> 00:07.000
from an external file, a YAML file,

3
00:07.000 --> 00:11.000
and we passed that information to a netmeco and ultimately sent a show command.

4
00:11.000 --> 00:16.450
Let's now build out that external file to include more files rather, more

5
00:16.450 --> 00:17.000
devices.

6
00:17.000 --> 00:21.260
And ultimately let's connect to more devices at once to really enjoy the

7
00:21.260 --> 00:23.000
benefits of automation.

8
00:23.000 --> 00:26.850
So the first thing I will do is go to my inventory file, in fact what I will do

9
00:26.850 --> 00:27.000
here.

10
00:27.000 --> 00:32.250
Let me just copy this over, I will just call this one new inventory. YAML, okay
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

10
00:27.000 --> 00:32.250
Let me just copy this over, I will just call this one new inventory. YAML, okay

11
00:32.250 --> 00:33.000
, so let's open this one up.

12
00:33.000 --> 00:37.520
Okay, so here's the big difference. Let's actually change this name to be

13
00:37.520 --> 00:39.000
plural, not that it has any effect,

14
00:39.000 --> 00:42.060
but it is a little bit more descriptive given the fact that we are going to be

15
00:42.060 --> 00:44.000
dealing with multiple different devices.

16
00:44.000 --> 00:47.370
And what I want to do here is I want to use a hyphen to denote that I have got

17
00:47.370 --> 00:49.000
multiple different entries, okay.

18
00:49.000 --> 00:53.230
So let me just indent the rest of this, and pretty much all I am going to do is

19
00:53.230 --> 00:54.000
copy this right here.

20
00:54.000 --> 00:57.930
And I am just going to paste this in, and then paste it in, and then paste it

21
00:57.930 --> 00:59.000
in one more time.

22
00:59.000 --> 01:02.120
Okay, so I have now got four entries. All I am going to do now though is change
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

22
00:59.000 --> 01:02.120
Okay, so I have now got four entries. All I am going to do now though is change

23
01:02.120 --> 01:04.000
the IP address of these.

24
01:04.000 --> 01:08.000
So I have got 102, 103 as well as 104, okay.

25
01:08.000 --> 01:11.000
So now essentially let me just zoom out a little bit.

26
01:11.000 --> 01:13.920
This is our file which ultimately defines four different devices in fact to

27
01:13.920 --> 01:15.000
make it a little bit easier.

28
01:15.000 --> 01:18.000
Let me just do some spacing, okay, just so it is a little bit cleaner.

29
01:18.000 --> 01:20.000
There we go right there. Okay, so let's save this.

30
01:20.000 --> 01:24.720
And now we have our new inventory.YML file. So what I will do here is I will

31
01:24.720 --> 01:27.000
copy over example 4.py,

32
01:27.000 --> 01:29.660
and I will create a new one called example 5.py, and I will do the

33
01:29.660 --> 01:31.000
modifications necessary.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

33
01:29.660 --> 01:31.000
modifications necessary.

34
01:31.000 --> 01:35.000
So let's open you up, go into example 5.py.

35
01:35.000 --> 01:38.000
The right now is it stands, let me just comment this out.

36
01:38.000 --> 01:40.000
So that way we are not actually executing.

37
01:40.000 --> 01:43.000
And all I am going to do is I am going to load my file in, although this time

38
01:43.000 --> 01:45.000
the file is going to be new on the score inventory,

39
01:45.000 --> 01:47.000
which has got the additional details.

40
01:47.000 --> 01:51.000
And this time here the key as you remember is not going to be device.

41
01:51.000 --> 01:55.000
We changed it to be devices just to be a little bit clearer.

42
01:55.000 --> 01:57.000
So it will just change this right here.

43
01:57.000 --> 02:00.000
And again similarly just to make things a little bit more descriptive.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

44
02:00.000 --> 02:03.000
Let's use a better name and use the plural here for devices.

45
02:03.000 --> 02:08.000
So ultimately if I just print out the devices variable right here.

46
02:08.000 --> 02:11.000
And I say Python 3 example 5.py right now.

47
02:11.000 --> 02:14.260
As we can see here I am getting access to all of this new connection

48
02:14.260 --> 02:15.000
information.

49
02:15.000 --> 02:18.000
Basically the connection details for all four of my devices.

50
02:18.000 --> 02:20.000
Now here is the thing.

51
02:20.000 --> 02:24.000
What I want to do is I want to essentially loop through each of the devices

52
02:24.000 --> 02:25.000
that I have access to right here.

53
02:25.000 --> 02:29.000
So if I just say for device and the devices object I have right here.

54
02:29.000 --> 02:32.000
And if I just print out that device, save this.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

54
02:29.000 --> 02:32.000
And if I just print out that device, save this.

55
02:32.000 --> 02:35.000
If I clear this green and run the script.

56
02:35.000 --> 02:38.050
What we are actually getting here is the first dictionary with all the

57
02:38.050 --> 02:39.000
connection details.

58
02:39.000 --> 02:42.000
Then we print out the second dictionary with all the connection details.

59
02:42.000 --> 02:45.000
Then the third and then lastly the fourth.

60
02:45.000 --> 02:48.000
Now what I want to do is as opposed to printing them out to one by one.

61
02:48.000 --> 02:52.270
I want to pass them in one by one into the connection handle just as we saw

62
02:52.270 --> 02:53.000
before.

63
02:53.000 --> 02:54.000
So here's what I am going to do.

64
02:54.000 --> 02:56.000
I am going to get rid of this print statement.

65
02:56.000 --> 02:59.000
So let me just uncomment this piece of code right here.

66
02:59.000 --> 03:00.000
There we go.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

67
03:00.000 --> 03:02.000
And what I will do is I will just cut this.

68
03:02.000 --> 03:05.000
And I am just going to move it inside the follow up right here.

69
03:05.000 --> 03:06.000
So let's paste this in.

70
03:06.000 --> 03:09.000
In fact let me just fix the indentation for this part here.

71
03:09.000 --> 03:10.000
As well as this.

72
03:10.000 --> 03:12.000
So the big difference here though.

73
03:12.000 --> 03:14.000
So we are doing the same thing as before.

74
03:14.000 --> 03:16.000
I will be loading a different file.

75
03:16.000 --> 03:19.000
This ultimately gives us access to our device information.

76
03:19.000 --> 03:23.000
And this top level key now contains the information for multiple devices.

77
03:23.000 --> 03:25.000
And we are saving this into a variable.

78
03:25.000 --> 03:28.000
And all we are doing is looping through that variable.

79
03:28.000 --> 03:32.470
And passing in the information that we loop through every single time into NITN
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

79
03:28.000 --> 03:32.470
And passing in the information that we loop through every single time into NITN

80
03:32.470 --> 03:33.000
IKO's

81
03:33.000 --> 03:36.540
KNET handler and then sending that show command to all of the devices one by

82
03:36.540 --> 03:37.000
one.

83
03:37.000 --> 03:42.000
So if I save this here and I try rerunning the script, let's hit enter.

84
03:42.000 --> 03:46.000
There is device one, now device two, then device three, and then finally device

85
03:46.000 --> 03:47.000
four comes through also.

86
03:47.000 --> 03:50.580
So now we are able to use NITNIKO to ultimately send show command to multiple

87
03:50.580 --> 03:52.000
devices utilizing Python loops.

88
03:52.000 --> 03:56.770
Let's now see how we can use NITNIKO to ultimately send configuration changes

89
03:56.770 --> 03:58.000
to those devices.
