Feature privilege status should only be checked if we need to escalate priv (https://github.com/ansible-collections/cisco.nxos/pull/61) (#69766)

Check feature privilege status only if priv escalation is required

Reviewed-by: https://github.com/apps/ansible-zuul
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
pull/69409/head
Nilashish Chakraborty 5 years ago committed by GitHub
parent 98a1e1f7a6
commit 6c9ebd76d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
---
bugfixes:
- Update terminal plugin to check feature privilege only when escalation is needed (https://github.com/ansible-collections/cisco.nxos/pull/61).

@ -57,8 +57,6 @@ class TerminalModule(TerminalBase):
out = self._exec_cli_command('show privilege')
out = to_text(out, errors='surrogate_then_replace').strip()
if 'Disabled' in out:
raise AnsibleConnectionFailure('Feature privilege is not enabled')
# if already at privilege level 15 return
if '15' in out:
@ -67,6 +65,9 @@ class TerminalModule(TerminalBase):
if self.validate_user_role():
return
if 'Disabled' in out:
raise AnsibleConnectionFailure('Feature privilege is not enabled')
cmd = {u'command': u'enable'}
if passwd:
cmd[u'prompt'] = to_text(r"(?i)[\r\n]?Password: $", errors='surrogate_or_strict')

Loading…
Cancel
Save