Python has become one of the most common programming languages in terms of network programmability. It is one of the easier languages to get started with and interpret.
Ex: Set the Environment Information Needed to Access Your Lab!
The provided sample code in this repository will reference this file to get the information needed to connect to your lab backend. You provide this info here once and the scripts in this repository will access it as needed by the lab
In the above example python script starts with three quotation marks. These three quotation marks begin and end a multiple line string. A string is simply one or more alphanumeric characters. A string can comprise many numbers or letters, depending on the Python version in use.
JSON stores all its information in key/value pairs. JSON uses objects for its format. Each JSON object starts with a { and ends with a }. (These are commonly referred to as curly braces.)
For Ex:
{ "student": "john", "Section": "D", "friend": "Lee", “School:"VBV" }
JSON: JSON short for JavaScript Object Notation, is an open-standard file format or data interchange format that uses human-readable text to transmit data objects consisting of attribute - value pairs and array data types.
Syntax for JSON objects and arrays is given briefly as below;
{ } - Object: A series of key;value pairs enclosed in a matched pair of curly brackets, with an opening left curly bracket and its matching right curly bracket.
[ ] - Array: A series of values (not key:value pairs) enclosed in a matched pair of square brackets, with an opening left square bracket and its matching right square bracket .
Key:value pairs inside objects: All key:value pairs inside an object conform to the earlier rules for key:value pairs.
Values inside arrays; All values conform to the earlier rules for formatting values (for example, double quotes around text, no quotes around numbers.
Yet Another Next Generation (YANG): YANG (Yet Another Next Generation) is different from YAML, XML, and JSON. YANG is a data modeling language used to define data. YANG models data using a hierarchical, tree-based structure with nodes. YANG defines four nodes types. Each node has a name, and depending on the node type, the node might either define a value or contain a set of child nodes. The nodes types are:
1. leaf node - Contains a single value of a specific type
2. leaf-list node - Contains a sequence of leaf nodes
3. container node- Contains a grouping of related nodes containing only child nodes, which can be any of the four node types
4. list node - Contains a sequence of list entries, each of which is uniquely identified by one or more key leafs
YANG is a significantly refined data modeling language. It allows definition of constraints and separation of configuration and state elements. Unlike SNMP, NETCONF supports atomic transactions for configuration change. YANG Data models are very powerful in that they create a uniform way to describe data, which can be beneficial across vendors platforms. Data models allow network operators to configure, monitor, and interact with network devices holistically across the entire enterprise environment. YANG models make a clear distinction between configuration data and state information.
YANG (Yet Another Next Generation): YANG is a data modeling language used to model configuration data, state data, Remote Procedure Calls, and notifications for network management protocols
NETCONF: NETCONF is an IETF standard protocol that uses the YANG data models to communicate with the various devices on the network.
RESTCONF: An IETF draft that describes how to map a YANG specification to a RESTful interface.
The DNA center provides Path trace feature that allows the operator to visualize the path of an application or service from the client through all devices and to the server. A common, and critical, troubleshooting task that normally requires 6 to 10 minutes is displayed instantly upon clicking on a client or application. Troubleshoots issues along the network path. Using this feature, you can Run a path trace from source to destination to quickly get key performance statistics for each device along the network path Identify access control lists (ACLs) that may be blocking or affecting the traffic flow.
The REST API (or RESTful API) is one of the Northbound APIs supported by NSO, and the client can operate NSO using HTTP(S). The REST API itself is used not only in NSO but also in other products, and because it is easy to call from Javascript, it is often used in web portals and so on. The token is used to authenticate the restful API service. Restful API does not support authorization.
RESTCONF uses HTTP methods to identify the CRUD operations defined in NETCONF for accessing the YANG-defined data.
Following are the RESTCONF operations methods
GET: The GET method is used to obtain device configuration and state data.
HEAD: The HEAD method is used to query whether device configurations and status data exist.
POST: The POST method is used by the client to create configuration or invoke a remote procedure call (RPC) operation.
PATCH: The PATCH method is used to modify configuration.
DELETE: The DELETE method is used to delete the target data and returns the specific state.
HTTP functions are similar to the functions that most applications or databases use to store or alter data - whether the data is stored in a database or within the application. These functions are called "CRUD" functions. CRUD is an acronym that stands for CREATE, READ, UPDATE, and DELETE. For example, in a SQL database, the CRUD functions are used to interact with or manipulate the data stored in the database.
CRUD Function | Action | Use Case |
CREATE | Inserts data in a database or application | Updating a customer's home address in a database |
READ | Retrieves data from a database or application | Pulling up a customer's home address from a database |
UPDATE | Modifies or replaces data in a database or application | Changing a street address stored in a database |
DELETE | Removes data from a database or application | Removing a customer from a database |
Following table lists most common HTTP status codes as well as the reasons users may receive each one
HTTP Status Code | Result | Common Reason for Response |
200 | OK | Using GET or POST to exchange data with an API |
201 | Created | Creating resources by using a REST API call |
400 | Bad Request | Request failed due to client-side issue |
401 | Unauthorized | Client not authenticated to access site or API call |
403 | Forbidden | Access not granted based on supplied credentials |
404 | Not Found | Page at HTTP URL location does not exist or is hidden |
The EEM(Embedded Event manager is a software component of cisco IOS, XR, and NX-OS makes life easier for administrators by tracking and classifying events that take place on a router and providing notification options for those events. EEM allows you to automate tasks, perform minor enhancements and create workarounds.
EEM consists of three components:
Policies:Policies, or scripts, are either applets or Tcl scripts configured by the administrator.
EEM server:The EEM server is the director of EEM. When a configured event occurs, the associated action is implemented.
Event detectors:An event detector is used as a trigger, based on certain conditions. Some of these conditions include monitoring for syslog events, online insertion and removal (IOR), CLI input, and timers.
There are two independent pieces: Applets and Scripting
1. Applets are a collection of CLI commands
2. Scripts are actions coded up in TCL(interpreter language)
EEM uses event detectors and actions to provide notifications of those events:
EEM detectors can be:
1) SNMP:-Monitoring SNMP objects.
2) Syslog:-Responds to various syslog messages, allowing for matching on regular expressions.
3) Counter: Monitoring and responding to interface counter when cross threshold settings.
4) CLI events: Screening CLI input for a regular expression match.
5) None: This event detector is use to test EEM script/applet using "event manager run" command.
6) Timers :(Countdown, watchdog and CRON)
7) IP SLA and Netflows events.
Common regular expressions:
^ = Start of string
$ = End of string
. = Any single character
* = Zero or more instances
+ = One or more instance
? = Zero or one instance
EEM Actions can be:
1)Sending a email messages
2)Executing a cisco command.
3)Generating SNMP traps
4)Reloading the router
5)Generating priotized syslog messages
6)Switching to a secondary processor in a redundant platform
7)requesting system information when an event occurs(like sh tech,sh process cpu history).