Skip to main content

AvayaERSConnect’s main purpose is to connect to any Avaya ERS Device via Telnet and perform various administration operations easily, without the need to write any Python code at all.

Project description

AvayaERSConnect.py Documentation


The AvayaERSConnect Python module is build using Python 2.7.3, on top of the telnetlib library and it works with any version of Python >= 2.7.x. Other versions below 2.7.x were not tested.

AvayaERSConnect is published under the MIT License.

The official documentation of telnetlib is accessible here:
https://docs.python.org/2/library/telnetlib.html


AvayaERSConnect’s main purpose is to connect to any Avaya ERS Device via Telnet and perform various administration operations easily, without the need to write any Python code at all.

The main prerequisites when using this module are:

Running it inside a Linux host / virtual machine is highly recommended.
Running it inside the Python interpreter, after importing it: import AvayaERSConnect
IP connectivity from the host / virtual machine to the Avaya ERS device(s)
Mandatory: Telnet connectivity should be enabled on each device, using the “cli password telnet local” command, in the Global Configuration mode. Default Avaya credentials for read and write via Telnet are: username: RW , password: securepasswd


Supported Avaya ERS platforms:

Avaya ERS 25xx (all models)
Avaya ERS 35xx (all models)
Avaya ERS 45xx (all models)
Avaya ERS 48xx (all models)
Avaya ERS 55xx (all models)
Avaya ERS 56xx (all models)
Avaya ERS 59xx (all models)


AvayaERSConnect usable functions:

ReadConfig(ip, username, password, show_command, to_file = True, to_screen = False)
SendConfig(ip, cmd_file, username, password, save_config = True)
SendConfigToMultiDev(username, password, save_config = True)
ReadConfig()
The ReadConfig() function in AvayaERSConnect is responsible for connecting to an Avaya device via Telnet, sending a “show” command that the user specifies as an argument and capturing and storing the output of that command. This command should be invoked in the Python interpreter, after importing the AvayaERSConfig module.


The format:

ReadConfig(ip, username, password, show_command, to_file = True, to_screen = False)

Note: Please follow the exact order of arguments (as shown above) when calling the function!


Example:

>>> import AvayaERSConnect
>>> AvayaERSConnect.ReadConfig("172.16.1.1", "RW", "securepasswd", "show vlan", to_file = True, to_screen = False)

Output was written to SwitchOne_show_vlan.txt.


Main features and requirements for ReadConfig():

Prepend the function name with “AvayaERSConnect.” when calling it.
The first argument is the IP address of the device you want to read from, in between double quotes.
The second argument is the Telnet username for logging into the device. This will be “RW” if you leave it at default. “cli password telnet local” should be configured on the device, prior to running the ReadConfig() function.
The third argument is the Telnet password for logging into the device. This will be “securepasswd” if you leave it at default. “cli password telnet local” should be configured on the device, prior to running the ReadConfig() function.
The fourth argument is the “show” command you want to send to the device.
The “to_file” argument can be set to either True or False.
The “to_screen” argument can be set to either True or False. When set to True, the command output is printed on the screen, in the Python interpreter.
If both “to_file” and “to_screen” are set to True, the output will be both stored in an external file and printed to the screen. If both are set to False, nothing happens.

Writing the output to a file using the to_file argument:

If you set to_file = False, the output is not saved to a file.
If you set to_file = True, then the output of the “show” command is stored inside a file in the current directory, which is going to be automatically named following this format: Hostname_Command.txt. This is useful when querying multiple devices, one by one.


Example:

SwitchOne(config)#cli password telnet local

>>> import AvayaERSConnect
>>> AvayaERSConnect.ReadConfig("172.16.1.1", "RW", "securepasswd", "show vlan", to_file = True, to_screen = False)

Output was written to SwitchOne_show_vlan.txt.

root@kali:/home# cat SwitchOne_show_vlan.txt
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
2 VLAN #2 Port None 0x0000 Yes IVL No
Port Members: NONE
3 VLAN #3 Port None 0x0000 Yes IVL No
Port Members: NONE
4 VLAN #4 Protocol Ipv6 Ether2 0x86dd Yes IVL No
Port Members: NONE
55 VLAN #55 Port None 0x0000 Yes IVL No
Port Members: NONE
77 VLAN #77 Port None 0x0000 Yes IVL No
Port Members: NONE


The ReadConfig() function returns a customized error message and quits execution if:

Invalid commands are sent to the device
Incorrect device IP address, username or password are used
The device IP address is unreachable
The user types the Ctrl+C sequence


SendConfig()
The SendConfig() function in AvayaERSConnect is responsible for connecting to an Avaya device via Telnet, sending configuration commands stored in an external text file, each specified one per line. In the function call, you can also specify whether you want the configuration you just made to be saved to the device’s NVRAM. This command should be invoked in the Python interpreter, after importing the AvayaERSConfig module.



The format:

SendConfig(ip, cmd_file, username, password, save_config = True)

Note: Please follow the exact order of arguments (as shown above) when calling the function!



Example:

SwitchOne(config)#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
Total VLANs: 1

root@kali:/home# cat avayatestcmd.txt
vlan create 100 type port
vlan create 101 type proto
vlan create 102 type port

>>> import AvayaERSConnect
>>> AvayaERSConnect.SendConfig("172.16.1.1", "avayatestcmd.txt", "RW", "securepasswd", save_config = True)

Configuration was saved to NVRAM.

SwitchOne(config)#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
100 VLAN #100 Port None 0x0000 Yes IVL No
Port Members: NONE
101 VLAN #101 Protocol Ipv6 Ether2 0x86dd Yes IVL No
Port Members: NONE
102 VLAN #102 Port None 0x0000 Yes IVL No
Port Members: NONE
Total VLANs: 4


Main features and requirements for SendConfig():

Prepend the function name with “AvayaERSConnect.” when calling it.
The first argument is the IP address of the device you want to write commands to, in between double quotes.
The second argument is the filename (+ extension) in which the configuration commands are stored, in between double quotes.
The third argument is the Telnet username for logging into the device. This will be “RW” if you leave it at default. “cli password telnet local” should be configured on the device, prior to running the SendConfig() function.
The fourth argument is the Telnet password for logging into the device. This will be “securepasswd” if you leave it at default. “cli password telnet local” should be configured on the device, prior to running the SendConfig() function.
The “save_config” argument can be set to either True or False.



Saving the configuration to NVRAM (configuration is kept across reboot, when autosave is disabled on the device) using the save_config argument:

If you set save_config = False, the configuration is not saved to NVRAM (the configuration may be lost across reboot, if autosave is disabled on the device).
If you set save_config = True, the configuration is saved to NVRAM.



The SendConfig() function returns a customized error message and quits execution if:

Telnet login timeout expires (connectivity / network lag / delay issues)
Incorrect device IP addresses, username or password are used
Invalid filename or inexistent file containing the commands
The device IP address is unreachable
The user types the Ctrl+C sequence
SendConfigToMultiDev()

The SendConfigToMultiDev() function in AvayaERSConnect is responsible for connecting to multiple Avaya devices simultaneously via Telnet, sending configuration commands stored in an external text file, specified one per line. In the function call, you can also specify whether you want the configuration you just made to be saved to the device’s NVRAM or not. This command should be invoked in the Python interpreter, after importing the AvayaERSConfig module.

This function uses threading for initiating multiple concurrent sessions to multiple Avaya ERS IP addresses, specified inside an external, dedicated file.



The format:

SendConfigToMultiDev(username, password, save_config = True)

Note: Please follow the exact order of arguments (as shown above) when calling the function!



Example:

Let’s consider three Avaya ERS 35xx switches [IPs: 10.105.62.23, 10.105.62.24, 10.105.62.25]:


2.3#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: 1/ALL,2/ALL
Total VLANs: 1

2.4#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
Total VLANs: 1


2.5#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
Total VLANs: 1


Let’s create the files we need: one holding the IP addresses and one holding the commands.

root@kali:/home# cat avayamultiip.txt
10.105.62.23
10.105.62.24
10.105.62.25

root@kali-teo:/home# cat avayamulticmd.txt
vlan create 77 type port
vlan create 88 type port
vlan create 99 type port


Let’s run the function in the Python interpreter.

>>> import AvayaERSConnect
>>> AvayaERSConnect.SendConfigToMultiDev("RW", "securepasswd", save_config = True)
Enter IP file name and extension: avayamultiip.txt

Checking IP reachability...

All devices are reachable. Waiting for command file...

Enter command file name and extension: avayamulticmd.txt

Commands file was found.


Configuration was saved to NVRAM.


Configuration was saved to NVRAM.


Configuration was saved to NVRAM.
Let’s verify the configuration on the three switches - vlans 77, 88, 99 should have been configured.

2.3#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: 1/ALL,2/ALL
77 VLAN #77 Port None 0x0000 Yes IVL No
Port Members: NONE
88 VLAN #88 Port None 0x0000 Yes IVL No
Port Members: NONE
99 VLAN #99 Port None 0x0000 Yes IVL No
Port Members: NONE
Total VLANs: 4


2.4#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
77 VLAN #77 Port None 0x0000 Yes IVL No
Port Members: NONE
88 VLAN #88 Port None 0x0000 Yes IVL No
Port Members: NONE
99 VLAN #99 Port None 0x0000 Yes IVL No
Port Members: NONE
Total VLANs: 4


2.5#show vlan
Id Name Type Protocol PID Active IVL/SVL Mgmt
---- -------------------- -------- ---------------- ------- ------ ------- ----
1 VLAN #1 Port None 0x0000 Yes IVL Yes
Port Members: ALL
77 VLAN #77 Port None 0x0000 Yes IVL No
Port Members: NONE
88 VLAN #88 Port None 0x0000 Yes IVL No
Port Members: NONE
99 VLAN #99 Port None 0x0000 Yes IVL No
Port Members: NONE
Total VLANs: 4

Main features and requirements for SendConfigToMultiDev():

Prepend the function name with “AvayaERSConnect.” when calling it.
The first argument is the Telnet username for logging into the device. This will be “RW” if you leave it at default. “cli password telnet local” should be configured on the device, prior to running the SendConfigToMultiDev() function.
The second argument is the Telnet password for logging into the device. This will be “securepasswd” if you leave it at default. “cli password telnet local” should be configured on the device, prior to running the SendConfigToMultiDev() function.
The “save_config” argument can be set to either True or False.
Other necessary arguments are automatically picked up by calling the SendConfig() function from within the SaveConfigToMultiDev() function.




Saving the configuration to NVRAM (configuration is kept across reboot, when autosave is disabled on the device) using the save_config argument:

If you set save_config = False, the configuration is not saved to NVRAM (the configuration may be lost across reboot, if autosave is disabled on the device).
If you set save_config = True, the configuration is saved to NVRAM.




The SendConfigToMultiDev() function returns a customized error message and quits execution if:

Telnet login timeout expires (connectivity issue)
Incorrect device IP addresses, username or password are used
Invalid filename or inexistent file containing the commands
The device IP address is unreachable
The user types the Ctrl+C sequence



Note: Other functions in the AvayaERSConnect.py file take care of checking IP format validity, IP reachability and commands file path corectness. These functions are not to be used directly in the Python interpreter.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

AvayaERSConnect.tar.gz (3.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page