From c11d41e99296a3578c3dc773092e7553ab04008c Mon Sep 17 00:00:00 2001 From: Cristian Matiut Date: Thu, 5 Oct 2023 15:59:55 +0300 Subject: [PATCH 1/2] pep8: fix api/v1 --- coriolis/api/v1/diagnostics.py | 7 +++-- coriolis/api/v1/endpoint_actions.py | 6 ++--- ...ndpoint_destination_minion_pool_options.py | 12 +++++---- .../api/v1/endpoint_destination_options.py | 6 ++--- coriolis/api/v1/endpoint_instances.py | 6 ++--- coriolis/api/v1/endpoint_networks.py | 6 ++--- .../v1/endpoint_source_minion_pool_options.py | 9 ++++--- coriolis/api/v1/endpoint_source_options.py | 6 ++--- coriolis/api/v1/endpoint_storage.py | 6 ++--- coriolis/api/v1/endpoints.py | 11 ++++---- coriolis/api/v1/migration_actions.py | 6 ++--- coriolis/api/v1/migrations.py | 18 +++++++------ coriolis/api/v1/minion_pool_actions.py | 8 +++--- coriolis/api/v1/minion_pools.py | 26 +++++++++++-------- coriolis/api/v1/providers.py | 6 ++--- coriolis/api/v1/regions.py | 10 +++---- coriolis/api/v1/replica_actions.py | 6 ++--- coriolis/api/v1/replica_schedules.py | 14 +++++----- .../api/v1/replica_tasks_execution_actions.py | 2 +- coriolis/api/v1/replica_tasks_executions.py | 6 ++--- coriolis/api/v1/replicas.py | 11 ++++---- coriolis/api/v1/router.py | 2 +- coriolis/api/v1/services.py | 10 +++---- 23 files changed, 104 insertions(+), 96 deletions(-) diff --git a/coriolis/api/v1/diagnostics.py b/coriolis/api/v1/diagnostics.py index 85b647aaa..4f7b3e0b4 100644 --- a/coriolis/api/v1/diagnostics.py +++ b/coriolis/api/v1/diagnostics.py @@ -1,14 +1,13 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -import logging - -from coriolis import exception -from coriolis.api import wsgi as api_wsgi from coriolis.api.v1.views import diagnostic_view +from coriolis.api import wsgi as api_wsgi from coriolis.diagnostics import api from coriolis.policies import diagnostics +import logging + LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/endpoint_actions.py b/coriolis/api/v1/endpoint_actions.py index d15eea6c5..7ab7b1881 100644 --- a/coriolis/api/v1/endpoint_actions.py +++ b/coriolis/api/v1/endpoint_actions.py @@ -1,13 +1,13 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from webob import exc - -from coriolis import exception from coriolis.api import wsgi as api_wsgi from coriolis.endpoints import api +from coriolis import exception from coriolis.policies import endpoints as endpoint_policies +from webob import exc + class EndpointActionsController(api_wsgi.Controller): def __init__(self): diff --git a/coriolis/api/v1/endpoint_destination_minion_pool_options.py b/coriolis/api/v1/endpoint_destination_minion_pool_options.py index 30b75cb2a..39b990e52 100644 --- a/coriolis/api/v1/endpoint_destination_minion_pool_options.py +++ b/coriolis/api/v1/endpoint_destination_minion_pool_options.py @@ -1,13 +1,13 @@ # Copyright 2020 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api.v1.views import endpoint_options_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_options import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) @@ -35,9 +35,11 @@ def index(self, req, endpoint_id): else: options = {} - return endpoint_options_view.destination_minion_pool_options_collection( + return (endpoint_options_view. + destination_minion_pool_options_collection)( req, - self._minion_pool_options_api.get_endpoint_destination_minion_pool_options( + (self._minion_pool_options_api. + get_endpoint_destination_minion_pool_options)( context, endpoint_id, env=env, option_names=options)) diff --git a/coriolis/api/v1/endpoint_destination_options.py b/coriolis/api/v1/endpoint_destination_options.py index e1130a4a1..3082eee03 100644 --- a/coriolis/api/v1/endpoint_destination_options.py +++ b/coriolis/api/v1/endpoint_destination_options.py @@ -1,13 +1,13 @@ # Copyright 2018 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api.v1.views import endpoint_options_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_options import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/endpoint_instances.py b/coriolis/api/v1/endpoint_instances.py index 68fde292c..a16db3cf2 100644 --- a/coriolis/api/v1/endpoint_instances.py +++ b/coriolis/api/v1/endpoint_instances.py @@ -1,14 +1,14 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api import common from coriolis.api.v1.views import endpoint_resources_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_resources import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/endpoint_networks.py b/coriolis/api/v1/endpoint_networks.py index d640759dd..7cd2b5e8f 100644 --- a/coriolis/api/v1/endpoint_networks.py +++ b/coriolis/api/v1/endpoint_networks.py @@ -1,13 +1,13 @@ # Copyright 2017 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api.v1.views import endpoint_resources_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_resources import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/endpoint_source_minion_pool_options.py b/coriolis/api/v1/endpoint_source_minion_pool_options.py index a21b28a5f..3aab73c87 100644 --- a/coriolis/api/v1/endpoint_source_minion_pool_options.py +++ b/coriolis/api/v1/endpoint_source_minion_pool_options.py @@ -1,13 +1,13 @@ # Copyright 2020 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api.v1.views import endpoint_options_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_options import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) @@ -37,7 +37,8 @@ def index(self, req, endpoint_id): return endpoint_options_view.source_minion_pool_options_collection( req, - self._minion_pool_options_api.get_endpoint_source_minion_pool_options( + (self._minion_pool_options_api. + get_endpoint_source_minion_pool_options)( context, endpoint_id, env=env, option_names=options)) diff --git a/coriolis/api/v1/endpoint_source_options.py b/coriolis/api/v1/endpoint_source_options.py index b47f7a579..5e96f6e48 100644 --- a/coriolis/api/v1/endpoint_source_options.py +++ b/coriolis/api/v1/endpoint_source_options.py @@ -1,13 +1,13 @@ # Copyright 2019 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api.v1.views import endpoint_options_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_options import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/endpoint_storage.py b/coriolis/api/v1/endpoint_storage.py index ed4619038..5ddf1b446 100644 --- a/coriolis/api/v1/endpoint_storage.py +++ b/coriolis/api/v1/endpoint_storage.py @@ -1,13 +1,13 @@ # Copyright 2018 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - -from coriolis import utils from coriolis.api.v1.views import endpoint_resources_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoint_resources import api from coriolis.policies import endpoints as endpoint_policies +from coriolis import utils + +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/endpoints.py b/coriolis/api/v1/endpoints.py index 4b5baadf9..2877d5335 100644 --- a/coriolis/api/v1/endpoints.py +++ b/coriolis/api/v1/endpoints.py @@ -1,16 +1,17 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging -from webob import exc - -from coriolis import exception -from coriolis.api.v1.views import endpoint_view from coriolis.api.v1 import utils as api_utils +from coriolis.api.v1.views import endpoint_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoints import api +from coriolis import exception from coriolis.policies import endpoints as endpoint_policies +from oslo_log import log as logging +from webob import exc + + LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/migration_actions.py b/coriolis/api/v1/migration_actions.py index 9d91e2653..64bd5b7d4 100644 --- a/coriolis/api/v1/migration_actions.py +++ b/coriolis/api/v1/migration_actions.py @@ -1,13 +1,13 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from webob import exc - -from coriolis import exception from coriolis.api import wsgi as api_wsgi +from coriolis import exception from coriolis.migrations import api from coriolis.policies import migrations as migration_policies +from webob import exc + class MigrationActionsController(api_wsgi.Controller): def __init__(self): diff --git a/coriolis/api/v1/migrations.py b/coriolis/api/v1/migrations.py index 6a15aad98..20e0c5af6 100644 --- a/coriolis/api/v1/migrations.py +++ b/coriolis/api/v1/migrations.py @@ -1,18 +1,18 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_config import cfg as conf -from oslo_log import log as logging -from webob import exc - -from coriolis import exception from coriolis.api.v1 import utils as api_utils from coriolis.api.v1.views import migration_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoints import api as endpoints_api +from coriolis import exception from coriolis.migrations import api from coriolis.policies import migrations as migration_policies +from oslo_config import cfg as conf +from oslo_log import log as logging +from webob import exc + MIGRATIONS_API_OPTS = [ conf.BoolOpt("include_task_info_in_migrations_api", @@ -53,7 +53,8 @@ def _list(self, req): req, self._migration_api.get_migrations( context, include_tasks=CONF.api.include_task_info_in_migrations_api, - include_task_info=CONF.api.include_task_info_in_migrations_api)) + include_task_info=CONF.api.include_task_info_in_migrations_api + )) def index(self, req): return self._list(req) @@ -143,8 +144,9 @@ def create(self, req, body): # NOTE: destination environment for replica should have been # validated upon its creation. migration = self._migration_api.deploy_replica_instances( - context, replica_id, instance_osmorphing_minion_pool_mappings, clone_disks, - force, skip_os_morphing, user_scripts=user_scripts) + context, replica_id, instance_osmorphing_minion_pool_mappings, + clone_disks, force, skip_os_morphing, + user_scripts=user_scripts) else: (origin_endpoint_id, destination_endpoint_id, diff --git a/coriolis/api/v1/minion_pool_actions.py b/coriolis/api/v1/minion_pool_actions.py index 32792f696..e617e6089 100644 --- a/coriolis/api/v1/minion_pool_actions.py +++ b/coriolis/api/v1/minion_pool_actions.py @@ -1,13 +1,13 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from webob import exc - -from coriolis import exception from coriolis.api.v1.views import minion_pool_view from coriolis.api import wsgi as api_wsgi -from coriolis.policies import minion_pools as minion_pool_policies +from coriolis import exception from coriolis.minion_pools import api +from coriolis.policies import minion_pools as minion_pool_policies + +from webob import exc class MinionPoolActionsController(api_wsgi.Controller): diff --git a/coriolis/api/v1/minion_pools.py b/coriolis/api/v1/minion_pools.py index 70fc2f391..b40013678 100644 --- a/coriolis/api/v1/minion_pools.py +++ b/coriolis/api/v1/minion_pools.py @@ -1,17 +1,17 @@ # Copyright 2020 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging -from webob import exc - -from coriolis import constants -from coriolis import exception -from coriolis.api.v1.views import minion_pool_view from coriolis.api.v1 import utils as api_utils +from coriolis.api.v1.views import minion_pool_view from coriolis.api import wsgi as api_wsgi +from coriolis import constants from coriolis.endpoints import api as endpoints_api -from coriolis.policies import minion_pools as pools_policies +from coriolis import exception from coriolis.minion_pools import api +from coriolis.policies import minion_pools as pools_policies + +from oslo_log import log as logging +from webob import exc LOG = logging.getLogger(__name__) @@ -105,7 +105,8 @@ def _validate_create_body(self, ctxt, body): self._endpoints_api.validate_endpoint_source_minion_pool_options( ctxt, endpoint_id, environment_options) elif pool_platform == constants.PROVIDER_PLATFORM_DESTINATION: - self._endpoints_api.validate_endpoint_destination_minion_pool_options( + (self._endpoints_api. + validate_endpoint_destination_minion_pool_options)( ctxt, endpoint_id, environment_options) minimum_minions = minion_pool.get("minimum_minions", 1) @@ -175,13 +176,16 @@ def _validate_update_body(self, id, context, body): if 'environment_options' in vals: if minion_pool['platform'] == ( constants.PROVIDER_PLATFORM_SOURCE): - self._endpoints_api.validate_endpoint_source_minion_pool_options( + (self._endpoints_api. + validate_endpoint_source_minion_pool_options)( context, minion_pool['endpoint_id'], vals['environment_options']) 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']) + (self._endpoints_api. + validate_endpoint_destination_minion_pool_options)( + context, minion_pool['endpoint_id'], + vals['environment_options']) else: raise Exception( "Unknown pool platform: %s" % minion_pool[ diff --git a/coriolis/api/v1/providers.py b/coriolis/api/v1/providers.py index 45e68bc2e..7fe52da2d 100644 --- a/coriolis/api/v1/providers.py +++ b/coriolis/api/v1/providers.py @@ -1,11 +1,11 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging - from coriolis.api import wsgi as api_wsgi -from coriolis.providers import api from coriolis.policies import general as general_policies +from coriolis.providers import api + +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/regions.py b/coriolis/api/v1/regions.py index 8fae080e8..1cb6f4166 100644 --- a/coriolis/api/v1/regions.py +++ b/coriolis/api/v1/regions.py @@ -1,16 +1,16 @@ # Copyright 2020 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging -from webob import exc - -from coriolis import exception -from coriolis.api.v1.views import region_view from coriolis.api.v1 import utils as api_utils +from coriolis.api.v1.views import region_view from coriolis.api import wsgi as api_wsgi +from coriolis import exception from coriolis.policies import regions as region_policies from coriolis.regions import api +from oslo_log import log as logging +from webob import exc + LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/replica_actions.py b/coriolis/api/v1/replica_actions.py index 173ec9b7d..be092af58 100644 --- a/coriolis/api/v1/replica_actions.py +++ b/coriolis/api/v1/replica_actions.py @@ -1,14 +1,14 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from webob import exc - -from coriolis import exception from coriolis.api.v1.views import replica_tasks_execution_view from coriolis.api import wsgi as api_wsgi +from coriolis import exception from coriolis.policies import replicas as replica_policies from coriolis.replicas import api +from webob import exc + class ReplicaActionsController(api_wsgi.Controller): def __init__(self): diff --git a/coriolis/api/v1/replica_schedules.py b/coriolis/api/v1/replica_schedules.py index 611a00954..70aa41b7a 100644 --- a/coriolis/api/v1/replica_schedules.py +++ b/coriolis/api/v1/replica_schedules.py @@ -1,19 +1,19 @@ # Copyright 2017 Cloudbase Solutions Srl # All Rights Reserved. +from coriolis.api.v1.views import replica_schedule_view +from coriolis.api import wsgi as api_wsgi +from coriolis import exception +from coriolis.policies import replica_schedules as schedules_policies +from coriolis.replica_cron import api +from coriolis import schemas + import jsonschema from oslo_log import log as logging from oslo_utils import strutils from oslo_utils import timeutils from webob import exc -from coriolis import exception -from coriolis import schemas -from coriolis.api.v1.views import replica_schedule_view -from coriolis.api import wsgi as api_wsgi -from coriolis.policies import replica_schedules as schedules_policies -from coriolis.replica_cron import api - LOG = logging.getLogger(__name__) diff --git a/coriolis/api/v1/replica_tasks_execution_actions.py b/coriolis/api/v1/replica_tasks_execution_actions.py index 0446d666e..b7bcca857 100644 --- a/coriolis/api/v1/replica_tasks_execution_actions.py +++ b/coriolis/api/v1/replica_tasks_execution_actions.py @@ -3,8 +3,8 @@ from webob import exc -from coriolis import exception from coriolis.api import wsgi as api_wsgi +from coriolis import exception from coriolis.policies import replica_tasks_executions as execution_policies from coriolis.replica_tasks_executions import api diff --git a/coriolis/api/v1/replica_tasks_executions.py b/coriolis/api/v1/replica_tasks_executions.py index f19e670b6..ddb377702 100644 --- a/coriolis/api/v1/replica_tasks_executions.py +++ b/coriolis/api/v1/replica_tasks_executions.py @@ -1,13 +1,13 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from webob import exc - from coriolis.api.v1.views import replica_tasks_execution_view from coriolis.api import wsgi as api_wsgi from coriolis import exception -from coriolis.replica_tasks_executions import api from coriolis.policies import replica_tasks_executions as executions_policies +from coriolis.replica_tasks_executions import api + +from webob import exc class ReplicaTasksExecutionController(api_wsgi.Controller): diff --git a/coriolis/api/v1/replicas.py b/coriolis/api/v1/replicas.py index 0497586ed..6d9a734b2 100644 --- a/coriolis/api/v1/replicas.py +++ b/coriolis/api/v1/replicas.py @@ -1,19 +1,18 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_config import cfg as conf -from oslo_log import log as logging -from webob import exc - -from coriolis import exception from coriolis.api.v1 import utils as api_utils -from coriolis.api.v1.views import replica_view from coriolis.api.v1.views import replica_tasks_execution_view +from coriolis.api.v1.views import replica_view from coriolis.api import wsgi as api_wsgi from coriolis.endpoints import api as endpoints_api +from coriolis import exception from coriolis.policies import replicas as replica_policies from coriolis.replicas import api +from oslo_config import cfg as conf +from oslo_log import log as logging +from webob import exc REPLICA_API_OPTS = [ conf.BoolOpt("include_task_info_in_replicas_api", diff --git a/coriolis/api/v1/router.py b/coriolis/api/v1/router.py index 3a17fdd56..94286f234 100644 --- a/coriolis/api/v1/router.py +++ b/coriolis/api/v1/router.py @@ -16,8 +16,8 @@ from coriolis.api.v1 import endpoints from coriolis.api.v1 import migration_actions from coriolis.api.v1 import migrations -from coriolis.api.v1 import minion_pools from coriolis.api.v1 import minion_pool_actions +from coriolis.api.v1 import minion_pools from coriolis.api.v1 import provider_schemas from coriolis.api.v1 import providers from coriolis.api.v1 import regions diff --git a/coriolis/api/v1/services.py b/coriolis/api/v1/services.py index fd738356c..c8667dc0e 100644 --- a/coriolis/api/v1/services.py +++ b/coriolis/api/v1/services.py @@ -1,16 +1,16 @@ # Copyright 2020 Cloudbase Solutions Srl # All Rights Reserved. -from oslo_log import log as logging -from webob import exc - -from coriolis import exception -from coriolis.api.v1.views import service_view from coriolis.api.v1 import utils as api_utils +from coriolis.api.v1.views import service_view from coriolis.api import wsgi as api_wsgi +from coriolis import exception from coriolis.policies import services as service_policies from coriolis.services import api +from oslo_log import log as logging +from webob import exc + LOG = logging.getLogger(__name__) From e6d3e8aa82d109ffb714672d1b7f09081c54cd5e Mon Sep 17 00:00:00 2001 From: Cristian Matiut Date: Thu, 5 Oct 2023 16:09:16 +0300 Subject: [PATCH 2/2] pep8: fix scheduler/rpc --- coriolis/scheduler/rpc/client.py | 12 ++++++------ coriolis/scheduler/rpc/server.py | 11 +++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/coriolis/scheduler/rpc/client.py b/coriolis/scheduler/rpc/client.py index 61c009064..93729165e 100644 --- a/coriolis/scheduler/rpc/client.py +++ b/coriolis/scheduler/rpc/client.py @@ -1,18 +1,18 @@ # Copyright 2016 Cloudbase Solutions Srl # All Rights Reserved. +import oslo_messaging as messaging import random import time -import oslo_messaging as messaging -from oslo_config import cfg -from oslo_log import log as logging - from coriolis import constants from coriolis import exception from coriolis import rpc -from coriolis import utils from coriolis.tasks import factory as tasks_factory +from coriolis import utils + +from oslo_config import cfg +from oslo_log import log as logging VERSION = "1.0" @@ -163,7 +163,7 @@ def get_worker_service_for_task( worker_service['id'], task['id'], task['task_type'], origin_endpoint['id'], destination_endpoint['id']) return worker_service - except Exception as ex: + except Exception: LOG.warn( "Failed to schedule task with ID '%s' (attempt %d/%d). " "Waiting %d seconds and then retrying. Error was: %s", diff --git a/coriolis/scheduler/rpc/server.py b/coriolis/scheduler/rpc/server.py index 1456ff8c4..bec093e61 100644 --- a/coriolis/scheduler/rpc/server.py +++ b/coriolis/scheduler/rpc/server.py @@ -1,20 +1,15 @@ # Copyright 2020 Cloudbase Solutions Srl # All Rights Reserved. -import copy -import functools -import random -import uuid - from oslo_config import cfg from oslo_log import log as logging +from coriolis.conductor.rpc import client as rpc_conductor_client from coriolis import constants +from coriolis.db import api as db_api from coriolis import exception -from coriolis import utils -from coriolis.conductor.rpc import client as rpc_conductor_client from coriolis.scheduler.filters import trivial_filters -from coriolis.db import api as db_api +from coriolis import utils VERSION = "1.0"