Skip to content

Instantly share code, notes, and snippets.

@hellt
Created February 10, 2017 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellt/94096b34f1996b59465d4155cd1c418e to your computer and use it in GitHub Desktop.
Save hellt/94096b34f1996b59465d4155cd1c418e to your computer and use it in GitHub Desktop.
from ncclient import manager
import logging
# logging.basicConfig(
# level=logging.DEBUG,
# )
with manager.connect(host='172.17.14.242', port=830, username='admin', password='admin',
device_params={'name': 'alu'},
hostkey_verify=False) as m:
# this request uses CLI content layer (i.e. as viewed on CLI)
# req = '''
# <oper-data-format-cli-block>
# <cli-show>router interface</cli-show>
# </oper-data-format-cli-block>
# '''
# c = m.get(('subtree', req))
req_xml_1 = '''
<configure xmlns="urn:alcatel-lucent.com:sros:ns:yang:conf-r13">
<system>
<netconf>
</netconf>
</system>
</configure>
'''
req_xml_2 = '''
<configure xmlns="urn:alcatel-lucent.com:sros:ns:yang:conf-r13">
<router/>
</configure>
'''
# prints all running config as XML
# print(m.get_config(source='running'))
c = m.get_config(source='running', filter=('subtree', req_xml_3))
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment