mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes get_prompt() issue for network platforms using cliconf plugins (#34221)
Fixes #34220
This commit is contained in:
parent
98f3424ed0
commit
f1bda19dea
1 changed files with 3 additions and 3 deletions
|
@ -25,7 +25,7 @@ from abc import ABCMeta, abstractmethod
|
|||
from functools import wraps
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.module_utils._text import to_bytes, to_text
|
||||
from ansible.module_utils.six import with_metaclass
|
||||
|
||||
try:
|
||||
|
@ -45,8 +45,8 @@ except ImportError:
|
|||
def enable_mode(func):
|
||||
@wraps(func)
|
||||
def wrapped(self, *args, **kwargs):
|
||||
prompt = self.get_prompt()
|
||||
if not str(prompt).strip().endswith('#'):
|
||||
prompt = self._connection.get_prompt()
|
||||
if not to_text(prompt, errors='surrogate_or_strict').strip().endswith('#'):
|
||||
raise AnsibleError('operation requires privilege escalation')
|
||||
return func(self, *args, **kwargs)
|
||||
return wrapped
|
||||
|
|
Loading…
Reference in a new issue