We will use a pretty straightforward example to execute show version. We will name this file junos_netconf_1.py:
#!/usr/bin/env python3 from ncclient import manager conn = manager.connect( host='192.168.24.252', port='830', username='netconf', password='juniper!', timeout=10, device_params={'name':'junos'}, hostkey_verify=False) result = conn.command('show version', format='text') print(result) conn.close_session()
All the fields in the script should be pretty self-explanatory, with the exception of device_params. Starting with ncclient 0.4.1, the device handler was added to specify different vendors or platforms. For example, the name can be juniper, CSR, Nexus, or Huawei. We also added hostkey_verify=False because ...