Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Practical Network Automation

You're reading from   Practical Network Automation Leverage the power of Python and Ansible to optimize your network

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788299466
Length 266 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Ratan Ratan
Author Profile Icon Ratan
Ratan
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Fundamental Concepts FREE CHAPTER 2. Python for Network Engineers 3. Accessing and Mining Data from Network 4. Web Framework for Automation Triggers 5. Ansible for Network Automation 6. Continuous Integration for Network Engineers 7. SDN Concepts in Network Automation

Network automation use case


As we have now interacted with multiple sections of Python and device interaction, let's create a use case to incorporate what we have learned so far. The use case is as follows:

Log into the router and fetch some information:

  1. task1(): Show the version, show the IP in brief, show the clock, and show the configured usernames on the router.
  2. task2(): Create another username on the test router with the password test and check whether we can log in successfully with the newly created username.
  3. task3(): Log in with the newly created username test, and delete all the other usernames from the running-config. Once this is done, return all the current usernames configured on the router to confirm whether only the test username is configured on the router.

Let's build a script to tackle these tasks one by one:

from netmiko import ConnectHandler

device = ConnectHandler(device_type='cisco_ios', ip='192.168.255.249', username='cisco', password='cisco')

def task1():
    output ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images