【问题标题】:AttributeError: 'NoneType' object has no attribute 'group' problemAttributeError: 'NoneType' 对象没有属性 'group' 问题
【发布时间】:2020-03-31 06:53:41
【问题描述】:

大家好,我的代码有问题,它没有运行:

from napalm import get_network_driver


driver = get_network_driver('ios')
device = driver('192.168.112.130', 'abc', '123')
device.open()


device.load_merge_candidate(filename='IOSConfig.txt')
print(device.compare_config())

if len(device.compare_config()) > 0:
    choice = input('\nWould you like commit these changes? [y/n]: ')
    if choice == 'y':
        print('Committing ...')
        device.commit_config()
    else:
        print('Discarding ...')
        device.discard_config()
else:
    print('No difference')

# close the session with the device.
device.close()
print('Done.')

错误是: AttributeError:“NoneType”对象没有属性“组”

【问题讨论】:

  • 欢迎来到 Stack Overflow。请提供MVCE,包括您的错误的回溯。目前,我们甚至无法猜测问题所在。
  • minimal reproducible example 和完整匹配的回溯-如果您希望至少得到任何帮助...

标签: python ios


【解决方案1】:

脚本没问题,但您需要确保您的 cisco 设备必须有真正的闪存并且应该通过 SCP 服务器启用。在模拟中,有时 cisco 映像没有闪存。

在下面尝试使用具有闪存的路由器。确保您已经拥有用户凭据。 ! aaa 新型号 ! ! aaa 认证登录 默认本地 aaa 授权 exec 默认本地 ! ip scp 服务器启用 ! 档案 路径 flash0:

脚本将执行以下任务,以便您的路由器 CMD:'终端宽度 511' 19:23:52 UTC 2021 年 9 月 3 日星期五 CMD:'终端长度 0' 19:23:52 UTC 2021 年 9 月 3 日星期五 CMD:'dir' 19:23:52 UTC 2021 年 9 月 3 日星期五 CMD:'dir flash0:' 19:23:52 UTC 2021 年 9 月 3 日星期五 CMD:'dir flash0:/merge_config.txt' 19:23:53 UTC 2021 年 9 月 3 日星期五 CMD:'验证 /md5 flash0:/merge_config.txt' 19:23:53 UTC 2021 年 9 月 3 日星期五 CMD:'show archive config incremental-diffs flash0:/merge_config.txt ignorecase' 19:23:53 UTC Fri Sep 3 2021

【讨论】:

  • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
猜你喜欢
  • 2018-08-03
  • 1970-01-01
  • 1970-01-01
  • 2019-01-01
  • 2021-12-26
  • 2019-07-23
  • 2018-05-13
  • 2020-09-07
  • 2017-05-03
相关资源
最近更新 更多