Junos Automation (Scripting)
Junos Automation (Scripting)

Trying to convert a slax script to pyhton

3 weeks ago

I found the login.slax in a github repository, trying to convert to python but having a hard time finding the user to logout.

 

Trying to conver the slax:

if ($response == "no") {
var $rpc = <command> "request system logout user " _ $user;
var $noresponse = jcs:invoke($rpc);

 

to python

with Device() as dev: #Call Device this way becuase it will automatically open and close the connection
jcs.output('..')
jcs.output('..')
jcs.output('Logging Out')
res = dev.rpc.cli('request system logout user ' + username, format='text', normalize=False)

 

I am hoping someone knows how to fund the logged in user. We are suing Cisco ISE and TACACS to login which gets mapped to a local user on the switch so cant log that user out.

 

I am hoping to logout the user that attempted to login using their username they entered: JDI

show system users
fpc0:
--------------------------------------------------------------------------
6:48AM up 1 day, 19:54, 1 users, load averages: 0.15, 0.23, 0.24
USER TTY FROM LOGIN@ IDLE WHAT
JDIZZLE pts/0 10.192.175.124 6:14AM - -cl

2 REPLIES 2
Junos Automation (Scripting)

Re: Trying to convert a slax script to pyhton

3 weeks ago

What user names show up when you run

show system users

 

With RADIUS this does still show as the actual user name even when mapped for permissions to a local user.  If that is true for the Cisco auth you should be able to use the script as designed with user name.

 

Steve Puluka BSEET - Juniper Ambassador
IP Architect - DQE Communications Pittsburgh, PA (Metro Ethernet & ISP)
http://puluka.com/home
Junos Automation (Scripting)

Re: Trying to convert a slax script to pyhton

3 weeks ago

The logged in users, my question is how to do I get the current logged in user. I have been looking at the juniper PyEZ documentation but cannot find anything