Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Course
- Designing and Implementing Cisco Network Programmability
- Shepherd, Jodie
- Sign Out Settings Help
- Table of Contents
- Lab Listing
- Video Playlist
- Bookmarks
- Glossary
- Medals & Achievements
- Leaderboard
- Table of Contents
- Back to full menu
- Welcome
- Silver Medal
- Section 1:
- Introduction to Network Programmability
- Gold Medal
- Section 2:
- Linux Primer for Network Engineers
- Bronze Medal
- Section 3:
- Linux Networking
- Silver Medal
- Section 4:
- Python Foundations for Network Engineers – Part 1
- Silver Medal
- Section 5:
- Python Foundations for Network Engineers – Part 2
- Silver Medal
- Section 6:
- Writing and Troubleshooting Python Scripts
- Bronze Medal
- Section 7:
- Python Libraries
- Bronze Medal
- Section 8:
- Introduction to Network APIs and Protocols
- Silver Medal
- Section 9:
- Cisco ASA REST API
- Gold Medal
- Section 10:
- NX-OS Programmability
- Silver Medal
- Section 11:
- Cisco IOS XE APIs
- No Medal
- Section 12:
- Cisco IOS XR APIs
- 12.1 Introduction
- 12.2 IOS XR NETCONF APIs
- 12.3 Challenge
- Gold Medal
- Section 13:
- Securing the Management Plane
- Bronze Medal
- Section 14:
- YANG Data Modeling
- Gold Medal
- Section 15:
- YANG Tools
- Bronze Medal
- Section 16:
- Introduction to Controller Networking
- Gold Medal
- Section 17:
- OpenDaylight
- Silver Medal
- Section 18:
- Cisco APIC-EM
- Bronze Medal
- Section 19:
- Cisco Application Centric Infrastructure
- Bronze Medal
- Section 20:
- Cisco Element and Domain Managers
- Gold Medal
- Section 21:
- Software Development Methodologies
- Gold Medal
- Section 22:
- Introduction to DevOps
- Bronze Medal
- Section 23:
- Version Control
- Silver Medal
- Section 24:
- Automated Testing
- Silver Medal
- Section 25:
- Continuous Integration
- Bronze Medal
- Section 26:
- Configuration Management and Automation Tools
- Bookmarks
- Back to full menu
- Cisco IOS XR APIs
- Challenge
- Cisco Systems, Inc.
- Question 8 of 8
- ×
- Interacting with the Cisco IOS XR NETCONF API
- After testing NETCONF on IOS XE, you are the NETCONF expert in your company. The WAN backbone team needs your help automating their IOS XR devices. In this lab, you will configure an interface using NETCONF and the ncclient to ensure that they have enough knowledge to continue making interface changes as needed.
- Note
- All IOS XR labs for this course are using IOS-XR version 5.3.2 on IOS-XRv (xrv). API requests may diff on live hardware platforms and on other versions of IOX-XR.
- Perform the following tasks to complete this challenge:
- Consume NETCONF with Python
- SSH to your IOS XR router and verify that you do not have a Loopback100 interface and that GigabitEthernet0/0/0/0 has no configuration other than being shut down.
- Navigate to the files/module2/lab7 and execute the xr_nc_configure_ipinterface.py script.
- Update the script and configure GigabitEthernet0/0/0/0 with a primary ipv4 address of 10.23.23.1/24 and secondary ipv4 address of 20.32.32.1/24.
- Verify the configuration of GigabitEthernet0/0/0/0.
- Note
- When grading this lab please be aware that only the last task will show Red if the lab was not performed correctly.
- Note
- If you find that a page has become unresponsive, it’s likely being caused by the “Unlock Login Keyring” prompt. You might need to scroll down to find it. Click “Cancel” on that prompt and your ability to type on the page will be restored.
- Consume NETCONF with Python
- Step 1
- SSH to your IOS XR router and verify that you do not have a Loopback100 interface and that GigabitEthernet0/0/0/0 has no configuration other than being shut down.
- Answer
- Verify that the loopback does not exist on your router and that GigabitEthernet0/0/0/0 has no configuration.
- RP/0/0/CPU0:xrv# show run interface loopback100
- Mon Jul 25 17:12:54.990 UTC
- % No such configuration item(s)
- RP/0/0/CPU0:xrv#
- RP/0/0/CPU0:xrv# show run interface GigabitEthernet 0/0/0/0
- Mon Jul 25 17:13:03.190 UTC
- interface GigabitEthernet0/0/0/0
- shutdown
- !
- Step 2 Show Me
- Navigate to the files/module2/lab7 and execute the xr_nc_configure_ipinterface.py script.
- Note
- This is a working script that adds configures a loopback100 with an IPv4 Address.
- Step 3
- Update the script and configure GigabitEthernet0/0/0/0 with a primary ipv4 address of 10.23.23.1/24 and secondary ipv4 address of 20.32.32.1/24.
- Note
- Use a get operation with the ncclient to better understand how to model the filter required to configure the interface. You may even want to manually configure the settings first to see how exactly it should be modeled in your NETCONF request!
- Answer
- Before looking at the solution script:
- You need to understand how to model the secondary IP addresses in XML.
- The simplest way to learn it is by configuring an interface with a primary and secondary IP address and then do a NETCONF get operation using the ncclient to see what the model is. It should give you enough information on how to model the configuration request.
- As an added hint, the first line in the XML subtree filter should be the following:
- <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
- After executing the modified script, you should see the following on the CLI:
- RP/0/0/CPU0:xrv# show run interface gigabitEthernet 0/0/0/0
- Mon Jul 25 15:34:29.315 UTC
- interface GigabitEthernet0/0/0/0
- ipv4 address 10.23.23.1 255.255.255.0
- ipv4 address 20.32.32.1 255.255.255.0 secondary
- shutdown
- !
- Solution Script:
- #!/usr/bin/env python
- from lxml import etree
- from ncclient import manager
- if __name__ == "__main__":
- with manager.connect(host='xrv', port=830, username='cisco', password='cisco',
- hostkey_verify=False, device_params={'name': 'iosxr'},
- allow_agent=False, look_for_keys=False) as device:
- nc_filter = """
- <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
- <interface-configuration>
- </interface-configuration>
- </interface-configurations>
- """
- nc_get_reply = device.get(('subtree', nc_filter))
- print nc_get_reply
- nc_filter = """
- <config>
- <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
- <interface-configuration>
- <active>act</active>
- <interface-name>GigabitEthernet0/0/0/0</interface-name>
- <ipv4-network xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-io-cfg">
- <addresses>
- <primary>
- <address>10.23.23.1</address>
- <netmask>255.255.255.0</netmask>
- </primary>
- <secondaries>
- <secondary>
- <address>20.32.32.1</address>
- <netmask>255.255.255.0</netmask>
- </secondary>
- </secondaries>
- </addresses>
- </ipv4-network>
- <shutdown></shutdown>
- </interface-configuration>
- </interface-configurations>
- </config>
- """
- nc_reply = device.edit_config(target='candidate', config=nc_filter)
- print nc_reply
- device.commit()
- Missing configuration for GigabitEthernet0/0/0/0
- Submit
- Previous Page Next Page
- Terms & Conditions Privacy Statement Cookie Policy EULA Trademarks Keyboard Shortcuts
- Devices
- Scenario
- Hints
- Job Aid
- This device is connected in a separate window.
- Switch to Device Window
- Bring the device back to this window.
- Desktop Devices
- Workstation
- Console Devices
- Internet-Rtr
- xrv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement