Fix aesthetic issues from I4974a28de541aace043504f

Followon to address minor formatting issues from [1]. This is purely
aesthetic, no functional changes.

[1] I4974a28de541aace043504f788cf0d100f778cae

Change-Id: I3e8698c2a6dc753c484fd93e57707fe05c31af0a
This commit is contained in:
Eric Fried 2018-09-04 15:53:21 -05:00
parent c0ec9b4f86
commit 699afee900
6 changed files with 18 additions and 26 deletions

View File

@ -24,8 +24,7 @@ from placement import exception
from placement.i18n import _
from placement import microversion
from placement.objects import resource_provider as rp_obj
from placement.policies import allocation_candidate as \
policies
from placement.policies import allocation_candidate as policies
from placement.schemas import allocation_candidate as schema
from placement import util
from placement import wsgi_wrapper

View File

@ -3975,8 +3975,7 @@ class AllocationCandidates(base.VersionedObject):
be randomized.
:param context: Nova RequestContext.
:param requests: Dict, keyed by suffix, of
placement.util.RequestGroup
:param requests: Dict, keyed by suffix, of placement.lib.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 +4009,7 @@ class AllocationCandidates(base.VersionedObject):
(or writer) context.
:param context: Nova RequestContext.
:param request: One placement.util.RequestGroup
:param request: One placement.lib.RequestGroup
:param sharing_providers: dict, keyed by resource class internal ID, of
the set of provider IDs containing shared
inventory of that resource class

View File

@ -62,8 +62,7 @@ def get_enforcer():
def authorize(context, action, target, do_raise=True):
"""Verifies that the action is valid on the target in this context.
:param context: instance of
placement.context.RequestContext
:param context: instance of 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,8 +71,8 @@ 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 placement.exception.PolicyNotAuthorized: if
verification fails and do_raise is True.
: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.
"""

View File

@ -414,8 +414,8 @@ 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('placement.objects.'
'resource_provider._set_root_provider_id'):
with mock.patch('placement.objects.resource_provider.'
'_set_root_provider_id'):
rps = rp_obj.ResourceProviderList.get_all_by_filters(
self.ctx,
filters={
@ -1765,9 +1765,8 @@ class TestAllocationListCreateDelete(tb.PlacementDbBaseTestCase):
'RP_CONFLICT_RETRY_COUNT', 3):
unmocked_set = functools.partial(
rp_obj.AllocationList._set_allocations, alloc_list)
with mock.patch(
'placement.objects.resource_provider.'
'AllocationList._set_allocations') as mock_set:
with mock.patch('placement.objects.resource_provider.'
'AllocationList._set_allocations') as mock_set:
exceptions = iter([
exception.ResourceProviderConcurrentUpdateDetected(),
exception.ResourceProviderConcurrentUpdateDetected(),
@ -1934,9 +1933,8 @@ class ResourceClassTestCase(tb.PlacementDbBaseTestCase):
rc.create()
self.assertEqual(min_id + 1, rc.id)
@mock.patch.object(
placement.objects.resource_provider.ResourceClass,
"_get_next_id")
@mock.patch.object(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
# create rc2 with the same ID, and then return 43 in the retry loop.
@ -1954,9 +1952,8 @@ class ResourceClassTestCase(tb.PlacementDbBaseTestCase):
self.assertEqual(rc1.id, 42)
self.assertEqual(rc2.id, 43)
@mock.patch.object(
placement.objects.resource_provider.ResourceClass,
"_get_next_id")
@mock.patch.object(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"""
# This order of ID generation will create rc1 with an ID of 44, try to

View File

@ -182,8 +182,8 @@ class TestJSONErrorFormatter(testtools.TestCase):
'1.0',
'1.1',
]
mod_str = 'placement.microversion.VERSIONS'
self.useFixture(fixtures.MonkeyPatch(mod_str, _versions))
self.useFixture(fixtures.MonkeyPatch('placement.microversion.VERSIONS',
_versions))
def test_status_to_int_code(self):
body = ''

View File

@ -368,8 +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 = placement.microversion
want_version = req.environ[microversion.MICROVERSION_ENVIRON]
want_version = req.environ[placement.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:
raise webob.exc.HTTPBadRequest(
@ -493,8 +492,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 = placement.microversion
want_version = req.environ[microversion.MICROVERSION_ENVIRON]
want_version = req.environ[placement.microversion.MICROVERSION_ENVIRON]
# Control whether we handle forbidden traits.
allow_forbidden = want_version.matches((1, 22))
# Temporary dict of the form: { suffix: RequestGroup }