Fix network_cli exec_command connection init (#62344)
* Fix network_cli exec_command connection init Fixes https://github.com/ansible/ansible/issues/61596 * If `exec_command` method is invoked from module side on connection object to execute the command on target host check if connection is created if not create the connection. * Fix review comment
This commit is contained in:
parent
7a5a5e7c87
commit
74e4993628
1 changed files with 4 additions and 0 deletions
|
@ -138,6 +138,10 @@ class ConnectionProcess(object):
|
|||
if log_messages:
|
||||
display.display("jsonrpc request: %s" % data, log_only=True)
|
||||
|
||||
request = json.loads(to_text(data, errors='surrogate_or_strict'))
|
||||
if request.get('method') == "exec_command" and not self.connection.connected:
|
||||
self.connection._connect()
|
||||
|
||||
signal.alarm(self.connection.get_option('persistent_command_timeout'))
|
||||
|
||||
resp = self.srv.handle_request(data)
|
||||
|
|
Loading…
Reference in a new issue