Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def policy_options_collector_juniper(device_name,tacacs_password):
- print "Capturing device policy options config for " + device_name
- device_config = {}
- config = []
- contents = StringIO()
- output_config = ""
- remote_conn_pre = paramiko.SSHClient()
- remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- remote_conn_pre.connect(device_name.strip(), port=22, username=getpass.getuser(), password=tacacs_password,look_for_keys=False, allow_agent=False, timeout=None)
- channel = remote_conn_pre.invoke_shell()
- channel.send('\n')
- time.sleep(1)
- channel.send('show configuration | display set | match policy-options | no-more\n')
- time.sleep(5)
- i = 0
- while i < 5:
- if channel.recv_ready():
- output_config += channel.recv(65535)
- contents.write(output_config)
- else:
- break
- i += 1
- print "This is " + str(i)
- print contents.getvalue()
- for line in output_config.splitlines():
- if 'set' in line:
- config.append(line.strip())
- device_config['policy_options'] = config
- return device_config
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement