objects: Use common plugin _model_query in get_object

_model_query() composes query that supports rbac, shared attribute and
model hooks.

Change-Id: I5208e6be193e93e565bc0cb1309ff8e4a6adf4a8
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This commit is contained in:
Jakub Libosvar
2016-06-07 08:31:39 +00:00
parent d8ae9cf475
commit 75ac49aa7a
2 changed files with 9 additions and 13 deletions

View File

@@ -13,16 +13,16 @@
from neutron_lib import exceptions as n_exc
from oslo_utils import uuidutils
from neutron.db import common_db_mixin
from neutron import manager
# Common database operation implementations
def get_object(context, model, **kwargs):
# TODO(jlibosva): decompose _model_query from plugin instance
plugin = manager.NeutronManager.get_plugin()
with context.session.begin(subtransactions=True):
return (common_db_mixin.model_query(context, model)
.filter_by(**kwargs)
.first())
return plugin._model_query(context, model).filter_by(
**kwargs).first()
def _kwargs_to_filters(**kwargs):

View File

@@ -273,8 +273,13 @@ class _BaseObjectTestCase(object):
_test_class = FakeNeutronObject
CORE_PLUGIN = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
def setUp(self):
super(_BaseObjectTestCase, self).setUp()
# TODO(ihrachys): revisit plugin setup once we decouple
# neutron.objects.db.api from core plugin instance
self.setup_coreplugin(self.CORE_PLUGIN)
self.context = context.get_admin_context()
self.db_objs = list(self.get_random_fields() for _ in range(3))
self.db_obj = self.db_objs[0]
@@ -672,15 +677,6 @@ class BaseDbObjectMultipleForeignKeysTestCase(_BaseObjectTestCase,
class BaseDbObjectTestCase(_BaseObjectTestCase):
CORE_PLUGIN = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
def setUp(self):
super(BaseDbObjectTestCase, self).setUp()
# TODO(ihrachys): revisit plugin setup once we decouple
# neutron.objects.db.api from core plugin instance
self.setup_coreplugin(self.CORE_PLUGIN)
def _create_test_network(self):
# TODO(ihrachys): replace with network.create() once we get an object
# implementation for networks