From 06f178c7e7b04f7c9b608d16640f612f8e6cef98 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 15 Mar 2018 04:22:46 -0400 Subject: [PATCH 1/2] Enhance rpower bmcreboot, clear dumps if reboot to new firmware --- .../agent/hwctl/executor/openbmc_power.py | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py index 024f455cf..43d2c2429 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py @@ -159,13 +159,32 @@ class OpenBMCPowerTask(ParallelNodesCommand): new_status = '' try: obmc.login() + except (SelfServerException, SelfClientException) as e: + return self.callback.error(e.message, node) + + firm_obj_dict = {} + try: + has_functional, firm_obj_dict = obmc.list_firmware() + except (SelfServerException, SelfClientException) as e: + self.callback.syslog('%s: %s' % (node, e.message)) + + clear_flag = False + for key, value in firm_obj_dict.items(): + if not value.functional and value.priority == 0: + clear_flag = True + break + + if clear_flag: + self.callback.info('%s: Firmware will be flashed on reboot, deleting all BMC diagnostics...' % node) + try: + obmc.clear_dump('all') + except (SelfServerException, SelfClientException) as e: + self.callback.warn('%s: Could not clear BMC diagnostics successfully %s, ignoring...' % (node, e.message)) + + try: + obmc.reboot_bmc(optype) except (SelfServerException, SelfClientException) as e: self.callback.error(e.message, node) else: - try: - obmc.reboot_bmc(optype) - except (SelfServerException, SelfClientException) as e: - self.callback.error(e.message, node) - else: - self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES['bmcreboot'])) + self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES['bmcreboot'])) From 49d19b9017214a7186fe6ec54232407add1f431c Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 15 Mar 2018 23:04:24 -0400 Subject: [PATCH 2/2] modified depending on comments --- .../lib/python/agent/hwctl/executor/openbmc_power.py | 2 +- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py index 43d2c2429..807c23f16 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py @@ -179,7 +179,7 @@ class OpenBMCPowerTask(ParallelNodesCommand): try: obmc.clear_dump('all') except (SelfServerException, SelfClientException) as e: - self.callback.warn('%s: Could not clear BMC diagnostics successfully %s, ignoring...' % (node, e.message)) + self.callback.warn('%s: Could not clear BMC diagnostics successfully %s' % (node, e.message)) try: obmc.reboot_bmc(optype) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 5bbc34877..09f4de63b 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -3879,7 +3879,7 @@ sub rspconfig_dump_response { my $dump_id = $status_info{RSPCONFIG_DUMP_CLEAR_RESPONSE}{argv}; xCAT::MsgUtils->message("I", { data => ["[$dump_id] clear"] }, $callback) unless ($next_status{ $node_info{$node}{cur_status} }); } else { - my $error_msg = "Could not clear BMC diagnostics successfully (". $response_info->{'message'} . "), ignoring..."; + my $error_msg = "Could not clear BMC diagnostics successfully (". $response_info->{'message'} . ")"; xCAT::MsgUtils->message("W", { data => ["$node: $error_msg"] }, $callback) if ($next_status{ $node_info{$node}{cur_status} }); } }