Professional Documents
Culture Documents
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 3
Cloud Computing
Video - Cloud and Virtualization
This video will cover the following:
• Data centers
• Cloud computing (SaaS, PaaS, and IaaS)
• Virtualization (Type 1 Hypervisor, Type 2 Hypervisor)
Cloud Computing
Cloud Overview
Cloud computing addresses a variety of data management issues:
• Enables access to organizational data anywhere and at any time
• Streamlines the organization’s IT operations by subscribing only to needed services
• Eliminates or reduces the need for onsite IT equipment, maintenance, and
management
• Reduces cost for equipment, energy, physical plant requirements, and personnel
training needs
• Enables rapid responses to increasing data volume requirements
Cloud Computing
Cloud Services
The three main cloud computing services defined by the National Institute of Standards
and Technology (NIST) in their Special Publication 800-145 are as follows:
• Software as a Service (SaaS) - The cloud provider is responsible for access to
applications and services that are delivered over the internet.
• Platform as a Service (PaaS) - The cloud provider is responsible for providing users
access to the development tools and services used to deliver the applications.
• Infrastructure as a Service (IaaS) - The cloud provider is responsible for giving IT
managers access to the network equipment, virtualized network services, and
supporting network infrastructure.
Cloud service providers have extended this model to also provide IT support for each of
the cloud computing services (ITaaS). For businesses, ITaaS can extend the capability of
the network without requiring investment in new infrastructure, training new personnel, or
licensing new software.
Cloud Computing
Cloud Models
There are four primary cloud models:
• Public clouds - Cloud-based applications and services made available to the general
population.
• Private clouds - Cloud-based applications and services intended for a specific
organization or entity, such as the government.
• Hybrid clouds - A hybrid cloud is made up of two or more clouds (example: part
private, part public), where each part remains a separate object, but both are
connected using a single architecture.
• Community clouds - A community cloud is created for exclusive use by a specific
community. The differences between public clouds and community clouds are the
functional needs that have been customized for the community. For example,
healthcare organizations must remain compliant with policies and laws (e.g., HIPAA)
that require special authentication and confidentiality.
Cloud Computing
Cloud Computing versus Data Center
These are the correct definitions of data center and cloud computing:
• Data center: Typically, a data storage and processing facility run by an in-house IT
department or leased offsite. Data centers are typically very expensive to build and
maintain.
• Cloud computing: Typically, an off-premise service that offers on-demand access to
a shared pool of configurable computing resources. These resources can be rapidly
provisioned and released with minimal management effort.
Data centers are the physical facilities that provide the compute, network, and storage
needs of cloud computing services. Cloud service providers use data centers to host their
cloud services and cloud-based resources.
Virtualization
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 9
Virtualization
Cloud Computing and Virtualization
• The terms “cloud computing” and
“virtualization” are often used
interchangeably; however, they mean
different things. Virtualization is the
foundation of cloud computing.
Without it, cloud computing, as it is
most-widely implemented, would not
be possible.
• Virtualization separates the operating
system (OS) from the hardware.
Various providers offer virtual cloud
services that can dynamically
provision servers as required. These
virtualized instances of servers are
created on demand.
Virtualization
Dedicated Servers
Historically, enterprise servers consisted of a
server OS, such as Windows Server or Linux
Server, installed on specific hardware. All of
a server’s RAM, processing power, and hard
drive space were dedicated to the service
provided (e.g., Web, email services, etc.).
• When a component fails, the service that is
provided by this server becomes unavailable.
This is known as a single point of failure.
• Dedicated servers were generally underused.
They often sat idle for long periods of time,
waiting until there was a need to deliver the
specific service they provide. These servers
wasted energy and took up more space than
was warranted by the amount of service
provided. This is known as server sprawl.
Virtualization
Server Virtualization
• Server virtualization takes advantage of idle
resources and consolidates the number of
required servers. This also allows for
multiple operating systems to exist on a
single hardware platform.
• The use of virtualization normally includes
redundancy to protect from a single point of
failure.
• The hypervisor is a program, firmware, or
hardware that adds an abstraction layer on
top of the physical hardware. The
abstraction layer is used to create virtual
machines which have access to all the
hardware of the physical machine such as
CPUs, memory, disk controllers, and NICs.
Virtualization
Advantages of Virtualization
One major advantage of virtualization is overall reduced cost:
• Less equipment is required
• Less energy is consumed
• Less space is required
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 16
Virtual Network Infrastructure
Type 1 Hypervisors
• Type 1 hypervisors are also called the “bare metal” approach because the hypervisor
is installed directly on the hardware. Type 1 hypervisors are usually used on
enterprise servers and data center networking devices.
• With Type 1 hypervisors, the hypervisor is installed directly on the server or
networking hardware. Then, instances of an OS are installed on the hypervisor, as
shown in the figure. Type 1 hypervisors have direct access to the hardware resources.
Therefore, they are more efficient than hosted architectures. Type 1 hypervisors
improve scalability, performance, and robustness.
Virtual Network Infrastructure
Installing a VM on a Hypervisor
• Type 1 hypervisors require a “management console” to manage the hypervisor.
Management software is used to manage multiple servers using the same hypervisor.
The management console can automatically consolidate servers and power on or off
servers as required.
• The management console provides recovery from hardware failure. If a server
component fails, the management console automatically moves the VM to another
server. Cisco Unified Computing System (UCS) Manager controls multiple servers
and manages resources for thousands of VMs.
• Some management consoles also allow server over allocation. Over allocation is
when multiple OS instances are installed, but their memory allocation exceeds the
total amount of memory that a server has. Over allocation is a common practice
because all four OS instances rarely require the all their allocated resources at any
one moment.
Virtual Network Infrastructure
The Complexity of Network Virtualization
• Server virtualization hides server resources. This
can create problems when using traditional
network architectures.
• VMs are movable, and the network administrator
must be able to add, drop, and change network
resources and profiles to support their mobility.
This process would be manual and time-
consuming with traditional network switches.
• Traffic flows differ from the traditional client-
server model. Typically, there is a considerable
amount of traffic being exchanged between
virtual servers (East-West traffic) that changes in
location and intensity over time. North-South
traffic is typically traffic destined for offsite
locations such as another data center, other
cloud providers, or the internet.
Virtual Network Infrastructure
The Complexity of Network Virtualization (Cont.)
• Dynamic ever-changing traffic requires a flexible approach to network resource
management. Existing network infrastructures can respond to changing requirements
related to the management of traffic flows by using Quality of Service (QoS) and
security level configurations for individual flows. However, in large enterprises using
multivendor equipment, each time a new VM is enabled, the necessary
reconfiguration can be very time-consuming.
• The network infrastructure can also benefit from virtualization. Network functions can
be virtualized. Each network device can be segmented into multiple virtual devices
that operate as independent devices. Examples include subinterfaces, virtual
interfaces, VLANs, and routing tables. Virtualized routing is called virtual routing and
forwarding (VRF).
Software-Defined Networking
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 21
Software-Defined Networking
Video - Software-Defined Networking
This video will cover the following:
• Network Programming
• SDN (Open Network Foundation, OpenFlow, and OpenStack)
• Controllers
Software-Defined Networking
Control Plane and Data Plane
A network device contains the following planes:
• Control plane - This is typically regarded as the brains of a device. It is used to make
forwarding decisions. The control plane contains Layer 2 and Layer 3 route forwarding
mechanisms, such as routing protocol neighbor tables and topology tables, IPv4 and
IPv6 routing tables, STP, and the ARP table. Information sent to the control plane is
processed by the CPU.
• Data plane - Also called the forwarding plane, this plane is typically the switch fabric
connecting the various network ports on a device. The data plane of each device is
used to forward traffic flows. Routers and switches use information from the control
plane to forward incoming traffic out the appropriate egress interface. Information in
the data plane is typically processed by a special data plane processor without the
CPU getting involved.
Software-Defined Networking
Control Plane and Data Plane (Cont.)
• CEF is an advanced, Layer 3 IP switching
technology that enables forwarding of
packets to occur at the data plane without
consulting the control plane.
• SDN is basically the separation of the
control plane and data plane. The control
plane function is removed from each
device and is performed by a centralized
controller. The centralized controller
communicates control plane functions to
each device. Each device can now focus
on forwarding data while the centralized
controller manages data flow, increases
security, and provides other services.
Software-Defined Networking
Control Plane and Data Plane (Cont.)
• The management plane is responsible for managing a device through its connection
to the network.
• Network administrators use applications such as Secure Shell (SSH), Trivial File
Transfer Protocol (TFTP), Secure FTP, and Secure Hypertext Transfer Protocol
(HTTPS) to access the management plane and configure a device.
• The management plane is how you have accessed and configured devices in your
networking studies. In addition, protocols like Simple Network Management Protocol
(SNMP), use the management plane.
Software-Defined Networking
Network Virtualization Technologies
Two major network architectures have been developed to support network virtualization:
• Software-Defined Networking (SDN) - A network architecture that virtualizes the
network, offering a new approach to network administration and management that
seeks to simplify and streamline the administration process.
• Cisco Application Centric Infrastructure (ACI) - A purpose-built hardware solution
for integrating cloud computing and data center management.
Software-Defined Networking
Network Virtualization Technologies (Cont.)
Components of SDN may include the following:
• OpenFlow - This approach was developed at Stanford University to manage traffic
between routers, switches, wireless access points, and a controller. The OpenFlow
protocol is a basic element in building SDN solutions.
• OpenStack - This approach is a virtualization and orchestration platform designed to
build scalable cloud environments and provide an IaaS solution. OpenStack is often
used with Cisco ACI. Orchestration in networking is the process of automating the
provisioning of network components such as servers, storage, switches, routers, and
applications.
• Other components - Other components include Interface to the Routing System
(I2RS), Transparent Interconnection of Lots of Links (TRILL), Cisco FabricPath (FP),
and IEEE 802.1aq Shortest Path Bridging (SPB).
Software-Defined Networking
Traditional and SDN Architectures
In a traditional router or switch architecture, the control plane and data plane functions
occur in the same device. Routing decisions and packet forwarding are the responsibility
of the device operating system. In SDN, management of the control plane is moved to a
centralized SDN controller. The figure compares traditional and SDN architectures.
Software-Defined Networking
Traditional and SDN Architectures (Cont.)
• The SDN controller is a logical entity that enables
network administrators to manage and dictate how the
data plane of switches and routers should handle
network traffic. It orchestrates, mediates, and facilitates
communication between applications and network
elements.
• The complete SDN framework is shown in the figure.
Note the use of Application Programming Interfaces
(APIs). An API is a standardized definition of the proper
way for an application to request services from another
application.
• The SDN controller uses northbound APIs to
communicate with the upstream applications, helping
network administrators shape traffic and deploy services.
The SDN controller uses southbound APIs to define the
behavior of the data planes on downstream switches
and routers. OpenFlow is a widely implemented
southbound API.
Controllers
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 30
Controllers
SDN Controller and Operations
• The SDN controller defines the
data flows between the
centralized control plane and the
data planes on individual routers
and switches.
• Each flow traveling through the
network must first get permission
from the SDN controller, which
verifies that the communication is
permissible according to the
network policy.
• All complex functions are
performed by the controller. The
controller populates flow tables.
Switches manage the flow tables.
Controllers
SDN Controller and Operations (Cont.)
Within each switch, a series of tables implemented in hardware or firmware are used to
manage the flows of packets through the switch. To the switch, a flow is a sequence of
packets that matches a specific entry in a flow table.
The three table types shown in the previous figure are as follows:
○ Flow Table - This table matches incoming packets to a particular flow and specifies the functions
that are to be performed on the packets. There may be multiple flow tables that operate in a
pipeline fashion.
○ Group Table - A flow table may direct a flow to a Group Table, which may trigger a variety of
actions that affect one or more flows.
○ Meter Table - This table triggers a variety of performance-related actions on a flow including the
ability to rate-limit the traffic.
Controllers
Video - Cisco ACI
• Very few organizations actually have the desire or skill to program the network using
SDN tools. However, the majority of organizations want to automate the network,
accelerate application deployments, and align their IT infrastructures to better meet
business requirements. Cisco developed the Application Centric Infrastructure (ACI)
to meet these objectives in more advanced and innovative ways than earlier SDN
approaches.
• Cisco ACI is a hardware solution for integrating cloud computing and data center
management. At a high level, the policy element of the network is removed from the
data plane. This simplifies the way data center networks are created.
Controllers
Core Components of ACI
There are three core components of the ACI architecture:
• Application Network Profile (ANP) - An ANP is a collection of end-point groups (EPG), their
connections, and the policies that define those connections.
• Cisco Nexus 9000 Series switches - These switches provide an application-aware switching
fabric and work with an APIC to manage the virtual and physical network infrastructure.
The APIC is positioned between the APN and the ACI-enabled network infrastructure. The
APIC translates the application requirements into a network configuration to meet those
needs.
Controllers
Core Components of ACI (Cont.)
Controllers
Spine-Leaf Topology
• The Cisco ACI fabric is composed of the
APIC and the Cisco Nexus 9000 series
switches using two-tier spine-leaf
topology, as shown in the figure. The leaf
switches attach to the spines, but they
never attach to each other. Similarly, the
spine switches only attach to the leaf and
core switches (not shown). In this two-
tier topology, everything is one hop from
everything else.
• When compared to SDN, the APIC
controller does not manipulate the data
path directly. Instead, the APIC
centralizes the policy definition and
programs the leaf switches to forward
traffic based on the defined policies.
Controllers
SDN Types
The Cisco Application Policy Infrastructure Controller - Enterprise Module (APIC-EM)
extends ACI aimed at enterprise and campus deployments. To better understand APIC-
EM, it is helpful to take a broader look at the three types of SDN:
• Device-based SDN: Devices are programmable by applications running on the device
itself or on a server in the network, as shown in the figure.
Controllers
SDN Types (Cont.)
Controller-based SDN: Uses a centralized controller that has knowledge of all devices in
the network, as shown in the figure. The applications can interface with the controller
responsible for managing devices and manipulating traffic flows throughout the network.
The Cisco Open SDN Controller is a commercial distribution of OpenDaylight.
Controllers
SDN Types (Cont.)
Policy-based SDN: Similar to controller-
based SDN where a centralized controller
has a view of all devices in the network,
as shown in the figure. Policy-based SDN
includes an additional Policy layer that
operates at a higher level of abstraction.
It uses built-in applications that automate
advanced configuration tasks via a
guided workflow and user-friendly GUI.
No programming skills are required.
Cisco APIC-EM is an example of this
type of SDN.
Controllers
APIC-EM Features
Cisco APIC-EM provides a single
interface for network management
including:
• Discovering and accessing device
and host inventories.
• Viewing the topology (as shown in
the figure).
• Tracing a path between end points.
• Setting policies.
Controllers
APIC-EM Path Trace
The APIC-EM Path Trace tool allows
the administrator to easily visualize
traffic flows and discover any
conflicting, duplicate, or shadowed
ACL entries. This tool examines
specific ACLs on the path between
two end nodes, displaying any
potential issues. You can see where
any ACLs along the path either
permitted or denied your traffic, as
shown in the figure. Notice how
Branch-Router2 is permit all traffic.
The network administrator can now
make adjustments, if necessary, to
better filter traffic.
Module Practice and Quiz
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 42
Module Practice and Quiz
What Did I Learn In This Module?
• Cloud computing involves large numbers of computers connected through a network that can be
physically located anywhere. Cloud computing can reduce operational costs by using resources
more efficiently.
• The three main cloud computing services defined by the National Institute of Standards and
Technology (NIST) are Software as a Service (SaaS), Platform as a Service (PaaS), and
Infrastructure as a Service (IaaS).
• The four types of clouds are public, private, hybrid, and community.
• Virtualization is the foundation of cloud computing. Virtualization separates the operating
system (OS) from the hardware.
• Virtualization reduces costs because less equipment is required, less energy is consumed, and
less space is required. It provides for easier prototyping, faster server provisioning,
increased server uptime, improved disaster recovery, and legacy support.
• With Type 1 hypervisors, the hypervisor is installed directly on the server or networking
hardware. A Type 2 hypervisor is software that creates and runs VM instances. It can be
installed on top of the OS or can be installed between the firmware and the OS.
Module Practice and Quiz
What Did I Learn In This Module?
• Type 1 hypervisors are also called the “bare metal” approach because the hypervisor is
installed directly on the hardware. Type 1 hypervisors have direct access to the
hardware resources and are more efficient than hosted architectures. They improve
scalability, performance, and robustness.
• Type 1 hypervisors require a “management console” to manage the hypervisor.
• Server virtualization hides server resources, such as the number and identity of
physical servers, processors, and OSs from server users. This practice can create
problems if the data center is using traditional network architectures.
• Traffic flows in the data center differ substantially from the traditional client-server
model. Typically, a data center has a considerable amount of traffic being exchanged
between virtual servers (East-West traffic) and can change in location and intensity
over time. North-South traffic occurs between the distribution and core layers and is
typically traffic destined for offsite locations such as another data center, other
cloud providers, or the internet.
• Two major network architectures have been developed to support network virtualization:
Software-Defined Networking (SDN) and Cisco Application Centric Infrastructure (ACI).
• Components of SDN may include OpenFlow, OpenStack, and other components .
Module Practice and Quiz
What Did I Learn In This Module?
• A network device contains a control plane and a data plane. The control plane is regarded as
the brains of a device.
• SDN is basically the separation of the control plane and data plane. The control plane function
is removed from each device and is performed by a centralized controller
• The SDN controller is a logical entity that enables network administrators to manage and
dictate how the data plane of switches and routers should handle network traffic.
• The data plane, also called the forwarding plane, is typically the switch fabric connecting the
various network ports on a device, and is used to forward traffic flows.
• The management plane is responsible for managing a device through its connection to the
network.
• The SDN controller is a logical entity that enables network administrators to manage and
dictate how the data plane of switches and routers should handle network traffic.
• Cisco developed the Application Centric Infrastructure (ACI) which is more advanced and
innovative than earlier SDN approaches.
• Cisco ACI is a hardware solution for integrating cloud computing and data center management.
• At a high level, the policy element of the network is removed from the data plane. This
simplifies the way data center networks are created.
Module Practice and Quiz
What Did I Learn In This Module?
• The three core components of the ACI architecture are Application Network Profile (ANP),
Application Policy Infrastructure Controller (APIC), and Cisco Nexus 9000 Series switches.
• The Cisco ACI fabric is composed of the APIC and the Cisco Nexus 9000 series switches using
two-tier spine-leaf topology.
• When compared to SDN, the APIC controller does not manipulate the data path directly. Instead,
the APIC centralizes the policy definition and programs the leaf switches to forward traffic
based on the defined policies.
• There are three types of SDN: Device-based SDN, Controller-based SDN, and Policy-based SDN.
• Policy-based SDN includes an additional Policy layer that operates at a higher level of
abstraction. Policy-based SDN is the most robust, providing for a simple mechanism to control
and manage policies across the entire network.
• Cisco APIC-EM is an example of policy-based SDN. Cisco APIC-EM provides a single interface for
network management including discovering and accessing device and host inventories, viewing the
topology, tracing a path between end points, and setting policies.
• The APIC-EM Path Trace tool allows the administrator to easily visualize traffic flows and
discover any conflicting, duplicate, or shadowed ACL entries. This tool examines specific ACLs
on the path between two end nodes, displaying any potential issues.
Module 13: Network Virtualization
New Terms and Commands
● cloud computing ▪ management plane
● Software as a Service (SaaS) ▪ Cisco Application Centric
● Platform as a Service (PaaS) Infrastructure (ACI)
● Infrastructure as a Service (IaaS) ▪ OpenFlow
● IT as a Service (ITaaS) ▪ OpenStack
● public clouds ▪ Application Network Profile (ANP)
● private clouds ▪ Application Policy Infrastructure
● hybrid clouds Controller (APIC)
▪ spin-leaf topology
● community clouds
▪ device-based SDN
● virtualization
▪ controller-based SDN
● abstraction layers
▪ policy-based SDN
● type 1 hypervisor
▪ Application Policy Infrastructure
● type 2 hypervisor Controller - Enterprise Module
● bare metal server (APIC-EM)
● software-defined networking ▪ APIC-EM path trace
● control plane
● data plane
Network Automation
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 50
Automation Overview
Video - Automation Everywhere
We now see automation everywhere, from self-serve checkouts at stores and automatic
building environmental controls, to autonomous cars and planes. How many automated
systems do you encounter in a single day?
Automation Overview
The Increase in Automation
These are some of the benefits of automation:
• Machines can work 24 hours a day without breaks, which results in greater output.
• Machines provide a more uniform product.
• Automation allows the collection of vast amounts of data that can be quickly analyzed
to provide information which can help guide an event or process.
• Robots are used in dangerous conditions such as mining, firefighting, and cleaning up
industrial accidents. This reduces the risk to humans.
• Under certain circumstances, smart devices can alter their behavior to reduce energy
usage, make a medical diagnosis, and improve automobile driving safety.
Automation Overview
Thinking Devices
• Many devices now incorporate smart technology to help to govern their behavior. This
can be as simple as a smart appliance lowering its power consumption during periods
of peak demand or as complex as a self-driving car.
• Whenever a device takes a course of action based on an outside piece of information,
then that device is referred to as a smart device. Many devices that we interact with
now have the word smart in their names. This indicates that the device has the ability
to alter its behavior depending on its environment.
• In order for devices to “think”, they need to be programmed using network automation
tools.
Data Formats
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 54
Data Formats
Video - Data Formats
This video covers the following:
• HTML
• XML
• JSON
• YAML
Data Formats
The Data Formats Concept
• Data formats are simply a way to store and exchange data in a structured format. One
such format is called Hypertext Markup Language (HTML). HTML is a standard
markup language for describing the structure of web pages.
• These are some common data formats that are used in many applications including
network automation and programmability:
XML Format
Data Formats
JSON Data Format
• JSON is a human readable data format used by applications for storing, transferring
and reading data. JSON is a very popular format used by web services and APIs to
provide public data. This is because it is easy to parse and can be used with most
modern programming languages, including Python.
Data Formats
JSON Data Format (Cont.)
GigabitEthernet0/0/0 is up, line protocol is up (connected)
Description: Wide Area Network
Internet address is 172.16.0.2/24
{
"ietf-interfaces:interface": {
Compare the IOS output "name": "GigabitEthernet0/0/0",
above to the output in "description": "Wide Area Network”,
JSON format. Notice that "enabled": true,
"ietf-ip:ipv4": {
each object (each
"address": [
key/value pair) is a {
different piece of data "ip": "172.16.0.2",
about the interface "netmask": "255.255.255.0"
including its name, a }
description, and whether ]
the interface is enabled. }
}
}
Data Formats
JSON Syntax Rules
These are some of the characteristics of JSON:
• It uses a hierarchical structure and contains nested values.
• It uses braces { } to hold objects and square brackets [ ] hold arrays.
• Its data is written as key/value pairs.
With JSON, the data known as an object is one or more key/value pairs enclosed in
braces { }. The syntax for a JSON object includes:
• Keys must be strings within double quotation marks " ".
• Values must be a valid JSON data type (string, number, array, Boolean, null, or
another object).
• Keys and values are separated by a colon.
• Multiple key/value pairs within an object are separated by commas.
• White space is not significant.
Data Formats
JSON Syntax Rules (Cont.)
At times a key may contain more than one value. This is known as an array. An array in
JSON is an ordered list of values. Characteristics of arrays in JSON include:
• The key followed by a colon and a list of values enclosed in square brackets [ ].
• The array is an ordered list of values.
• The array can contain multiple value types including a string, number, Boolean, object
or another array inside the array.
• Each value in the array is separated by a comma.
Data Formats
JSON Syntax Rules (Cont.)
For example, a list of IPv4 {
addresses might look like the "addresses": [
following output. The key is {
“addresses”. Each item in the list is "ip": "172.16.0.2",
a separate object, separated by "netmask": "255.255.255.0"
braces { }. The objects are two },
key/value pairs: an IPv4 address {
(“ip”) and a subnet mask "ip": "172.16.0.3",
(“netmask”) separated by a comma. "netmask": "255.255.255.0"
The array of objects in the list is },
also separated by a comma {
following the closing brace for each "ip": "172.16.0.4",
object. "netmask": "255.255.255.0"
}
]
}
Data Formats
YAML Data Format
YAML is another type of human readable data format used by applications for storing,
transferring, and reading data. Some of the characteristic of YAML include:
• It is like JSON and is considered a superset of JSON.
• It has a minimalist format making it easy to both read and write.
• It uses indentation to define its structure, without the use of brackets or commas.
Data Formats
YAML Data Format (Cont.)
{
"ietf-interfaces:interface": { • IOS output in JSON is to the left. The same data
"name": "GigabitEthernet2", in YAML format is below. It is easier to read.
"description": "Wide Area Network", • Similar to JSON, a YAML object is one or more
"enabled": true, key value pairs. Key value pairs are separated
"ietf-ip:ipv4": {
"address": [
by a colon without the use of quotation marks. In
{ YAML, a hyphen is used to separate each
"ip": "172.16.0.2", element in a list.
"netmask": "255.255.255.0"
}, ietf-interfaces:interface:
{ name: GigabitEthernet2
"ip": "172.16.0.3", description: Wide Area Network
"netmask": "255.255.255.0" enabled: true
}, ietf-ip:ipv4:
{ address:
"ip": "172.16.0.4", - ip: 172.16.0.2
"netmask": "255.255.255.0" netmask: 255.255.255.0
} - ip: 172.16.0.3
] netmask: 255.255.255.0
} - ip: 172.16.0.4
} netmask: 255.255.255.0
}
Data Formats
XML Data Format
XML is one more type of human readable data format used to store, transfer, and read
data by applications. Some of the characteristics of XML include:
• It is like HTML , which is the standardized markup language for creating web pages
and web applications.
• It is self-descriptive. It encloses data within a related set of tags: <tag>data</tag>
• Unlike HTML, XML uses no predefined tags or document structure.
XML objects are one or more key/value pairs, with the beginning tag used as the name of
the key: <key>value</key>
Data Formats
XML Data Format (Cont.)
<?xml version="1.0" encoding="UTF-8" ?>
The output shows the same data for <ietf-interfaces:interface>
<name>GigabitEthernet2</name>
GigabitEthernet2 formatted as an <description>Wide Area Network</description>
XML data structure. Notice how the <enabled>true</enabled>
values are enclosed within the object <ietf-ip:ipv4>
<address>
tags. In this example, each key/value <ip>172.16.0.2</ip>
pair is on a separate line and some <netmask>255.255.255.0</netmask>
lines are indented. This is not </address>
<address>
required but is done for readability. <ip>172.16.0.3</ip>
The list uses repeated instances <netmask>255.255.255.0</netmask>
of <tag></tag> for each element in </address>
<address>
the list. The elements within these <ip>172.16.0.4</ip>
repeated instances represent one or <netmask>255.255.255.0</netmask>
more key/value pairs. </address>
</ietf-ip:ipv4>
</ietf-interfaces:interface>
APIs
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 68
APIs
Video - APIs
This video will cover the following:
• Define API
• See examples of popular APIs:
• SOAP
• REST
• NETCONF
• RESTCONF
• Execute an API call in a browser and in Postman.
APIs
The API Concept
• An API is software that allows other applications to access its data or services. It is a
set of rules describing how one application can interact with another, and the
instructions to allow the interaction to occur. The user sends an API request to a
server asking for specific information and receives an API response in return from the
server along with the requested information.
• An API is similar to a waiter in a restaurant, as shown in the following figure.
APIs
An API Example
To really understand how APIs
can be used to provide data
and services, we will look at
two options for booking airline
reservations. The first option
uses the web site of a specific
airline. Using the airline’s web
site, the user enters the
information to make a
reservation request. The web
site interacts directly with the
airline’s own database and
provides the user with
information matching the
user’s request.
APIs
An API Example (Cont.)
A travel site can access this same
information, not only from a specific
airline but a variety of airlines. In this
case, the user enters in similar
reservation information. The travel
service web site interacts with the
various airline databases using APIs
provided by each airline. The travel
service uses each airline API to request
information from that specific airline,
and then it displays the information from
all the airlines on the its web page.
The API acts as a kind of messenger
between the requesting application and
the application on the server that
provides the data or service. The
message from the requesting
application to the server where the data
resides is known as an API call.
APIs
Open, Internal, and Partner APIs
An important consideration when developing an API is the distinction between open,
internal, and partner APIs:
• Open APIs or Public APIs - These APIs are publicly available and can be used with
no restrictions. Because these APIs are public, many API providers require the user to
get a free key, or token, prior to using the API. This is to help control the number of
API requests they receive and process.
• Internal or Private APIs - These are APIs that are used by an organization or
company to access data and services for internal use only. An example of an internal
API is allowing authorized salespeople access to internal sales data on their mobile
devices.
• Partner APIs - These are APIs that are used between a company and its business
partners or contractors to facilitate business between them. The business partner
must have a license or other form of permission to use the API. A travel service using
an airline’s API is an example of a partner API.
APIs
Types of Web Service APIs
A web service is a service that is available over the internet, using the World Wide Web.
There are four types of web service APIs:
• Simple Object Access Protocol (SOAP)
• Representational State Transfer (REST)
• eXtensible Markup Language-Remote Procedure Call (XML-RPC)
• JavaScript Object Notation-Remote Procedure Call (JSON-RPC)
Characteristic SOAP REST XML-RPC JSON-RPC
JSON, XML, YAML,
Data Format XML XML JSON
and others
First released 1998 2000 1998 2005
Flexible formatting and Well-established,
Strengths Well-established Simplicity
most widely used simplicity
REST
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 75
Software-Defined Networking
Video - REST
This video covers the following:
• Execute a REST API request
• Web browser - HTTP
• Command Line - CURL
• Application - Postman
• Programming Language - Python, Javascript, Ruby, and more
Software-Defined Networking
REST and RESTful API
• Web browsers use HTTP or HTTPS to request (GET) a web page. If successfully
requested (HTTP status code 200), web servers respond to GET requests with an
HTML coded web page.
• Simply stated, a REST API is an API that works on top of the HTTP protocol. It
defines a set of functions developers can use to perform requests and receive
responses via HTTP protocol such as GET and POST.
• Conforming to the constraints of the REST architecture is generally referred to as
being “RESTful”. An API can be considered “RESTful” if it has the following features:
• Client-Server - The client handles the front end and the server handles the back end. Either can
be replaced independently of the other.
• Stateless - No client data is stored on the server between requests. The session state is stored
on the client.
• The base Uniform Resource Identifier (URI) for the web service, such as http://example.com/resources.
• The data format supported by the web service. This is often JSON, YAML, or XML but could be any other data
format that is a valid hypertext standard.
• The set of operations supported by the web service using HTTP methods.
○ Format – This is usually JSON but can be YAML or XML. In this example JSON is requested.
○ Key - The key is for authorization, if required. MapQuest requires a key for their directions API. In the
above URI, you would need to replace “KEY” with a valid key to submit a valid request.
○ Parameters - Parameters are used to send information pertaining to the request. In this example, the
query parameters include information about the directions that the API needs so it knows what
directions to return: "from=San+Jose,Ca" and "to=Monterey,Ca".
Software-Defined Networking
Anatomy of a RESTful Request (Cont.)
Many RESTful APIs, including public APIs, require a key. The key is used to identify the
source of the request. Here are some reasons why an API provider may require a key:
• To authenticate the source to make sure they are authorized to use the API.
• Developer Web Site: Developers often maintain web sites that include information about the API, parameter
information, and usage examples. These sites may also allow the user to perform the API request within the
developer web page by entering in the parameters and other information.
• Postman: Postman is an application for testing and using REST APIs. It contains everything required for
constructing and sending REST API requests, including entering query parameters and keys.
• Python: APIs can also be called from within a Python program. This allows for possible automation,
customization, and App integration of the API.
• Network Operating Systems: Using protocols such as NETCONF (NET CONFiguration) and RESTCONF,
network operating systems are beginning to provide an alternative method for configuration, monitoring, and
management.
Configuration Management
Tools
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 84
Configuration Management Tools
Video - Configuration Management Tools
This video will cover the following:
• Compare configuration management tools including Ansible, Puppet, Chef and
SaltStack.
• Review plays, tasks, modules, parameters, and variables in a sample playbook
Configuration Management Tools
Traditional Network Configuration
Network devices have
traditionally been
configured by a network
administrator using the
CLI. Whenever there is
a change or new
feature, the necessary
configuration
commands must be
manually entered on all
of the appropriate
devices. This becomes
a major issue on larger
networks or with more
complex configurations.
Configuration Management Tools
Traditional Network Configuration
Simple Network Management Protocol
(SNMP) lets administrators manage
nodes on an IP network. With a
network management station (NMS),
network administrators use SNMP to
monitor and manage network
performance, find and solve network
problems, and perform queries for
statistics. SNMP is not typically used
for configuration due to security
concerns and difficulty in
implementation.
You can also use APIs to automate the
deployment and management of
network resources. Instead of manually
configuring ports, access lists, QoS,
and load balancing policies, you can
use tools to automate configurations.
Configuration Management Tools
Network Automation
We are rapidly moving away from a world
where a network administrator manages a
few dozen network devices, to one where
they are deploying and managing a great
number of complex network devices (both
physical and virtual) with the help of
software. This transformation is quickly
spreading to all places in the network. There
are new and different methods for network
administrators to automatically monitor,
manage, and configure the network. These
include protocols and technologies such as
REST, Ansible, Puppet, Chef, Python,
JSON, XML, and more.
Configuration Management Tools
Configuration Management Tools
Configuration management tools make use of RESTful API requests to automate tasks
and can scale across thousands of devices. These are some characteristics of the
network that administrators benefit from automating:
• Protocol configurations
• ACL configurations
Configuration management tools typically include automation and orchestration.
Automation is when a tool automatically performs a task on a system. Orchestration is the
arranging of the automated tasks that results in a coordinate process or workflow.
Configuration Management Tools
Configuration Management Tools (Cont.)
There are several tools available to make configuration management easier:
• Ansible
• Chef
• Puppet
• SaltStack
The goal of all of these tools is to reduce the complexity and time involved in configuring
and maintaining a large-scale network infrastructure with hundreds, even thousands of
devices. These same tools can benefit smaller networks as well.
Configuration Management Tools
Compare Ansible, Chef, Puppet, and SaltStack
Ansible, Chef, Puppet, and SaltStack all come with API documentation for configuring
RESTful API requests. All of them support JSON and YAML as well as other data
formats. The following table shows a summary of a comparison of major characteristics of
Ansible, Puppet, Chef, and SaltStack configuration management tools.
IBN and Cisco DNA Center
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 92
IBN and Cisco DNA Center
Video - Intent-Based Networking
• You have learned of the many tools and software that can help you automate your
network. Intent-Based Networking (IBN) and Cisco Digital Network Architecture (DNA)
Center can help you bring it all together to create an automated network.
• Play the video by Cisco’s John Apostolopoulos and Anand Oswal explaining how
artificial intelligence and intent-based networking (IBN) can improve networks.
IBN and Cisco DNA Center
Intent-Based Networking Overview
• IBN is the emerging industry model for the next generation of networking. IBN builds
on Software-Defined Networking (SDN), transforming a hardware-centric and manual
approach to designing and operating networks to one that is software-centric and fully
automated.
• Business objectives for the network are expressed as intent. IBN captures business
intent and uses analytics, machine learning, and automation to align the network
continuously and dynamically as business needs change.
• IBN captures and translates business intent into network policies that can be
automated and applied consistently across the network.
IBN and Cisco DNA Center
Intent-Based Networking Overview (Cont.)
Cisco views IBN as having three essential functions: translation, activation, and
assurance. These functions interact with the underlying physical and virtual infrastructure,
as shown in the figure.
Translation - The translation function enables the
network administrator to express the expected
networking behavior that will best support the
business intent.
Activation - The captured intent then needs to be
interpreted into policies that can be applied across
the network. The activation function installs these
policies into the physical and virtual network
infrastructure using networkwide automation.
Assurance - In order to continuously check that the
expressed intent is honored by the network at any
point in time, the assurance function maintains a
continuous validation-and-verification loop.
IBN and Cisco DNA Center
Network Infrastructure as Fabric
• From the perspective of IBN, the physical and
virtual network infrastructure is a fabric; an
overlay that represents the logical topology
used to virtually connect to devices. The
overlay limits the number of devices the
network administrator must program and
provides services and alternative forwarding
methods not controlled by the underlying
physical devices.
• The overlay is where encapsulation protocols
like IPsec and CAPWAP occur. Using an IBN
solution, the network administrator can use
policies to specify exactly what happens in the
overlay control plane. Notice that how the
switches are physically connected is not a
concern of the overlay.
IBN and Cisco DNA Center
Network Infrastructure as Fabric (Cont.)
The underlay network is the
physical topology that includes
all hardware required to meet
business objectives. The
underlay reveals additional
devices and specifies how these
devices are connected. End
points, such as the servers in
the figure, access the network
through the Layer 2 devices.
The underlay control plane is
responsible for simple
forwarding tasks.
IBN and Cisco DNA Center
Cisco Digital Network Architecture (DNA)
Cisco implements the IBN fabric
using Cisco DNA. The business
intent is securely deployed into the
network infrastructure (the fabric).
Cisco DNA then continuously
gathers data from a multitude of
sources (devices and applications)
to provide a rich context of
information. This information can
then be analyzed to make sure the
network is performing securely at its
optimal level and in accordance with
business intent and network
policies.
IBN and Cisco DNA Center
Cisco Digital Network Architecture (DNA) (Cont.)
IBN and Cisco DNA Center
Cisco Digital Network Architecture (DNA) (Cont.)
IBN and Cisco DNA Center
Cisco DNA Center
• Cisco DNA Center is the foundational controller and analytics platform at the heart of
Cisco DNA. It supports the expression of intent for multiple use cases, including basic
automation capabilities, fabric provisioning, and policy-based segmentation in the
enterprise network. Cisco DNA Center is a network management and command
center for provisioning and configuring network devices. It is a hardware and software
platform providing a ‘single-pane-of-glass’ (single interface) that focuses on
assurance, analytics, and automation.
• The DNA Center interface launch page gives you an overall health summary and
network snapshot. From here, the network administrator can quickly drill down into
areas of interest.
IBN and Cisco DNA Center
Cisco DNA Center (Cont.)
At the top, menus provide you access to DNA Center’s five main areas. As shown in the
figure, these are:
• Design - Model your entire network, from sites and buildings to devices and links, both physical
and virtual, across campus, branch, WAN, and cloud.
• Policy - Use policies to automate and simplify network management, reducing cost and risk while
speeding rollout of new and enhanced services.
• Provision - Provide new services to users with ease, speed, and security across your enterprise
network, regardless of network size and complexity.
• Assurance - Use proactive monitoring and insights from the network, devices, and applications to
predict problems faster and ensure that policy and configuration changes achieve the business
intent and the user experience you want.
• Platform - Use APIs to integrate with your preferred IT systems to create end-to-end solutions and
add support for multi-vendor devices.
IBN and Cisco DNA Center
Video - DNA Center Overview and Platform APIs
This video is an overview of the Cisco DNA Center GUI. It includes
design, policy, provision, and assurance tools used to control multiple
sites and multiple devices.
IBN and Cisco DNA Center
Video - DNA Center Design and Provision
This video is an overview of the Cisco DNA Center design and provision areas where you
can add new devices and update existing devices.
IBN and Cisco DNA Center
Video - DNA Center Policy and Assurance
This video explains the Cisco DNA Center policy and assurance areas. The policy area
enables you to create policies that reflect your organization’s business intent and deploy
them across networks and devices. Assurance provides you with an interface to quickly
view and troubleshoot devices connected to the network.
IBN and Cisco DNA Center
Video - DNA Center Troubleshooting User Connectivity
This video explains how to use Cisco DNA Center to troubleshoot devices.
Module Practice and Quiz
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 107
Module Practice and Quiz
What Did I Learn In This Module?
Module Practice and Quiz
What Did I Learn In This Module?
Module Practice and Quiz
What Did I Learn In This Module?
Module Practice and Quiz
What Did I Learn In This Module?
Module 14 : Network Automation
New Terms and Commands
How to be a Network Engineer in a
Programmable Age
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
The Network Engineer of Old
©
2
0
1
7
C
i
s
c
o
Meet Carl the Network Engineer
a
n
d
/
o
● Networking Skills
•
r
i
t
Spanning-Tree
s
a • Routing Protocols
•
f
f
i
QoS
l
i • VPN Design
•
a
t
e
Spanning-Tree
s
.
Programming Skills • VOIP
•
A
l
Fibre Channel
•
l
r
i
TCL • Security Policy
g
h • EEM • MPLS
•
t
s
r
Expect Scripts • Spanning-Tree
•
e
s
e
Did I mention Spanning-
r
v Tree?
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
The Network…
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
The Network…
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
The Network…
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
The Network…
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
The Network…
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
The Network…
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
L7: Application
Please don’t ask
n
d
/
o
r
about this…
i
t
s
L6: Presentation
a
f
f
i
l
i
L5: Session
a
t
e
s
.
A
L4: Transport Oh Yeah…We Got
l
l
r
i
g
h
t
L3: Network this
s
r
e
s
e
r
v
L2: Data Link
e
d
.
C
Black Magic
i
s
L1: Physical
c
o
C
o
n
The Four Ages of
Networking
©
2
0
1
7
C
i
s
c
o
a
n
d
/
o
r
i
t
s
a
f
Stone Age
f
i Spanning Tree
l
i
a VLANs
t
e
s
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
•
g
h
t
Network Controllers
•
s
r
e
IOT Networking
•
s
e
r
Cloud Networking
•
v
e
d
NFV
• ”DevOps”
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
i
s Carl has Embraced Programmability!
c
o
a
(and got himself a new shirt)
n
d
/
o
r
i
13
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 9
Introduction to API and python
warm up
Github
https://github.com/wleppens/PythonExperiments
How To Install PIP to Manage Python Packages
On Windows
https://phoenixnap.com/kb/install-pip-windows
Understanding and Using APIs
REST web service APIs
A REST web service API (REST API) is a
programming interface that communicates over
HTTP while adhering to the principles of the
REST architectural style
HTTP requests/responses
HTTP verbs
HTTP status codes
HTTP headers/body
Understanding and Using APIs
REST web service APIs
A REST web service API (REST API) is a
Request/reponses programming interface that communicates over
HTTP while adhering to the principles of the
Verbs REST architectural style
Get – download
Post – add new date (insert) Since REST APIs communicate over HTTP, they use
Put – update the same concepts as the HTTP protocol, such
Delete as:
curl Manual
● https://curl.haxx.se/docs/manual.html
curl
Curl is a command-line tool for transferring
data specified with URL syntax. It can be used
to execute http and other commands from the
command line
curl Manual
● https://curl.haxx.se/docs/manual.html
STATEMENTS:
What can be done with CURL can also be done with Python!
Not Executable :
chmod -x *.sh
Run your curl script!
https://www.youtube.com/watch?v=ij8yy-7EQ2Y
API key required!
API Security is in the header!
Add API Token and add a book:
# PREPARE
import requests
import json
from faker import Faker
APIHOST = "http://library.demo.local"
LOGIN = "cisco"
PASSWORD = "Cisco123!"
School Library API => Python script (2)
def getAuthToken():
r = requests.post(
f"{APIHOST}/api/v1/loginViaBasic",
auth = authCreds
)
if r.status_code == 200:
return r.json()["token"]
else:
raise Exception(f"Status code {r.status_code} and text {r.text}, while trying to Auth.")
School Library API => Python script (3)
def addBook(book, apiKey):
r = requests.post(
f"{APIHOST}/api/v1/books",
headers = {
"Content-type": "application/json",
"X-API-Key": apiKey
},
data = json.dumps(book)
)
if r.status_code == 200:
print(f"Book {book} added.")
else:
raise Exception(f"Error code {r.status_code} and text {r.text}, while trying to add book {book}.")
School Library API => Python script (4)
# EXECUTE
pip3 install –r requirements.txt : install the same packages in new virtual environment
https://www.analyticssteps.com/blogs/working-python-json-object
Labs to do:
4.5.5 - Lab - Explore REST APIs with API Simulator and Postman School library
API
Data Formats: Understanding and
using JSON, XML and YAML
A Network Programmability Basics Presentation
Network Programmability Basics/Programming Fundamentals/Data Formats: Understanding and using JSON, XML and YAML
©
2
0
1
7
C
i
s
c
o
a
Topics to Cover
n
d
/
o
r
• Importance of a Data Format
i
t
s
a
f
• Common Data Formats in
f
i
l
Programming
i
a
t
e
• Demystify XML
s
.
A
l
l
• Breakdown JSON
r
i
g
h
t
• Simplify YAML
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
C
o
n
Importance of a Data
Format
Know Your Audience
Interface IP-Address OK? Method Status Proto
col
GigabitEthernet1 10.0.2.15 YES DHCP up up
GigabitEthernet2 172.16.0.2 YES manual up up
GigabitEthernet3 172.17.0.1 YES manual up up
> ????
CARL Defy
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
{
"ietf-interfaces:interfaces": {
"interface": [
• Array/List
i
g
h
t
s
r { • Bool
e
s
e
"name": "GigabitEthernet2", • Object
r
v
"description": "Wide Area Network”,
e
d "enabled": true
.
C }
i
s
c
o
C
o
n
Demystify XML
©
2
0
1
7
C
i
s
c
o
XML- eXtensible Markup Language.
a
n
d
/
o
r
<?xml version="1.0" encoding="UTF-8" ?>
i
t
<interface xmlns="ietf-interfaces">
s
a <name>GigabitEthernet2</name>
f
f <description>
i
l Wide Area Network
i
a
t
A human readable data structure </description>
e
<enabled>true</enabled>
that applications use to
s
.
A <ipv4>
l
l
r store, transfer, and read data. <address>
i
g
<ip>172.16.0.2</ip>
h
t <netmask>255.255.255.0</netmask>
s
r </address>
e
s
e
</ipv4>
r
v
</interface>
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
i
s
c
o
XML
a
n
d
/
o
r
• Designed for the Internet
i
t
s
a • Schema or namespace defines
f
f
i
l
data model
i
a
t
e
• <tags></tags> surround
s
.
A
elements for structure and
l
l
r
i
layout
g
h
t
s
• Key/Value representation
r
e
s
• <key>value</key>
e
r
v
e
d
.
• Whitespace not significant
C
i
s
c
o
C
o
n
©
2
0
1
7
C
i
s
c
o
XML Object
a
n
d
/
o
r
i
• A related set of data surrounded
t
s
a
by <tags></tags>
f
f
i
l
i
• An object can contain other
a
t
e
objects or data entries
s
.
A
l
l
• <key>value</key> contained
r
i
g
within the object tags
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
i
s
c
o
XML List
a
n
d
/
o
r
i
▪ List of data
t
s
a
f
▪ Can be composed of XML objects
f
i
l
i
a
▪ Repeated instances of
t
e
s
<tags></tags> for each
.
A
l
element
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
Breakdown JSON
©
2
0
1
7
C
i
s
c
o
JSON - JavaScript Object Notation
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
A human readable data structure
e
▪
t
e
s - ip: 172.16.0.4
.
A
l
list element netmask: 255.255.255.0
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
Summing up
©
2
0
1
7
C
i
s
c
o
Review
a
n
d
/
o
r
i
• Importance of the Audience
t
s
a
f
f
• Common data formats in programming
i
l
i
• XML
a
t
e • JSON
s
• YAML
.
A
l
l
r
i
g
h
• Data Formats are mostly interchangeable
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
Working with data
©
2
0
1
7
C
i
s
c
o
Parsing
a
n
d
/
o
r
i
• Parsing means analyzing a message, breaking it into its
t
s
a
f
component parts, and understanding the purpose of each part
f
i
l
in context.
i
a
t
e
s
• Data parsing is the process of taking data in one format and
.
A
l
transforming it to another format
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
©
2
0
1
7
C
i
s
c
o
Parsing is needed when you need (examples):
a
n
d
/
o
r
i
• XML in Python
t
s
a
f
f
• JSON in Python
i
l
i
a
t
• YAML in Python
e
s
.
A • Serialization in Python
l
l
r
i
g
• ……
h
t
s
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
Useful Python Libraries for
Network Engineers
Libraries to Work with Data
Manipulating Data of All Formats
• XML - xmltodict • CSV
• pip install xmltodict • import csv
import xmltodict
• JSON
• import json
• YAML - PyYAML
• pip install PyYAML
import yaml
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Treat XML like Python Dictionaries with xmltodict
• Easily work with XML data
• Convert from XML - > Dict* and
back
• xmltodict.parse(xml_data)
• xmltodict.unparse(dict)
https://pypi.python.org/pypi/xmltodict
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
netprog_basics/programming_fundamentals/python_part_3/xml_example.xml
To JSON and back again with json
• JSON and Python go together
like peanut butter and jelly
• json.loads(json_data)
• json.dumps(object)
https://docs.python.org/3/library/json.html
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
netprog_basics/programming_fundamentals/python_part_3/json_example.json
YAML? Yep, Python Can Do That Too!
• Easily convert a YAML file to a
Python Object
• yaml.load(yaml_data)
• yaml.dump(object)
https://pypi.python.org/pypi/PyYAML/3.12
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
netprog_basics/programming_fundamentals/python_part_3/yaml_example.yaml
Import Spreadsheets and Data with csv
• Treat CSV data as lists
• csv.reader(file_object)
https://docs.python.org/3/library/csv.html
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
netprog_basics/programming_fundamentals/python_part_3/csv_example.csv
Python – Things you must know
What is a dictonary in
Python?
What is a dictonary in Python?
● Python’s implementation of a data structure
● A data structure for storing a group of objects
● Tree structure
● A dictonary is needed in order to be processed by python. It’s using
pointers!
● It’s using identation (blanc spaces
● A dictonary starts with curly brackets {}
● Curly brackets indicates it’s a complex structure
● A dictionary consists of a collection of key-value pairs
● Each key-value pair maps the key to its associated value
What is a dictonary in Python? (continuation)
● Python Dictionary is a set of key-value pairs. The keys are unique in a dictionary.
● A dictionary is an object of class dict. It’s an unordered collection.
● Dictionary keys must be immutable. So we can use string, numbers, tuple as dict key.
● If the tuple contains any mutable objects, we can’t use it as a dictionary key.
● We can’t use a List as a Dictionary key because they can be modified.
● A dictionary is created using a pair of braces {}. The key-value pairs are separated
using a comma.
● The dictionary keys and values can be of any types. They can also be None.
● The key and its value are separated using a colon.
● Dictionary records are indexed using the key.
Key and value pairs in a dictionary:
● KEY : VALUE
○ Value can be :
■ Atomic
■ Or a DICT
Data Type in Python:
● Data type
NEW_SPACE_ID = res_space.json()["id"]
for mbr in rec["group"]["members"]:
room_id = NEW_SPACE_ID
person_email = mbr["email"]
url2 = 'https://api.ciscospark.com/v1/memberships'
payload_member = {'roomId': room_id, 'personEmail': person_email}
res_member = requests.post(url2, headers=headers, json=payload_member)
Webex Rest API -- safer code
import requests
import json
api = WebexTeamsAPI(access_token=access_token)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 245
Version Control Systems
Types of Version Control Systems
• Version control, also called version control systems, revision control or source control, is a
way to manage changes to a set of files in order to keep a history of those changes.
• Benefits of version control are:
• Enables collaboration
• Accountability and visibility
• Work in isolation
• Safety
• Work anywhere
• There are three types of version control systems:
• Local
• Centralized
• Distributed
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 246
Version Control Systems
Types of Version Control Systems (Contd.)
Local Version Control
System (LVCS)
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 247
Version Control Systems
Types of Version Control Systems (Contd.)
Centralized Version Control
System (CVCS)
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 248
Version Control Systems
Types of Version Control Systems (Contd.)
Distributed Version Control
System (DVCS)
• DVCS is a peer-to-peer model.
• If the file does not change, Git uses a reference link to the last snapshot in the system instead of taking a
new and identical snapshot.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 250
Version Control Systems
Git (Contd.)
• Git is organized by 3s- three
stages and three states.
• A local repository is stored on the file system of a client machine, which is the same one on
which the git commands are being executed.
• A remote repository is stored somewhere other than the client machine, usually a server or
repository hosting service.
• A remote repository with Git continues to be a DVCS because the remote repository will contain
the full repository, which includes the code and the file history.
• When a client machine clones the repository, it gets the full repository without requiring to lock
it, as in a CVCS.
• After the local repository is cloned from the remote repository or the remote repository is
created from the local repository, the two repositories are independent of each other until the
content changes are applied to the other branch through a manual Git command execution.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 252
Version Control Systems
What is Branching?
• Branching enables users to work on code independently without affecting the main code in the
repository. When a repository is created, the code is automatically put on a branch called Master.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 253
Version Control Systems
GitHub and Other Providers
• Git and GitHub are not the same.
• While Git is an implementation of distributed version control and provides a command line
interface, GitHub is a service provided by Microsoft that implements a repository hosting
service with Git.
• In addition to providing the distributed version control and source code management
functionality of Git, GitHub provides additional features such as:
• code review
• documentation
• project management
• bug tracking
• feature requests
• GitHub introduced the concept of the ‘pull request’, which is a way of formalizing a request
by a contributor to review changes such as new code, edits to existing code, etc., in the
contributor's branch for inclusion in the project's main or other curated branches.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 254
Version Control Systems
Git Commands
Setting up Git
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 255
Version Control Systems
Git Commands (Contd.)
Command: git init
• To make a new or existing project a Git repository, use the following command:
$ git init <project directory>
where the <project directory> is the absolute or relative path to the new or existing project.
• For a new Git repository, the directory in the provided path will be created first, followed by the creation of
the .git directory.
Get an Existing Git Repository
• Git provides a git status command to get a list of files that have differences between the
working directory and the parent branch.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 257
Version Control Systems
Adding and Removing Files
Adding Files to the Staging Area
• Command: git add
• This command can be used more than once before the
Git repository is updated (using commit).
• Only the files specified in the git command can be
added to the staging area
• To add a single file to the staging area:
$ git add <file path>
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 258
Version Control Systems
Adding and Removing Files (Contd.)
Removing Files from the Git Repository
• There are two ways to remove files from the Git
repository.
• Option 1: git rm command is used to remove files
from the Git repository and add to the staging area.
• Command: git rm
• To remove the specified file(s) from the working
directory and add the change to the staging
area, use the following command:
$ git rm <file path 1> ... <file path n>
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 259
Version Control Systems
Adding and Removing Files (Contd.)
• To add the specified file(s) to be removed from the staging area without removing the file(s)
itself from the working directory, use the following command:
$ git rm --cached <file path 1> ... <file path n>
The git rm command will not work if the file is already in the staging area with changes.
• Option 2: This option is a two-step process. First use the regular filesystem command to
remove the file(s) and then add the file to the stage using the Git command.
$ rm <file path 1> ... <file path n>
$ git add <file path 1> ... <file path n>
This two step process is equivalent to using the git rm <file path 1> ... <file path n> command.
Using this option does not allow the file to be preserved in the working directory.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 260
Version Control Systems
Updating Repositories
Updating the Local Repository with the
Changes in the Staging Area
Command: git commit
• This command combines all the content
changes in the staging area into a single
commit and updates the local Git
repository.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 264
Version Control Systems
Branching Features
Creating and Deleting a Branch
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 266
Version Control Systems
Branching Features (Contd.)
Fast-Forward Merge
• A fast-forward merge is when the Git algorithm is able to apply the changes/commits from the
source branch(es) to the target branch automatically and without any conflicts.
Merge Conflicts
• A merge conflict is when Git is not able to perform a fast-forward merge because it does not
know how to automatically apply the changes from the branches together for the file(s).
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 267
Version Control Systems
Branching Features (Contd.)
Performing the Merge
• Git provides a git merge command to join two or more branches together.
• Command: git merge
• To merge a branch into the client's current branch/repository, use the below command:
$ git merge <branch name>
• To merge a branch into a branch that is not the client's current branch/repository, use the
following command:
$ git checkout <target branch name>
$ git merge <source branch name>
• To merge more than one branch into the client's current branch/repository, use the below
command:
$ git merge <branch name 1>...<branch name n>
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 268
Version Control Systems
.diff Files
What is a .diff file?
• A .diff file is used to show how two different versions of a file have changed.
• By using specific symbols, this file can be read by other systems to interpret how files can
be updated.
• The symbols and meanings in a unified diff file are:
Symbol Meaning
+ Indicates that the line has been added.
- Indicates that the line has been removed.
/dev/null Shows that a file has been added or removed.
or "blank" Gives context lines around changed lines.
@@ A visual indicator that the next block of information is starting. Within the changes for one
file, there may be multiple.
index Displays the commits compared.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 269
Version Control Systems
Lab - Software Version Control with Git
• In this lab, you will complete the following objectives:
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 270
©
2
0
1
7
C
i
s
c
o
Call to Action!
a
n
d
/
o
r
i
t
s
a
f
f
i
l
i
a
t
e
s
.
A
l
l
r
• NETCONF • YANG
l
r
i
g
h
t
s
• RESTCONF
• gRPC
r
e
s
e
r
v
e
d
.
C
i
s
c
o
C
o
n
API Libraries
Access Different APIs Easily
• REST APIs – requests
• pip install requests
import requests
• NETCONF – ncclient
• pip install ncclient
import ncclient
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
NETMIKO
● Python for Network Engineers - Netmiko Library
● https://pynet.twb-tech.com/blog/netmiko-python-library.html
Network Programmability Basics/Network Device APIs/Getting the “YANG” of it with Standard Data Models
Network Programmability Basics Modules
• Network Device APIs
Topics to Cover
• Model Driven Programmability
• What is YANG?
• Working with YANG Data Models
• Network Device Data in YANG
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
The Network is No Longer Isolated
What about SNMP?
• Typical config: SNMPv2 read-only
community strings
SNMP works • Typical usage: interface
“reasonably well for statistics queries and traps
• NETCONF • YANG
• RESTCONF
• gRPC
What is YANG?
Three Meanings of “YANG “
What is a Data Model?
• Person
• Gender - male, female, other
A data model is simply a well • Height - Feet/Inches or Meters
Industry Vendor
Standard Specific
https://github.com/YangModels/yang
Where to get the Models?
• https://github.com/YangModels/yang
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--rw link-up-down-trap-enable? enumeration {if-
mib}?
Example output edited for simplicity and brevity
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
netprog_basics/network_device_apis/yang/ietf-interfaces.yang
Using pyang module: ietf-interfaces
+--rw interfaces
Module Name
| +--rw interface* [nKaemey]
container
| +--rw name strinL
g eaf
| +--rw description? string
Python YANG Library
list
• | +--rw type identityref
| +--rw enaObplteiodn?al boolean
containe
+--ro last-change? yang:dateD
-aa ta
nd-tT
imyepe
list
+--ro if-index int32 {if-mib}?
• HTML: jstree
+--ro phys-address? yang:phys-address
+--ro higher-layer-if* interface-state-ref
r
Read +--ro lower-layer-if* interface-state-ref
Only +--ro speed? yang:gauge64
+--ro statistics
+--ro discontinuity-time yang:date-and-time
+--ro in-octets? yang:counter64
[OUTPUT REMOVED]
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Example edited for simplicity and brevity
Network Device Data in
YANG
Actual Device Data Modeled in YANG
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Use NETCONF to Retrieve ietf-interfaces data
• NETCONF details covered in
another session
• ncclient provides a Python
client for NETCONF
• Using built-in library to print
reply
• xml.dom.minidom
netprog_basics/network_device_apis/yang/device_info.py
netprog_basics/network_device_apis/yang/example1.py
Use NETCONF to Retrieve ietf-interfaces data
DevNet$ python example1.py
netprog_basics/network_device_apis/yang/device_info.py
netprog_basics/network_device_apis/yang/example1.py
Summing up
Review
• YANG is a Data Modeling Language
• YANG Modules are constructed to create standard data models for
network data
• YANG Data sent to or from a network device will be formatted in
either XML or JSON depending on the protocol (ex: NETCONF or
RESTCONF)
Goodbye SNMP <hello> NETCONF!
A Network Programmability Basics Presentation
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Understanding NETCONF
Introducing the NETCONF Protocol
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.1</capability>
<capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
<capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</capability>
result = m.get_config('running')
NETCONF Communications
NETCONF in Code with
Python
NETCONF and Python: ncclient
• Full NETCONF Manager
implementation in Python
• https://ncclient.readthedocs.io
• Simplifies connection and
communication.
• Deals in raw XML
From: http://ncclient.readthedocs.io/en/latest/
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Saying <hello> with Python and ncclient
• example1.py: Saying <hello>
• manager.connect() opens
NETCONF session with device
• Parameters: host & port, user &
password
• hostkey_verify=False
Trust cert
• Stores capabilities
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
netprog_basics/network_device_apis/netconf/device_info.py
netprog_basics/network_device_apis/netconf/example1.py
Understanding the Capabilities List
DevNet$ python example1.py
Here are the NETCONF Capabilities
urn:ietf:params:netconf:base:1.0
urn:ietf:params:netconf:base:1.1
.
urn:ietf:params:xml:ns:yang:ietf-interfaces?module=ietf-interfaces&revision=2014-05-08&features=pre-
provisioning,if-mib,arbitrary-names&deviations=ietf-ip-devs
.
http://cisco.com/ns/ietf-ip/devs?module=ietf-ip-devs&revision=2016-08-10
.
http://cisco.com/ns/yang/Cisco-IOS-XE-native?module=Cisco-IOS-XE-native&revision=2017-02-07
netprog_basics/network_device_apis/netconf/example2.py
Getting Interface Details
DevNet$ python example2.py
Interface Details:
Name: GigabitEthernet1
Description: DON'T TOUCH ME
Type: ianaift:ethernetCsmacd
MAC Address: 00:50:56:bb:74:d5
Packets Input: 592268689
Packets Output: 21839
netprog_basics/network_device_apis/netconf/example2.py
Configuring Interface Details
• example3.py: Editing
configuration with ncclient
• Constructing XML Config
Payload for NETCONF
• Sending <edit-config>
operation with ncclient
• Verify result
netprog_basics/network_device_apis/netconf/config-temp-ietf-interfaces.xml
netprog_basics/network_device_apis/netconf/example3.py
Configuring Interface Details
config-temp-ietf-interfaces.xml
• example3.py: Editing
configuration with ncclient
• Constructing XML Config
Payload for NETCONF
• Sending <edit-config>
operation with ncclient
• Verify result
netprog_basics/network_device_apis/netconf/config-temp-ietf-interfaces.xml
netprog_basics/network_device_apis/netconf/example3.py
Configuring Interface Details
• example3.py: Editing
configuration with ncclient
• Constructing XML Config
Payload for NETCONF
• Sending <edit-config>
operation with ncclient
• Verify result
netprog_basics/network_device_apis/netconf/config-temp-ietf-interfaces.xml
netprog_basics/network_device_apis/netconf/example3.py
Configuring Interface Details
DevNet$ python -i example3.py
Configuration Payload:
<config>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
<name>GigabitEthernet2</name>
<description>Configured by NETCONF</description>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">
ianaift:ethernetCsmacd
</type>
<enabled>true</enabled>
<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
<address>
<ip>10.255.255.1</ip>
<netmask>255.255.255.0</netmask>
</address>
</ipv4>
</interface>
</interfaces>
</config>
Network Programmability Basics/Network Device APIs/Learn to CRUD with GET, POST and DELETE using RESTCONF
Topics to Cover
• Understanding RESTCONF
• Using RESTCONF with
Postman
• Automate Your Network with
RESTCONF
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Understanding RESTCONF
RESTCONF Details
• https://tools.ietf.org/html/rfc8040
What about NETCONF?
RESTCONF Protocol Stack & Transport
Operations - HTTP CRUD
RESTCONF NETCONF
GET <get> , <get-config>
POST <edit-config> (operation="create")
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--rw link-up-down-trap-enable? enumeration {if-mib}?
Options Examples:
• depth=unbounded
Follow nested models to end. Integer also
supported
Key: • content=[all, config, nonconfig]
https://<ADDRESS>/<ROOT>/data>/<[YANG MODULE:]CONTAINER>/<LEAF>[?<OPTIONS>] Query option controls type of data returned.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential • fields=expr
Limit what leafs are returned
Using RESTCONF with
Postman
Postman: Powerful but Simple REST API Client
• Quickly test APIs in GUI
• Save APIs into Collections for
reuse
• Manage multiple environments
• Auto generate code from API
calls https://www.getpostman.com
• Standalone Application or
Chrome Plugin
Setup Environment for RESTCONF
• Add variables for host, and
credentials
• Reference anywhere with
{{variable name}} syntax
Step 1: Get Capabilities List via RESTCONF
• GET
/restconf/data/netconf-state/capabilities