strip garbage from end of comware backup

This commit is contained in:
ROTTLER Tamas 2023-03-04 22:06:17 +01:00
parent 7961bb6ce7
commit 62f6891024

View File

@ -397,6 +397,10 @@ class ComwareConfig(ConfigWithShell):
channel = self.ssh.invoke_shell() channel = self.ssh.invoke_shell()
self._shell_command(channel, 'screen-length disable', waitfor='>\s*$', waitmax=1) self._shell_command(channel, 'screen-length disable', waitfor='>\s*$', waitmax=1)
dicur = self._shell_command(channel, 'display current-configuration', waitfor='(?m:^return\s*$)') dicur = self._shell_command(channel, 'display current-configuration', waitfor='(?m:^return\s*$)')
# strip garbage after 'return' if return appears *before* last line
for i in range(-2, -6, -1):
if re.search('^\s*return\s*$', dicur[i]):
del dicur[i:]
self.config = '\n'.join(dicur) self.config = '\n'.join(dicur)
def is_bad_config(self): def is_bad_config(self):