0

when I configure automation with napalm. I try use load_merge_candidate but it not running. My file configuration

import json
from napalm import get_network_driver
print ('conecting ssh')
driver = get_network_driver('ios')
iosvl2 = driver('192.168.1.2', 'khamnguyen', 'admin')
iosvl2.open()

print ('Accessing 192.168.1.2')
iosvl2.load_merge_candidate(filename='ACL1.cfg')

diffs = iosvl2.compare_config()
if len(diffs) > 0:
    print(diffs)
    iosvl2.commit_config()
else:
    print('No changes required.')
    iosvl2.discard_config()

iosvl2.close()

[enter image description here][1]

And ERR

   File "ConfACLWithNapalm2.py", line 9, in <module>
    iosvl2.load_merge_candidate(filename='ACL1.cfg')
  File "/usr/local/lib/python3.8/dist-packages/napalm/ios/ios.py", line 315, in                                               load_merge_candidate
    return_status, msg = self._load_candidate_wrapper(
  File "/usr/local/lib/python3.8/dist-packages/napalm/ios/ios.py", line 282, in                                               _load_candidate_wrapper
    (return_status, msg) = self._scp_file(
  File "/usr/local/lib/python3.8/dist-packages/napalm/ios/ios.py", line 620, in                                               _scp_file
    return self._xfer_file(
  File "/usr/local/lib/python3.8/dist-packages/napalm/ios/ios.py", line 676, in                                               _xfer_file
    if not transfer.verify_space_available():
  File "/usr/local/lib/python3.8/dist-packages/netmiko/scp_handler.py", line 178                                              , in verify_space_available
    space_avail = self.remote_space_available(search_pattern=search_pattern)
  File "/usr/local/lib/python3.8/dist-packages/netmiko/scp_handler.py", line 122                                              , in remote_space_available
    if "kbytes" in match.group(0) or "Kbytes" in match.group(0):
AttributeError: 'NoneType' object has no attribute 'group'

(I was enable SCP)

enter image description here

enter code here
  • It says that the error occurs in this line: `iosvl2.load_replace_candidate(filename='ACL1.cfg')` but I can't find this in your code, can you make sure that you show all your code. Also, edit your question so the first image can be opened. – debsim Jun 23 '20 at 18:02
  • That error is of another file. i edited the post.That is the err I encountered – Khám Nguyễn Jun 24 '20 at 01:49

1 Answers1

0

Can you try your config commands explicitly?

driver = get_network_driver('ios')
device = driver('192.168.159.10', 'admin', 'ultraconfig')
device.open()
device.load_merge_candidate(config='interface GigabitEthernet2\n ip address 
10.0.0.1 255.255.255.0\n no shutdown\n end\n')
print(device.compare_config())
device.commit_config()
device.close()
Mert Kulac
  • 294
  • 2
  • 19