Fix exec_command to hang indefinitely

Execution `recv_exit_status` before reading from channel may cause it hang
indefinitely.

Change-Id: I24dd3802133509f250659582ffb7d7f759e80988
Closes-Bug: #1615659
diff --git a/tempest/lib/common/ssh.py b/tempest/lib/common/ssh.py
index a831dbd..8e83775 100644
--- a/tempest/lib/common/ssh.py
+++ b/tempest/lib/common/ssh.py
@@ -121,7 +121,6 @@
             channel.fileno()  # Register event pipe
             channel.exec_command(cmd)
             channel.shutdown_write()
-            exit_status = channel.recv_exit_status()
 
             # If the executing host is linux-based, poll the channel
             if self._can_system_poll():
@@ -162,6 +161,8 @@
                 out_data = out_data.decode(encoding)
                 err_data = err_data.decode(encoding)
 
+            exit_status = channel.recv_exit_status()
+
             if 0 != exit_status:
                 raise exceptions.SSHExecCommandFailed(
                     command=cmd, exit_status=exit_status,