Commit Graph

19 Commits

Author SHA1 Message Date
Nurmatov Mamatisa ce3b86eef3 Use neutron-lib standard_attr
Now only neutron uses neutron/db/standard_attr.py
Shim can be removed

Change-Id: I980265335c5f3f6b5ee2e5fbcad9491aad91defe
2021-09-15 09:19:26 +00:00
Boden R a962b20ba9 shim standard_attr db for neutron-lib
This patch shims the attributes of the neutron.db.standard_attr module
to reference neutron-lib's implementation to allow consumers to move
over to lib's standard_attr at their leisure. Once all consumers are
moved over we will remove these neutron shims.

Change-Id: Ie3f55432a772b3e51a45252fa57fe5c9fa9cbe40
2019-07-23 14:17:29 -06:00
Boden R 94221c60ad consume sqlalchemytypes from neutron-lib
The neutron.db.sqlalchemytypes module we rehomed into neutron-lib [1].
This patch consumes it by removing the module and unit tests from
neutron and using them from neutron-lib where applicable.

NeutronLibImpact

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

Change-Id: I3ab76ca3813d550a4de454cc83156a55325f6abc
2019-03-25 07:51:23 -06:00
Mike Bayer d841ce72bf Run revision bump operations en masse
Refactored RevisionPlugin to operate upon sets of objects at
once.   In the case of "related" objects, the bump operation
no longer makes use of compare-and-swap and instead updates
version numbers directly without testing for their previous value.
This removes the issue of StaleDataErrors being
prevalent within the related object update phase, given the assumption
that the compare-and-swap logic is only desireable for the primary object
being updated.

Change-Id: I2fef298041c59a03dfd06912764973995b80690c
2019-02-18 15:12:17 -05:00
Brian Haley fc95db987d Fix flake8 N534 untranslated exception message
Fix N534 untranslated exception message warnings and
enable enforcement.

Trivialfix

Change-Id: I9e2b51c768cbb6fcf5588070d1b9e9835775b374
2018-10-19 15:46:04 -04:00
Thomas Morin 5179896e77 Allow sub-resources to have standard attributes
Prior to this change a DB model with standard
attributes could declare that it was mapping to
an API resource, but not declare a mapping to a
sub-resources (see bug 1763347).

This change allows DB models with standard attributes
to advertise that they map API *sub*-resources, and
modifies the code that extends DB resources to support
these specific declarations.

Closes-Bug: 1763347
Needed-By: I77ce46c0f33e2a366076d51ce6586fb3008dc6b1

Change-Id: I7630aab5e4f38d0fba862adc2426d4a7ca04a679
2018-07-04 20:52:37 +00:00
Brian Haley c3b83a9ca6 Fix all pep8 E265 errors
Fixed all pep8 E265 errors and changed tox.ini to no longer
ignore them.  Also removed an N536 comment missed from a
previous change.

Change-Id: Ie6db8406c3b884c95b2a54a7598ea83476b8dba1
2018-04-30 16:35:52 -04:00
Inessa Vasilevskaya 7322bd6efb Make code follow log translation guideline
Since Pike log messages should not be translated.
This patch removes calls to i18n _LC, _LI, _LE, _LW from
logging logic throughout the code. Translators definition
from neutron._i18n is removed as well.
This patch also removes log translation verification from
ignore directive in tox.ini.

Change-Id: If9aa76fcf121c0e61a7c08088006c5873faee56e
2017-08-14 02:01:48 +00:00
Hirofumi Ichihara 96f0142b80 Tag mechanism supports resources with standard attribute
Tag mechanism supports network, subnet, port, subnetpool
router resources only. This patch allow tag mechanism to support
 resources with standard attribute.

Two old extenions are kept because of backward compatibility.
They will be removed in Queens release.

APIImpact: Tag is supported by resources with standard attribute
DocImpact: allow users to set tags on resources with standard attribute

Change-Id: Id7bb13b5beb58c313eea94ca03835d3daf5c94bc
Closes-Bug: #1682775
2017-07-25 08:14:04 +09:00
Kevin Benton 9c0a0de556 Manually increment revision numbers in revision plugin
Don't rely on the SQLAlchemy revision_col flag to bump revision
numbers and instead bump them in a before_flush handler. This
will allow the follow-up patch to do enforcement on conditional
updates before the revision number is incremented.

Partial-Bug: #1493714
Partially-Implements: blueprint push-notifications
Change-Id: I5feeec5b8385727eff53dc669363bc41db8ceaba
2017-06-14 18:47:17 -07:00
Kevin Benton 553ab6d86e Register sqlalchemy events through hook for UT cleanup
Register all sqlalchemy events through a new function in
neutron.db.api so we can keep track of active events and
ensure all are removed at the end of each test run.

Without this, an instance of a plugin may be left around
with the only reference to it existing in SQLAlchemy, where
it will receive events for tests unrelated to it and potentially
interfere.

Change-Id: I8e93eb4e8ef5a13f015db9cd20e44941cdcb72ef
2017-01-20 04:15:01 -08:00
Kevin Benton b87715d764 Protect against '.delete()' for quota and revisions
The devref was suggesting to do exactly the wrong thing for cases where
we have SQLAlchemy event listeners waiting for deleted objects.
DELETE statements fail to trigger any kind of SQLAlchemy event
listeners and the majority of our delete operations are small
(<10 items at once) so the performance difference is negligible
(especially since we do it so infrequently).

Change-Id: Id142179418a7b94d8d9695871b3fcd5dcc64730c
2017-01-09 09:09:18 -08:00
Henry Gessau 1c5bf09a03 Use DB field sizes instead of _MAX_LEN constants
Remove The following _MAX_LEN constants from
neutron/api/v2/attributes.py and use the corresponding DB field size
constants from neutron_lib.db.constants instead.

 NAME_MAX_LEN              -->  NAME_FIELD_SIZE
 TENANT_ID_MAX_LEN         -->  PROJECT_ID_FIELD_SIZE
 DESCRIPTION_MAX_LEN       -->  DESCRIPTION_FIELD_SIZE
 LONG_DESCRIPTION_MAX_LEN  -->  LONG_DESCRIPTION_FIELD_SIZE
 DEVICE_ID_MAX_LEN         -->  DEVICE_ID_FIELD_SIZE
 DEVICE_OWNER_MAX_LEN      -->  DEVICE_NAME_FIELD_SIZE

In alembic migration scripts, the raw numerical value is used.

For more information, see:
http://lists.openstack.org/pipermail/openstack-dev/2016-October/105789.html

NeutronLibImpact

Change-Id: I734890372584fe27e5d6ec38c0cad2de882ff11c
2016-12-23 13:48:57 +00:00
Kevin Benton 6bd3ad2bb3 Bump revision of resource on tag add/remove
This updates the tag to bump the revision of the standard
attr record it's associated with. This required a small change
to include a bump revision method directly on the standard
attr records.

Closes-Bug: #1643879
Change-Id: Ia096cd342ed3eeec33a8ae64efe13d469c375dd6
2016-12-19 11:20:54 -08:00
zhangyanxian 1a0da09b4b Fix typos in standard_attr.py & attributes.py
TrivalFix

Change-Id: I220262991e2af9cb9ec649c1a15f2923765fbf2f
2016-11-16 10:09:35 +00:00
Kevin Benton 465d22180e Add common way to extend standard attribute models
This adds a way for standard attribute models to declare
the API resources they show up in. It then adds a utility
function to the standard_attr module to grab a map of all
API resources and their corresponding models.

This can be used by any processing code that wants to add
fields to standard attribute resources.

This also adjusts the existing extensions to leverage this
new functionality.

Partially-Implements: blueprint add-neutron-extension-resource-timestamp
Change-Id: Idc8923d0e983fcb0690f8cb5b55a5aff8690154f
2016-09-15 01:42:24 +00:00
Kevin Benton cd80ae6e42 Truncate microseconds before DB insertion
During the development of patch [1], it became apparent
that the DB was rounding the microseconds part of a datetime
object. This caused inconsistencies between what would be
stored in the DB and what was returned to the user via the
API because the API uses strftime.

For an example, see the INSERT statement on L1-L2 and then
the subsequent retrieval of the same record on L43 of [2].
The microseconds were rounded up even though the mysql docs
say they will be truncated.

In order to ensure consistency across SQL drivers, backends,
and our API, this patch adds a TruncatedDateTime object which
truncates off the microseconds before they go into the database.

1. I78b00516e31ce83376d37f57299b2229b6fb8fcf
2. http://paste.openstack.org/show/565116/

Closes-Bug: #1619299
Change-Id: I47d5ad5a5cdc0cb0d61f0642616cccc8f341ed62
2016-09-01 13:25:24 +00:00
Henry Gessau 61cc14fd67 Switch to neutron-lib for model_base
Change-Id: If5b2b4cc0346515ddef3da1255ab49327c8e5732
2016-08-31 11:12:18 -04:00
Kevin Benton bdd7298284 Move standard attr out of model_base
The model_base file is going to move to Neutron lib in
I2087c6f5f66154cdaa4d8fa3d86f5e493f1d24d9. This will mainly leave
behind only the standard attributes related stuff so the name
'model_base' won't make much sense. This moves the standard attribute
related things into its own module so model_base can conceivably be
eliminated entirely.

Change-Id: Icaf3220fbc5723f2b5421a494371ef274d7073c7
2016-08-27 17:46:38 -04:00