简体   繁体   中英

AttributeError: 'NoneType' object has no attribute 'group' problem

hello guys i have a problem with my code this isn't running:

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.')

and the error is: AttributeError: 'NoneType' object has no attribute 'group'

Script is okay , but you need to make sure your cisco device must have real flash and should be enable with SCP server. In Simulation sometime cisco image doesn't have flash.

Try below with router which have flash. Make sure you have user credentials in place already. ! aaa new-model ! ! aaa authentication login default local aaa authorization exec default local ! ip scp server enable ! archive path flash0:

Script will do below task so your router CMD: 'terminal width 511' 19:23:52 UTC Fri Sep 3 2021 CMD: 'terminal length 0' 19:23:52 UTC Fri Sep 3 2021 CMD: 'dir' 19:23:52 UTC Fri Sep 3 2021 CMD: 'dir flash0:' 19:23:52 UTC Fri Sep 3 2021 CMD: 'dir flash0:/merge_config.txt' 19:23:53 UTC Fri Sep 3 2021 CMD: 'verify /md5 flash0:/merge_config.txt' 19:23:53 UTC Fri Sep 3 2021 CMD: 'show archive config incremental-diffs flash0:/merge_config.txt ignorecase' 19:23:53 UTC Fri Sep 3 2021

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM