diff --git a/coriolis/minion_manager/rpc/tasks.py b/coriolis/minion_manager/rpc/tasks.py index 60d4b5018..f52e9482a 100644 --- a/coriolis/minion_manager/rpc/tasks.py +++ b/coriolis/minion_manager/rpc/tasks.py @@ -185,8 +185,9 @@ class ReportMinionAllocationFailureForMigrationTask( _BaseReportMinionAllocationFailureForActionTask): def _get_task_name(self, action_id): - return MINION_POOL_REPORT_MIGRATION_ALLOCATION_FAILURE_TASK_NAME_FORMAT % ( - action_id) + return ( + MINION_POOL_REPORT_MIGRATION_ALLOCATION_FAILURE_TASK_NAME_FORMAT + % (action_id)) def _report_machine_allocation_failure( self, context, action_id, failure_str): @@ -198,8 +199,9 @@ class ReportMinionAllocationFailureForReplicaTask( _BaseReportMinionAllocationFailureForActionTask): def _get_task_name(self, action_id): - return MINION_POOL_REPORT_REPLICA_ALLOCATION_FAILURE_TASK_NAME_FORMAT % ( - action_id) + return ( + MINION_POOL_REPORT_REPLICA_ALLOCATION_FAILURE_TASK_NAME_FORMAT + % (action_id)) def _report_machine_allocation_failure( self, context, action_id, failure_str): @@ -402,8 +404,9 @@ def _get_action_label(self): return "migration" def _get_task_name(self, action_id): - return MINION_POOL_CONFIRM_MIGRATION_MINION_ALLOCATION_TASK_NAME_FORMAT % ( - action_id) + return ( + MINION_POOL_CONFIRM_MIGRATION_MINION_ALLOCATION_TASK_NAME_FORMAT + % (action_id)) def _confirm_machine_allocation_for_action( self, context, action_id, machine_allocations): @@ -418,8 +421,9 @@ def _get_action_label(self): return "replica" def _get_task_name(self, action_id): - return MINION_POOL_CONFIRM_REPLICA_MINION_ALLOCATION_TASK_NAME_FORMAT % ( - action_id) + return ( + MINION_POOL_CONFIRM_REPLICA_MINION_ALLOCATION_TASK_NAME_FORMAT + % (action_id)) def _confirm_machine_allocation_for_action( self, context, action_id, machine_allocations): @@ -624,7 +628,7 @@ def __init__( resource_deployment_task_type = ( constants.TASK_TYPE_SET_UP_DESTINATION_POOL_SHARED_RESOURCES) resource_cleanup_task_type = ( - constants.TASK_TYPE_TEAR_DOWN_DESTINATION_POOL_SHARED_RESOURCES) + constants.TASK_TYPE_TEAR_DOWN_DESTINATION_POOL_SHARED_RESOURCES) # noqa: E501 super(AllocateSharedPoolResourcesTask, self).__init__( minion_pool_id, minion_machine_id, resource_deployment_task_type, cleanup_task_runner_type=resource_cleanup_task_type, **kwargs) @@ -699,7 +703,7 @@ def __init__( constants.TASK_TYPE_TEAR_DOWN_SOURCE_POOL_SHARED_RESOURCES) if minion_pool_type != constants.PROVIDER_PLATFORM_SOURCE: resource_deallocation_task = ( - constants.TASK_TYPE_TEAR_DOWN_DESTINATION_POOL_SHARED_RESOURCES) + constants.TASK_TYPE_TEAR_DOWN_DESTINATION_POOL_SHARED_RESOURCES) # noqa: E501 super(DeallocateSharedPoolResourcesTask, self).__init__( minion_pool_id, minion_machine_id, resource_deallocation_task, **kwargs) @@ -770,7 +774,8 @@ def execute(self, context, origin, destination, task_info): "Minion machine entry with ID '%s' already exists within " "the DB and it is in '%s' status instead of the expected " "'%s' status. Existing machine's properties are: %s" % ( - self._minion_machine_id, minion_machine.allocation_status, + self._minion_machine_id, + minion_machine.allocation_status, constants.MINION_MACHINE_STATUS_UNINITIALIZED, minion_machine.to_dict())) if minion_machine.pool_id != self._minion_pool_id: @@ -962,8 +967,9 @@ def revert(self, context, origin, destination, task_info, **kwargs): context, origin, destination, cleanup_info, **kwargs) except Exception: log_msg = ( - "[Task '%s'] Exception occurred while attempting to revert " - "deployment of minion machine with ID '%s' for pool '%s'." % ( + "[Task '%s'] Exception occurred while attempting to " + "revert deployment of minion machine with ID '%s' " + "for pool '%s'." % ( self._task_name, self._minion_machine_id, self._minion_pool_id)) if not self._raise_on_cleanup_failure: @@ -1063,7 +1069,7 @@ class HealthcheckMinionMachineTask(BaseMinionManangerTask): def __init__( self, minion_pool_id, minion_machine_id, minion_pool_type, fail_on_error=False, - machine_status_on_success=constants.MINION_MACHINE_STATUS_AVAILABLE, + machine_status_on_success=constants.MINION_MACHINE_STATUS_AVAILABLE, # noqa: E501 **kwargs): self._fail_on_error = fail_on_error self._machine_status_on_success = machine_status_on_success @@ -1232,7 +1238,8 @@ def execute(self, context, origin, destination, task_info): machine = self._get_minion_machine( context, self._minion_machine_id, raise_if_not_found=True) - if machine.power_status == constants.MINION_MACHINE_POWER_STATUS_POWERED_ON: + if (machine.power_status == + constants.MINION_MACHINE_POWER_STATUS_POWERED_ON): LOG.debug( "[Task '%s'] Minion machine with ID '%s' from pool '%s' is " "already marked as powered on. Returning early." % ( @@ -1240,7 +1247,8 @@ def execute(self, context, origin, destination, task_info): self._minion_pool_id)) return task_info - if machine.power_status != constants.MINION_MACHINE_POWER_STATUS_POWERED_OFF: + if (machine.power_status != + constants.MINION_MACHINE_POWER_STATUS_POWERED_OFF): raise exception.InvalidMinionMachineState( "Minion machine with ID '%s' from pool '%s' is in '%s' state " "instead of the expected '%s' required for it to be powered " diff --git a/coriolis/tests/conductor/rpc/test_server.py b/coriolis/tests/conductor/rpc/test_server.py index 702bdc7bd..9132e2adc 100644 --- a/coriolis/tests/conductor/rpc/test_server.py +++ b/coriolis/tests/conductor/rpc/test_server.py @@ -7,12 +7,16 @@ from unittest import mock -from coriolis import constants, exception, schemas, utils from coriolis.conductor.rpc import server +from coriolis import constants from coriolis.db import api as db_api from coriolis.db.sqlalchemy import models +from coriolis import exception from coriolis.licensing import client as licensing_client -from coriolis.tests import test_base, testutils +from coriolis import schemas +from coriolis.tests import test_base +from coriolis.tests import testutils +from coriolis import utils from coriolis.worker.rpc import client as rpc_worker_client from oslo_concurrency import lockutils from oslo_config import cfg @@ -2104,8 +2108,7 @@ def call_set_task_host(): # task status is not in accepted state with self.assertRaisesRegex( exception.InvalidTaskState, - "expected statuses", - ): + "expected statuses"): call_set_task_host() mock_get_task.assert_called_once_with( @@ -2133,8 +2136,7 @@ def call_set_task_host(): ) with self.assertRaisesRegex( exception.InvalidTaskState, - "has no host", - ): + "has no host"): call_set_task_host() @mock.patch.object( @@ -2551,8 +2553,7 @@ def test_advance_execution_state_scheduled_tasks( mock_cancel_tasks_execution, # pylint: disable=unused-argument mock_get_execution_status, # pylint: disable=unused-argument mock_set_tasks_execution_status, # pylint: disable=unused-argument - config, - ): + config): tasks = config.get('tasks', []) execution = mock.Mock( status=constants.EXECUTION_STATUS_RUNNING, @@ -2575,7 +2576,7 @@ def test_advance_execution_state_scheduled_tasks( ) for task in tasks: - if not 'expected_status' in task: + if 'expected_status' not in task: continue kwargs = {'exception_details': mock.ANY} if task['expected_status'] == constants.TASK_STATUS_PENDING: