
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
Explore Python 3 basics through practical exercises that prepare you to use Python 3 network modules and build automated scripts for upcoming modules.
Practise Python if Statement and how it works
Explore how Python dictionaries store key-value pairs and how to print a dictionary, measure its length, and extract the IP address 192.168.3.1 from a sample router dictionary.
Demonstrate Python for loop using range(7) to iterate from 0 to 6 and print each number.
Learn how the Python input function collects user values such as name, device hostname, and IP address, stores them in variables, and prints the inputs to demonstrate basic input handling.
Explore Python lists through a rotor example with a for loop and conditional prints for p1 and p2, then split input of host IPs into a list and print each.
Learn how to read from a file in a Python script, open a routers file, iterate lines, print each line, split lines into fields, and display names and IP addresses.
Explore how to write a Python script that prompts for router host names, collects interface name, IP, and subnet mask, and writes the formatted data to a file named router_interfaces.
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.
Discover netmiko, a multi-vendor library that simplifies establishing ssh connections to network devices using parameter-based configurations, enabling client or server interactions across devices.
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)
Learn to configure OSPF on Huawei routers via CLI, creating process 1, area 0, enabling interface 101, and assigning 192.168.1.1/30, with commit and verification steps using Python scripts.
Automate ospf configuration on two routers with napalm and python, setting interface ethernet 101 ip 192.168.1.1/30 and ospf area 0, with validation and commit.
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.
Explore netconf, the network configuration protocol that uses yang data modeling and xml over ssh to get, edit, and delete device configurations via rpc messages.
Install the netconf client on Ubuntu Linux, fix lxml errors by reinstalling it, and configure netconf server with a local user at privilege level 3 on port 830 ssh.
Test netconf connectivity between a linux client and a netconf server using a python script. Export netconf server capabilities to a file and verify netconf yang api capabilities.
Connect from a linux desktop to the router via netconf using a Python 3 script to fetch interface ethernet 1/0/2 details and format the XML response.
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.
Ansible automates network configuration by pushing modules over ssh for vendors like Cisco, Huawei, Juniper, F5, without agents on devices, and requires no Python knowledge while supporting netconf and restconf.
Learn how Ansible executes tasks with playbooks, manage hosts from an inventory, organize them into groups, and apply variables via group_vars and host_vars, guided by ansible.cfg.
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 an ethernet trunk with manual mode using an Ansible playbook to add interfaces 101 and 102 to the cloud engine switch 12 800.
Create an Ansible playbook to save the running configuration to the cloud engine switch 12 800, using the c_config_network module with save: yes, and verify the saved config.
Configure VLANs, switch-ports, IP Interface
This lecture demonstrates running an Ansible playbook for Huawei NE40E routers, configuring inventory and group vars, and applying a name change while switching ssh port to 22.
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.