Bug #20549
Updated by Tomáš Strachota over 7 years ago
When a reboot fails for one or more hosts, api glues the error messages together and puts them into one message. It also prints details about exception class (Foreman::WrappedException) which makes it even worse to read. We should remove the wrapped exception details and put each message on it's own line. *Current response:* <pre> Current situation : ` {"error" => { "message" => "Errors during reboot: mac525400d8c85d: ERF50-4973 [Foreman::WrappedException]: Unable to reboot mac525400d8c85d via https://192.168.122.25:8443: Failed to open TCP connection to 192.168.122.25:8443 (No route to host - connect(2) for "192.168.122.25" port 8443) ([Errno::EHOSTUNREACH]: Failed to open TCP connection to 192.168.122.25:8443 (No route to host - connect(2) for...) mac52540022ab12: ERF50-4973 [Foreman::WrappedException]: Unable to reboot mac52540022ab12 via https://192.168.122.156:8443: Failed to open TCP connection to 192.168.122.156:8443 (No route to host - connect(2) for "192.168.122.156" port 8443) ([Errno::EHOSTUNREACH]: Failed to open TCP connection to 192.168.122.156:8443 (No route to host - connect(2) fo...)" } } </pre> *Expected result:* The common messages should put status of each host on a single line. The response should also contain the data about failures in machine readable format. <pre> { "error" => { "message" => "Errors during reboot:\n Unable to reboot mac525400d8c85d via https://192.168.122.25:8443: Failed to open TCP connection to 192.168.122.25:8443\n Unable to reboot mac52540022ab12 via https://192.168.122.156:8443: Failed to open TCP connection to 192.168.122.156:8443" "host_details" => [{ "name" => "mac525400d8c85d", "error" => "Failed to open TCP connection to 192.168.122.25:8443" },{ "name" => "mac52540022ab12", "error" => "Failed to open TCP connection to 192.168.122.156:8443" }] } } </pre> ` It will enable for easier usage in scripts. Eg. hammer can use the 'host_details' for printing nicely formatted messages: Expected : ` <pre> hammer discovery reboot --all Could not reboot the host(s): mac525400d8c85d: Failed to open TCP connection to 192.168.122.25:8443 mac52540022ab12: Failed to open TCP connection to 192.168.122.156:8443 </pre> `