Fixes eos sending 'None' to device (#33015)
* Fix network_cli sometimes sending 'None' to device * Also fix `--become-method=enable`
This commit is contained in:
parent
5747bf34d1
commit
71a6dcdf3e
2 changed files with 6 additions and 4 deletions
|
@ -59,7 +59,7 @@ def set_constant(name, value, export=vars()):
|
||||||
|
|
||||||
|
|
||||||
# CONSTANTS ### yes, actual ones
|
# CONSTANTS ### yes, actual ones
|
||||||
BECOME_METHODS = ['sudo', 'su', 'pbrun', 'pfexec', 'doas', 'dzdo', 'ksu', 'runas', 'pmrun']
|
BECOME_METHODS = ['sudo', 'su', 'pbrun', 'pfexec', 'doas', 'dzdo', 'ksu', 'runas', 'pmrun', 'enable']
|
||||||
BECOME_ERROR_STRINGS = {
|
BECOME_ERROR_STRINGS = {
|
||||||
'sudo': 'Sorry, try again.',
|
'sudo': 'Sorry, try again.',
|
||||||
'su': 'Authentication failure',
|
'su': 'Authentication failure',
|
||||||
|
@ -68,7 +68,8 @@ BECOME_ERROR_STRINGS = {
|
||||||
'doas': 'Permission denied',
|
'doas': 'Permission denied',
|
||||||
'dzdo': '',
|
'dzdo': '',
|
||||||
'ksu': 'Password incorrect',
|
'ksu': 'Password incorrect',
|
||||||
'pmrun': 'You are not permitted to run this command'
|
'pmrun': 'You are not permitted to run this command',
|
||||||
|
'enable': '',
|
||||||
} # FIXME: deal with i18n
|
} # FIXME: deal with i18n
|
||||||
BECOME_MISSING_STRINGS = {
|
BECOME_MISSING_STRINGS = {
|
||||||
'sudo': 'sorry, a password is required to run sudo',
|
'sudo': 'sorry, a password is required to run sudo',
|
||||||
|
@ -78,7 +79,8 @@ BECOME_MISSING_STRINGS = {
|
||||||
'doas': 'Authorization required',
|
'doas': 'Authorization required',
|
||||||
'dzdo': '',
|
'dzdo': '',
|
||||||
'ksu': 'No password given',
|
'ksu': 'No password given',
|
||||||
'pmrun': ''
|
'pmrun': '',
|
||||||
|
'enable': '',
|
||||||
} # FIXME: deal with i18n
|
} # FIXME: deal with i18n
|
||||||
BLACKLIST_EXTS = ('.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt')
|
BLACKLIST_EXTS = ('.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt')
|
||||||
BOOL_TRUE = BOOLEANS_TRUE
|
BOOL_TRUE = BOOLEANS_TRUE
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Connection(ConnectionBase):
|
||||||
cmd = json.loads(to_text(cmd, errors='surrogate_or_strict'))
|
cmd = json.loads(to_text(cmd, errors='surrogate_or_strict'))
|
||||||
kwargs = {'command': to_bytes(cmd['command'], errors='surrogate_or_strict')}
|
kwargs = {'command': to_bytes(cmd['command'], errors='surrogate_or_strict')}
|
||||||
for key in ('prompt', 'answer', 'send_only'):
|
for key in ('prompt', 'answer', 'send_only'):
|
||||||
if key in cmd:
|
if cmd.get(key) is not None:
|
||||||
kwargs[key] = to_bytes(cmd[key], errors='surrogate_or_strict')
|
kwargs[key] = to_bytes(cmd[key], errors='surrogate_or_strict')
|
||||||
return self.send(**kwargs)
|
return self.send(**kwargs)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in a new issue