我正在编写一些非常基本的 netconf 脚本来了解它。需要帮助找出问题所在。当前尝试连接到运行 IOS XE 16.9.4 的 Cisco 9300
脚本如下:
from ncclient import manager
from pprint import pprint
import xmltodict
import xml.dom.minidom
router = {
'ip': '10.1.10.114',
'port': '830',
'username': '*****',
'password': '*****'
}
m = manager.connect(host=router['ip'], port=router['port'], username=router['username'], password=router['password'], device_params={'name':'iosxe'}, hostkey_verify=False)
print(m.connected)
running_config = m.get_config(source='running').xml
print(xml.dom.minidom.parseString(running_config).toprettyxml())
m.close_session()
它几乎是从解释 netconf 基础的博客中逐字复制的。脚本在 running_config 变量处失败(我尝试注释掉第二个打印语句,并得到相同的结果)
这是错误输出:
(network_automation) PS C:\automate\Network> python .\netconftest.py
True
Traceback (most recent call last):
File "C:\automate\Network\netconftest.py", line 19, in <module>
running_config = m.get_config(source='running').xml
File "C:\automate\Network\network_automation\lib\site-packages\ncclient\manager.py", line 246, in execute
return cls(self._session,
File "C:\automate\Network\network_automation\lib\site-packages\ncclient\operations\retrieve.py", line 166, in request
return self._request(node)
File "C:\automate\Network\network_automation\lib\site-packages\ncclient\operations\rpc.py", line 373, in _request
raise RPCError(to_ele(self._reply._raw), errs=errors)
ncclient.operations.rpc.RPCError: error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
error: 0 is not a valid value.
(network_automation) PS C:\automate\Network>
我不确定这是脚本错误还是与 IOS XE 版本有关,或者可能是我不知道的另一个变量。关于如何走上正轨的任何想法都会有所帮助。
谢谢,JD