Commit Graph

15 Commits

Author SHA1 Message Date
Boden R 1382bf9a32 remove the neutron.db._model_query module
The functionality from model_query is already in neutron-lib and
consumers are using it. This patch removes the _model_query module
from neutron and updates all imports to use neutron-lib's version of
it instead.

NeutronLibImpact

Change-Id: Ib2eae9edb009a93e60b3b0d63ca365056138566b
2019-01-25 08:55:25 -07:00
Zuul d8c06b002f Merge "Support fetching specific db column in OVO" 2018-12-20 03:56:14 +00:00
Hongbin Lu f24f422373 Support fetching specific db column in OVO
There is a analysis [1] suggested to run queries against specific
columns rather than full ORM entities to optimize the performance.
Right now, it is impossible to execute such optimization because
OVO doesn't support fetching specific column yet.

This commit introduces a new method 'get_values' in the base
neutron object class. Subclass of neutron object can leverage
this method to fetch specific field of a OVO. It supports fetching
non-synthetic fields only as syntheic fields are not directly backed
by corresponding DB table columns.

neutron-lib patch: https://review.openstack.org/#/c/619047/

[1] https://review.openstack.org/#/c/592361/

Needed-By: https://review.openstack.org/#/c/610184/

Change-Id: Ib90eae7738a5d2e4548fe9fed001d6cdaffddf3b
Partial-Implements: blueprint adopt-oslo-versioned-objects-for-db
2018-12-11 19:29:28 +00:00
Hongbin Lu 3e2e2e5577 Sync up model_query module to neutron-lib
The implementation of method 'apply_filters' in
neutron_lib.db.model_query is updated [1]. This patch sync up
the neutron's side implementation.

[1] https://review.openstack.org/#/c/609847/

Change-Id: I180c0813bb433088f6037ff108327fd7a119512b
2018-11-27 21:12:21 +00:00
Boden R 5c208a313a shim model query hooks to use neutron-lib
This patch shims the model query hook functionality to use neutron-lib.
A shim is used as the query hooks are cached in a shared dict and by
shimming them to use neutron-lib we can let consumers move over to
neutron-lib's version at will. Once all current consumers are moved
over to lib, we can remove the shim and consume from lib directly.

The DBQueryHooksFixture is also used in this patch to replace the
existing cleanup function in the unit tests.

Change-Id: I18a4e836ce89b607b5452527e5f8dd172cad6b4f
2018-08-14 15:24:13 -06:00
Boden R 6a89dd2feb use db utils from lib
The APIs our consumers are using from neutron.db_utils were rehomed into
neutron-lib with https://review.openstack.org/#/c/540161/

This patch consumes them by removing the rehomed APIs and using lib's
implementation where applicable.

NeutronLibImpact

Change-Id: I7ee53bce917feae8e37bf278eb3121a5af47131c
2018-07-02 08:24:36 -06:00
Boden R 100491cec7 use object utils from neutron-lib
The neutron.object.utils module was rehomed into neutron-lib with
https://review.openstack.org/#/c/557809/
This patch consumes it by removing the neutron.objects.utils module
and corresponding test module, updating the contributor internals for
objects and using lib's version of the module.

NeutronLibImpact

Change-Id: If53d0ad660851275462d2641ed1829cdb4c32d05
2018-06-11 11:10:53 -06:00
Boden R ce8b73ba87 use make_weak_ref and resolve_ref from neutron-lib
The make_weak_ref and resolve_ref functions were rehomed into
neutron-lib with https://review.openstack.org/#/c/557809/
This patch consumes them by removing the functions and using lib's
version of them instead.

NeutronLibImpact

Change-Id: I41169ed0d93ea8caee530dcfc01a91271f02d538
2018-06-11 11:10:53 -06:00
Lujin 0bbfad2de7 Reorder checks in apply_filters in db/_model_query
Function _kwargs_to_filters() in objects/db/api.py creates a filter
dictionary where all the values are made iterables except in the case
of StringMatchingFilterObj objects. As a consequence, when processing
such a filter, function apply_filters() in db/_model_query.py must
check if a value is a StringMatchingFilterObj before assuming it is
an iterable.

Change-Id: I1b43a06f6e35eaa61c6e6770076a167e6ee83987
Closes-Bug: #1724177
2017-11-01 09:44:26 +09:00
Lujin d104ec67c9 Add NULL check before passing to in_() column operator
In some cases we may need to pass key=None filters to get_object()
and get_objects() methods, however we lack of NULL check before these
filters reach in_(), which will not return any matching queries in db
layer.

We need to do manual equals matches if NULL element exists in filters,
instead of pass them to in_() operator.

Change-Id: I7980b82e2627b7b097cae0a714d22e680cddd340
Closes-Bug: #1724177
2017-10-18 10:23:53 +09:00
Jenkins e939092006 Merge "Support object string field filtering on "LIKE" statement" 2017-07-07 22:58:04 +00:00
tonytan4ever 8702eaa0e2 Support object string field filtering on "LIKE" statement
This patch allows objects' get_objects method take in "LIKE" filters.
e.g:
objs = agent.Agent.get_objects(
     self.context,
     resource_versions=obj_utils.StringContains('obj2')
)

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: I15a76ce20defbcb5b23a13171f93049e84383e0c
Co-Authored-By: Manjeet Singh Bhatia <manjeet.s.bhatia@intel.com>
2017-07-07 16:15:44 +00:00
Boden R cbb0970b36 use attribute functions/operations from neutron-lib
neutron-lib now contains the functionality from neutron's attributes
module. This patch moves the local references over to neturon-lib's
implementation and removes the functionality from the attributes
module.

NeutronLibImpact

Change-Id: I773702ebd4b66d28059cb3ced64b2b477ceff8af
2017-06-21 10:58:28 -06:00
Henry Gessau ef471a652b Refactor CommonDbMixin for removal
Move the CommonDbMixin methods to model_query.py and
resource_extend.py

This leaves CommonDbMixin as just a shim, and it should be easy
to remove once subprojects have stopped depending on it.

Related-Blueprint: neutron-lib

Change-Id: I5b804e09e630d88d551271d9731cc1f65c065259
2017-04-25 14:13:30 -04:00
Henry Gessau e7cd868c20 Decouple hook and func registration from CommonDbMixin
Move the model query hook registration and resource extend funcs
registration methods out of the CommonDbMixin class and make them
regular utility functions.

This is a step in refactoring the CommonDbMixin class.

Change-Id: Iec1bb7f7098c83640ae695fd7cf2f4736f414ad2
2017-03-11 18:04:11 -05:00