handle invalid utf8 characters in router configs
This commit is contained in:
parent
c0f32f6a12
commit
8386c35096
@ -282,7 +282,7 @@ class RouterosConfig(Config):
|
||||
iproute.append(line)
|
||||
|
||||
stdin, stdout, stderr = self.ssh.exec_command('/system backup save dont-encrypt=yes name=autobck')
|
||||
output = str(stdout.read(), 'utf8')
|
||||
output = str(stdout.read(), 'utf8', 'backslashreplace')
|
||||
if not re.search('Configuration backup saved', output):
|
||||
raise RuntimeError(f'"/system backup" failed: {output.strip()}')
|
||||
|
||||
@ -415,7 +415,7 @@ class ConfigWithShell(Config):
|
||||
raise RuntimeError(f'shell recv timeout (after receiving {len(output)} characters)')
|
||||
time.sleep(0.1)
|
||||
while channel.recv_ready():
|
||||
output += str(channel.recv(65536), 'utf8')
|
||||
output += str(channel.recv(65536), 'utf8', 'backslashreplace')
|
||||
|
||||
|
||||
class AsaConfig(ConfigWithShell):
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: set router configuration backup directory
|
||||
hosts: routeros,ciscoasa,!ciscoasa_slave,ciscoios,cisconexus,hpcomware
|
||||
hosts: routeros,ciscoasa,!ciscoasa_slave,ciscoios,cisconexus,hpcomware,!no_routerbackup
|
||||
gather_facts: no
|
||||
tags: always
|
||||
tasks:
|
||||
@ -11,7 +11,7 @@
|
||||
routerbackup_maxage: 24
|
||||
|
||||
- name: use router backup role
|
||||
hosts: routeros,ciscoasa,!ciscoasa_slave,ciscoios,cisconexus,hpcomware
|
||||
hosts: routeros,ciscoasa,!ciscoasa_slave,ciscoios,cisconexus,hpcomware,!no_routerbackup
|
||||
gather_facts: no
|
||||
roles:
|
||||
- routerbackup
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user