• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

pyIOSXR/H16-Apr-2018-771499

pyIOSXR.egg-info/H03-May-2022-1312

test/H16-Apr-2018-750506

MANIFEST.inH A D16-Apr-201825 21

PKG-INFOH A D16-Apr-2018420 1312

README.mdH A D16-Apr-20186.2 KiB214176

setup.cfgH A D16-Apr-201879 85

setup.pyH A D16-Apr-20181.5 KiB4320

README.md

1[![PyPI](https://img.shields.io/pypi/v/pyiosxr.svg)](https://pypi.python.org/pypi/pyIOSXR)
2[![PyPI](https://img.shields.io/pypi/dm/pyiosxr.svg)](https://pypi.python.org/pypi/pyIOSXR)
3[![Build Status](https://travis-ci.org/fooelisa/pyiosxr.svg?branch=master)](https://travis-ci.org/fooelisa/pyiosxr)
4[![Coverage Status](https://coveralls.io/repos/github/fooelisa/pyiosxr/badge.svg?branch=master)](https://coveralls.io/github/fooelisa/pyiosxr?branch=master)
5
6
7pyIOSXR: Python library to manage devices running IOS-XR using the XML agent
8============================================================================
9
10pyIOSXR is a Python library that facilitates communication with Cisco devices running IOS-XR through the XML agent.
11Initially was developed by Elisa Jasinska [@fooelisa](https://github.com/fooelisa) and integrated in [NAPALM](https://github.com/napalm-automation/napalm-iosxr).
12It is now maintained by Mircea Ulinic [@mirceaulinic](https://github.com/mirceaulinic)
13
14Requirements
15=============
16
17* netmiko >= 0.5.2
18* lxml >= 3.4.2
19
20* IOS-XR >= 5.1.0
21
22
23Install
24=======
25
26Install via pip:
27```bash
28pip install pyIOSXR
29```
30
31For upgrade:
32```bash
33pip install --upgrade pyIOSXR
34```
35
36Usage
37======
38
39Firstly make sure that the XML agent is properly enabled on the device:
40
41    # xml agent tty iteration off
42
43
44Documentation
45=============
46
47### Connect and lock config
48Connect to an IOS-XR device and auto-lock config:
49```python
50>>> from pyIOSXR import IOSXR
51>>> device = IOSXR(hostname='lab001', username='ejasinska', password='passwd', port=22, timeout=120)
52>>> device.open()
53```
54
55### Connect without auto-lock
56Connect to an IOS-XR device withoug locking the config:
57```python
58>>> from pyIOSXR import IOSXR
59>>> device = IOSXR(hostname='lab001', username='ejasinska', password='passwd', port=22, timeout=120, lock=False)
60>>> device.open()
61```
62
63### Lock and unlock manually
64```python
65If we connected to the device without locking the config, we might want to lock/unlock it later:
66>>> device.lock()
67>>> ...
68>>> device.unlock()
69```
70
71### Load and Compare Config
72Load a candidate configuration from a file and show the diff that is going to
73be applied when committing the config:
74```python
75>>> device.load_candidate_config(filename='unit/test/config.txt')
76>>> device.compare_config()
77---
78+++
79@@ -704,0 +705,3 @@
80+interface TenGigE0/0/0/21
81+ description testing-xml-from-file
82+!
83```
84
85### Get current loaded candidate config
86Get the currently pending changes from the candidate configuration loaded by
87load_candidate_config(). candidate can be merged with the current
88running configuration by applying the "merge" keyword
89```python
90>>> device.get_candidate_config(merge=False, formal=False)
91!! IOS XR Configuration 5.2.2
92interface GigabitEthernet0/0/0/0
93 description test
94!
95end
96```
97
98### Discard Candidate Config
99If an already loaded configuration should be discarded without committing it,
100call discard_config():
101```python
102>>> device.discard_config()
103>>> device.compare_config()
104>>>
105```
106
107### Load, Compare and Merge Config
108If you want to commit the loaded configuration and merge it with the existing
109configuration, call commit_config():
110(comment and label is optional parameters)
111```python
112>>> device.load_candidate_config(filename='unit/test/other_config.txt')
113>>> device.compare_config()
114---
115+++
116@@ -704,0 +705,3 @@
117+interface TenGigE0/0/0/21
118+ description testing-xml-from-the-other-file
119+!
120>>> device.commit_config(label='my label', comment='my comment')
121```
122
123### Merge Config with Timer based autorollback
124If you want to commit the loaded configuration with a timed autorollback that
125needs to be confirmed use the confirmed= keyword on the commit, parameters is
126seconds to wait before autorollback, values from 30 to 300sec.
127when using confirmed= you need to do another commit_config() without parameters
128within the time spesified to acknowledge the commit or else it rolls back your changes.
129(comment and label are optional parameters)
130```python
131>>> device.load_candidate_config(filename='unit/test/other_config.txt')
132>>> device.commit_config(label='my label', comment='my comment', confirmed=30)
133.... Code to do checks etc ....
134>>> device.commit_config()
135```
136
137### Commit Replace Config
138If you would rather commit the config by replacing the existing configuration,
139call commit_replace_config():
140(comment and label is optional parameters)
141```python
142>>> device.load_candidate_config(filename='unit/test/full_config.txt')
143>>> device.compare_replace_config()
144>>> device.commit_replace_config(label='my label', comment='my comment')
145```
146
147### Rollback Config
148After a previous commit, rollback() will return to the configuration prior
149to the commit:
150```python
151>>> device.rollback()
152```
153
154### Running Show Commands
155Any show command can be executed in the following fashion, with the command
156embedded into the call:
157```python
158>>> device.show_bgp_summary()
159...
160>>> device.show_interfaces()
161...
162>>> device.show_interfaces("GigabitEthernet0/0/0/0")
163...
164>>> device.show_controller("GigabitEthernet0/0/0/0", "phy")
165...
166>>> device.show_configuration(config=True)
167```
168
169### Running XML Commands
170An arbitrary XML command can be executed with the command:
171```python
172>>> device.make_rpc_call("<Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get>")
173...
174```
175
176### Close Connection
177Call close() to close the connection to the device:
178```python
179>>> device.close()
180```
181
182### Debugging Connection
183Log the communication between pyIOSXR and the router to any file-like like stdout, or an actual file:
184```python
185>>> from pyIOSXR import IOSXR
186>>> import sys
187>>> device=IOSXR(hostname="router", username="cisco", password="cisco", port=22, timeout=120, logfile=sys.stdout)
188
189OR
190
191>>> from pyIOSXR import IOSXR
192>>> import sys
193>>> file = open("logfile.log")
194>>> device=IOSXR(hostname="router", username="cisco", password="cisco", port=22, timeout=120, logfile=file)
195```
196
197Thanks
198======
199A special thanks to David Barroso! The first versions were entirely based on David's
200[pyEOS](https://github.com/spotify/pyeos), which is a wrapper around Arista's
201eAPI for EOS.
202
203Also, many thanks go out to Brady Walsh, without whom staying sane while
204digging through Cisco docs and XML would have been impossible.
205
206
207License
208======
209
210Copyright 2015 Netflix, Inc.
211Copyright 2016 BigWave IT
212
213Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
214