Get Webhook’d How to Build your Cisco DNA Center Integration
Gabriel Zapodeanu Technical Marketing Engineer, Cisco Systems @zapodeanu Gabriel Zapodeanu Technical Marketing Engineer, Cisco Systems
Gabriel Zapodeanu is a Network Programmability Technical Marketing Engineer, focused on Cisco DNA Center Platform, APIs and Integrations. His work includes developing programmability technical content, use cases, demos, SDKs, supporting Customers and Partners, publishing code on GitHub and videos on the Cisco EN Programmability YouTube channel. He is a Distinguished Cisco Live Speaker and a Cisco Live Master Series Speaker. Gabriel recently co-authored the book "IOS XE Programmability: Automating Device Lifecycle Management”. Network Troubleshooting The most time-consuming “status quo” task is troubleshooting
Source: 2019 Global Networking Trends Survey, 2061 completed surveys 3 Get Webhook’d – Cisco DNA Center Integration
• Automate the incident detection and logging • Initiate network issue assessment • Network operator notifications • End-user alerts integration • Lower cost of incident management • Decreased time between network issue and operator response
4 Cisco DNA Center - Programmability
Event Subscriptions Northbound REST APIs • Assurance Issues • Network Visibility • Assurance • Network • Webhooks • Network Topology • Policy • Wireless • Email • Network Design • SDA • Fabric • Provisioning • Templates • System Health • SWIM, PnP • Operations • AI/ML Insights • Event Mgmt
3rd Party Device Support Developer Resources • Device Pack SDK • Sample Code, Videos • Support for • Python SDK, Ansible • Network Visibility • Cisco DevNet • Network Topology • Sandboxes • Command Runner • Learning Labs • Template Editor • Documentation
5 API Lifecycle Management
• Beta -The API has been released in Beta for feedback and will be supported in the future. However, the API design is not frozen and therefore may include changes in the future: request / response payload, URL change , query / header parameters. • Supported - In production and supported. The design is frozen - breaking changes will require a new API version to be released • Deprecated - Still supported but will soon be sunset. A Sunset header will be used to programmatically communicate when it will be sunset. Typical support of API will be at least a year before it is retired. Example of response header - Sunset: Sat, 31 Dec 2018 23:59:59 GMT • Retired - No longer available or supported
https://developer.cisco.com/docs/dna-center/#!api-lifecycle
6 REST API Request and Response Exchange Retrieve the Cisco DNA Center information for the client with the MAC address {mac_address}, at the timestamp {epoch_time} url = DNAC_URL + ‘/dna/intent/api/v1/client-detail?timestamp=' + str(epoch_time) + '&macAddress=' + mac_address header = {'content-type': 'application/json', 'x-auth-token': dnac_jwt_token} client_response = requests.get(url, headers=header, verify=False)
Request Client Cisco DNA Center Your Application Response
{ "hostIp" : "10.93.140.35" , "hostMac" : "00:0c:29:6d:df:40" , "hostType" : "wired" , The response value will "connectedNetworkDeviceIpAddress" : "10.93.140.50" , be assigned to variable "connectedInterfaceName" : "GigabitEthernet1/0/13" , client_response "connectedNetworkDeviceName" : "NYC-9300" , "vlanId" : "123" , … }
client_json = client_response.json() client_info = client_json['response'][0] Parse JSON
7 Cisco DNA Center Event Notification Framework
Network Event Management Business Use Event Source Notification Method Infrastructure System case
Switching Automation Webhooks Mobile Event Apps Catalog
Routing Assurance Email NOC
Subscription ITSM Wireless DNAC System ServiceNow
Cisco DNA Center
8 Configure Cisco DNA Center Webhooks
• Name your subscription • Subscription Type – REST • Create a new endpoint • Description of the new endpoint • URL - https://your_app_url/webhook • Trust Certificate – yes • HTTP Method – POST • Authentication – Basic • Headers – Authorization + Basic YWRtaW4… • Subscribe
9 Webhook Request and Response Exchange
Webhook
{ "version": "", "instanceId": "ea6e28c5-b7f2-43a4-9937-def73771c5ef", (POST, PUT) "eventId": "NETWORK-NON-FABRIC_WIRED-1-251", "namespace": "ASSURANCE", "name": "", "description": "", "type": "NETWORK", "category": "ALERT", "domain": "Connectivity", "subDomain": "Non-Fabric Wired", "severity": 1, "source": "ndp", Response "timestamp": 1574457834497, "tags": "", Application Server Receiver "details": { "Type": "Network Device", (Status Code) "Assurance Issue Priority": "P1", "Assurance Issue Details": "Interface GigabitEthernet1/0/3 on the following network device is down: Local Node: PDX-M", "Device": "10.93.141.17", "Assurance Issue Name": "Interface GigabitEthernet1/0/3 is Down on Network Device 10.93.141.17", "Assurance Issue Category": "Connectivity", "Assurance Issue Status": "active" }, "ciscoDnaEventLink": "https://10.93.141.35/dna/assurance/issueDetails?issueId=ea6e28c5-b7f2-43a4-9937-def73771c5ef", "note": "To programmatically get more info see here - https://
Parse the notification Request for more details using REST APIs Execute next steps
10 REST APIs vs. Webhooks
• REST APIs: – Used by client applications to interact with servers – Using POST, GET, PUT, DELETE methods – The client application makes a request and the server responds – Any client applications may access them – Pull model • Webhooks: – Used by servers to publish data (or event notifications) – Pre-configured destinations for the data to be sent to – Using POST or PUT methods, typically – Server sends data when something new – Push Model
11 Integration Architectures - Options
3rd Party Cisco DNA Center API App
DNAC DNAC Platform
3rd Party DNAC API Middleware App Vendor API Platform
Vendor API 3rd Party Platform Adapter
rd Vendor & Cisco DNA Center API 3 Party App
DNAC DNAC Platform Adapter
12 Middleware App Integrations
• Enable data transform between Cisco DNA Center and other Platforms • Ability to build custom integrations with any platforms • Most feature-rich option • Proxy between Cisco DNA Center and 3rd Party Platform
Cisco DNA Center
13 Use Case
• Automate the process to detect issues and create new incidents • Update the new incident with impacted device information • Identify if any device configurations changes • Execute and log the Cisco DNA Center Assurance suggested actions • Log all received notifications for reporting and dashboards • Notifications sent to multiple platforms: Webex Teams, PagerDuty • Close the incident when resolved by Cisco DNA Center
14 Solution
• Build a Simple Webhook Receiver - Flask • Use Cisco DNA Center REST APIs – device details, command runner, issue enrichment details, tasks and file operations, template programmer • Use the Jira Service Desk REST APIs - create, update and close ticket • Notifications sent using the Webex Teams REST APIs – Adaptive Cards • PagerDuty notifications send using the Events REST APIs
15 Webex Teams App Workflow
Webhook Cisco DNA Center Receiver REST API
Webhook Notification REST API
PagerDuty
REST API
REST API
Webhook Notification
Other Cisco Jira Platforms Service Desk
16 Demo
Resources https://github.com/cisco-en-programmability
• Cisco DNA Center Cisco DevNet Code Exchange https://developer.cisco.com/codeexchange/platforms/dnac • DevNet Sandboxes • DevNet Labs • API Docs • Use Cases
• Cisco EN Programmability GitHub Organization: • Cisco DNA Center SDK • Sample Code • Cisco EN Programmability YouTube Channel http://cs.co/EN-Programmability-Videos
19 Cisco DNA Center on DevNet – Developer Guides Cisco DNA Center on DevNet – API Docs Code - https://github.com/zapodeanu/centos_flask_receiver Thank you