Readability fixes for cleaning_reboot code

As requested in code review for Change ID
Iee3aeea198c556ab9adb9dcfd949d9cffb51418c, this refactors the two if
statements into an if/else for improved readability.

Change-Id: I07e502965ee14072f51d4e43f2d44fcc0f9f6413
This commit is contained in:
Jay Faulkner 2016-03-30 16:28:59 +00:00
parent bf985bcdd9
commit 2cd88d8691

View File

@ -300,19 +300,18 @@ class BaseAgentVendor(base.VendorInterface):
manual_clean = node.target_provision_state == states.MANAGEABLE
agent_commands = self._client.get_commands_status(task.node)
if (not agent_commands and
task.node.driver_internal_info.get('cleaning_reboot')):
# Node finished a cleaning step that requested a reboot, and
# this is the first heartbeat after booting. Continue cleaning.
info = task.node.driver_internal_info
info.pop('cleaning_reboot', None)
task.node.driver_internal_info = info
self.notify_conductor_resume_clean(task)
return
if not agent_commands:
# Agent has no commands whatsoever
return
if task.node.driver_internal_info.get('cleaning_reboot'):
# Node finished a cleaning step that requested a reboot, and
# this is the first heartbeat after booting. Continue cleaning.
info = task.node.driver_internal_info
info.pop('cleaning_reboot', None)
task.node.driver_internal_info = info
self.notify_conductor_resume_clean(task)
return
else:
# Agent has no commands whatsoever
return
command = self._get_completed_cleaning_command(task, agent_commands)
LOG.debug('Cleaning command status for node %(node)s on step %(step)s:'