cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1366
Views
0
Helpful
4
Replies

Accessing Unity express SRE-module via Python Netmiko

vgrigoriadis
Level 1
Level 1

Dear all.

I have prepared a small python script to ssh several CUCME routers (2901) and get some "show" info, using the Netmiko Python library. No problem so far. The issue is that I'd like to access the cisco unity Express (v8.8.7) ISM (SRE-300) module within the cucme router to get some info from there too. The way I would do that manually from the cli is using the command #"service-module ISM 0/0 session". Then I would be prompted to enter username and password. After that, I would be connected to the module and could issue any show command. However, when I am trying to do that from my script, after sending command "service-module ISM 0/0 session", I don't have a way to send the credentials in, so the session expires. I tried many different combinations- sending the credentials in seperate commands, or within one command etc.., nothing worked. BTW, the session is a basic tty (131) serial connection (from the router to its internal SRE module). So the whole procedure is as follows: ssh to router, and from there vty-line (console) connection to the internal module. Any ideas to solve that, would be highly appreciated. Thank you all in advance.

Vasilis

4 Replies 4

TI2491
Level 1
Level 1

when you enter the credentials, is the password entered as a secure string?  
I don't see why passing the credentials in your existing ssh session wouldn't work if that's how you access it from inside of the CUCME anyway...

Hello TI2491. Thanks for your response.

No they are not entered in a secure string (not even when I enter them manually). The problem is as follows:

I enter the: "service-module ISM 0/0 session" command -> this would the prompt for credentials.

Then I send a different command with the username and then a third one with the password.

The error I get is as if no credentials were entered, and the authentication process expired. After that the username and password conmmands are executeded in cisco as normal commands in # , eg "my_username", obvisously there is no such command in cisco and I get the

"% Bad IP address or host name
% Unknown command or computer name, or unable to find computer address".

Somehow I need to enter the credentials within the first command("service-module ISM 0/0 session").

I fail to do so...

Thanks anyway.

Could you post the code that you're using to do this?  omit the username and password and any proprietary information, of course.  I don't have one of these here that I can play with so I'll see if I can help anywhere!

 

and if possible, the results of reading the input buffer after executing the code.

Sure.

Thanks again.

I have replaced the router ip with <router_IP>, the username with 'user' and the password with 'pass'.

BTW I have tried many different versions of that...

 

Basic script
------------

 

from netmiko import Netmiko
from netmiko import ConnectHandler

target = {
'host':'router_IP',
'username':'user',
'password':'pass',
'device_type':'cisco_ios',
'secret':'pass'
}

net_connect = ConnectHandler(**target)
result = net_connect.enable()
output0 = net_connect.send_command('service-module ISM 0/0 session')
output1=net_connect.send_command('user')
output2=net_connect.send_command('pass')
print(net_connect.find_prompt(), output0, output1, output2)

net_connect.disconnect()

 


OUTPUT coming from router
------------------------

 

router# Trying <router_IP>, 2131 ... Open
CC
*****************************************************************
* !!!Authorized Use Only!!! *
* *
* You must be assigned an account on this system to access. By *
* accessing this system you are consenting to system monitoring *
* for law enforcement purpose. *
*****************************************************************

username:
% username: timeout expired!
[Connection to <router_IP> closed by foreign host] Translating "user"

% Bad IP address or host name
% Unknown command or computer name, or unable to find computer address % Bad IP address or host name
% Unknown command or computer name, or unable to find computer address