Bug 1890: Use output from action 72/12472/3
authorMark Beierl <mark.beierl@canonical.com>
Fri, 19 Aug 2022 19:02:24 +0000 (15:02 -0400)
committerbeierlm <mark.beierl@canonical.com>
Tue, 23 Aug 2022 00:49:59 +0000 (02:49 +0200)
Pass the output from the action command back to the caller,
regardless of the status of action completion.  This allows
for failure messages to be passed through to the LCM for
storage in the action record.

Change-Id: I268c43225b71a80e54712743e61586d57952553e
Signed-off-by: Mark Beierl <mark.beierl@canonical.com>
n2vc/n2vc_juju_conn.py

index f0569b1..c6d00a8 100644 (file)
@@ -1061,15 +1061,17 @@ class N2VCJujuConnector(N2VCConnector):
                 if status == "completed":
                     return output
                 else:
-                    raise Exception("status is not completed: {}".format(status))
+                    if "output" in output:
+                        raise Exception(f'{status}: {output["output"]}')
+                    else:
+                        raise Exception(
+                            f"{status}: No further information received from action"
+                        )
+
             except Exception as e:
-                self.log.error(
-                    "Error executing primitive {}: {}".format(primitive_name, e)
-                )
+                self.log.error(f"Error executing primitive {primitive_name}: {e}")
                 raise N2VCExecutionException(
-                    message="Error executing primitive {} into ee={} : {}".format(
-                        primitive_name, ee_id, e
-                    ),
+                    message=f"Error executing primitive {primitive_name} in ee={ee_id}: {e}",
                     primitive_name=primitive_name,
                 )