嘿伙计们,我正在尝试测试凝固汽油弹的提交,但它无法找到 cfg 文件,我也尝试更改为“txt”,但同样的错误。这是我的代码:
import napalm
import json
driver = napalm.get_network_driver("ios")
device = driver(
hostname="10.0.0.254",
username="cisco",
password="cisco",
optional_args={"secret" : "cisco"}
)
device.open()
device.load_merge_candidate(filename="config.cfg")
device.commit_config()
device.close()
这是错误,两个文件都在同一个文件夹中:
user@user-pc:~/Documents/python_files$ /usr/bin/python3 /home/user/Documents/python_files/network/config_compare.py Traceback(最近一次调用最后):文件“/home/user/Documents/python_files /network/config_compare.py”,第 18 行,在 device.load_merge_candidate(filename="config.cfg") 文件“/home/user/.local/lib/python3.8/site-packages/napalm/ios/ios. py”,第 315 行,在 load_merge_candidate return_status 中,msg = self._load_candidate_wrapper(文件“/home/user/.local/lib/python3.8/site-packages/napalm/ios/ios.py”,第 282 行,在 _load_candidate_wrapper (return_status, msg) = self._scp_file( File "/home/user/.local/lib/python3.8/site-packages/napalm/ios/ios.py", line 620, in _scp_file return self._xfer_file( File “/home/user/.local/lib/python3.8/site-packages/napalm/ios/ios.py”,第 670 行,在 _xfer_file 中,使用 TransferClass(**kwargs) 作为传输:文件“/home/user/.local/lib/python3.8/site-packages/ netmiko/ssh_dispatcher.py”,第 278 行,在 FileTransfer 返回 FileTransferClass(*args, **kwargs) 文件“/home/user/.local/lib/python3.8/site-packages/netmiko/scp_handler.py”,行80,在初始化 self.source_md5 = self.file_md5(source_file) 文件“/home/user/.local/lib/python3.8/site-packages/netmiko/scp_handler.py”,第 257 行,在 file_md5 中打开(file_name,“rb ") as f: FileNotFoundError: [Errno 2] 没有这样的文件或目录:'config.c
求任何帮助。。