cisco devnet series · hostess: kara sullivan | cisco networking academy 14 september 2017 session...
TRANSCRIPT
![Page 1: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/1.jpg)
Speaker: Matt Denapoli
Hostess: Kara Sullivan | Cisco Networking Academy
14 September 2017
Session 2: Introduction to Coding
Cisco DevNet Series
![Page 2: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/2.jpg)
2© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Welcome to the 2nd session of the
Cisco DevNetwebinar series
• Use the Q and A panel to ask questions.
• Use the Chat panel to communicate with attendees and panelists.
• A link to a recording of the session will be sent to all registered attendees.
• Please take the feedback survey at the end of the webinar.
![Page 3: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/3.jpg)
3© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Matt DenapoliDeveloper EvangelistDevNet, Cisco
Giuseppe CinqueManager for the Emerging TechnologiesNetAcad, Cisco
Joining You Today:
![Page 4: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/4.jpg)
THIRD SESSION:
Intent Networks
25 October – 9:00 A.M. PT
Register at: http://bit.ly/DevNetSession3
Next DevNet Session
![Page 5: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/5.jpg)
Intro to Coding
September 2017
Solutions & Marketing
Giuseppe Cinque & Wadih Zaatar
![Page 6: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/6.jpg)
CarTelephone Router
The world is becoming connected and programmable
![Page 7: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/7.jpg)
This is the Digital Transformation
You can ernoll today to learn more http://bit.ly/IntroIoT
![Page 8: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/8.jpg)
WHERE THE NETWORK
IS PROGRAMMABLE
![Page 9: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/9.jpg)
DevNet Developer Evangelist
Matthew DeNapoli
Intro to CodingModule 01
![Page 10: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/10.jpg)
10© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Agenda
Getting Started
Learning APIC-EM
APIC-EM with Postman – HTTP Calls & Generate Code
Calling APIC-EM REST APIs with Python
Q&A
![Page 11: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/11.jpg)
11© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Learning APIC-EM
![Page 12: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/12.jpg)
• Easy QoS
• Application Priority
• Plug-n-Play
• Agent based control
• IWAN
• Policy based automated deployment
• Path Trace
• Path troubleshooting
APIC-EM Applications and Use Cases
![Page 13: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/13.jpg)
APIC-EM Uses REST
13
• Hosts
• Devices
• Users
• + more
Easy to use:
• In mobile apps
• In console apps
• In web apps
How does this work?
Cisco APIC-EM REST APIs
![Page 14: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/14.jpg)
Anatomy of a REST Request
14
Method
– POST, GET, PUT, DELETE (CRUD)
URL
– Example: http://{APIC-EMController}/api/v1/host
Authentication
– Basic HTTP, OAuth, none, Custom
Custom Headers
– HTTP Headers
– Example: Content-Type: application/json
Request Body
– JSON or XML containing data needed to complete request
![Page 15: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/15.jpg)
APIC-EM Example: Post Ticket
15
3rd Party
App
POST http://{APIC-EMController}/api/v1/ticket
Authorization Code returned in JSON
Application Policy Infrastructure Controller (APIC) Enterprise Module (EM)
Request
Response
![Page 16: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/16.jpg)
APIC-EM Example: Get Host
16
3rd Party
App
GET http://{APIC-EMController}/api/v1/host
List of Hosts returned in JSON
Application Policy Infrastructure Controller (APIC) Enterprise Module (EM)
Request
Response
![Page 17: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/17.jpg)
Using the API Reference Documentation
![Page 18: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/18.jpg)
API Reference Guide Details
![Page 19: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/19.jpg)
19© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
APIC-EM with Postman
![Page 21: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/21.jpg)
Postman
![Page 22: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/22.jpg)
Create a ticket
22
Request body
method url
![Page 23: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/23.jpg)
Header Specification
23
Header Key Header Value
![Page 24: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/24.jpg)
Ticket Returned in Response Body
24
Response Ticket
(save this)
![Page 25: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/25.jpg)
Use ticket in Header in all API Calls
25
Header Ticket
![Page 26: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/26.jpg)
APIC-EM – List of Hosts
26
Header
URL
Method
Response
Body
Return Code
![Page 27: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/27.jpg)
Using Postman to Generate Code
![Page 28: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/28.jpg)
Selecting the Code to Generate
![Page 29: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/29.jpg)
Generated Python Requests Code
![Page 30: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/30.jpg)
REST Demo – Using Postman
30
Get Hosts– Method: GET– Headers: ‘X-Auth-Token’ (insert your ticket value)– URL: http://<APIC-EMController>/api/v1/host
Get Devices– Method: GET– Headers: ‘X-Auth-Token’ (insert your ticket value)– URL: http://<APIC-EMController>/api/v1/network-device
Get Users– Method: GET– Headers: ‘X-Auth-Token’ (insert your ticket value)– URL: http://<APIC-EMController>/api/v1/user
![Page 31: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/31.jpg)
31© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
APIC-EM with Python
![Page 32: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/32.jpg)
First APIC-EM REST call from Python
32
import requests
import json
url = 'https://198.18.129.100/api/v1/ticket’
payload = {"username":“admin","password":"C1sco12345"}
header = {"content-type": "application/json”}
response= requests.post(url,data=json.dumps(payload), headers=header, verify=False)
print(response.text)
![Page 33: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/33.jpg)
Getting Ticket Function
apic_em_ip = "https://198.18.129.100/api/v1"
def get_token(url):
api_call = "/ticket"
payload = {"username": "admin", "password": "C1sco12345"}
headers = {"content-type": "application/json"}
url += api_call
response = requests.post(url, data=json.dumps(payload),
headers=headers, verify=False).json()
return response["response"]["serviceTicket"]
![Page 34: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/34.jpg)
Getting Network Device ID/Config Functions
def get_device_id(token, url):
api_call = "/network-device"
headers = {"X-AUTH-TOKEN": token}
url += api_call
response = requests.get(url, headers=headers, verify=False).json()
for item in response['response']:
if item['role'] == 'ACCESS':
return item['id']
![Page 35: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/35.jpg)
35© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Q&A
![Page 36: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/36.jpg)
36© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
This is the Digital Transformation
You can ernoll today to learn more http://bit.ly/IntroIoT
![Page 37: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/37.jpg)
THIRD SESSION:
Intent Networks
25 October – 9:00 A.M. PT
Register at: http://bit.ly/DevNetSession3
Next DevNet Session
![Page 38: Cisco DevNet Series · Hostess: Kara Sullivan | Cisco Networking Academy 14 September 2017 Session 2: Introduction to Coding Cisco DevNet Series ... Header Specification 23 Header](https://reader034.vdocument.in/reader034/viewer/2022042109/5e8938d7b76422254d2e0489/html5/thumbnails/38.jpg)