Debian Codegraph @

ansible_collections/f5networks/f5_modules/plugins/terminal/bigip.py

raw symbols SCIP
1 #
2 # (c) 2016 Red Hat Inc.
3 #
4 # This file is part of Ansible
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19 from __future__ import (absolute_import, division, print_function)
20 __metaclass__ = type
21
22 import re
23
24 from ansible.plugins.terminal import TerminalBase
25
26
27 class TerminalModule(TerminalBase):
28
29 terminal_stdout_re = [
30 re.compile(br"[\r\n]?(?:\([^\)]+\)){,5}(?:>|#)\s*$"),
31 re.compile(br"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#)\s*$"),
32 re.compile(br"\[\w+\@[\w\-\.]+(?: [^\]])\] ?[>#\$]\s*$"),
33 re.compile(br"(?:new|confirm) password:")
34 ]
35
36 terminal_stderr_re = [
37 re.compile(br"% ?Error"),
38 re.compile(br"Syntax Error", re.I),
39 re.compile(br"% User not present"),
40 re.compile(br"% ?Bad secret"),
41 re.compile(br"invalid input", re.I),
42 re.compile(br"(?:incomplete|ambiguous) command", re.I),
43 re.compile(br"connection timed out", re.I),
44 re.compile(br"the new password was not confirmed", re.I),
45 re.compile(br"[^\r\n]+ not found", re.I),
46 re.compile(br"'[^']' +returned error code: ?\d+"),
47 re.compile(br"[^\r\n]\/bin\/(?:ba)?sh")
48 ]
49
50 def on_open_shell(self):
51 prompt = self._get_prompt()
52 if "tmos" in str(prompt):
53 self._exec_cli_command(b'modify cli preference display-threshold 0 pager disabled')
54 self._exec_cli_command(b'run /util bash -c "stty cols 1000000" 2> /dev/null')
55 else:
56 self._exec_cli_command(b'stty cols 1000000" 2> /dev/null')
57 self._exec_cli_command(b'tmsh modify cli preference display-threshold 0 pager disabled')