Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 28 lines (19 sloc) 859 Bytes
#!/usr/bin/env python
import logging
from ncclient import manager
from ncclient.xml_ import *
def connect(host, port, user, password):
conn = manager.connect(host=host,
port=port,
username=user,
password=password,
timeout=60,
device_params={'name': 'junos'},
hostkey_verify=False)
rpc = new_ele('get-software-information')
result = conn.rpc(rpc)
logging.info('Hostname: %s', result.xpath('//software-information/host-name')[0].text)
if __name__ == '__main__':
LOG_FORMAT = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(message)s'
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=LOG_FORMAT)
connect('router', 830, 'netconf', 'juniper!')