mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixes exec_command in shell (#20948)
transforms command to dict for processing by instance of Shell
This commit is contained in:
parent
64f98f855d
commit
67646a0771
1 changed files with 12 additions and 2 deletions
|
@ -282,11 +282,21 @@ class CliBase(object):
|
||||||
raise NetworkError(to_native(exc), commands=commands)
|
raise NetworkError(to_native(exc), commands=commands)
|
||||||
|
|
||||||
def exec_command(self, command):
|
def exec_command(self, command):
|
||||||
|
|
||||||
|
transform = ComplexDict(dict(
|
||||||
|
command=dict(key=True),
|
||||||
|
prompt=dict(),
|
||||||
|
response=dict()
|
||||||
|
))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmdobj = json.loads(command)
|
cmdobj = json.loads(command)
|
||||||
return self.shell.send_command(cmdobj)
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return (1, '', 'unable to parse request')
|
cmdobj = transform(command)
|
||||||
|
|
||||||
|
rc, out, err = self.shell.send_command(cmdobj)
|
||||||
|
|
||||||
|
return rc, out, err
|
||||||
|
|
||||||
def run_commands(self, commands):
|
def run_commands(self, commands):
|
||||||
return self.execute(to_list(commands))
|
return self.execute(to_list(commands))
|
||||||
|
|
Loading…
Reference in a new issue