1 00:00:05,490 --> 00:00:10,140 Rather than interacting with DNA center, let's just talk directly to a router. 2 00:00:10,500 --> 00:00:16,980 The advantage of using DNA centers, you can talk to a controller that's then managing many, many devices, 3 00:00:17,010 --> 00:00:21,330 but you can also talk directly to a device if it supports a rest API. 4 00:00:21,720 --> 00:00:27,750 So in this example, we're going to use the Cisco dev net, iOS, ESXi, always on sandbox. 5 00:00:27,960 --> 00:00:30,450 It uses this URL. 6 00:00:30,480 --> 00:00:32,159 This is its DNS name. 7 00:00:32,460 --> 00:00:39,840 This is the protocol that we're going to use port number, username, password, and we're going to 8 00:00:39,840 --> 00:00:41,760 use Postman once again. 9 00:00:42,210 --> 00:00:43,720 Now, very important. 10 00:00:43,740 --> 00:00:45,270 Before you do anything else. 11 00:00:46,100 --> 00:00:51,360 And I want to show you this in both windows and on a mac in Postman. 12 00:00:51,380 --> 00:01:00,290 Go to file on your Windows installation settings and make sure that you turn off SSL certificate verification. 13 00:01:00,680 --> 00:01:03,720 The route in this example is using a self signed certificate. 14 00:01:03,740 --> 00:01:05,900 If you don't turn this off, it's not going to work. 15 00:01:05,900 --> 00:01:07,870 You're going to drive yourself crazy. 16 00:01:07,880 --> 00:01:12,020 You have to override self signed certificates to make this work. 17 00:01:12,720 --> 00:01:13,440 On a mac. 18 00:01:13,440 --> 00:01:20,310 You need to go to postman preferences and disable SSL certificate verification. 19 00:01:20,610 --> 00:01:22,890 Before you do anything else, make sure you've done that. 20 00:01:22,890 --> 00:01:24,570 Otherwise, you're going to drive yourself crazy. 21 00:01:25,280 --> 00:01:27,110 So I've got. 22 00:01:28,140 --> 00:01:29,760 Some pre-built stuff here. 23 00:01:29,910 --> 00:01:31,950 But again, let's not use that. 24 00:01:31,950 --> 00:01:33,510 Let's do stuff. 25 00:01:34,870 --> 00:01:37,500 Manually so that you can see how it works. 26 00:01:37,510 --> 00:01:38,980 I'll close all these tabs. 27 00:01:40,210 --> 00:01:41,110 New Tab. 28 00:01:41,320 --> 00:01:43,060 Untitled Request. 29 00:01:43,810 --> 00:01:47,410 First thing I want to do is get a list of interfaces on the router. 30 00:01:47,590 --> 00:01:50,830 This is the URL that I'm going to use. 31 00:01:51,860 --> 00:01:54,530 So I'm simply going to paste that in here. 32 00:01:54,560 --> 00:01:57,380 It's a get statement we're using. 33 00:01:57,380 --> 00:01:59,060 Get your roll. 34 00:01:59,060 --> 00:01:59,720 Is that. 35 00:01:59,930 --> 00:02:02,930 But we need to put our authorization information in. 36 00:02:03,410 --> 00:02:05,270 It's basic authentication. 37 00:02:05,300 --> 00:02:07,640 You can see that here in the PowerPoint slide. 38 00:02:08,330 --> 00:02:10,930 Username is developer password of Cisco. 39 00:02:10,940 --> 00:02:14,300 One, two, three, four, five with a second character being a one. 40 00:02:15,140 --> 00:02:20,300 So we're going to use developer as our username password. 41 00:02:20,510 --> 00:02:21,740 Is that. 42 00:02:22,610 --> 00:02:28,010 This should connect to that router and give us a list of interfaces on the router. 43 00:02:28,250 --> 00:02:33,020 Notice it's returned the information in this example in XML format. 44 00:02:34,290 --> 00:02:37,140 So I can see gigabit one. 45 00:02:37,170 --> 00:02:38,580 This is the management interface. 46 00:02:38,580 --> 00:02:39,660 Don't touch it. 47 00:02:39,690 --> 00:02:43,890 IP addresses this net mask is this will subnet mask is that. 48 00:02:45,130 --> 00:02:48,460 Here's another interface that was configured by rest. 49 00:02:48,490 --> 00:02:55,600 Someone else is configuring this, so this isn't always on sandbox so anyone can connect to this. 50 00:02:55,600 --> 00:02:58,750 So you'll see other people creating stuff on the router. 51 00:02:59,420 --> 00:03:03,750 Now XML like this isn't that easy for us as a human to read. 52 00:03:03,770 --> 00:03:10,580 You can see someone has added loopback 100 year using risk conf someone has added in this example loopback 53 00:03:10,580 --> 00:03:17,960 103 using the client net mico someone has also added a loopback of 200 using python. 54 00:03:18,800 --> 00:03:21,800 XML isn't the easiest to read. 55 00:03:21,830 --> 00:03:24,920 Let's rather change this to JSON formatting. 56 00:03:25,220 --> 00:03:34,610 So to do that I'm going to go to headers and what we're going to do is create a key called accept. 57 00:03:35,920 --> 00:03:44,110 And the value of that key is going to be application yang hyphen data plus JSON so that. 58 00:03:45,910 --> 00:03:47,290 And then I'm going to click Send. 59 00:03:47,990 --> 00:03:53,390 And notice we've got Jason formatting now rather than XML formatting. 60 00:03:53,870 --> 00:04:01,040 That's probably a lot easier to read for us as humans so we can see IETF interfaces. 61 00:04:01,430 --> 00:04:04,790 Notice this is an array of square brackets there. 62 00:04:05,960 --> 00:04:07,100 Gigabit interfaces. 63 00:04:07,100 --> 00:04:08,960 This we're told not to touch it. 64 00:04:08,960 --> 00:04:10,400 There's the IP address. 65 00:04:10,970 --> 00:04:15,200 Here's interface gigabit two configured by Hy-Vee with his information. 66 00:04:15,870 --> 00:04:21,690 Here's gigabit to 100 and other interfaces that have been added. 67 00:04:21,709 --> 00:04:23,490 You can see suddenly we've got loopback. 68 00:04:23,510 --> 00:04:24,350 ADHD. 69 00:04:24,380 --> 00:04:27,080 So there are other people once again working on this. 70 00:04:27,080 --> 00:04:28,520 He has loopback 99. 71 00:04:29,210 --> 00:04:30,350 Loopback 100. 72 00:04:31,150 --> 00:04:33,760 So once again, other people are configuring this device. 73 00:04:33,760 --> 00:04:34,930 But there you go. 74 00:04:34,930 --> 00:04:40,690 That is an example of using rest to connect to a browser and retrieve information back. 75 00:04:40,990 --> 00:04:46,140 Notice we using HTTPS, we are not using net configure. 76 00:04:46,150 --> 00:04:50,500 We're not using SSH, we're using https rest API call. 77 00:04:51,070 --> 00:04:55,780 Now one thing I'll say is if you have problems, then add the second key. 78 00:04:55,780 --> 00:05:01,450 So if you have problems where it doesn't send back the information, then add the second key. 79 00:05:01,450 --> 00:05:08,860 But in my tests it's not required, but it will be required when you want to add an interface. 80 00:05:09,340 --> 00:05:14,410 So in the PowerPoint slide, once again, I've given you all that information, but now let's use a 81 00:05:14,410 --> 00:05:17,950 post and let's add an interface. 82 00:05:18,520 --> 00:05:21,220 So post will allow us to add something. 83 00:05:21,490 --> 00:05:24,760 So click on this tab, put the URL in. 84 00:05:25,940 --> 00:05:26,800 It's a post. 85 00:05:26,810 --> 00:05:31,220 We need to use the same username and password so not a get but post. 86 00:05:31,400 --> 00:05:32,840 Go to authorization. 87 00:05:34,580 --> 00:05:37,190 In this example, we're using basic authentication. 88 00:05:40,370 --> 00:05:43,280 On DNA center, we were using tokens. 89 00:05:43,280 --> 00:05:45,650 So X auth tokens for authorization. 90 00:05:46,010 --> 00:05:47,480 Here we are using. 91 00:05:48,550 --> 00:05:50,020 Basic authentication. 92 00:05:50,020 --> 00:05:55,570 So username is developer password Cisco one, two, three, four, five. 93 00:05:55,570 --> 00:05:56,560 That's correct. 94 00:05:56,980 --> 00:06:00,550 We need to go to headers and we need to add two headers. 95 00:06:00,550 --> 00:06:02,050 Share key. 96 00:06:02,050 --> 00:06:03,550 One is accept. 97 00:06:04,630 --> 00:06:07,090 Once again, we want to use JSON. 98 00:06:08,750 --> 00:06:13,430 And we're going to do the same thing again for Key too. 99 00:06:13,790 --> 00:06:16,400 But Key too is going to be content type. 100 00:06:18,830 --> 00:06:20,780 This kind of stuff is determined by the developer. 101 00:06:20,780 --> 00:06:22,250 In other words, by the API. 102 00:06:22,520 --> 00:06:27,980 If you want to interact with an API, you need to send the information as required by that API. 103 00:06:27,980 --> 00:06:32,750 And the developers of that API will decide what that API requires. 104 00:06:33,020 --> 00:06:35,420 So don't worry too much about what the values are. 105 00:06:35,450 --> 00:06:42,380 This is the API developed by the Cisco iOS X people and we interacting with that API now. 106 00:06:43,220 --> 00:06:49,280 Now step three is we need to add this to the body because we want to create a specific interface. 107 00:06:49,280 --> 00:06:52,760 We need to tell the router what interface we want to create. 108 00:06:52,880 --> 00:06:59,420 So to do that, we're going to use this text in the body of our API call. 109 00:06:59,570 --> 00:07:09,770 So go to body, go to raw and paste this in now because other people just go back to get our creating 110 00:07:09,770 --> 00:07:10,880 interfaces on this. 111 00:07:10,880 --> 00:07:17,990 Rather, I've specifically used a high end loopback number so that I'm not interfering with what they're 112 00:07:17,990 --> 00:07:20,180 doing and they're not interfering with what I'm doing. 113 00:07:20,180 --> 00:07:25,730 So I'm going to create a loopback of one, two, three, four and say that this was added using rest 114 00:07:25,730 --> 00:07:31,460 conf IP address is going to be one, two, three, four subnet mask is going to be slash 32. 115 00:07:34,900 --> 00:07:41,110 So if I go back to the get statement and click send notice that loopback doesn't exist on the router. 116 00:07:41,350 --> 00:07:43,540 We've got some physical interfaces. 117 00:07:44,440 --> 00:07:47,690 We've got some loop backs, but we don't have a loopback. 118 00:07:47,740 --> 00:07:48,790 One, two, three, four. 119 00:07:49,450 --> 00:07:51,160 So back to our post. 120 00:07:51,190 --> 00:07:52,810 I've put the URL in. 121 00:07:53,290 --> 00:08:00,490 Authorization is basic authorization using developer password of Cisco headers are specified except 122 00:08:00,490 --> 00:08:02,220 and content type body. 123 00:08:02,230 --> 00:08:03,770 I've put this information in. 124 00:08:03,790 --> 00:08:04,780 Click send. 125 00:08:05,080 --> 00:08:12,580 We have got 201 request has been fulfilled and resulted in a new resource being created. 126 00:08:12,610 --> 00:08:13,590 That's good. 127 00:08:13,600 --> 00:08:16,360 So let's confirm the results. 128 00:08:16,360 --> 00:08:19,000 So go back to get click send. 129 00:08:19,450 --> 00:08:21,850 Scroll down and notice. 130 00:08:21,850 --> 00:08:24,490 Here's our loopback interface. 131 00:08:24,940 --> 00:08:32,620 Now, if I try to create that again, I'm getting an error for one conflict object already exists, 132 00:08:32,860 --> 00:08:38,140 so I've already got that interface so I can't create it. 133 00:08:38,140 --> 00:08:41,679 But if I created another one, let's create a loopback. 134 00:08:41,679 --> 00:08:44,350 One, two, three, five and click send. 135 00:08:44,980 --> 00:08:47,110 We've got two of one created. 136 00:08:47,140 --> 00:08:48,490 Go back to get. 137 00:08:49,240 --> 00:08:51,640 Click send notice. 138 00:08:51,940 --> 00:08:54,780 One, two, three, five exists and so does. 139 00:08:54,790 --> 00:08:55,840 One, two, three, four. 140 00:08:56,410 --> 00:09:03,010 So there's is an example of creating a loopback interface on a router using a rest API direct connection 141 00:09:03,010 --> 00:09:04,930 to the rest API of the router. 142 00:09:05,300 --> 00:09:05,480 Okay. 143 00:09:05,530 --> 00:09:08,890 So I've once again put that in the PowerPoint presentation for you. 144 00:09:09,490 --> 00:09:12,640 Let's delete that loopback. 145 00:09:13,150 --> 00:09:15,160 So I'm going to create a new tab here. 146 00:09:15,160 --> 00:09:18,310 But this is a delete your URL. 147 00:09:18,310 --> 00:09:21,340 Is that notice at the end here? 148 00:09:21,340 --> 00:09:24,460 I've specified the interface that I want to delete. 149 00:09:24,760 --> 00:09:28,960 Authorization is going to be basic authorization. 150 00:09:28,960 --> 00:09:34,390 Using our credentials, we have to have a key of accept. 151 00:09:34,690 --> 00:09:37,690 So go to headers key of accept. 152 00:09:37,690 --> 00:09:45,040 Here application is Yang data plus JSON Click send. 153 00:09:45,760 --> 00:09:47,380 We told that there's no content. 154 00:09:47,470 --> 00:09:49,720 Let's do a send again here. 155 00:09:50,950 --> 00:09:53,080 Notice the interface has been deleted. 156 00:09:53,350 --> 00:09:55,270 Let's change that to interface. 157 00:09:55,270 --> 00:09:57,370 One, three, four, five. 158 00:09:57,820 --> 00:09:58,860 I should have checked that first. 159 00:09:58,870 --> 00:09:59,860 I'll do it again in a moment. 160 00:09:59,860 --> 00:10:02,290 But notice she has one, two, three, five. 161 00:10:03,980 --> 00:10:05,120 So that exists. 162 00:10:05,150 --> 00:10:06,890 One, two, three, four is deleted. 163 00:10:06,890 --> 00:10:07,850 But let's delete. 164 00:10:07,850 --> 00:10:09,440 One, two, three, five. 165 00:10:09,740 --> 00:10:11,360 No content has been returned. 166 00:10:11,390 --> 00:10:12,290 That's correct. 167 00:10:12,680 --> 00:10:16,040 So back on our get click send. 168 00:10:16,070 --> 00:10:19,130 Notice one, three, five is gone. 169 00:10:20,900 --> 00:10:23,120 Let's create one, two, three, four once again. 170 00:10:26,280 --> 00:10:28,980 If you want to, you can duplicate this tab. 171 00:10:29,010 --> 00:10:35,820 So now I've got two posts and what I could do is to oppose for one, two, three, four, and. 172 00:10:37,040 --> 00:10:38,600 One, two, three, four, five. 173 00:10:40,350 --> 00:10:42,540 So let's create. 174 00:10:42,540 --> 00:10:43,410 So it's a post. 175 00:10:43,410 --> 00:10:44,340 Let's create a loopback. 176 00:10:44,340 --> 00:10:45,300 One, two, three, four. 177 00:10:45,960 --> 00:10:47,190 It's created now. 178 00:10:47,190 --> 00:10:49,230 So back on our get statement. 179 00:10:49,320 --> 00:10:50,400 Click send. 180 00:10:50,580 --> 00:10:53,550 Notice one, two, three, four has been created. 181 00:10:54,360 --> 00:10:57,510 Let's create one, two, three, five, click send. 182 00:10:57,810 --> 00:10:58,940 It says created. 183 00:10:58,950 --> 00:10:59,820 That's good. 184 00:11:01,790 --> 00:11:04,610 Do get to gain it's created. 185 00:11:05,120 --> 00:11:08,150 But if I delete in this case. 186 00:11:08,150 --> 00:11:09,380 One, two, three, four. 187 00:11:09,770 --> 00:11:10,760 Click send. 188 00:11:11,180 --> 00:11:12,740 No content returned. 189 00:11:13,100 --> 00:11:16,850 Previously that loopback was created. 190 00:11:17,420 --> 00:11:18,530 But now it's gone. 191 00:11:19,250 --> 00:11:22,700 We've got loopback 200 and then loopback. 192 00:11:22,700 --> 00:11:24,230 One, two, three, five. 193 00:11:24,500 --> 00:11:26,210 One, two, three, four has gone. 194 00:11:26,240 --> 00:11:27,050 Let's delete. 195 00:11:27,050 --> 00:11:28,520 One, two, three, five. 196 00:11:28,550 --> 00:11:29,540 Click send. 197 00:11:31,960 --> 00:11:35,650 To get once again notice that loopback has gone. 198 00:11:36,010 --> 00:11:43,150 So I've shown you now how to use Postman to interact directly with a router and find out the interfaces 199 00:11:43,150 --> 00:11:43,930 on the router. 200 00:11:44,020 --> 00:11:48,680 Create a new interface as well as delete an interface rest APIs. 201 00:11:48,700 --> 00:11:54,310 That is an example of using rest APIs on an individual device, but I've also shown you previously how 202 00:11:54,310 --> 00:11:56,200 to do that with DNA center. 203 00:11:56,290 --> 00:12:01,450 So DNA center once again, rest API allows me to interact with a whole bunch of devices. 204 00:12:01,450 --> 00:12:03,520 Here I am interacting with one device. 205 00:12:04,270 --> 00:12:09,640 Now the comment I always get is David I could just use the clay might be quicker, but don't forget 206 00:12:09,640 --> 00:12:12,190 that with programming you can scale. 207 00:12:12,310 --> 00:12:16,090 So I'm going to show you now how to get to the interfaces of one router. 208 00:12:16,090 --> 00:12:21,220 But if I had 200 routers, I could write a Python script with a loop. 209 00:12:21,700 --> 00:12:28,930 No human would be able to compete with a Python script written properly or an Ansible script written 210 00:12:28,930 --> 00:12:33,430 properly where it's connecting to many devices and doing things on many devices. 211 00:12:33,430 --> 00:12:39,010 You may be quick on one device, but if I write my script right, there's no way a human can compete 212 00:12:39,130 --> 00:12:42,580 if I've got 100 or 200 devices or 1000 devices. 213 00:12:42,950 --> 00:12:43,180 Okay. 214 00:12:43,180 --> 00:12:45,550 So let me show you the Python script.