0% found this document useful (0 votes)
0 views

21. Network Programming and Automation

The document discusses the challenges of conventional network operations and maintenance (O&M), highlighting the inefficiencies of manual interventions. It introduces network automation, particularly using tools like Ansible and Python, to streamline tasks and improve efficiency. Additionally, it covers Python's advantages in network automation, including its simplicity and the use of libraries like telnetlib for automating device interactions.

Uploaded by

farhan riyas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

21. Network Programming and Automation

The document discusses the challenges of conventional network operations and maintenance (O&M), highlighting the inefficiencies of manual interventions. It introduces network automation, particularly using tools like Ansible and Python, to streamline tasks and improve efficiency. Additionally, it covers Python's advantages in network automation, including its simplicity and the use of libraries like telnetlib for automating device interactions.

Uploaded by

farhan riyas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

21.

Network Programming and


Automation

1. Difficulties in Conventional Network O&M


Conventional Network O&M relies heavily on manual intervention, where
engineers need to log in to each device, check configurations, and execute
commands.

This method is time-consuming and inefficient, and it also poses challenges


in auditing the changes made.

Examples:

Upgrading multiple devices in a network manually.

Performing configuration audits across an entire enterprise network.

Making routine changes like password updates across thousands of


devices.

2. Introduction to Network Automation


Network automation involves using tools to automate deployment,
operations, and O&M tasks, reducing manual dependency and improving
efficiency.

Common Tools: Ansible, SaltStack, Puppet, and Chef are popular in the
industry. They help automate network tasks such as configuration updates
and audits.

3. Programming-Based Network Automation with


Python
Python Automation: Python is widely used in network automation. Scripts
written in Python can automate repetitive tasks like device configuration.

Example Process:

21. Network Programming and Automation 1


1. Write a configuration file in a format understood by the devices (CLI
mode).

2. Write a Python script to upload and push this configuration to the


device using protocols like Telnet or SSH.

4. Overview of Programming Languages


Types:

Compiled Languages (e.g., C, C++): Require compilation before


execution.

Interpreted Languages (e.g., Python, Java): Executed line by line


without pre-compilation.

5. Python Programming for Network Automation


Python's Advantages: Python is popular for network automation because
of its simplicity and readability. The Python interpreter executes code
directly from the source, converting it into bytecode and running it on a
virtual machine (VM).

Functions and Modules:

Function: A block of reusable code (defined using def keyword) to


perform a single task.

Module: A file containing Python code, which can include functions,


classes, and variables, making it reusable across other programs.

6. Classes and Methods in Python


Class: A template for creating objects that bundle data and methods
together.

Method: A function defined within a class, usually referring to the instance


( self ) of the class.

7. Introduction to telnetlib

21. Network Programming and Automation 2


Overview: telnetlib is a Python library for handling Telnet communication.
It defines how commands and data are transmitted over Telnet using a
network virtual terminal (NVT).

Usage: The telnetlib.Telnet class provides methods for logging in and


executing commands on network devices.

7.1 Case Study: Using telnetlib to Log into a Device


Steps:

1. Configure the Telnet Service on the network device.

2. Verify the Telnet login procedure manually before coding.

3. Write and execute the Python code using telnetlib to automate the
login.

4. Verify the result to ensure that the script correctly logs into the device
and performs the required tasks.

21. Network Programming and Automation 3

You might also like