1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix junos terminal regex for cluster srx devices (#53006)

* Fix junos terminal regex for cluster srx devices

Fixes #50726

*  Modify junos terminal regex to match for
   string `{primary:node0}` which is also part of the
   prompt.
*  Modify network_cli connection plugin to ignore
   multiple prompt matched lines.

* Fix review comment
This commit is contained in:
Ganesh Nalawade 2019-03-07 13:52:36 +05:30 committed by GitHub
parent be3fe8f364
commit 7a36c7ae2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -539,9 +539,14 @@ class Connection(NetworkConnectionBase):
''' '''
cleaned = [] cleaned = []
for line in resp.splitlines(): for line in resp.splitlines():
if (command and line.strip() == command.strip()) or self._matched_prompt.strip() in line: if command and line.strip() == command.strip():
continue continue
cleaned.append(line)
for prompt in self._matched_prompt.strip().splitlines():
if prompt.strip() in line:
break
else:
cleaned.append(line)
return b'\n'.join(cleaned).strip() return b'\n'.join(cleaned).strip()
def _find_prompt(self, response): def _find_prompt(self, response):

View file

@ -32,7 +32,7 @@ display = Display()
class TerminalModule(TerminalBase): class TerminalModule(TerminalBase):
terminal_stdout_re = [ terminal_stdout_re = [
re.compile(br"[\r\n]?[\w@+\-\.:\/\[\]]+[>#%] ?$"), re.compile(br"({primary:node\d+})?[\r\n]?[\w@+\-\.:\/\[\]]+[>#%] ?$"),
] ]
terminal_stderr_re = [ terminal_stderr_re = [