File: nc09.py

package info (click to toggle)
python-ncclient 0.6.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,448 kB
  • sloc: python: 9,548; xml: 476; makefile: 77; sh: 5
file content (34 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
#
# Connect to the NETCONF server passed on the command line while passing
# custom capabilities on the default device handler and display the
# client capabilities. For brevity and clarity of the examples, we omit
# proper exception handling.
#
# $ ./nc09.py host username password

import logging
import os
import sys
import warnings

warnings.simplefilter("ignore", DeprecationWarning)
from ncclient import manager

def demo(host, user, password):
    with manager.connect(
            host=host, port=830, username=user, password=password,
            nc_params={
                'capabilities': [
                    'urn:custom:capability:1.0',
                    'urn:custom:capability:2.0'
                ]},
            hostkey_verify=False) as m:

        for c in m.client_capabilities:
            print(c)

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)
    demo(sys.argv[1], sys.argv[2], sys.argv[3])