cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1246
Views
0
Helpful
2
Replies

Using pyATS / Genie and need to customize the Password: prompt logic

jeff.garvas
Level 1
Level 1

I'm experimenting with the Genie / pyATS scripts to remotely gather configurations so they can be compared.  When I try to connect the SSH session is hanging indefinitely.

Upon further review I realized that due to our custom tacacs+ implementation we're not sending a Password: prompt, but a custom message on what is expected.  I'm trying to find where in the genie or pyATS code to modify it so that I can add this particular string of text as an alternative to Password:

Anyone run into this or know where to adjust?

2 Replies 2

LanDownUnda
Spotlight
Spotlight

Hi Jeff,

 

I haven't run into this one before when I've used pyATS but then again my implimentation of AAA hasn't required any changes to the password field before.

 

Are you able to post a picture of what the CLI spits out? I'm curious to see if you can indeed right a simple function that parses that particular output so the SSH connection continues on instead of just hanging.

*** Rate All Helpful Responses ***

omz
VIP Alumni
VIP Alumni

Hi 

Please have a look at  Login and Password Prompts section in the docs - 

https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/connection.html#login-and-password-prompts

It can be done by setting regular expression to LOGIN_PROMPT and PASSWORD_PROMPT attributes of device settings.

Example:

# Unicon standalone mode
dev = Connection(hostname='R2', start=['telnet x.x.x.x'],\
    credentials={{'default': {'username': 'admin', 'password': 'Cisc0123'}})
dev.settings.LOGIN_PROMPT = r'USERNAME:\s?$'
dev.settings.PASSWORD_PROMPT = r'PASSWORD:\s$'

In pyATS testbed yaml file, this can be set in the following way:

devices:
  R2
    credentials:
        default:
            username: admin
            password: Cisc0123
    connections:
      defaults: {class: 'unicon.Unicon'}
      a:
        protocol: telnet
        ip: x.x.x.x
        port: 2042
        prompts:
            login: r'USERNAME:\s?$'
            password: r'PASSWORD:\s$'

Hope this helps ..

please hit the helpful button for any helpful posts..