Skip to Main Content
Mastering Python Networking - Second Edition
book

Mastering Python Networking - Second Edition

by Eric Chou
August 2018
Intermediate to advanced content levelIntermediate to advanced
466 pages
10h 23m
English
Packt Publishing
Content preview from Mastering Python Networking - Second Edition

Pyeapi examples

Now, we are ready to take a look around the usage. Let's start by connecting to the EOS node by creating an object in the interactive Python shell:

Python 3.5.2 (default, Nov 17 2016, 17:05:23)[GCC 5.4.0 20160609] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import pyeapi>>> arista1 = pyeapi.connect_to('Arista1')

We can execute show commands to the node and receive the output:

>>> import pprint>>> pprint.pprint(arista1.enable('show hostname'))[{'command': 'show hostname', 'encoding': 'json', 'result': {'fqdn': 'arista1', 'hostname': 'arista1'}}]

The configuration field can be either a single command or a list of commands using the config() method:

>>> arista1.config('hostname arista1-new') ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python Networking

Mastering Python Networking

Eric Chou
Learning Python Networking - Second Edition

Learning Python Networking - Second Edition

José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington

Publisher Resources

ISBN: 9781789135992Supplemental Content