Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. from ncclient import manager
  2. import logging
  3.  
  4. # logging.basicConfig(
  5. # level=logging.DEBUG,
  6. # )
  7.  
  8. with manager.connect(host='172.17.14.242', port=830, username='admin', password='admin',
  9. device_params={'name': 'alu'},
  10. hostkey_verify=False) as m:
  11.  
  12. # this request uses CLI content layer (i.e. as viewed on CLI)
  13. # req = '''
  14. # <oper-data-format-cli-block>
  15. # <cli-show>router interface</cli-show>
  16. # </oper-data-format-cli-block>
  17. # '''
  18. # c = m.get(('subtree', req))
  19.  
  20. req_xml_1 = '''
  21. <configure xmlns="urn:alcatel-lucent.com:sros:ns:yang:conf-r13">
  22. <system>
  23. <netconf>
  24. </netconf>
  25. </system>
  26. </configure>
  27. '''
  28.  
  29. req_xml_2 = '''
  30. <configure xmlns="urn:alcatel-lucent.com:sros:ns:yang:conf-r13">
  31. <router/>
  32. </configure>
  33. '''
  34.  
  35.  
  36. # prints all running config as XML
  37. # print(m.get_config(source='running'))
  38.  
  39. c = m.get_config(source='running', filter=('subtree', req_xml_3))
  40. print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement