Skip to content

Commit

Permalink
pep8: fix using autopep8 agressive
Browse files Browse the repository at this point in the history
  • Loading branch information
ader1990 committed Oct 3, 2023
1 parent 79407dd commit ce58f6c
Show file tree
Hide file tree
Showing 58 changed files with 408 additions and 349 deletions.
13 changes: 7 additions & 6 deletions coriolis/api/v1/minion_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ def _check_pool_numeric_values(
if maximum_minions < minimum_minions:
raise Exception(
"'maximum_minions' value (%s) must be at least as large as"
" the 'minimum_minions' value (%s)." % (
maximum_minions, minimum_minions))
" the 'minimum_minions' value (%s)." %
(maximum_minions, minimum_minions))
if minion_max_idle_time is not None:
if minion_max_idle_time <= 0:
raise Exception(
"'minion_max_idle_time' must be a strictly positive "
"integer. Got: %s" % maximum_minions)

@api_utils.format_keyerror_message(resource='minion_pool', method='create')
@api_utils.format_keyerror_message(resource='minion_pool',
method='create')
def _validate_create_body(self, ctxt, body):
minion_pool = body["minion_pool"]
name = minion_pool["name"]
Expand Down Expand Up @@ -141,7 +142,8 @@ def create(self, req, body):
minion_max_idle_time, minion_retention_strategy, notes=notes,
skip_allocation=skip_allocation))

@api_utils.format_keyerror_message(resource='minion_pool', method='update')
@api_utils.format_keyerror_message(resource='minion_pool',
method='update')
def _validate_update_body(self, id, context, body):
minion_pool = body["minion_pool"]
if 'endpoint_id' in minion_pool:
Expand Down Expand Up @@ -179,8 +181,7 @@ def _validate_update_body(self, id, context, body):
elif minion_pool['platform'] == (
constants.PROVIDER_PLATFORM_DESTINATION):
self._endpoints_api.validate_endpoint_destination_minion_pool_options(
context, minion_pool['endpoint_id'],
vals['environment_options'])
context, minion_pool['endpoint_id'], vals['environment_options'])
else:
raise Exception(
"Unknown pool platform: %s" % minion_pool[
Expand Down
3 changes: 2 additions & 1 deletion coriolis/api/v1/replica_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __init__(self):
@api_wsgi.action('delete-disks')
def _delete_disks(self, req, id, body):
context = req.environ['coriolis.context']
context.can(replica_policies.get_replicas_policy_label("delete_disks"))
context.can(
replica_policies.get_replicas_policy_label("delete_disks"))
try:
return replica_tasks_execution_view.single(
req, self._replica_api.delete_disks(context, id))
Expand Down
3 changes: 2 additions & 1 deletion coriolis/api/v1/replicas.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def _update_storage_mappings(original_storage_mappings,

backend_mappings = original_storage_mappings.get(
'backend_mappings', [])
new_backend_mappings = new_storage_mappings.get('backend_mappings', [])
new_backend_mappings = new_storage_mappings.get(
'backend_mappings', [])
new_backend_mapping_sources = [mapping['source'] for mapping in
new_backend_mappings]

Expand Down
10 changes: 5 additions & 5 deletions coriolis/api/v1/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ def _setup_routes(self, mapper, ext_mgr):

self.resources['endpoint_destination_minion_pool_options'] = \
endpoint_destination_minion_pool_options.create_resource()
mapper.resource('minion_pool_options',
'endpoints/{endpoint_id}/destination-minion-pool-options',
controller=(
self.resources[
'endpoint_destination_minion_pool_options']))
mapper.resource(
'minion_pool_options',
'endpoints/{endpoint_id}/destination-minion-pool-options',
controller=(self.resources
['endpoint_destination_minion_pool_options']))

endpoint_actions_resource = endpoint_actions.create_resource()
self.resources['endpoint_actions'] = endpoint_actions_resource
Expand Down
4 changes: 2 additions & 2 deletions coriolis/api/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def validate_instances_list_for_transfer(instances):
inst: count for (inst, count) in appearances.items() if count > 1}
if duplicates:
raise exception.InvalidInput(
"Transfer action instances (%s) list contained duplicates: %s " % (
instances, duplicates))
"Transfer action instances (%s) list contained duplicates: %s " %
(instances, duplicates))

return instances
2 changes: 1 addition & 1 deletion coriolis/api/v1/views/diagnostic_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def single(req, diag):
return {"diagnostic": diag}
return {"diagnostic": diag}


def collection(req, diag):
Expand Down
7 changes: 3 additions & 4 deletions coriolis/cmd/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from coriolis import utils

api_opts = [
cfg.IntOpt('worker_count',
min=1, default=processutils.get_worker_count(),
help='Number of processes in which the service will be running')
]
cfg.IntOpt(
'worker_count', min=1, default=processutils.get_worker_count(),
help='Number of processes in which the service will be running')]

CONF = cfg.CONF
CONF.register_opts(api_opts, 'api')
Expand Down
7 changes: 3 additions & 4 deletions coriolis/cmd/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
from coriolis import utils

conductor_opts = [
cfg.IntOpt('worker_count',
min=1, default=processutils.get_worker_count(),
help='Number of processes in which the service will be running')
]
cfg.IntOpt(
'worker_count', min=1, default=processutils.get_worker_count(),
help='Number of processes in which the service will be running')]

CONF = cfg.CONF
CONF.register_opts(conductor_opts, 'conductor')
Expand Down
7 changes: 3 additions & 4 deletions coriolis/cmd/minion_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
from coriolis.minion_manager.rpc import server as rpc_server

minion_manager_opts = [
cfg.IntOpt('worker_count',
min=1, default=1,
help='Number of processes in which the service will be running')
]
cfg.IntOpt(
'worker_count', min=1, default=1,
help='Number of processes in which the service will be running')]

CONF = cfg.CONF
CONF.register_opts(minion_manager_opts, 'minion_manager')
Expand Down
7 changes: 3 additions & 4 deletions coriolis/cmd/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
from coriolis.scheduler.rpc import server as rpc_server

scheduler_opts = [
cfg.IntOpt('worker_count',
min=1, default=1,
help='Number of processes in which the service will be running')
]
cfg.IntOpt(
'worker_count', min=1, default=1,
help='Number of processes in which the service will be running')]

CONF = cfg.CONF
CONF.register_opts(scheduler_opts, 'scheduler')
Expand Down
7 changes: 3 additions & 4 deletions coriolis/cmd/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
from coriolis.worker.rpc import server as rpc_server

worker_opts = [
cfg.IntOpt('worker_count',
min=1, default=processutils.get_worker_count(),
help='Number of processes in which the service will be running')
]
cfg.IntOpt(
'worker_count', min=1, default=processutils.get_worker_count(),
help='Number of processes in which the service will be running')]

CONF = cfg.CONF
CONF.register_opts(worker_opts, 'worker')
Expand Down
20 changes: 10 additions & 10 deletions coriolis/conductor/rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,10 @@ def migrate_instances(self, ctxt, origin_endpoint_id,
source_environment=source_environment,
user_scripts=user_scripts)

def deploy_replica_instances(self, ctxt, replica_id,
instance_osmorphing_minion_pool_mappings=None,
clone_disks=False,
force=False, skip_os_morphing=False,
user_scripts=None):
def deploy_replica_instances(
self, ctxt, replica_id,
instance_osmorphing_minion_pool_mappings=None, clone_disks=False,
force=False, skip_os_morphing=False, user_scripts=None):
return self._call(
ctxt, 'deploy_replica_instances', replica_id=replica_id,
instance_osmorphing_minion_pool_mappings=(
Expand Down Expand Up @@ -286,8 +285,8 @@ def set_task_error(self, ctxt, task_id, exception_details):
exception_details=exception_details)

def add_task_event(self, ctxt, task_id, level, message):
self._cast(
ctxt, 'add_task_event', task_id=task_id, level=level, message=message)
self._cast(ctxt, 'add_task_event', task_id=task_id,
level=level, message=message)

def add_task_progress_update(
self, ctxt, task_id, message, initial_step=0, total_steps=0,
Expand All @@ -306,8 +305,8 @@ def update_task_progress_update(
self._cast(
ctxt, 'update_task_progress_update', task_id=task_id,
progress_update_index=progress_update_index,
new_current_step=new_current_step, new_total_steps=new_total_steps,
new_message=new_message)
new_current_step=new_current_step,
new_total_steps=new_total_steps, new_message=new_message)

def create_replica_schedule(self, ctxt, replica_id,
schedule, enabled, exp_date,
Expand Down Expand Up @@ -426,7 +425,8 @@ def confirm_replica_minions_allocation(
def report_replica_minions_allocation_error(
self, ctxt, replica_id, minion_allocation_error_details):
self._call(
ctxt, 'report_replica_minions_allocation_error', replica_id=replica_id,
ctxt, 'report_replica_minions_allocation_error',
replica_id=replica_id,
minion_allocation_error_details=minion_allocation_error_details)

def confirm_migration_minions_allocation(
Expand Down
71 changes: 38 additions & 33 deletions coriolis/conductor/rpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,8 @@ def _check_task_cls_param_requirements(task, instance_task_info_keys):
for new_field in _check_task_cls_param_requirements(
task, task_info_keys):
if new_field not in modified_fields_by_queued_tasks:
modified_fields_by_queued_tasks[new_field] = [task]
modified_fields_by_queued_tasks[new_field] = [
task]
else:
modified_fields_by_queued_tasks[new_field].append(
task)
Expand Down Expand Up @@ -793,9 +794,8 @@ def _check_task_cls_param_requirements(task, instance_task_info_keys):
LOG.debug(
"Successfully processed following tasks for instance '%s' "
"for execution %s (type '%s') for any state conflict "
"checks: %s",
instance, execution.id, execution.type, [
(t.id, t.task_type) for t in queued_tasks])
"checks: %s", instance, execution.id, execution.type,
[(t.id, t.task_type) for t in queued_tasks])
LOG.debug(
"Successfully checked all tasks for instance '%s' as part of "
"execution '%s' (type '%s') for any state conflicts: %s",
Expand Down Expand Up @@ -1020,7 +1020,8 @@ def execute_replica_tasks(self, ctxt, replica_id, shutdown_instances):
else:
self._begin_tasks(ctxt, replica, execution)

return self.get_replica_tasks_execution(ctxt, replica_id, execution.id)
return self.get_replica_tasks_execution(
ctxt, replica_id, execution.id)

@replica_synchronized
def get_replica_tasks_executions(self, ctxt, replica_id,
Expand Down Expand Up @@ -1144,7 +1145,8 @@ def delete_replica_disks(self, ctxt, replica_id):
LOG.info("Replica tasks execution created: %s", execution.id)

self._begin_tasks(ctxt, replica, execution)
return self.get_replica_tasks_execution(ctxt, replica_id, execution.id)
return self.get_replica_tasks_execution(
ctxt, replica_id, execution.id)

@staticmethod
def _check_endpoints(ctxt, origin_endpoint, destination_endpoint):
Expand All @@ -1169,7 +1171,8 @@ def create_instances_replica(self, ctxt, origin_endpoint_id,
network_map, storage_mappings, notes=None,
user_scripts=None):
origin_endpoint = self.get_endpoint(ctxt, origin_endpoint_id)
destination_endpoint = self.get_endpoint(ctxt, destination_endpoint_id)
destination_endpoint = self.get_endpoint(
ctxt, destination_endpoint_id)
self._check_endpoints(ctxt, origin_endpoint, destination_endpoint)

replica = models.Replica()
Expand Down Expand Up @@ -1271,11 +1274,10 @@ def _get_provider_types(self, ctxt, endpoint):
return provider_types["types"]

@replica_synchronized
def deploy_replica_instances(self, ctxt, replica_id,
clone_disks, force,
instance_osmorphing_minion_pool_mappings=None,
skip_os_morphing=False,
user_scripts=None):
def deploy_replica_instances(
self, ctxt, replica_id, clone_disks, force,
instance_osmorphing_minion_pool_mappings=None,
skip_os_morphing=False, user_scripts=None):
replica = self._get_replica(ctxt, replica_id, include_task_info=True)
self._check_reservation_for_transfer(
replica, licensing_client.RESERVATION_TYPE_REPLICA)
Expand Down Expand Up @@ -1710,16 +1712,16 @@ def report_migration_minions_allocation_error(
ctxt, execution,
constants.EXECUTION_STATUS_ERROR_ALLOCATING_MINIONS)

def migrate_instances(self, ctxt, origin_endpoint_id,
destination_endpoint_id, origin_minion_pool_id,
destination_minion_pool_id,
instance_osmorphing_minion_pool_mappings,
source_environment, destination_environment,
instances, network_map, storage_mappings,
replication_count, shutdown_instances=False,
notes=None, skip_os_morphing=False, user_scripts=None):
def migrate_instances(
self, ctxt, origin_endpoint_id, destination_endpoint_id,
origin_minion_pool_id, destination_minion_pool_id,
instance_osmorphing_minion_pool_mappings, source_environment,
destination_environment, instances, network_map, storage_mappings,
replication_count, shutdown_instances=False, notes=None,
skip_os_morphing=False, user_scripts=None):
origin_endpoint = self.get_endpoint(ctxt, origin_endpoint_id)
destination_endpoint = self.get_endpoint(ctxt, destination_endpoint_id)
destination_endpoint = self.get_endpoint(
ctxt, destination_endpoint_id)
self._check_endpoints(ctxt, origin_endpoint, destination_endpoint)

destination_provider_types = self._get_provider_types(
Expand Down Expand Up @@ -2611,9 +2613,9 @@ def _start_task(task):
LOG.error(
"No info present for instance '%s' in action '%s' for task"
" '%s' (type '%s') of execution '%s' (type '%s'). "
"Defaulting to empty dict." % (
task.instance, action.id, task.id, task.task_type,
execution.id, execution.type))
"Defaulting to empty dict." %
(task.instance, action.id, task.id, task.task_type,
execution.id, execution.type))
task_info = {}
else:
task_info = action.info[task.instance]
Expand Down Expand Up @@ -2751,8 +2753,8 @@ def _start_task(task):
"tasks have been finalized and there are "
"no non-error parents to directly depend on, "
"but one or more on-error tasks have completed"
" successfully: %s",
task.id, parent_task_statuses)
" successfully: %s", task.id,
parent_task_statuses)
task_statuses[task.id] = _start_task(task)
# start on-error tasks only if at least one non-error
# parent task has completed successfully:
Expand Down Expand Up @@ -2989,7 +2991,8 @@ def _check_other_tasks_running(execution, current_task):
task_info['destination_minion_machine_id'],
task.id, task_type, updated_values)
db_api.update_minion_machine(
ctxt, task_info['destination_minion_machine_id'], updated_values)
ctxt, task_info['destination_minion_machine_id'],
updated_values)

elif task_type in (
constants.TASK_TYPE_ATTACH_VOLUMES_TO_OSMORPHING_MINION,
Expand Down Expand Up @@ -3137,7 +3140,8 @@ def task_completed(self, ctxt, task_id, task_result):
execution.type] % execution.action_id,
external=True):
action_id = execution.action_id
action = db_api.get_action(ctxt, action_id, include_task_info=True)
action = db_api.get_action(
ctxt, action_id, include_task_info=True)

updated_task_info = None
if task_result:
Expand Down Expand Up @@ -3204,8 +3208,8 @@ def _cancel_execution_for_osmorphing_debugging(self, ctxt, execution):
msg = (
"%s Please note that any cleanup operations this task "
"should have included will need to performed manually "
"once the debugging process has been completed." % (
msg))
"once the debugging process has been completed." %
(msg))
db_api.set_task_status(
ctxt, subtask.id,
constants.TASK_STATUS_CANCELED_FOR_DEBUGGING,
Expand Down Expand Up @@ -3503,8 +3507,8 @@ def delete_replica_schedule(self, ctxt, replica_id, schedule_id):
if replica_status not in valid_statuses:
raise exception.InvalidReplicaState(
'Replica Schedule cannot be deleted while the Replica is in '
'%s state. Please wait for the Replica execution to finish' % (
replica_status))
'%s state. Please wait for the Replica execution to finish' %
(replica_status))
db_api.delete_replica_schedule(
ctxt, replica_id, schedule_id, None,
lambda ctxt, sched: self._cleanup_schedule_resources(
Expand Down Expand Up @@ -3620,7 +3624,8 @@ def update_replica(

self._begin_tasks(ctxt, replica, execution)

return self.get_replica_tasks_execution(ctxt, replica_id, execution.id)
return self.get_replica_tasks_execution(
ctxt, replica_id, execution.id)

def get_diagnostics(self, ctxt):
diagnostics = utils.get_diagnostics_info()
Expand Down
4 changes: 2 additions & 2 deletions coriolis/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@

DEFAULT_OS_TYPE = OS_TYPE_LINUX

VALID_OS_TYPES = [
OS_TYPE_BSD, OS_TYPE_LINUX, OS_TYPE_OS_X, OS_TYPE_SOLARIS, OS_TYPE_WINDOWS]
VALID_OS_TYPES = [OS_TYPE_BSD, OS_TYPE_LINUX,
OS_TYPE_OS_X, OS_TYPE_SOLARIS, OS_TYPE_WINDOWS]

TMP_DIRS_KEY = "__tmp_dirs"

Expand Down
Loading

0 comments on commit ce58f6c

Please sign in to comment.