Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # SCRIPT BODY app.py
- from ncclient import manager
- import logging
- # logging.basicConfig(
- # level=logging.DEBUG,
- # )
- with manager.connect(host='172.17.14.102', port=830, username='admin', password='admin',
- device_params={'name': 'alu'},
- hostkey_verify=False) as m:
- req = '''
- <oper-data-format-cli-block>
- <cli-show>router interface</cli-show>
- </oper-data-format-cli-block>
- '''
- c = m.get(('subtree', req))
- print(c)
- # ROUTER CONFIG
- /configure system netconf no shutdown
- /configure system security user "admin" access netconf
- # EXAMPLE OUTPUT
- $ python app.py
- <?xml version="1.0" encoding="UTF-8"?>
- <rpc-reply message-id="urn:uuid:a9dd308f-0b70-4879-854d-0ec53488c4b8" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <data xmlns="urn:alcatel-lucent.com:sros:ns:yang:cli-content-layer-r13">
- <oper-data-format-cli-block>
- <item>
- <cli-show>router interface</cli-show>
- <response>
- ===============================================================================
- Interface Table (Router: Base)
- ===============================================================================
- Interface-Name Adm Opr(v4/v6) Mode Port/SapId
- IP-Address PfxState
- -------------------------------------------------------------------------------
- NB-RNC17-EVO-Cluster13-IuB-3210 Up Down/Down Network n/a
- - -
- NB-RNC17-EVO-Cluster13-IuB-3213 Up Down/Down Network n/a
- - -
- system Up Up/Down Network system
- 2.2.2.2/32 n/a
- toAlunet Up Up/Down Network 1/1/1
- 172.17.14.102/21 n/a
- to_078-0000-BH14 Up Down/Down Network n/a
- 10.220.0.5/31 n/a
- to_078-0000-BH14-2 Up Down/Down Network n/a
- 10.220.5.19/31 n/a
- to_078-0001-BH05 Up Down/Down Network n/a
- 10.220.0.16/31 n/a
- to_078-0011-BH02 Up Down/Down Network 4/1/2
- 10.220.0.50/31 n/a
- to_078-0023-BH04 Up Down/Down Network n/a
- 10.220.0.12/31 n/a
- to_078-0061-BH02 Up Down/Down Network 7/1/3
- 10.220.1.170/31 n/a
- to_078-0089-BH02 Up Down/Down Network 4/1/3
- 10.220.1.17/31 n/a
- to_078-0104-BH02 Up Down/Down Network 6/2/1
- 10.220.0.52/31 n/a
- to_078-0205-BH04 Up Down/Down Network n/a
- 10.220.0.14/31 n/a
- to_078-0352-BH02 Up Down/Down Network 7/1/2
- 10.220.0.54/31 n/a
- to_078-0503-BH02 Up Down/Down Network 4/2/5
- 10.220.5.233/31 n/a
- to_078-0729-BH02 Up Down/Down Network 2/1/9
- 10.220.5.55/31 n/a
- to_078-1035-BH02 Up Down/Down Network 7/1/4
- 10.220.2.202/31 n/a
- to_078-1109-BH02 Up Down/Down Network 4/1/4
- 10.220.2.46/31 n/a
- to_078-1154-BH02 Up Down/Down Network n/a
- 10.220.4.248/31 n/a
- to_078-1241-BH02 Up Down/Down Network 4/1/1
- 10.220.0.48/31 n/a
- to_078-1406-BH01 Up Down/Down Network n/a
- 10.220.0.222/31 n/a
- to_078-2579-BH01 Up Down/Down Network n/a
- 10.220.5.234/31 n/a
- -------------------------------------------------------------------------------
- Interfaces : 22
- ===============================================================================
- </response>
- </item>
- </oper-data-format-cli-block>
- </data>
- </rpc-reply>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement