Advertisement
Guest User

Untitled

a guest
Feb 9th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1.  
  2. $ python nc_show_version.py
  3. Response as XML String:
  4. <?xml version="1.0" encoding="ISO-8859-1"?>
  5. <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:if="http://www.cisco.com/nxos:1.0:if_manager" xmlns:nfcli="http://www.cisco.com/nxos:1.0:nfcli" xmlns:nxos="http://www.cisco.com/nxos:1.0" xmlns:vlan_mgr_cli="http://www.cisco.com/nxos:1.0:vlan_mgr_cli" xmlns:mod="http://www.cisco.com/nxos:1.0:sysmgrcli" message-id="urn:uuid:6b917998-4db6-11e6-9d80-080027cee472">
  6. <data>
  7. <mod:show>
  8. <mod:version>
  9. <mod:__XML__OPT_Cmd_sysmgr_show_version___readonly__>
  10. <mod:__readonly__>
  11. <mod:header_str>Cisco Nexus Operating System (NX-OS) Software
  12. TAC support: http://www.cisco.com/tac
  13. Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_series_home.html
  14. Copyright (c) 2002-2016, Cisco Systems, Inc. All rights reserved.
  15. The copyrights to certain works contained herein are owned by
  16. other third parties and are used and distributed under license.
  17. Some parts of this software are covered under the GNU Public
  18. License. A copy of the license is available at
  19. http://www.gnu.org/licenses/gpl.html.
  20.  
  21. NX-OSv is a demo version of the Nexus Operating System
  22. </mod:header_str>
  23. <mod:loader_ver_str>N/A</mod:loader_ver_str>
  24. <mod:kickstart_ver_str>7.3(1)D1(1) [build 7.3(1)D1(0.10)]</mod:kickstart_ver_str>
  25. <mod:sys_ver_str>7.3(1)D1(1) [build 7.3(1)D1(0.10)]</mod:sys_ver_str>
  26. <mod:kick_file_name>bootflash:///titanium-d1-kickstart.7.3.1.D1.0.10.bin</mod:kick_file_name>
  27. <mod:kick_cmpl_time> 1/11/2016 16:00:00</mod:kick_cmpl_time>
  28. <mod:kick_tmstmp>02/22/2016 23:39:33</mod:kick_tmstmp>
  29. <mod:isan_file_name>bootflash:///titanium-d1.7.3.1.D1.0.10.bin</mod:isan_file_name>
  30. <mod:isan_cmpl_time> 1/11/2016 16:00:00</mod:isan_cmpl_time>
  31. <mod:isan_tmstmp>02/23/2016 01:43:36</mod:isan_tmstmp>
  32. <mod:chassis_id>NX-OSv Chassis</mod:chassis_id>
  33. <mod:module_id>NX-OSv Supervisor Module</mod:module_id>
  34. <mod:cpu_name>Intel(R) Xeon(R) CPU E5-2670</mod:cpu_name>
  35. <mod:memory>4002312</mod:memory>
  36. <mod:mem_type>kB</mod:mem_type>
  37. <mod:proc_board_id>TM29D1D533B</mod:proc_board_id>
  38. <mod:host_name>nxosv</mod:host_name>
  39. <mod:bootflash_size>1582402</mod:bootflash_size>
  40. <mod:kern_uptm_days>2</mod:kern_uptm_days>
  41. <mod:kern_uptm_hrs>21</mod:kern_uptm_hrs>
  42. <mod:kern_uptm_mins>1</mod:kern_uptm_mins>
  43. <mod:kern_uptm_secs>51</mod:kern_uptm_secs>
  44. <mod:manufacturer>Cisco Systems, Inc.</mod:manufacturer>
  45. </mod:__readonly__>
  46. </mod:__XML__OPT_Cmd_sysmgr_show_version___readonly__>
  47. </mod:version>
  48. </mod:show>
  49. </data>
  50. </rpc-reply>
  51. =================================
  52. Chassis ID: NX-OSv Chassis
  53. Software Version: 7.3(1)D1(1) [build 7.3(1)D1(0.10)]
  54.  
  55.  
  56. ################################################################
  57.  
  58. #!/usr/bin/env python
  59.  
  60. from ncclient import manager
  61.  
  62. if __name__ == '__main__':
  63.  
  64. with manager.connect(host='nxosv', port=22, username='cisco', password='cisco',
  65. hostkey_verify=False, device_params={'name': 'nexus'},
  66. allow_agent=False, look_for_keys=False) as device:
  67.  
  68. commands = ['config t', 'interface Ethernet2/6', 'switchport', 'description Configured by Python ncclient']
  69. nc_config_reply = device.exec_command(commands)
  70. print nc_config_reply.xml
  71.  
  72. ################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement