
This course introduces Python 3 on Ubuntu, Napalm and Netconf for Huawei routers, and Ansible automation, covering OSPF configuration, backups, and network health checks.
How to remove Python 2.7, and install python 3.6, PIP3 (version 21.1.1) to get Ubuntu Linux desktop (16.04) terminal ready to develop python 3 scripts
Practise Python if Statement and how it works
Demonstrate Python for loop using range(7) to iterate from 0 to 6 and print each number.
Learn how the while loop in Python executes statements while a condition is true, using a countdown from five to one that prints n and decrements, ending with 100 stores.
Automate router configuration with a Python telnet library: log in, enter system view, and configure interface ethernet 1/0/5 with IP 192.168.5.1, then commit and verify.
sudo apt-get update
sudo apt-get install build-essential libssl-dev libffi-dev -y
pip install paramiko
pip install netmiko
#!/usr/bin/env python
# This to display ip interface brief on linux terminal with Netmiko connection to Huawei router
from netmiko import ConnectHandler
NE40E = {
'device_type':'huawei',
'ip':'10.1.1.2',
'username':'huawei',
'password':'Hamdy@123',
}
net_connect = ConnectHandler(**NE40E)
output = net_connect.send_command('display ip int brief')
print(output)
Napalm stands for network automation and programmability abstraction layer with multi-vendor support. The Python library provides a unified API to interact with diverse device operating systems and installs with pip.
#!/usr/bin/env python
# Connect to Huawei router with Napalm SSH connection, receive general info about the router
# selects the hostname to be printed separatelly
from napalm import get_network_driver
import pprint
driver = get_network_driver('huawei_vrp')
device = driver(hostname='10.1.1.2', username='huawei', password = 'Hamdy@123')
device.open()
get_facts = device.get_facts()
pprint.pprint(get_facts)
print(get_facts['hostname'])
#!/usr/bin/env python
# This script is to display ip interface brief
from napalm import get_network_driver
import pprint
driver = get_network_driver('huawei_vrp')
device = driver(hostname='10.1.1.2', username='huawei', password='Hamdy@123')
device.open()
get_interfaces_ip = device.get_interfaces_ip()
pprint.pprint(get_interfaces_ip)
#!/usr/bin/env python
# This script is to ping remote IP after logging to Huawei router
from napalm import get_network_driver
import pprint
driver = get_network_driver('huawei_vrp')
device = driver(hostname='10.1.1.2', username='huawei', password='Hamdy@123')
device.open()
ping_remote_ip = device.ping('10.1.1.9')
pprint.pprint(ping_remote_ip)
Leverage Python with Netmiko to enable OSPF on router p1 and p2, configuring interface ethernet 101 with a new OSPF area 0, then verify and save the changes.
Run a Python 3 script to back up the running configurations of two routers, NE41 and NE40, via SSH and save outputs to the backup_config_files directory.
Develop a Python 3 automated script to scan a user-specified IP across routers, ping the IP, and verify if it is live and configured on an interface.
Configure a network device interface using netconf with a Python script, applying a template to set the interface description, IP address, and subnet mask, then verify with interface brief.
Use Python with netconf to configure vlan on a router by loading a vlan template, applying a vlan id (3) via a yang api, and verifying the running configuration.
Install Ansible on Linux by setting up an inventory directory and hosts file, configuring localhost, and adding a switch host with IP 192.168.129.253 under the switches group.
Configure the cloud engine switch C12 800 with an Ansible playbook, setting the device name via the C_config network module. Execute the playbook and verify the name changes to Ansible_c12_800-1.
Configure VLANs, switch-ports, IP Interface
Welcome to Huawei Datacom Network Automation Developer Course, Network programming and automation became one of the most important network topics for building large automated networks that can scale and react easily to network changes. All daily network manual tasks should be converted into automated tasks to save time, increase productivity, and minimise human mistakes specially when it comes to large networks like Telecom Operator Networks. Python programming language is commonly and widely used for network engineers because of its simplicity and its rich network modules. Because Huawei is widely used in Telecom operators networks all over the world, it would be important to discuss automation tools Huawei devices.
Python Network Programming for Huawei devices course introduces how to install python 3 on Ubuntu linux with getting rid of python 2 when the terminal comes by default with python 2, and how to install network libraries (like Netmiko and Napalm) to connect with Huawei Routers like a robot (on behalf of a network engineer) that can automatically collect information and configure the routers with the usage of python scripts. The course is explained through practical exercises on EVE-NG and ubuntu Linux desktop.
Upon completing this course, you will be familiar with python 3 and network modules and build automated scripts to collect information about Huawei router with Netmiko library, and use napalm different libraries to collect information such as ‘display ip interface brief’ or ‘display version’, build automated script to check ip connectivity to a certain IP address with ping module and get the result, make automated configuration changes like configuring OSPF on Huawei Routers with the usage of both Netmiko and Napalm modules to know the difference between them.
You will also get familiar to NETCONF and how to practise it with Huawei NE40 to get information from it, and make configuration (configure interface and VLAN).
Ansible! you will learn about it, and how to perform automation for Huawei devices. It’s easy, simple to deploy with ready network modules, scalable, and doesn’t require python knowledge to deploy automated scripts.
The module gives you support on how to install all required modules on Ubuntu Linux.