Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1. Course
  2.  
  3. Designing and Implementing Cisco Network Programmability
  4. Shepherd, Jodie
  5. Sign Out Settings Help
  6.  
  7. Table of Contents
  8.  
  9.  
  10. Lab Listing
  11.  
  12. Video Playlist
  13.  
  14. Bookmarks
  15.  
  16.  
  17. Glossary
  18.  
  19. Medals & Achievements
  20.  
  21. Leaderboard
  22. Table of Contents
  23. Back to full menu
  24. Welcome
  25. Silver Medal
  26. Section 1:
  27. Introduction to Network Programmability
  28. Gold Medal
  29. Section 2:
  30. Linux Primer for Network Engineers
  31. Bronze Medal
  32. Section 3:
  33. Linux Networking
  34. Silver Medal
  35. Section 4:
  36. Python Foundations for Network Engineers – Part 1
  37. Silver Medal
  38. Section 5:
  39. Python Foundations for Network Engineers – Part 2
  40. Silver Medal
  41. Section 6:
  42. Writing and Troubleshooting Python Scripts
  43. Bronze Medal
  44. Section 7:
  45. Python Libraries
  46. Bronze Medal
  47. Section 8:
  48. Introduction to Network APIs and Protocols
  49. Silver Medal
  50. Section 9:
  51. Cisco ASA REST API
  52. Gold Medal
  53. Section 10:
  54. NX-OS Programmability
  55. Silver Medal
  56. Section 11:
  57. Cisco IOS XE APIs
  58. No Medal
  59. Section 12:
  60. Cisco IOS XR APIs
  61. 12.1 Introduction
  62. 12.2 IOS XR NETCONF APIs
  63. 12.3 Challenge
  64. Gold Medal
  65. Section 13:
  66. Securing the Management Plane
  67. Bronze Medal
  68. Section 14:
  69. YANG Data Modeling
  70. Gold Medal
  71. Section 15:
  72. YANG Tools
  73. Bronze Medal
  74. Section 16:
  75. Introduction to Controller Networking
  76. Gold Medal
  77. Section 17:
  78. OpenDaylight
  79. Silver Medal
  80. Section 18:
  81. Cisco APIC-EM
  82. Bronze Medal
  83. Section 19:
  84. Cisco Application Centric Infrastructure
  85. Bronze Medal
  86. Section 20:
  87. Cisco Element and Domain Managers
  88. Gold Medal
  89. Section 21:
  90. Software Development Methodologies
  91. Gold Medal
  92. Section 22:
  93. Introduction to DevOps
  94. Bronze Medal
  95. Section 23:
  96. Version Control
  97. Silver Medal
  98. Section 24:
  99. Automated Testing
  100. Silver Medal
  101. Section 25:
  102. Continuous Integration
  103. Bronze Medal
  104. Section 26:
  105. Configuration Management and Automation Tools
  106. Bookmarks
  107. Back to full menu
  108.  
  109. Cisco IOS XR APIs
  110.  
  111. Challenge
  112.  
  113. Cisco Systems, Inc.
  114. Question 8 of 8
  115. ×
  116. Interacting with the Cisco IOS XR NETCONF API
  117. 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.
  118.  
  119. Note
  120. 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.
  121.  
  122. Perform the following tasks to complete this challenge:
  123.  
  124. Consume NETCONF with Python
  125.  
  126. 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.
  127.  
  128. Navigate to the files/module2/lab7 and execute the xr_nc_configure_ipinterface.py script.
  129.  
  130. 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.
  131.  
  132. Verify the configuration of GigabitEthernet0/0/0/0.
  133.  
  134. Note
  135. When grading this lab please be aware that only the last task will show Red if the lab was not performed correctly.
  136.  
  137. Note
  138. 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.
  139.  
  140. Consume NETCONF with Python
  141. Step 1
  142. 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.
  143.  
  144. Answer
  145. Verify that the loopback does not exist on your router and that GigabitEthernet0/0/0/0 has no configuration.
  146.  
  147. RP/0/0/CPU0:xrv# show run interface loopback100
  148. Mon Jul 25 17:12:54.990 UTC
  149. % No such configuration item(s)
  150.  
  151. RP/0/0/CPU0:xrv#
  152. RP/0/0/CPU0:xrv# show run interface GigabitEthernet 0/0/0/0
  153. Mon Jul 25 17:13:03.190 UTC
  154. interface GigabitEthernet0/0/0/0
  155. shutdown
  156. !
  157. Step 2 Show Me
  158. Navigate to the files/module2/lab7 and execute the xr_nc_configure_ipinterface.py script.
  159.  
  160. Note
  161. This is a working script that adds configures a loopback100 with an IPv4 Address.
  162.  
  163. Step 3
  164. 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.
  165.  
  166. Note
  167. 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!
  168.  
  169. Answer
  170. Before looking at the solution script:
  171.  
  172. You need to understand how to model the secondary IP addresses in XML.
  173.  
  174. 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.
  175.  
  176. As an added hint, the first line in the XML subtree filter should be the following:
  177.  
  178. <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
  179. After executing the modified script, you should see the following on the CLI:
  180.  
  181. RP/0/0/CPU0:xrv# show run interface gigabitEthernet 0/0/0/0
  182. Mon Jul 25 15:34:29.315 UTC
  183. interface GigabitEthernet0/0/0/0
  184. ipv4 address 10.23.23.1 255.255.255.0
  185. ipv4 address 20.32.32.1 255.255.255.0 secondary
  186. shutdown
  187. !
  188. Solution Script:
  189.  
  190. #!/usr/bin/env python
  191.  
  192. from lxml import etree
  193. from ncclient import manager
  194.  
  195. if __name__ == "__main__":
  196.  
  197. with manager.connect(host='xrv', port=830, username='cisco', password='cisco',
  198. hostkey_verify=False, device_params={'name': 'iosxr'},
  199. allow_agent=False, look_for_keys=False) as device:
  200.  
  201. nc_filter = """
  202. <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
  203. <interface-configuration>
  204. </interface-configuration>
  205. </interface-configurations>
  206. """
  207.  
  208. nc_get_reply = device.get(('subtree', nc_filter))
  209. print nc_get_reply
  210.  
  211. nc_filter = """
  212. <config>
  213. <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
  214. <interface-configuration>
  215. <active>act</active>
  216. <interface-name>GigabitEthernet0/0/0/0</interface-name>
  217. <ipv4-network xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-io-cfg">
  218. <addresses>
  219. <primary>
  220. <address>10.23.23.1</address>
  221. <netmask>255.255.255.0</netmask>
  222. </primary>
  223. <secondaries>
  224. <secondary>
  225. <address>20.32.32.1</address>
  226. <netmask>255.255.255.0</netmask>
  227. </secondary>
  228. </secondaries>
  229. </addresses>
  230. </ipv4-network>
  231. <shutdown></shutdown>
  232. </interface-configuration>
  233. </interface-configurations>
  234. </config>
  235. """
  236.  
  237.  
  238. nc_reply = device.edit_config(target='candidate', config=nc_filter)
  239. print nc_reply
  240. device.commit()
  241. Missing configuration for GigabitEthernet0/0/0/0
  242.  
  243. Submit
  244. Previous Page Next Page
  245. Terms & Conditions Privacy Statement Cookie Policy EULA Trademarks Keyboard Shortcuts
  246. Devices
  247. Scenario
  248. Hints
  249. Job Aid
  250. This device is connected in a separate window.
  251.  
  252. Switch to Device Window
  253.  
  254. Bring the device back to this window.
  255.  
  256. Desktop Devices
  257. Workstation
  258. Console Devices
  259. Internet-Rtr
  260. xrv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement