diff --git a/api-ref/ext/validator.py b/api-ref/ext/validator.py index 44a4cef36..16f177e00 100644 --- a/api-ref/ext/validator.py +++ b/api-ref/ext/validator.py @@ -13,7 +13,7 @@ import os -from nova.api.openstack.placement import handler +from placement import handler # A humane ordering of HTTP methods for sorted output. ORDERED_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] diff --git a/doc/source/contributor/placement.rst b/doc/source/contributor/placement.rst index 2f94c747e..ab28b9cf7 100644 --- a/doc/source/contributor/placement.rst +++ b/doc/source/contributor/placement.rst @@ -70,17 +70,17 @@ near the surface. The goal of this is to make things easy to trace when debugging or adding functionality. Functionality which is required for every request is handled in raw WSGI -middleware that is composed in the `nova.api.openstack.placement.deploy` +middleware that is composed in the `placement.deploy` module. Dispatch or routing is handled declaratively via the ``ROUTE_DECLARATIONS`` map defined in the -`nova.api.openstack.placement.handler` module. +`placement.handler` module. Mapping is by URL plus request method. The destination is a complete WSGI application, using a subclass of the `wsgify`_ method from `WebOb`_ to provide a `Request`_ object that provides convenience methods for accessing request headers, bodies, and query parameters and for generating responses. In the placement API these mini-applications are called `handlers`. The `wsgify` -subclass is provided in `nova.api.openstack.placement.wsgi_wrapper` as +subclass is provided in `placement.wsgi_wrapper` as `PlacementWsgify`. It is used to make sure that JSON formatted error responses are structured according to the API-WG `errors`_ guideline. @@ -190,7 +190,7 @@ lower microversion should return a ``404``. When adding a new method to an existing URL a request for a lower microversion should return a ``405``. In either case, the ``ROUTE_DECLARATIONS`` dictionary in the -`nova.api.openstack.placement.handler` module should be updated to point to a +`placement.handler` module should be updated to point to a function within a module that contains handlers for the type of entity identified by the URL. Collection and individual entity handlers of the same type should be in the same module. @@ -241,7 +241,7 @@ request, the caller is responsible for selecting the right one before calling When a handler needs to read or write the data store it should use methods on the objects found in the -`nova.api.openstack.placement.objects.resource_provider` package. Doing so +`placement.objects.resource_provider` package. Doing so requires a context which is provided to the handler method via the WSGI environment. It can be retrieved as follows:: @@ -259,7 +259,7 @@ response. This can be used to distinguish different errors with the same HTTP response status code (a common case is a generation conflict versus an inventory in use conflict). Error codes are simple namespaced strings (e.g., ``placement.inventory.inuse``) for which symbols are maintained in -``nova.api.openstack.placement.errors``. Adding a symbol to a response is done +``placement.errors``. Adding a symbol to a response is done by using the ``comment`` kwarg to a WebOb exception, like this:: except exception.InventoryInUse as exc: @@ -269,7 +269,7 @@ by using the ``comment`` kwarg to a WebOb exception, like this:: Code that adds newly raised exceptions should include an error code. Find additional guidelines on use in the docs for -``nova.api.openstack.placement.errors``. +``placement.errors``. Testing of handler code is described in the next section. diff --git a/placement/auth.py b/placement/auth.py index ff2551e26..81af1672c 100644 --- a/placement/auth.py +++ b/placement/auth.py @@ -17,7 +17,7 @@ from oslo_middleware import request_id import webob.dec import webob.exc -from nova.api.openstack.placement import context +from placement import context LOG = logging.getLogger(__name__) diff --git a/placement/context.py b/placement/context.py index ee0786f49..49535c5af 100644 --- a/placement/context.py +++ b/placement/context.py @@ -13,8 +13,8 @@ from oslo_context import context from oslo_db.sqlalchemy import enginefacade -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import policy +from placement import exception +from placement import policy @enginefacade.transaction_context_provider @@ -36,7 +36,7 @@ class RequestContext(context.RequestContext): {'project_id': self.project_id, 'user_id': self.user_id} :param fatal: if False, will return False when an exception.PolicyNotAuthorized occurs. - :raises nova.api.openstack.placement.exception.PolicyNotAuthorized: + :raises placement.exception.PolicyNotAuthorized: if verification fails and fatal is True. :return: returns a non-False value (not necessarily "True") if authorized and False if not authorized and fatal is False. diff --git a/placement/db/sqlalchemy/migration.py b/placement/db/sqlalchemy/migration.py index 79d8423a0..51917dc48 100644 --- a/placement/db/sqlalchemy/migration.py +++ b/placement/db/sqlalchemy/migration.py @@ -24,7 +24,7 @@ from oslo_log import log as logging import sqlalchemy from sqlalchemy.sql import null -from nova.api.openstack.placement import db_api as placement_db +from placement import db_api as placement_db from nova.db.sqlalchemy import api as db_session from nova import exception from nova.i18n import _ diff --git a/placement/deploy.py b/placement/deploy.py index 76de333eb..b2ec24676 100644 --- a/placement/deploy.py +++ b/placement/deploy.py @@ -15,14 +15,14 @@ from microversion_parse import middleware as mp_middleware import oslo_middleware from oslo_middleware import cors -from nova.api.openstack.placement import auth -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import fault_wrap -from nova.api.openstack.placement import handler -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider -from nova.api.openstack.placement import requestlog -from nova.api.openstack.placement import util +from placement import auth +from placement import db_api +from placement import fault_wrap +from placement import handler +from placement import microversion +from placement.objects import resource_provider +from placement import requestlog +from placement import util # TODO(cdent): NAME points to the config project being used, so for diff --git a/placement/direct.py b/placement/direct.py index 66e11e7f6..71240a4c3 100644 --- a/placement/direct.py +++ b/placement/direct.py @@ -25,7 +25,7 @@ from oslo_utils import uuidutils import requests from wsgi_intercept import interceptor -from nova.api.openstack.placement import deploy +from placement import deploy class PlacementDirect(interceptor.RequestsInterceptor): diff --git a/placement/fault_wrap.py b/placement/fault_wrap.py index 764d628b4..02282905e 100644 --- a/placement/fault_wrap.py +++ b/placement/fault_wrap.py @@ -19,7 +19,7 @@ from oslo_log import log as logging import six from webob import exc -from nova.api.openstack.placement import util +from placement import util LOG = logging.getLogger(__name__) diff --git a/placement/handler.py b/placement/handler.py index c714c464c..4ee2980b9 100644 --- a/placement/handler.py +++ b/placement/handler.py @@ -28,18 +28,18 @@ import webob from oslo_log import log as logging -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.handlers import aggregate -from nova.api.openstack.placement.handlers import allocation -from nova.api.openstack.placement.handlers import allocation_candidate -from nova.api.openstack.placement.handlers import inventory -from nova.api.openstack.placement.handlers import reshaper -from nova.api.openstack.placement.handlers import resource_class -from nova.api.openstack.placement.handlers import resource_provider -from nova.api.openstack.placement.handlers import root -from nova.api.openstack.placement.handlers import trait -from nova.api.openstack.placement.handlers import usage -from nova.api.openstack.placement import util +from placement import exception +from placement.handlers import aggregate +from placement.handlers import allocation +from placement.handlers import allocation_candidate +from placement.handlers import inventory +from placement.handlers import reshaper +from placement.handlers import resource_class +from placement.handlers import resource_provider +from placement.handlers import root +from placement.handlers import trait +from placement.handlers import usage +from placement import util from nova.i18n import _ LOG = logging.getLogger(__name__) diff --git a/placement/handlers/aggregate.py b/placement/handlers/aggregate.py index a26839c37..770ac3904 100644 --- a/placement/handlers/aggregate.py +++ b/placement/handlers/aggregate.py @@ -17,14 +17,14 @@ from oslo_utils import encodeutils from oslo_utils import timeutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import aggregate as policies -from nova.api.openstack.placement.schemas import aggregate as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import errors +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import aggregate as policies +from placement.schemas import aggregate as schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/handlers/allocation.py b/placement/handlers/allocation.py index 9b2f5d8f3..7a4097ec4 100644 --- a/placement/handlers/allocation.py +++ b/placement/handlers/allocation.py @@ -22,14 +22,14 @@ from oslo_utils import timeutils from oslo_utils import uuidutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import allocation as policies -from nova.api.openstack.placement.schemas import allocation as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import errors +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import allocation as policies +from placement.schemas import allocation as schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/handlers/allocation_candidate.py b/placement/handlers/allocation_candidate.py index f5425cdf4..e025b7d87 100644 --- a/placement/handlers/allocation_candidate.py +++ b/placement/handlers/allocation_candidate.py @@ -20,14 +20,14 @@ from oslo_utils import timeutils import six import webob -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import allocation_candidate as \ +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import allocation_candidate as \ policies -from nova.api.openstack.placement.schemas import allocation_candidate as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement.schemas import allocation_candidate as schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/handlers/inventory.py b/placement/handlers/inventory.py index 019ada01a..fac76c3e7 100644 --- a/placement/handlers/inventory.py +++ b/placement/handlers/inventory.py @@ -19,14 +19,14 @@ from oslo_serialization import jsonutils from oslo_utils import encodeutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import inventory as policies -from nova.api.openstack.placement.schemas import inventory as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import errors +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import inventory as policies +from placement.schemas import inventory as schema +from placement import util +from placement import wsgi_wrapper from nova.db import constants as db_const from nova.i18n import _ diff --git a/placement/handlers/reshaper.py b/placement/handlers/reshaper.py index a999a3e21..6571f24fb 100644 --- a/placement/handlers/reshaper.py +++ b/placement/handlers/reshaper.py @@ -22,18 +22,18 @@ import copy from oslo_utils import excutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception +from placement import errors +from placement import exception # TODO(cdent): That we are doing this suggests that there's stuff to be # extracted from the handler to a shared module. -from nova.api.openstack.placement.handlers import allocation -from nova.api.openstack.placement.handlers import inventory -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import reshaper as policies -from nova.api.openstack.placement.schemas import reshaper as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement.handlers import allocation +from placement.handlers import inventory +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import reshaper as policies +from placement.schemas import reshaper as schema +from placement import util +from placement import wsgi_wrapper # TODO(cdent): placement needs its own version of this from nova.i18n import _ diff --git a/placement/handlers/resource_class.py b/placement/handlers/resource_class.py index be1371709..7af6d4b6b 100644 --- a/placement/handlers/resource_class.py +++ b/placement/handlers/resource_class.py @@ -16,13 +16,13 @@ from oslo_utils import encodeutils from oslo_utils import timeutils import webob -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import resource_class as policies -from nova.api.openstack.placement.schemas import resource_class as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import resource_class as policies +from placement.schemas import resource_class as schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/handlers/resource_provider.py b/placement/handlers/resource_provider.py index 8ac38ef63..585d3620f 100644 --- a/placement/handlers/resource_provider.py +++ b/placement/handlers/resource_provider.py @@ -20,14 +20,14 @@ from oslo_utils import timeutils from oslo_utils import uuidutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import resource_provider as policies -from nova.api.openstack.placement.schemas import resource_provider as rp_schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import errors +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import resource_provider as policies +from placement.schemas import resource_provider as rp_schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/handlers/root.py b/placement/handlers/root.py index 298dab381..c416994ec 100644 --- a/placement/handlers/root.py +++ b/placement/handlers/root.py @@ -16,8 +16,8 @@ from oslo_utils import encodeutils from oslo_utils import timeutils -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement import wsgi_wrapper +from placement import microversion +from placement import wsgi_wrapper @wsgi_wrapper.PlacementWsgify diff --git a/placement/handlers/trait.py b/placement/handlers/trait.py index b76907f1a..caf60e720 100644 --- a/placement/handlers/trait.py +++ b/placement/handlers/trait.py @@ -17,14 +17,14 @@ from oslo_utils import encodeutils from oslo_utils import timeutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import trait as policies -from nova.api.openstack.placement.schemas import trait as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import errors +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import trait as policies +from placement.schemas import trait as schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/handlers/usage.py b/placement/handlers/usage.py index 85213302d..a12c661e4 100644 --- a/placement/handlers/usage.py +++ b/placement/handlers/usage.py @@ -16,13 +16,13 @@ from oslo_utils import encodeutils from oslo_utils import timeutils import webob -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.policies import usage as policies -from nova.api.openstack.placement.schemas import usage as schema -from nova.api.openstack.placement import util -from nova.api.openstack.placement import wsgi_wrapper +from placement import exception +from placement import microversion +from placement.objects import resource_provider as rp_obj +from placement.policies import usage as policies +from placement.schemas import usage as schema +from placement import util +from placement import wsgi_wrapper from nova.i18n import _ diff --git a/placement/objects/consumer.py b/placement/objects/consumer.py index 75bd93dfb..d09856153 100644 --- a/placement/objects/consumer.py +++ b/placement/objects/consumer.py @@ -15,10 +15,10 @@ from oslo_versionedobjects import base from oslo_versionedobjects import fields import sqlalchemy as sa -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import user as user_obj +from placement import db_api +from placement import exception +from placement.objects import project as project_obj +from placement.objects import user as user_obj from nova.db.sqlalchemy import api_models as models CONSUMER_TBL = models.Consumer.__table__ @@ -67,7 +67,7 @@ def delete_consumers_if_no_allocations(ctx, consumer_uuids): """Looks to see if any of the supplied consumers has any allocations and if not, deletes the consumer record entirely. - :param ctx: `nova.api.openstack.placement.context.RequestContext` that + :param ctx: `placement.context.RequestContext` that contains an oslo_db Session :param consumer_uuids: UUIDs of the consumers to check and maybe delete """ diff --git a/placement/objects/project.py b/placement/objects/project.py index a6742da2f..2e0b31429 100644 --- a/placement/objects/project.py +++ b/placement/objects/project.py @@ -16,8 +16,8 @@ from oslo_versionedobjects import base from oslo_versionedobjects import fields import sqlalchemy as sa -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import exception +from placement import db_api +from placement import exception from nova.db.sqlalchemy import api_models as models CONF = cfg.CONF diff --git a/placement/objects/resource_provider.py b/placement/objects/resource_provider.py index 246af4fb3..277c7f800 100644 --- a/placement/objects/resource_provider.py +++ b/placement/objects/resource_provider.py @@ -37,12 +37,12 @@ from sqlalchemy import func from sqlalchemy import sql from sqlalchemy.sql import null -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import user as user_obj -from nova.api.openstack.placement import resource_class_cache as rc_cache +from placement import db_api +from placement import exception +from placement.objects import consumer as consumer_obj +from placement.objects import project as project_obj +from placement.objects import user as user_obj +from placement import resource_class_cache as rc_cache from nova.db.sqlalchemy import api_models as models from nova.i18n import _ from nova import rc_fields @@ -3976,7 +3976,7 @@ class AllocationCandidates(base.VersionedObject): :param context: Nova RequestContext. :param requests: Dict, keyed by suffix, of - nova.api.openstack.placement.util.RequestGroup + placement.util.RequestGroup :param limit: An integer, N, representing the maximum number of allocation candidates to return. If CONF.placement.randomize_allocation_candidates is True @@ -4010,7 +4010,7 @@ class AllocationCandidates(base.VersionedObject): (or writer) context. :param context: Nova RequestContext. - :param request: One nova.api.openstack.placement.util.RequestGroup + :param request: One placement.util.RequestGroup :param sharing_providers: dict, keyed by resource class internal ID, of the set of provider IDs containing shared inventory of that resource class @@ -4169,7 +4169,7 @@ def reshape(ctx, inventories, allocations): with the transaction context manager if we want all changes involved in the sub-functions to operate within a single DB transaction. - :param ctx: `nova.api.openstack.placement.context.RequestContext` object + :param ctx: `placement.context.RequestContext` object containing the DB transaction context. :param inventories: dict, keyed by ResourceProvider, of `InventoryList` objects representing the replaced inventory information diff --git a/placement/objects/user.py b/placement/objects/user.py index 8d5af8473..a529378ab 100644 --- a/placement/objects/user.py +++ b/placement/objects/user.py @@ -16,8 +16,8 @@ from oslo_versionedobjects import base from oslo_versionedobjects import fields import sqlalchemy as sa -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import exception +from placement import db_api +from placement import exception from nova.db.sqlalchemy import api_models as models CONF = cfg.CONF diff --git a/placement/policies/__init__.py b/placement/policies/__init__.py index be0496d23..966a24d7c 100644 --- a/placement/policies/__init__.py +++ b/placement/policies/__init__.py @@ -12,16 +12,16 @@ import itertools -from nova.api.openstack.placement.policies import aggregate -from nova.api.openstack.placement.policies import allocation -from nova.api.openstack.placement.policies import allocation_candidate -from nova.api.openstack.placement.policies import base -from nova.api.openstack.placement.policies import inventory -from nova.api.openstack.placement.policies import reshaper -from nova.api.openstack.placement.policies import resource_class -from nova.api.openstack.placement.policies import resource_provider -from nova.api.openstack.placement.policies import trait -from nova.api.openstack.placement.policies import usage +from placement.policies import aggregate +from placement.policies import allocation +from placement.policies import allocation_candidate +from placement.policies import base +from placement.policies import inventory +from placement.policies import reshaper +from placement.policies import resource_class +from placement.policies import resource_provider +from placement.policies import trait +from placement.policies import usage def list_rules(): diff --git a/placement/policies/aggregate.py b/placement/policies/aggregate.py index 8e2bd8c3a..4fbd86a20 100644 --- a/placement/policies/aggregate.py +++ b/placement/policies/aggregate.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base PREFIX = 'placement:resource_providers:aggregates:%s' diff --git a/placement/policies/allocation.py b/placement/policies/allocation.py index a5f1c2e00..b4a544769 100644 --- a/placement/policies/allocation.py +++ b/placement/policies/allocation.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base RP_ALLOC_LIST = 'placement:resource_providers:allocations:list' diff --git a/placement/policies/allocation_candidate.py b/placement/policies/allocation_candidate.py index e2ae65537..6a0639fcc 100644 --- a/placement/policies/allocation_candidate.py +++ b/placement/policies/allocation_candidate.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base LIST = 'placement:allocation_candidates:list' diff --git a/placement/policies/inventory.py b/placement/policies/inventory.py index 1f3d38f41..e64fd8f28 100644 --- a/placement/policies/inventory.py +++ b/placement/policies/inventory.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base PREFIX = 'placement:resource_providers:inventories:%s' diff --git a/placement/policies/reshaper.py b/placement/policies/reshaper.py index a6615ac48..e66951196 100644 --- a/placement/policies/reshaper.py +++ b/placement/policies/reshaper.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base PREFIX = 'placement:reshaper:%s' diff --git a/placement/policies/resource_class.py b/placement/policies/resource_class.py index 75acab9d3..14d330a23 100644 --- a/placement/policies/resource_class.py +++ b/placement/policies/resource_class.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base PREFIX = 'placement:resource_classes:%s' diff --git a/placement/policies/resource_provider.py b/placement/policies/resource_provider.py index 7c4826bd7..e751b6fde 100644 --- a/placement/policies/resource_provider.py +++ b/placement/policies/resource_provider.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base PREFIX = 'placement:resource_providers:%s' diff --git a/placement/policies/trait.py b/placement/policies/trait.py index 6b35a703d..c33d76c4e 100644 --- a/placement/policies/trait.py +++ b/placement/policies/trait.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base RP_TRAIT_PREFIX = 'placement:resource_providers:traits:%s' diff --git a/placement/policies/usage.py b/placement/policies/usage.py index 6543fa435..42ce354b4 100644 --- a/placement/policies/usage.py +++ b/placement/policies/usage.py @@ -13,7 +13,7 @@ from oslo_policy import policy -from nova.api.openstack.placement.policies import base +from placement.policies import base PROVIDER_USAGES = 'placement:resource_providers:usages' diff --git a/placement/policy.py b/placement/policy.py index cad6fdf83..9eb63ad58 100644 --- a/placement/policy.py +++ b/placement/policy.py @@ -16,8 +16,8 @@ from oslo_log import log as logging from oslo_policy import policy from oslo_utils import excutils -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import policies +from placement import exception +from placement import policies CONF = cfg.CONF @@ -63,7 +63,7 @@ def authorize(context, action, target, do_raise=True): """Verifies that the action is valid on the target in this context. :param context: instance of - nova.api.openstack.placement.context.RequestContext + placement.context.RequestContext :param action: string representing the action to be checked this should be colon separated for clarity, i.e. ``placement:resource_providers:list`` @@ -72,7 +72,7 @@ def authorize(context, action, target, do_raise=True): owner of the object e.g. ``{'project_id': context.project_id}``. :param do_raise: if True (the default), raises PolicyNotAuthorized; if False, returns False - :raises nova.api.openstack.placement.exception.PolicyNotAuthorized: if + :raises placement.exception.PolicyNotAuthorized: if verification fails and do_raise is True. :returns: non-False value (not necessarily "True") if authorized, and the exact value False if not authorized and do_raise is False. diff --git a/placement/requestlog.py b/placement/requestlog.py index da7be6a37..adbaa2a67 100644 --- a/placement/requestlog.py +++ b/placement/requestlog.py @@ -14,7 +14,7 @@ from oslo_log import log as logging -from nova.api.openstack.placement import microversion +from placement import microversion LOG = logging.getLogger(__name__) diff --git a/placement/resource_class_cache.py b/placement/resource_class_cache.py index a72b4177e..ec86ed55d 100644 --- a/placement/resource_class_cache.py +++ b/placement/resource_class_cache.py @@ -13,8 +13,8 @@ from oslo_concurrency import lockutils import sqlalchemy as sa -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import exception +from placement import db_api +from placement import exception from nova.db.sqlalchemy import api_models as models from nova import rc_fields as fields diff --git a/placement/schemas/allocation.py b/placement/schemas/allocation.py index 169a953f5..8c49bf771 100644 --- a/placement/schemas/allocation.py +++ b/placement/schemas/allocation.py @@ -13,7 +13,7 @@ import copy -from nova.api.openstack.placement.schemas import common +from placement.schemas import common ALLOCATION_SCHEMA = { diff --git a/placement/schemas/inventory.py b/placement/schemas/inventory.py index cddea1306..c019de8ec 100644 --- a/placement/schemas/inventory.py +++ b/placement/schemas/inventory.py @@ -13,7 +13,7 @@ import copy -from nova.api.openstack.placement.schemas import common +from placement.schemas import common from nova.db import constants as db_const diff --git a/placement/schemas/reshaper.py b/placement/schemas/reshaper.py index 1658d9251..1730e5b37 100644 --- a/placement/schemas/reshaper.py +++ b/placement/schemas/reshaper.py @@ -13,9 +13,9 @@ import copy -from nova.api.openstack.placement.schemas import allocation -from nova.api.openstack.placement.schemas import common -from nova.api.openstack.placement.schemas import inventory +from placement.schemas import allocation +from placement.schemas import common +from placement.schemas import inventory ALLOCATIONS = copy.deepcopy(allocation.POST_ALLOCATIONS_V1_28) diff --git a/placement/schemas/resource_class.py b/placement/schemas/resource_class.py index 32f75bc88..1f79b7536 100644 --- a/placement/schemas/resource_class.py +++ b/placement/schemas/resource_class.py @@ -13,7 +13,7 @@ import copy -from nova.api.openstack.placement.schemas import common +from placement.schemas import common POST_RC_SCHEMA_V1_2 = { diff --git a/placement/schemas/trait.py b/placement/schemas/trait.py index b9c04e54d..3a8e03292 100644 --- a/placement/schemas/trait.py +++ b/placement/schemas/trait.py @@ -13,7 +13,7 @@ import copy -from nova.api.openstack.placement.schemas import common +from placement.schemas import common TRAIT = { diff --git a/placement/test.py b/placement/test.py index 92befa9c7..9f3b71ffc 100644 --- a/placement/test.py +++ b/placement/test.py @@ -49,7 +49,7 @@ from oslotest import moxstubout import six import testtools -from nova.api.openstack.placement.objects import resource_provider +from placement.objects import resource_provider from nova import context from nova.db import api as db from nova import exception diff --git a/placement/tests/fixtures.py b/placement/tests/fixtures.py index 647d3bc34..cf42859e8 100644 --- a/placement/tests/fixtures.py +++ b/placement/tests/fixtures.py @@ -39,9 +39,9 @@ from oslo_utils import uuidutils from requests import adapters from wsgi_intercept import interceptor -from nova.api.openstack.compute import tenant_networks -from nova.api.openstack.placement import db_api as placement_db -from nova.api.openstack import wsgi_app +from compute import tenant_networks +from placement import db_api as placement_db +from import wsgi_app from nova.api import wsgi from nova.compute import rpcapi as compute_rpcapi from nova import context @@ -257,7 +257,7 @@ class DatabasePoisonFixture(fixtures.Fixture): # nova.db.instance_get # # - mock at the api layer rather than the object layer, for example: - # nova.api.openstack.common.get_instance + # common.get_instance # vs. # nova.objects.instance.Instance.get # diff --git a/placement/tests/functional/base.py b/placement/tests/functional/base.py index b5cbd7e2c..2544fb6be 100644 --- a/placement/tests/functional/base.py +++ b/placement/tests/functional/base.py @@ -15,9 +15,9 @@ from oslo_config import fixture as config_fixture from oslotest import output import testtools -from nova.api.openstack.placement import context -from nova.api.openstack.placement import deploy -from nova.api.openstack.placement.objects import resource_provider +from placement import context +from placement import deploy +from placement.objects import resource_provider from nova.tests import fixtures from nova.tests.functional.fixtures import capture from nova.tests.unit import policy_fixture diff --git a/placement/tests/functional/db/test_allocation_candidates.py b/placement/tests/functional/db/test_allocation_candidates.py index 1979c40cc..5911a49c4 100644 --- a/placement/tests/functional/db/test_allocation_candidates.py +++ b/placement/tests/functional/db/test_allocation_candidates.py @@ -14,9 +14,9 @@ from oslo_config import cfg import six import sqlalchemy as sa -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import lib as placement_lib -from nova.api.openstack.placement.objects import resource_provider as rp_obj +from placement import exception +from placement import lib as placement_lib +from placement.objects import resource_provider as rp_obj from nova import rc_fields as fields from nova.tests.functional.db import test_base as tb from nova.tests import uuidsentinel as uuids diff --git a/placement/tests/functional/db/test_base.py b/placement/tests/functional/db/test_base.py index 1dc9a5d72..4168c3776 100644 --- a/placement/tests/functional/db/test_base.py +++ b/placement/tests/functional/db/test_base.py @@ -14,11 +14,11 @@ from oslo_utils import uuidutils -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.objects import user as user_obj +from placement import exception +from placement.objects import consumer as consumer_obj +from placement.objects import project as project_obj +from placement.objects import resource_provider as rp_obj +from placement.objects import user as user_obj from nova.tests.functional.api.openstack.placement import base from nova.tests import uuidsentinel as uuids diff --git a/placement/tests/functional/db/test_consumer.py b/placement/tests/functional/db/test_consumer.py index 1600c9f28..f03055377 100644 --- a/placement/tests/functional/db/test_consumer.py +++ b/placement/tests/functional/db/test_consumer.py @@ -13,12 +13,12 @@ from oslo_config import cfg import sqlalchemy as sa -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.objects import user as user_obj +from placement import db_api +from placement import exception +from placement.objects import consumer as consumer_obj +from placement.objects import project as project_obj +from placement.objects import resource_provider as rp_obj +from placement.objects import user as user_obj from nova import rc_fields as fields from nova.tests.functional.api.openstack.placement import base from nova.tests.functional.db import test_base as tb diff --git a/placement/tests/functional/db/test_project.py b/placement/tests/functional/db/test_project.py index 0dbd269c3..230b03882 100644 --- a/placement/tests/functional/db/test_project.py +++ b/placement/tests/functional/db/test_project.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import project as project_obj +from placement import exception +from placement.objects import project as project_obj from nova.tests.functional.db import test_base as tb from nova.tests import uuidsentinel as uuids diff --git a/placement/tests/functional/db/test_reshape.py b/placement/tests/functional/db/test_reshape.py index dd710b035..62400efaf 100644 --- a/placement/tests/functional/db/test_reshape.py +++ b/placement/tests/functional/db/test_reshape.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import resource_provider as rp_obj +from placement import exception +from placement.objects import consumer as consumer_obj +from placement.objects import resource_provider as rp_obj from nova.tests.functional.db import test_base as tb from nova.tests import uuidsentinel as uuids diff --git a/placement/tests/functional/db/test_resource_class_cache.py b/placement/tests/functional/db/test_resource_class_cache.py index 11b05c550..5e99fd185 100644 --- a/placement/tests/functional/db/test_resource_class_cache.py +++ b/placement/tests/functional/db/test_resource_class_cache.py @@ -15,8 +15,8 @@ import mock from oslo_utils import timeutils -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import resource_class_cache as rc_cache +from placement import exception +from placement import resource_class_cache as rc_cache from nova import rc_fields as fields from nova.tests.functional.api.openstack.placement import base diff --git a/placement/tests/functional/db/test_resource_provider.py b/placement/tests/functional/db/test_resource_provider.py index bee5f7d45..085480ae0 100644 --- a/placement/tests/functional/db/test_resource_provider.py +++ b/placement/tests/functional/db/test_resource_provider.py @@ -18,9 +18,9 @@ from oslo_db import exception as db_exc import sqlalchemy as sa import nova -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import resource_provider as rp_obj +from placement import exception +from placement.objects import consumer as consumer_obj +from placement.objects import resource_provider as rp_obj from nova.db.sqlalchemy import api_models as models from nova import rc_fields as fields from nova.tests.functional.db import test_base as tb @@ -414,7 +414,7 @@ class ResourceProviderTestCase(tb.PlacementDbBaseTestCase): # NOTE(jaypipes): This is just disabling the online data migration that # occurs in _from_db_object() that sets root provider ID to ensure we # don't have any migrations messing with the end result. - with mock.patch('nova.api.openstack.placement.objects.' + with mock.patch('placement.objects.' 'resource_provider._set_root_provider_id'): rps = rp_obj.ResourceProviderList.get_all_by_filters( self.ctx, @@ -553,7 +553,7 @@ class ResourceProviderTestCase(tb.PlacementDbBaseTestCase): rp.set_inventory, inv_list) - @mock.patch('nova.api.openstack.placement.objects.resource_provider.LOG') + @mock.patch('placement.objects.resource_provider.LOG') def test_set_inventory_over_capacity(self, mock_log): rp = self._create_provider(uuidsentinel.rp_name) @@ -707,7 +707,7 @@ class ResourceProviderTestCase(tb.PlacementDbBaseTestCase): self.assertIn('No inventory of class DISK_GB found', str(error)) - @mock.patch('nova.api.openstack.placement.objects.resource_provider.LOG') + @mock.patch('placement.objects.resource_provider.LOG') def test_update_inventory_violates_allocation(self, mock_log): # Compute nodes that are reconfigured have to be able to set # their inventory to something that violates allocations so @@ -1708,7 +1708,7 @@ class TestAllocationListCreateDelete(tb.PlacementDbBaseTestCase): self.ctx, empty_rp) self.assertEqual(0, len(allocations)) - @mock.patch('nova.api.openstack.placement.objects.resource_provider.LOG') + @mock.patch('placement.objects.resource_provider.LOG') def test_set_allocations_retry(self, mock_log): """Test server side allocation write retry handling.""" @@ -1766,7 +1766,7 @@ class TestAllocationListCreateDelete(tb.PlacementDbBaseTestCase): unmocked_set = functools.partial( rp_obj.AllocationList._set_allocations, alloc_list) with mock.patch( - 'nova.api.openstack.placement.objects.resource_provider.' + 'placement.objects.resource_provider.' 'AllocationList._set_allocations') as mock_set: exceptions = iter([ exception.ResourceProviderConcurrentUpdateDetected(), @@ -1935,7 +1935,7 @@ class ResourceClassTestCase(tb.PlacementDbBaseTestCase): self.assertEqual(min_id + 1, rc.id) @mock.patch.object( - nova.api.openstack.placement.objects.resource_provider.ResourceClass, + placement.objects.resource_provider.ResourceClass, "_get_next_id") def test_create_duplicate_id_retry(self, mock_get): # This order of ID generation will create rc1 with an ID of 42, try to @@ -1955,7 +1955,7 @@ class ResourceClassTestCase(tb.PlacementDbBaseTestCase): self.assertEqual(rc2.id, 43) @mock.patch.object( - nova.api.openstack.placement.objects.resource_provider.ResourceClass, + placement.objects.resource_provider.ResourceClass, "_get_next_id") def test_create_duplicate_id_retry_failing(self, mock_get): """negative case for test_create_duplicate_id_retry""" diff --git a/placement/tests/functional/db/test_user.py b/placement/tests/functional/db/test_user.py index 0f5293b28..bdc6e0dee 100644 --- a/placement/tests/functional/db/test_user.py +++ b/placement/tests/functional/db/test_user.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import user as user_obj +from placement import exception +from placement.objects import user as user_obj from nova.tests.functional.db import test_base as tb from nova.tests import uuidsentinel as uuids diff --git a/placement/tests/functional/fixtures/gabbits.py b/placement/tests/functional/fixtures/gabbits.py index 1f4cf5b6a..77e657152 100644 --- a/placement/tests/functional/fixtures/gabbits.py +++ b/placement/tests/functional/fixtures/gabbits.py @@ -20,12 +20,12 @@ from oslo_policy import opts as policy_opts from oslo_utils import uuidutils from oslotest import output -from nova.api.openstack.placement import context -from nova.api.openstack.placement import deploy -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.objects import user as user_obj -from nova.api.openstack.placement import policies +from placement import context +from placement import deploy +from placement.objects import project as project_obj +from placement.objects import resource_provider as rp_obj +from placement.objects import user as user_obj +from placement import policies from nova import rc_fields as fields from nova.tests import fixtures from nova.tests.functional.db import test_base as tb diff --git a/placement/tests/functional/fixtures/placement.py b/placement/tests/functional/fixtures/placement.py index f8c3948ef..e0774e72f 100644 --- a/placement/tests/functional/fixtures/placement.py +++ b/placement/tests/functional/fixtures/placement.py @@ -16,7 +16,7 @@ from oslo_config import fixture as config_fixture from oslo_utils import uuidutils from wsgi_intercept import interceptor -from nova.api.openstack.placement import deploy +from placement import deploy CONF = cfg.CONF diff --git a/placement/tests/functional/test_direct.py b/placement/tests/functional/test_direct.py index 829c5e3ee..8378c36d2 100644 --- a/placement/tests/functional/test_direct.py +++ b/placement/tests/functional/test_direct.py @@ -12,7 +12,7 @@ from oslo_config import cfg -from nova.api.openstack.placement import direct +from placement import direct from nova.tests.functional.api.openstack.placement import base from nova.tests import uuidsentinel diff --git a/placement/tests/functional/test_verify_policy.py b/placement/tests/functional/test_verify_policy.py index a6fb602f7..0901752ae 100644 --- a/placement/tests/functional/test_verify_policy.py +++ b/placement/tests/functional/test_verify_policy.py @@ -12,8 +12,8 @@ from oslo_config import cfg -from nova.api.openstack.placement import direct -from nova.api.openstack.placement import handler +from placement import direct +from placement import handler from nova.tests.functional.api.openstack.placement import base diff --git a/placement/tests/unit/handlers/test_aggregate.py b/placement/tests/unit/handlers/test_aggregate.py index 64db6f6fd..24dec9db3 100644 --- a/placement/tests/unit/handlers/test_aggregate.py +++ b/placement/tests/unit/handlers/test_aggregate.py @@ -16,9 +16,9 @@ import six import testtools import webob -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.handlers import aggregate -from nova.api.openstack.placement.objects import resource_provider +from placement import exception +from placement.handlers import aggregate +from placement.objects import resource_provider class TestAggregateHandlerErrors(testtools.TestCase): diff --git a/placement/tests/unit/objects/test_resource_provider.py b/placement/tests/unit/objects/test_resource_provider.py index 28fa449f4..93f2ffacb 100644 --- a/placement/tests/unit/objects/test_resource_provider.py +++ b/placement/tests/unit/objects/test_resource_provider.py @@ -15,9 +15,9 @@ from oslo_utils import timeutils import six import testtools -from nova.api.openstack.placement import context -from nova.api.openstack.placement import exception -from nova.api.openstack.placement.objects import resource_provider +from placement import context +from placement import exception +from placement.objects import resource_provider from nova import rc_fields as fields from nova.tests import uuidsentinel as uuids @@ -160,9 +160,9 @@ class TestProviderSummaryNoDB(_TestCase): class TestInventoryNoDB(_TestCase): - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' 'ensure_rc_cache', side_effect=_fake_ensure_cache) - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' '_get_inventory_by_provider_id') def test_get_all_by_resource_provider(self, mock_get, mock_ensure_cache): mock_ensure_cache(self.context) @@ -264,12 +264,12 @@ class TestInventoryList(_TestCase): class TestAllocationListNoDB(_TestCase): - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' '_create_incomplete_consumers_for_provider') - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' 'ensure_rc_cache', side_effect=_fake_ensure_cache) - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' '_get_allocations_by_provider_id', return_value=[_ALLOCATION_DB]) def test_get_allocations(self, mock_get_allocations_from_db, @@ -305,7 +305,7 @@ class TestResourceClass(_TestCase): class TestTraits(_TestCase): - @mock.patch("nova.api.openstack.placement.objects.resource_provider." + @mock.patch("placement.objects.resource_provider." "_trait_sync") def test_sync_flag(self, mock_sync): synced = resource_provider._TRAITS_SYNCED @@ -315,9 +315,9 @@ class TestTraits(_TestCase): synced = resource_provider._TRAITS_SYNCED self.assertTrue(synced) - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' 'ResourceProvider.obj_reset_changes') - @mock.patch('nova.api.openstack.placement.objects.resource_provider.' + @mock.patch('placement.objects.resource_provider.' '_set_traits') def test_set_traits_resets_changes(self, mock_set_traits, mock_reset): trait = resource_provider.Trait(name="HW_CPU_X86_AVX2") diff --git a/placement/tests/unit/policy_fixture.py b/placement/tests/unit/policy_fixture.py index 651f096bc..24ec6941e 100644 --- a/placement/tests/unit/policy_fixture.py +++ b/placement/tests/unit/policy_fixture.py @@ -18,7 +18,7 @@ import fixtures from oslo_policy import policy as oslo_policy from oslo_serialization import jsonutils -from nova.api.openstack.placement import policy as placement_policy +from placement import policy as placement_policy import nova.conf from nova.conf import paths from nova import policies diff --git a/placement/tests/unit/test_context.py b/placement/tests/unit/test_context.py index 181016159..f538c8bfe 100644 --- a/placement/tests/unit/test_context.py +++ b/placement/tests/unit/test_context.py @@ -13,8 +13,8 @@ import mock import testtools -from nova.api.openstack.placement import context -from nova.api.openstack.placement import exception +from placement import context +from placement import exception class TestPlacementRequestContext(testtools.TestCase): @@ -26,7 +26,7 @@ class TestPlacementRequestContext(testtools.TestCase): self.default_target = {'user_id': self.ctxt.user_id, 'project_id': self.ctxt.project_id} - @mock.patch('nova.api.openstack.placement.policy.authorize', + @mock.patch('placement.policy.authorize', return_value=True) def test_can_target_none_fatal_true_accept(self, mock_authorize): self.assertTrue(self.ctxt.can('placement:resource_providers:list')) @@ -34,7 +34,7 @@ class TestPlacementRequestContext(testtools.TestCase): self.ctxt, 'placement:resource_providers:list', self.default_target) - @mock.patch('nova.api.openstack.placement.policy.authorize', + @mock.patch('placement.policy.authorize', side_effect=exception.PolicyNotAuthorized( action='placement:resource_providers:list')) def test_can_target_none_fatal_true_reject(self, mock_authorize): @@ -44,7 +44,7 @@ class TestPlacementRequestContext(testtools.TestCase): self.ctxt, 'placement:resource_providers:list', self.default_target) - @mock.patch('nova.api.openstack.placement.policy.authorize', + @mock.patch('placement.policy.authorize', side_effect=exception.PolicyNotAuthorized( action='placement:resource_providers:list')) def test_can_target_none_fatal_false_reject(self, mock_authorize): @@ -54,7 +54,7 @@ class TestPlacementRequestContext(testtools.TestCase): self.ctxt, 'placement:resource_providers:list', self.default_target) - @mock.patch('nova.api.openstack.placement.policy.authorize', + @mock.patch('placement.policy.authorize', return_value=True) def test_can_target_none_fatal_true_accept_custom_target( self, mock_authorize): diff --git a/placement/tests/unit/test_deploy.py b/placement/tests/unit/test_deploy.py index 680d92cd1..b99b17f45 100644 --- a/placement/tests/unit/test_deploy.py +++ b/placement/tests/unit/test_deploy.py @@ -18,7 +18,7 @@ from oslo_policy import opts as policy_opts import testtools import webob -from nova.api.openstack.placement import deploy +from placement import deploy CONF = cfg.CONF diff --git a/placement/tests/unit/test_fault_wrap.py b/placement/tests/unit/test_fault_wrap.py index 6b794631c..a221fc2d1 100644 --- a/placement/tests/unit/test_fault_wrap.py +++ b/placement/tests/unit/test_fault_wrap.py @@ -18,7 +18,7 @@ from oslo_serialization import jsonutils import testtools import webob -from nova.api.openstack.placement import fault_wrap +from placement import fault_wrap ERROR_MESSAGE = 'that was not supposed to happen' @@ -58,7 +58,7 @@ class TestFaultWrapper(testtools.TestCase): call_args = self.start_response_mock.call_args self.assertEqual('500 Internal Server Error', call_args[0][0]) - @mock.patch("nova.api.openstack.placement.fault_wrap.LOG") + @mock.patch("placement.fault_wrap.LOG") def test_fault_log(self, mocked_log): self.fail_app(self.environ, self.start_response_mock) mocked_log.exception.assert_called_once_with( diff --git a/placement/tests/unit/test_handler.py b/placement/tests/unit/test_handler.py index 01dda7ab3..39afcf5f6 100644 --- a/placement/tests/unit/test_handler.py +++ b/placement/tests/unit/test_handler.py @@ -19,9 +19,9 @@ import routes import testtools import webob -from nova.api.openstack.placement import handler -from nova.api.openstack.placement.handlers import root -from nova.api.openstack.placement import microversion +from placement import handler +from placement.handlers import root +from placement import microversion from nova.tests import uuidsentinel @@ -125,7 +125,7 @@ class MapperTest(testtools.TestCase): class PlacementLoggingTest(testtools.TestCase): - @mock.patch("nova.api.openstack.placement.handler.LOG") + @mock.patch("placement.handler.LOG") def test_404_no_error_log(self, mocked_log): environ = _environ(path='/hello', method='GET') context_mock = mock.Mock() diff --git a/placement/tests/unit/test_microversion.py b/placement/tests/unit/test_microversion.py index 25e53a7f7..a0dfac570 100644 --- a/placement/tests/unit/test_microversion.py +++ b/placement/tests/unit/test_microversion.py @@ -21,8 +21,8 @@ import microversion_parse import mock # import the handlers to load up handler decorators -import nova.api.openstack.placement.handler # noqa -from nova.api.openstack.placement import microversion +import placement.handler # noqa +from placement import microversion def handler(): @@ -41,7 +41,7 @@ class TestMicroversionFindMethod(testtools.TestCase): class TestMicroversionDecoration(testtools.TestCase): - @mock.patch('nova.api.openstack.placement.microversion.VERSIONED_METHODS', + @mock.patch('placement.microversion.VERSIONED_METHODS', new=collections.defaultdict(list)) def test_methods_structure(self): """Test that VERSIONED_METHODS gets data as expected.""" @@ -97,7 +97,7 @@ class TestMicroversionIntersection(testtools.TestCase): @staticmethod def _check_intersection(method_info): # See check_for_versions_intersection in - # nova.api.openstack.wsgi. + # wsgi. pairs = [] counter = 0 for min_ver, max_ver, func in method_info: @@ -112,7 +112,7 @@ class TestMicroversionIntersection(testtools.TestCase): return True return False - @mock.patch('nova.api.openstack.placement.microversion.VERSIONED_METHODS', + @mock.patch('placement.microversion.VERSIONED_METHODS', new=collections.defaultdict(list)) def test_faked_intersection(self): microversion.version_handler('1.0', '1.9')(handler) @@ -121,7 +121,7 @@ class TestMicroversionIntersection(testtools.TestCase): for method_info in microversion.VERSIONED_METHODS.values(): self.assertTrue(self._check_intersection(method_info)) - @mock.patch('nova.api.openstack.placement.microversion.VERSIONED_METHODS', + @mock.patch('placement.microversion.VERSIONED_METHODS', new=collections.defaultdict(list)) def test_faked_non_intersection(self): microversion.version_handler('1.0', '1.8')(handler) diff --git a/placement/tests/unit/test_policy.py b/placement/tests/unit/test_policy.py index ad0bdf637..ea364e3d7 100644 --- a/placement/tests/unit/test_policy.py +++ b/placement/tests/unit/test_policy.py @@ -15,9 +15,9 @@ import os from oslo_policy import policy as oslo_policy import testtools -from nova.api.openstack.placement import context -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import policy +from placement import context +from placement import exception +from placement import policy from nova.tests.unit import conf_fixture from nova.tests.unit import policy_fixture from nova import utils diff --git a/placement/tests/unit/test_requestlog.py b/placement/tests/unit/test_requestlog.py index 9e2847187..ccd5cdfd2 100644 --- a/placement/tests/unit/test_requestlog.py +++ b/placement/tests/unit/test_requestlog.py @@ -16,7 +16,7 @@ import mock import testtools import webob -from nova.api.openstack.placement import requestlog +from placement import requestlog class TestRequestLog(testtools.TestCase): @@ -45,7 +45,7 @@ class TestRequestLog(testtools.TestCase): req_uri = requestlog.RequestLog._get_uri(self.environ) self.assertEqual('/placement/resource_providers?name=myrp', req_uri) - @mock.patch("nova.api.openstack.placement.requestlog.RequestLog.write_log") + @mock.patch("placement.requestlog.RequestLog.write_log") def test_middleware_writes_logs(self, write_log): start_response_mock = mock.MagicMock() app = requestlog.RequestLog(self.application) @@ -53,7 +53,7 @@ class TestRequestLog(testtools.TestCase): write_log.assert_called_once_with( self.environ, '/resource_providers?name=myrp', '200 OK', '0') - @mock.patch("nova.api.openstack.placement.requestlog.LOG") + @mock.patch("placement.requestlog.LOG") def test_middleware_sends_message(self, mocked_log): start_response_mock = mock.MagicMock() app = requestlog.RequestLog(self.application) diff --git a/placement/tests/unit/test_util.py b/placement/tests/unit/test_util.py index 86d8efdea..2cf7fb530 100644 --- a/placement/tests/unit/test_util.py +++ b/placement/tests/unit/test_util.py @@ -26,14 +26,14 @@ import webob import six -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import lib as pl -from nova.api.openstack.placement import microversion -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import resource_provider as rp_obj -from nova.api.openstack.placement.objects import user as user_obj -from nova.api.openstack.placement import util +from placement import exception +from placement import lib as pl +from placement import microversion +from placement.objects import consumer as consumer_obj +from placement.objects import project as project_obj +from placement.objects import resource_provider as rp_obj +from placement.objects import user as user_obj +from placement import util from nova.tests import uuidsentinel CONF = cfg.CONF @@ -182,7 +182,7 @@ class TestJSONErrorFormatter(testtools.TestCase): '1.0', '1.1', ] - mod_str = 'nova.api.openstack.placement.microversion.VERSIONS' + mod_str = 'placement.microversion.VERSIONS' self.useFixture(fixtures.MonkeyPatch(mod_str, _versions)) def test_status_to_int_code(self): @@ -907,22 +907,22 @@ class TestEnsureConsumer(testtools.TestCase): def setUp(self): super(TestEnsureConsumer, self).setUp() self.mock_project_get = self.useFixture(fixtures.MockPatch( - 'nova.api.openstack.placement.objects.project.' + 'placement.objects.project.' 'Project.get_by_external_id')).mock self.mock_user_get = self.useFixture(fixtures.MockPatch( - 'nova.api.openstack.placement.objects.user.' + 'placement.objects.user.' 'User.get_by_external_id')).mock self.mock_consumer_get = self.useFixture(fixtures.MockPatch( - 'nova.api.openstack.placement.objects.consumer.' + 'placement.objects.consumer.' 'Consumer.get_by_uuid')).mock self.mock_project_create = self.useFixture(fixtures.MockPatch( - 'nova.api.openstack.placement.objects.project.' + 'placement.objects.project.' 'Project.create')).mock self.mock_user_create = self.useFixture(fixtures.MockPatch( - 'nova.api.openstack.placement.objects.user.' + 'placement.objects.user.' 'User.create')).mock self.mock_consumer_create = self.useFixture(fixtures.MockPatch( - 'nova.api.openstack.placement.objects.consumer.' + 'placement.objects.consumer.' 'Consumer.create')).mock self.ctx = mock.sentinel.ctx self.consumer_id = uuidsentinel.consumer diff --git a/placement/util.py b/placement/util.py index 6b3ae052f..b6799d674 100644 --- a/placement/util.py +++ b/placement/util.py @@ -23,15 +23,15 @@ from oslo_utils import timeutils from oslo_utils import uuidutils import webob -from nova.api.openstack.placement import errors -from nova.api.openstack.placement import exception -from nova.api.openstack.placement import lib as placement_lib +from placement import errors +from placement import exception +from placement import lib as placement_lib # NOTE(cdent): avoid cyclical import conflict between util and # microversion -import nova.api.openstack.placement.microversion -from nova.api.openstack.placement.objects import consumer as consumer_obj -from nova.api.openstack.placement.objects import project as project_obj -from nova.api.openstack.placement.objects import user as user_obj +import placement.microversion +from placement.objects import consumer as consumer_obj +from placement.objects import project as project_obj +from placement.objects import user as user_obj from nova.i18n import _ CONF = cfg.CONF @@ -115,7 +115,7 @@ def json_error_formatter(body, status, title, environ): http://specs.openstack.org/openstack/api-wg/guidelines/errors.html """ # Shortcut to microversion module, to avoid wraps below. - microversion = nova.api.openstack.placement.microversion + microversion = placement.microversion # Clear out the html that webob sneaks in. body = webob.exc.strip_tags(body) @@ -368,7 +368,7 @@ def normalize_member_of_qs_params(req, suffix=''): :raises `webob.exc.HTTPBadRequest` if the val parameter is not in the expected format. """ - microversion = nova.api.openstack.placement.microversion + microversion = placement.microversion want_version = req.environ[microversion.MICROVERSION_ENVIRON] multi_member_of = want_version.matches((1, 24)) if not multi_member_of and len(req.GET.getall('member_of' + suffix)) > 1: @@ -493,7 +493,7 @@ def parse_qs_request_groups(req): :raises `webob.exc.HTTPBadRequest` if any value is malformed, or if a trait list is given without corresponding resources. """ - microversion = nova.api.openstack.placement.microversion + microversion = placement.microversion want_version = req.environ[microversion.MICROVERSION_ENVIRON] # Control whether we handle forbidden traits. allow_forbidden = want_version.matches((1, 22)) diff --git a/placement/wsgi.py b/placement/wsgi.py index 3a58fe5ef..354a2861e 100644 --- a/placement/wsgi.py +++ b/placement/wsgi.py @@ -24,8 +24,8 @@ from oslo_policy import opts as policy_opts from oslo_utils import importutils import pbr.version -from nova.api.openstack.placement import db_api -from nova.api.openstack.placement import deploy +from placement import db_api +from placement import deploy from nova import conf diff --git a/placement/wsgi_wrapper.py b/placement/wsgi_wrapper.py index fcb6551d3..d3e5b899c 100644 --- a/placement/wsgi_wrapper.py +++ b/placement/wsgi_wrapper.py @@ -16,7 +16,7 @@ import webob from oslo_log import log as logging from webob.dec import wsgify -from nova.api.openstack.placement import util +from placement import util LOG = logging.getLogger(__name__) diff --git a/setup.cfg b/setup.cfg index 0fc5aa195..39bfe2feb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,7 @@ oslo.config.opts.defaults = oslo.policy.enforcer = nova = nova.policy:get_enforcer - placement = nova.api.openstack.placement.policy:get_enforcer + placement = placement.policy:get_enforcer oslo.policy.policies = # The sample policies will be ordered by entry point and then by list @@ -48,7 +48,7 @@ oslo.policy.policies = # list_rules method into a separate entry point rather than using the # aggregate method. nova = nova.policies:list_rules - placement = nova.api.openstack.placement.policies:list_rules + placement = placement.policies:list_rules nova.compute.monitors.cpu = virt_driver = nova.compute.monitors.cpu.virt_driver:Monitor @@ -75,8 +75,8 @@ console_scripts = nova-status = nova.cmd.status:main nova-xvpvncproxy = nova.cmd.xvpvncproxy:main wsgi_scripts = - nova-placement-api = nova.api.openstack.placement.wsgi:init_application - nova-api-wsgi = nova.api.openstack.compute.wsgi:init_application + nova-placement-api = placement.wsgi:init_application + nova-api-wsgi = compute.wsgi:init_application nova-metadata-wsgi = nova.api.metadata.wsgi:init_application nova.ipv6_backend =