SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2.  
  3. from lxml import etree
  4. from ncclient import manager
  5.  
  6. if __name__ == "__main__":
  7.  
  8.     with manager.connect(host='xrv', port=830, username='cisco', password='cisco',
  9.                          hostkey_verify=False, device_params={'name': 'iosxr'},
  10.                          allow_agent=False, look_for_keys=False) as device:
  11.  
  12.  
  13.         nc_filter = """
  14.             <config>
  15.               <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
  16.                <interface-configuration>
  17.                 <active>act</active>
  18.                 <interface-name>GigabitEthernet0/0/0/0</interface-name>
  19.                 <ipv4-network xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-io-cfg">
  20.                  <addresses>
  21.                   <primary>
  22.                    <address>10.23.23.1</address>
  23.                    <netmask>255.255.255.0</netmask>
  24.                   </primary>
  25.                  </addresses>
  26.  
  27.                  <secondaries>
  28.                   <secondary>
  29.                    <address>20.32.32.1</address>
  30.                    <netmask>255.255.255.0</netmask>
  31.                   </secondary>
  32.                  </secondaries>
  33.  
  34.                 </ipv4-network>
  35.                </interface-configuration>
  36.               </interface-configurations>
  37.             </config>
  38.         """
  39.  
  40.         nc_reply = device.edit_config(target='candidate', config=nc_filter)
  41.         print nc_reply
  42.         device.commit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top