[placement] Unregister the TraitList object

Since we don't use RPC in placement and intend to never use RPC in
placement it makes little sense to register the resource provider
objects and keep track of their versions. They still need to be
activated as structured objects to get their fields set and properly
inherited.

Tests of versioned objects inspect the dependency trees of objects that
have other objects as fields so this process starts with the TraitList
object. Nothing depends on it. In subsequence patches the other objects
will be unregistered.

There are two primary changes here:

* unregistering the TraitList class
* where objects.TraitList is used, point directly to the
  nova.objects.resource_provider package instead

Partially-Implements: bp placement-deregister-objects
Change-Id: If284b7d595a7dd214a5cd3a322419074dcf0373e
This commit is contained in:
Chris Dent 2017-09-08 05:59:54 +01:00
parent f390632d7a
commit fcf4b829eb
2 changed files with 6 additions and 4 deletions
nova
api/openstack/placement/handlers
tests/functional/api/openstack/placement

@ -24,6 +24,7 @@ from nova.api.openstack.placement import wsgi_wrapper
from nova import exception
from nova.i18n import _
from nova import objects
from nova.objects import resource_provider as rp_obj
TRAIT = {
"type": "string",
@ -183,7 +184,7 @@ def list_traits(req):
filters['associated'] = (
True if req.GET['associated'].lower() == 'true' else False)
traits = objects.TraitList.get_all(context, filters)
traits = rp_obj.TraitList.get_all(context, filters)
req.response.status = 200
req.response.body = encodeutils.to_utf8(
jsonutils.dumps(_serialize_traits(traits)))
@ -229,7 +230,7 @@ def update_traits_for_resource_provider(req):
"the generation and try again."),
json_formatter=util.json_error_formatter)
trait_objs = objects.TraitList.get_all(
trait_objs = rp_obj.TraitList.get_all(
context, filters={'name_in': traits})
traits_name = set([obj.name for obj in trait_objs])
non_existed_trait = set(traits) - set(traits_name)
@ -256,7 +257,7 @@ def delete_traits_for_resource_provider(req):
resource_provider = objects.ResourceProvider.get_by_uuid(context, uuid)
try:
resource_provider.set_traits(objects.TraitList(objects=[]))
resource_provider.set_traits(rp_obj.TraitList(objects=[]))
except exception.ConcurrentUpdateDetected as e:
raise webob.exc.HTTPConflict(explanation=e.format_message())

@ -21,6 +21,7 @@ from nova import conf
from nova import config
from nova import context
from nova import objects
from nova.objects import resource_provider as rp_obj
from nova.tests import fixtures
@ -283,7 +284,7 @@ class SharedStorageFixture(APIFixture):
self.context,
"MISC_SHARES_VIA_AGGREGATE",
)
ss.set_traits(objects.TraitList(objects=[t]))
ss.set_traits(rp_obj.TraitList(objects=[t]))
# Now associate the shared storage pool and both compute nodes with the
# same aggregate