Commit Graph

15 Commits

Author SHA1 Message Date
Zuul 8e38e57b80 Merge "Create a single method to set the quota usage dirty bit" 2023-09-21 17:52:23 +00:00
Slawek Kaplonski a4c8392209 Default SG rules - use new rules templates to create rules for SGs
Default SG rules created as template in the Neutron DB are now used to
create security group rules for each new default and non-default SG
created in Neutron.

Closes-bug: #1983053
Change-Id: Iaf27deb955c3844409fcd36239511478e9607a82
2023-08-30 10:18:19 +00:00
Slawek Kaplonski 5db57734aa Initialize config in DietTestCase class
Now, after [1] was merged all tests where neutron_lib.context.Context is
used needs to have configured config because every time
instance of the neutron_lib.context.Context class is created it tries to
initialize policies and check if it's service_role or not.

Until now this was done only in the BaseTestCase class so all tests
which inherits from the DietTestCase or SqlTestCaseLight classes did not
have it and those tests were failing.

Additionally this patch removes adding CONF.reset() to the cleanUp in
some tests as it's not needed anymore because it is done in the setUp of
the DietTestCase class.

Closes-Bug: #2025753

[1] https://review.opendev.org/c/openstack/neutron-lib/+/887191

Change-Id: I52597ab066c3d7a2d835278431e00b63c8f55c46
2023-07-19 12:58:58 +02:00
Rodolfo Alonso Hernandez 2c0e9cfa71 Create a single method to set the quota usage dirty bit
The method ``set_resources_quota_usage_dirty`` can be used now to set
the dirty bit for a single resource or multiple ones.

Trivial-Fix

Change-Id: I13ef43b71fe7a080d55a84119784433ad84380b6
2023-07-06 06:06:23 +00:00
Slawek Kaplonski 670cc383e0 [S-RBAC] Switch to new policies by default
As part of the Secure RBAC community goal, we should switch options
"enforce_new_defaults" and "enforce_scope" to be True by default.
It will be still possible to fallback to old policy rules by configuring
those config options to False in Neutron config.

Change-Id: I09c0026ccf87e6c0bb1fa59165c03dc508fba6fa
2023-04-21 16:22:42 +02:00
Rodolfo Alonso Hernandez 7dcddeb0bd Replace "tenant_id" with "project_id" in Quota engine
This is part of the remaining technical debt of the specs
https://specs.openstack.org/openstack/neutron-specs/specs/newton/moving-to-keystone-v3.html

Blueprint: https://blueprints.launchpad.net/neutron/+spec/keystone-v3

Change-Id: I1faf520d3cdafe2de873525c8ebe1fa2114bdcd7
2021-09-22 08:27:10 +00:00
Rodolfo Alonso Hernandez ad31c58d60 Remove ``ConfDriver`` code
The quota driver ``ConfDriver`` was deprecated in Liberty release.

``NullQuotaDriver`` is created for testing although it could be used
in production if no quota enforcement is needed. However, because
the Quota engine is not plugable (is an extension always loaded), it
could be interesting to make it plugable as any other plugin.

This patch also creates a Quota engine driver API class that should be
used in any Quota engine driver. Currently it is used in the three
in-tree drivers implemented: ``NullQuotaDriver``, ``DbQuotaDriver``
and ``DbQuotaNoLockDriver``.

Change-Id: Ib4af80e18fac52b9f68f26c84a215415e63c2822
Closes-Bug: #1928211
2021-07-26 15:00:32 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Aditya Reddy Nagaram cbc473e066 Support for stateless security groups
Blueprint: stateless-security-groups

Change-Id: Iae39a89b762786e4f05aa61aa0db634941806d41
2020-03-03 16:53:42 +01:00
Boden R 9e67ba5052 use core resource api defs from lib
The core resource API definitions are in neutron-lib and are already
setup in a RESOURCES map, similar to neutron's global
RESOURCE_ATTRIBUTE_MAP. However, a number of consumers directly use
RESOURCE_ATTRIBUTE_MAP and moreover can perform some interesting
operations on it while mockin" for tests. For that reason this
patch proposes we phase in the use of neutron's RESOURCES map rather
than a rip and replace of RESOURCE_ATTRIBUTE_MAP.

This patch removes the API definitions for the core neutron resources
by updating neutron's global RESOURCE_ATTRIBUTE_MAP to reference lib's
RESOURCE map. In addition the AttributeMapMemento class is removed; it
no longer servers a purpose and neutron-lib's fixture should be used
in its place.

This patch should be safe to merge without worry of impacting consumers.
No one is using AttributeMapMemento [1] and the global map only changed
its reference value.

[1] http://codesearch.openstack.org/?q=AttributeMapMemento

Change-Id: Ib04fddcbd4465074452b71b16befa4e33b27259e
2017-11-08 09:48:50 -07:00
Boden R 277996b68d cleanup unit test usage of api extension maps
Today our unit test code uses various ways to "patch" the global
RESOURCE_ATTRIBUTE_MAP as well as extension specific maps in some cases.
This patch consolidates such patching whereby tests should use neutron's
AttributeMapMemento in their setup() chain (only once) if they update
the global map and they should individually handle backup/restore of per
extension map updates. This change will simplify the code and make it
easier to phase-in API definition usage with neutron-lib where we have
some as API definitions and others not. Longer term the
AttributeMapMemento will be replace with neutron-lib's fixture as we
move all extension maps to API definitions in neutron-lib.

Change-Id: I2586f0b11b107d7f57214a0d65bcf7c38a5f0ebb
2017-10-24 10:38:52 -06:00
Kevin Benton db1058a499 Switch to Pecan for unit tests
This will drop Pecan in place of the old APIRouter for all
unit tests. This will significantly increase the UT coverage
of pecan and will allow us to drop the old API routing logic
completely.

The rest of the inline test changes are due to slight plugin loading
differences.

Implements: blueprint wsgi-pecan-switch
Change-Id: I76dc23fb7b96d82b0da50285bd0aac76142e81e5
2017-09-13 15:11:49 -07:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Sergey Belous c82f0021d5 Add relationship between port and floating ip
We need to have the relationship between port and floating ip, because updating
quota will happen when the event "after_delete" occurs. And current cascade
removal of the floating ip does not cause the event "after_delete" for floating
ip. The cascade on the ORM-level "delete" must be added.

Closes-bug: #1533687
Change-Id: Id414cf20069563085737fee5ddce94b1bf2f912d
2016-01-29 12:28:15 +03:00
Salvatore Orlando cdd049e4c4 ML2: Add tests to validate quota usage tracking
Ensure that event handlers are invoked upon completion of
ML2 operations which add or remove tracked resources.
Also validate that the event handlers are called for the
appropriate resources and that quota usage's dirty bit
is set and unset as expected.

These are not unit tests, but added in the unit test tree
as they leverage code both from the DB unit test and the ML2
unit test framework. This module has indeed been added to
the 'exclusion list' in check_unit_test_structure.sh, and
should be moved to the functional test tree together with
the other modules.

Closes-Bug: #1499358

Change-Id: I78c432c35f3f3339607cd533019ae6d0fa2a5cd6
2015-12-09 15:17:23 -08:00