Search

1 to 10 of 28
Sort by

Discussion Post
Trying to convert a slax script to pyhton

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 #pyezlogoffuser


Discussion Thread 4
Trying to convert a slax script to pyhton

Focus Search - Trying to conver the slax: if ($response == "no") ( var $rpc = "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


Blog Entry
Scripting How-To: Loop through devices using skeleton-code

The username is prompted "in the clear" and the password is not echoed to the screen. 01 import sys 02 from getpass import getpass 03 from jnpr.junos import Device 04 from jnpr.junos.op.xcvr import XcvrTable 05 06 devlist = [ 'mx240.chi' , 'mx480.chi' , 'mx80.chi' , 'srx3400.chi' ] 07 user = raw input ( 'username: ' ) 08 passwd = getpass( 'password: ' ) 09 10 for host in devlist: 11 sys.stdout.write( 'connecting to %s ... ' % host) 12 sys.stdout.flush() 13 14 dev = Device(host,user = user,password = passwd) 15 dev


Discussion Post
PyEz Inline Table View not returning any data from VirtualBox JunOS image

BTW if I try to execute the RPCs from the tables in JunOS directly I get error: Unrecognized command (chassis-control) #netstats.py from jnpr.junos import Device from jnpr.junos.factory.factory loader import FactoryLoader import yaml yaml data = """ -- EthPortTable: rpc: get-interface-information args: media: True interface name: '[afgxe]m*' args key: interface name item: physical-interface view: EthPortView EthPortView: groups: mac stats: ethernet-mac-statistics flags: if-device-flags fields: oper: oper-status admin: admin-status description: description mtu: ( mtu : int ) link mode: link-mode macaddr: current-physical-address fields mac stats: rx bytes: input-bytes rx packets: input-packets tx bytes: output-bytes tx packets: output-packets fields flags: running: ( ifdf-running: flag ) present: ( ifdf-present: flag ) """ dev = Device(host='192.168.56.20', user='root', password='njamal99', gather facts=False) dev.open() globals().update(FactoryLoader().load(yaml.load(yaml data))) hostmetrics = EthPortTable(dev) hostmetrics.get() for hostmetric in hostmetrics: print('status: ', hostmetric.oper) print('admin: ', hostmetric.admin) print('rx bytes:', hostmetric.rx bytes) print('rx packets:', hostmetric.rx packets) print('tx packets:', hostmetric.tx packets) print('mtu:', hostmetric.mtu) dev.close() Output from netstats.py: status: up admin: up rx bytes: None rx packets: None tx packets: None mtu: 1514 Process finished with exit code 0 #hoststats.py from jnpr.junos import Device from jnpr.junos.factory.factory loader import FactoryLoader import yaml yaml data=""" -- REStats: rpc: get-route-engine-information key: mastership-state item: route-engine view: REStatsView REStatsView: fields: status: status used: cpu-idle cpu-user : cpu-user cpu-background: cpu-background cpu-interrupt: cpu-interrupt cpu-system: cpu-system cpu-load average: load-average-five temperature : temperature/@celsius memory: memory-buffer-utilization """ dev = Device(host='192.168.56.20', user='root', password='njamal99', gather facts=False) dev.open() globals().update(FactoryLoader().load(yaml.load(yaml data))) hostmetrics = REStats(dev) hostmetrics.get() for hostmetric in hostmetrics: print('status: ', hostmetric.status) print('cpu used: ', hostmetric.used) print('cpu-user:', hostmetric.cpu-user) print('cpu-background:', hostmetric.cpu-background) print('cpu-system:', hostmetric.cpu-system) print(hostmetrics) dev.close() Output from hoststats.py: Process finished with exit code 0 Many thanks, Tahir-PyEz #PyEzVirtualBoxJunOSTableViews


Blog Entry
What are the features of Junos PyEZ?

Junos PyEZ is a Python micro-framework designed to provide the same capabilities as a user would have on the Junos OS CLI in an environment built for automation


Blog Entry
Scripting How-To: Connect to devices remotely

You can optionally provide a username (the default is $USER ) and a password (the default is using ssh-keys)...The purpose of Junos PyEZ is to abstract those differences so the user has a consistent automation interface


Blog Entry
How can I loop through a list of hostnames with the same credentials?

Junos PyEZ and skeleton-code To loop through a list of hostnames using the same username and password (credentials) using Junos PyEZ , you must have skeleton-code The skeleton-code defines a list of hosts and a devlist, and prompts the user to enter their username and password


Blog Entry
How can I remotely access a Junos OS device with Junos PyEZ?

You can optionally provide a username (the default is $USER) and a password (the default is using ssh-keys)...The purpose of Junos PyEZ is to abstract those differences so the user has a consistent automation interface


Blog Entry
How-To: Save table data

You have a list of device hostnames, and you prompt the user for their username and password


Blog Entry
How-To: Install Junos PyEZ correctly

Example from pprint import pprint from jnpr.junos import Device dev = Device(host='my host or ipaddr', user='jeremy', password='jeremy123' ) dev.open() pprint( dev.facts ) dev.close() Here is the sample output when connecting to an SRX210 device: >>> pprint(dev.facts) ('2RE': False, 'RE0': ('last reboot reason': '0x20:power-button soft power off', 'model': 'RE-SRX210H', 'status': 'OK', 'up time': '10 minutes, 3 seconds'), 'domain':'workflowsherpas.com' 'fqdn': 'srx210.workflowsherpas.com', 'hostname': 'srx210', 'ifd style': 'CLASSIC', 'model': 'SRX210H','personality': 'SRX BRANCH', 'serialnumber': 'AD2909AA0096', 'switch style': 'VLAN', 'version': '12.1X44-D10.4', 'version info': junos.versino info(major=(12, 1), type=X, minor=(44, 'D', 10), build=4)) Video #How-To #example #junospyez #Python #video