From ef798f872fa9872136046d07e8f5047df8ad2a70 Mon Sep 17 00:00:00 2001 From: Daniel Clavijo Coca Date: Mon, 25 Mar 2019 08:41:26 -0600 Subject: [PATCH] F #3099 Show container log when action fails (cherry picked from commit 43e42127487a9b40d74bbd69f0a821bf4886a648) --- src/vmm_mad/remotes/lib/lxd/container.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/vmm_mad/remotes/lib/lxd/container.rb b/src/vmm_mad/remotes/lib/lxd/container.rb index 50b8fff4af..e7834f658e 100644 --- a/src/vmm_mad/remotes/lib/lxd/container.rb +++ b/src/vmm_mad/remotes/lib/lxd/container.rb @@ -166,6 +166,17 @@ class Container Command.execute(cmd, true) end + def show_log + cmd = "#{@lxc_command} info --show-log #{@lxc['name']}" + rc, o, e = Command.execute(cmd, false) + + if rc.zero? + OpenNebula.log o + else + OpenNebula.log_error e + end + end + #--------------------------------------------------------------------------- # Contianer Status Control #--------------------------------------------------------------------------- @@ -406,6 +417,9 @@ class Container # Waits or no for response depending on wait value def wait?(response, wait, timeout) @client.wait(response, timeout) unless wait == false + rescue LXDError => e + show_log + raise e end # Performs an action on the container that changes the execution status.