This project provides a Python interface for accessing and modifying manageability data on an IOS-XR router.
The interface has the following requirements:
- Python 2 (>= 2.7) or Python 3 (>= 3.4).
- The
trollius
andenum34
packages if using Python 2. - The
paramiko
package.
Once the dependencies have been satisfied run setup.py
to install the xrm2m
module:
./setup.py install
In order to use the library SSH must be configured on the target router, and
SSH keys from the connecting machine installed (for this you'll need the k9
image):
- Configure an SSH server (on the router):
`conf
int Mgmt 0/0/CPU0/0
no shut
ipv4 addr dhcp
ssh server
commit`
- Generate an SSH fingerprint (on the router):
`crypto key generate dsa`
- Generate a 1024-bit RSA key (on the server):
`cd ~/.ssh
ssh-keygen -b 1024 -t rsa -f <key-name>`
- Create a base64-decoded binary public key for the router (on the server):
`cut -d" " -f2 <key-name>.pub | base64 -d > <key-name>.pub.b64`
- Copy the public key onto the router (on the server), e.g.
`scp -o PreferredAuthentications=password -o PubkeyAuthentication=no ~/.ssh/<key-name>.pub.b64 <user>@<router-ip>:/disk0:`
- Import the public key (on the router), e.g.
`crypto key import auth rsa disk0:/<key-name>.pub.b64`
You should now be able to connect to the IOS-XR router like so:
from xrm2m import *
conn = connect(SSHTransport("<rouer-ip>",
"<user>",
key_filename="<key-name>"))
conn.get_version()