Als pdf oder txt herunterladen
Als pdf oder txt herunterladen
Sie sind auf Seite 1von 38

Emerging Technologies Workshop

Network Programmability with Cisco APIC-EM


(Instruktoren-Qualifizierung)

Ulrich Stritzel
Berufliche Schule ITECH Elbinsel Wilhelmsburg, Hamburg
[email protected]
04.05.2019
!2

Agenda
• Chapter 1: Introduction to Basic Programming with Python
• Motivation zu diesem Kurs
• Getting (your equipment) ready
• Begriffsklärung
• Writing some code
• Chapter 2: Programming the APIC-EM
• Begriffsklärung
• Das APIC-EM REST Interface
• Klicken und gucken
• Final Exam
!3

Chapter 1: Introduction to Basic Programming with Python


From Zero to Hero
In 120 minutes
!5

Chapter 1: Introduction to Basic Programming with Python

Getting (your equipment) ready


• Schreiben Sie sich in den ITC-Kurs per Seat Token ein.
• Starten Sie den Kurs
• Folgen Sie den Schritten in Kap. 1.0.1.2 (Lab - PC Setup for Workshop)
• Laden Sie sich die „Script and data files“ herunter!
Demo…
!7

Chapter 1: Introduction to Basic Programming with Python

Begrifflichkeiten: CoPs = Community of Practice


• GitHub ist ein Onlinedienst, der Software-Entwicklungsprojekte auf seinen
Servern bereitstellt.
• Stack Overflow ist eine Internetplattform, auf der angemeldete Benutzer
Fragen zum Thema Softwareentwicklung diskutieren können.
• Cisco DevNet is Cisco's Entwickler Programm, vorrangig für Anwendungen
und Integration für und on Cisco Produkte.
!8

Chapter 1: Introduction to Basic Programming with Python

Begrifflichkeiten: Swagger

Swag = Jugendwort des Jahres 2011. 



Beschreibt in der Jugendsprache eine

„beneidenswerte lässig-coole Ausstrahlung“.

Bildquelle
!9

Chapter 1: Introduction to Basic Programming with Python

Begrifflichkeiten: Swagger

Swag = Jugendwort des Jahres 2011. 



Beschreibt in der Jugendsprache eine

„beneidenswerte lässig-coole Ausstrahlung“.

Bildquelle
!10

Chapter 1: Introduction to Basic Programming with Python

Begrifflichkeiten: Swagger
Das Swagger Framework ist ein Open-Source-Software-Framework, um
RESTful Webservices zu entwerfen, zu erstellen, zu dokumentieren und zu
nutzen.
RESTful Webservices (REST = Representational State Transfer) meint dabei
Webdienste, die APIs anbieten (API = Application Programming Interface).

→ Fokus: Standardisierte Form einer API-Dokumentation


!11

Chapter 1: Introduction to Basic Programming with Python

https://www.programmableweb.com/apis/directory
Beispiel: International Space Station (ISS)
http://api.open-notify.org
https://www.latlong.net
https://www.epochconverter.com
Let’s write some code…
!14

Chapter 1: Introduction to Basic Programming with Python


• Variablentypen (integer, float, string, boolean)
• Vergleichsoperatoren (>, <, ==, !=, >=, <=)
• Verknüpfen und ändern von Variablen und Variablentypen
• Listen und Verzeichnisse
• Eingaben
• If-Funktionen und Schleifen
• Zugriff auf externe Dateien
• Zugriff auf APIs
!15

Chapter 1: Introduction to Basic Programming with Python


• Variablentypen (integer, float, string, boolean)
• Vergleichsoperatoren (>, <, ==, !=, >=, <=)
• Verknüpfen und ändern von Variablen und Variablentypen
• Listen und Verzeichnisse
• Eingaben
• If-Funktionen und Schleifen
• Zugriff auf externe Dateien
• Zugriff auf APIs
Chapter 2: Programming the APIC-EM
!17

JSON vs. XML


• JSON = JavaScript Objekt Notation
• XML = Extensible Markup Language
• JSON ist kompakter als XML (Name-Werte-Paare statt Open-Close-Tags)
• JSON produziert kleinere Datenmengen
• JSON ist ähnlich wie JavaScript (bessere Lesbarkeit)

→ JSON ist besser für API-Daten geeignet!


!18

JSON data funktioniert wie Python-Listen und -Dictionarys


Die JSON-Daten rechts sind in Python
in der Variable json_data gespeichert
worden. Wie lautet die Anfrage, die den
Namen der dritten Person in der Liste
in der Variable iss_astronaut
speichern soll?

?
!19

JSON data funktioniert wie Python-Listen und -Dictionarys


Die JSON-Daten rechts sind in Python
in der Variable json_data gespeichert
worden. Wie lautet die Anfrage, die den
Namen der dritten Person in der Liste
in der Variable iss_astronaut
speichern soll?
iss_astronaut=
json_data[‚people’][2][name]
!20

Postman
… ist eine API-Entwicklungsumgebung um z.B. API-Requests durchzuführen
und REST-APIs auf Funktion zu prüfen.
!21

Chapter 2: Programming the APIC-EM

Cisco APIC-EM?
!22

Chapter 2: Programming the APIC-EM

Cisco APIC-EM =
Cisco Application Policy Infrastructure Controller - Enterprise Modul
!23

Chapter 2: Programming the APIC-EM


Cisco Application Policy Infrastructure Controller Enterprise-Modul –
Netzwerkkonfiguration und Bereitstellung vereinfachen
Der Cisco Application Policy Infrastructure Controller (APIC) bildet die Basis für die
anwendungszentrische Infrastruktur (Application Centric Infrastructure, ACI) der Cisco ONE-
Plattform. Das Cisco APIC Enterprise-Modul dient dabei zur Erweiterung des Cisco APIC vom
Rechenzentrum auf WAN- und Access-Domänen. Dadurch kann der Cisco APIC das
Netzwerk im Rahmen der Cisco ONE-Plattform auch für WAN und Zugriff abstrahieren und
automatisieren. Das Cisco APIC Enterprise-Modul bringt SDN (Software-defined Networking)
in die ACI und bildet die Steuerungsebene der Cisco ONE Enterprise Networks Architecture.
Der Controller ist umfassend programmierbar. So kann die IT-Abteilung die Konfiguration des
Netzwerks automatisieren und schnell auf neue Geschäftsmöglichkeiten reagieren.

Quelle: https://www.cisco.com/c/de_de/products/cloud-systems-management/application-policy-infrastructure-controller-enterprise-module/index.html
!24

Chapter 2: Programming the APIC-EM


Cisco Application Policy Infrastructure Controller Enterprise-Modul –
Netzwerkkonfiguration und Bereitstellung vereinfachen
Der Cisco Application Policy Infrastructure Controller (APIC) bildet die Basis für die
anwendungszentrische Infrastruktur (Application Centric Infrastructure, ACI) der Cisco ONE-
Plattform. Das Cisco APIC Enterprise-Modul dient dabei zur Erweiterung des Cisco APIC vom
Rechenzentrum auf WAN- und Access-Domänen. Dadurch kann der Cisco APIC das Netzwerk
im Rahmen der Cisco ONE-Plattform auch für WAN und Zugriff abstrahieren und
automatisieren. Das Cisco APIC Enterprise-Modul bringt SDN (Software-defined Networking)
in die ACI und bildet die Steuerungsebene der Cisco ONE Enterprise Networks Architecture.
Der Controller ist umfassend programmierbar. So kann die IT-Abteilung die Konfiguration des
Netzwerks automatisieren und schnell auf neue Geschäftsmöglichkeiten reagieren.

Quelle: https://www.cisco.com/c/de_de/products/cloud-systems-management/application-policy-infrastructure-controller-enterprise-module/index.html
!25

Network programmability concepts

SDN: Control Plane and Data Plane


Control Plane
Hardware Purpose Example Processes
Device makes decisions about where routing protocols, spanning
CPU traffic is sent tree, AAA, SNMP, CLI

ingress egress

Data Plane
Hardware Purpose Example Processes
Dedicated forwards traffic to the selected packet switching, L2 switching,
ASICs destination QoS, policies, ACLs

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 13
!26

Network programmability concepts

Traditional and SDN Architectures


SDN Architecture
with Centralized Control Plane
Control Plane
Traditional Architecture
(SDN Controller)

Control Control Control


Plane Plane Plane

Data Data Data Data Data Data


Plane Plane Plane Plane Plane Plane

Device 1 Device 2 Device 3 Device 1 Device 2 Device 3

OpenFlow is a protocol between SDN controllers and network


devices, as well as a specification of the logical structure of the
network switch functions.
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 14
!27

Network programmability concepts

OpenFlow SDN Model

Topology Routing Switching ... Applications

REST APIs Northbound APIs

SDN Controller
OpenFlow based controller
(control plane)
OpenFlow Southbound API

Physical Topology
(data plane)
Servers

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 15
!28

Network programmability concepts

Network-wide Abstractions Simplify the Network


Application
Programming Interfaces
(APIs) enable control
between layers.

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 16
!29

Network programmability concepts

Cisco SDN Model with APIC-EM


WebUI Orchestration Business apps Collaboration
Applications
Monitoring Policy Troubleshooting ...

REST APIs Northbound APIs

Cisco SDN Controller


APIC-EM

SNMP SSH Telnet Southbound APIs

Physical Topology
(data plane fabric)

Computers, Servers, IoT, etc.

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 17
!30

Chapter 2: Programming the APIC-EM

Interacting mit APIC-EM – Wie geht das?


• API (Application Programming Interface/
Anwendungsprogrammierschnittstelle)
• Requests (sending request, requesting token (bei APIC-EM: „service
ticket“), building request)
• In Python: modul „requests“ muss importiert werden
• Erfolgreicher request! („HTTP-Status-Code“)
!31

Chapter 2: Programming the APIC-EM

Die wichtigsten HTTP-Status-Codes (vgl. https://www.restapitutorial.com/httpstatuscodes.html)


2xx Success 4xx Client Error
200 OK 400 Bad Request
201 Created 401 Unauthorized
204 No Content 403 Forbidden
404 Not Found
3xx Redirection 409 Conflict
304 Not Modified
5xx Server Error
500 Internal Server Error
!32

Chapter 2: Programming the APIC-EM

Wie funktioniert das?


!33

Chapter 2: Programming the APIC-EM

Anatomy of a REST Request


REST requests require the following elements (requirements may differ
depending on the API):
Method
– GET (retrieve), POST (create), PUT (update), DELETE (remove)

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
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 30

30
!34

Chapter 2: Programming the APIC-EM

What is in the Response?


HTTP Status Codes
– http://www.w3.org/Protocols/HTTP/HTRESP.html
– 200 OK
– 201 Created
– 401, 403 Authorization error
– 404 Resource not found
– 500 Internal Error
Headers
Body
– JSON
– XML
Example output of a HTTP response in the Postman application
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 31

31
!35

Network programmability concepts

APIC-EM – Log in
Virtualized APIC-EM Controllers are available in several DevNet Sandboxes:

Always On, NetAcad instances


• For NetAcad users only
• https://DevNetSBX-NetAcad-APICEM-1.cisco.com
• https://DevNetSBX-NetAcad-APICEM-2.cisco.com
• https://DevNetSBX-NetAcad-APICEM-3.cisco.com
• User/PW: Ask your instructor

Always on, public instance


• For to all DevNet users
• https://SandBoxAPICEM.cisco.com
• User: devnetuser PW: Cisco123!

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 20
Demo…
!37

Und jetzt ans Eingemachte…


• 1.0.1.2: Lab - PC Setup for Workshop
• 1.2.1.5: Activity - Write, Save, and Run Your First Program
• 1.2.3.3: Activity - Troubleshoot List and Dictionary Code
• 1.2.6.4: Activity – Create a Script to Allow User to Add Devices
• 1.3.3: Parsing JSON with Python (alle Activities)
• 2.1.2.4: Activity - APIC-EM Topology Page
• 2.2.1.6: Activity - APIC-EM Swagger Documentation
• 2.3: Putting It All Together
Vielen Dank
und
weiterhin einen spannenden Akademietag!

Das könnte Ihnen auch gefallen