Commit Graph

18 Commits

Author SHA1 Message Date
Slawek Kaplonski d7371e13e4 Revert "Set system_scope='all' in elevated context"
This reverts commit 062336e59b.

Now, we have proper fix for the system_scope='all' in elevated context
in the neutron-lib so we can revert temporary fix made at the end of the
Wallaby cycle.

Related-Bug: #1920001

Conflicts:
    neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py
    neutron/common/utils.py
    neutron/db/address_group_db.py
    neutron/services/segments/db.py

Change-Id: Ife9b647b403bdd76a8a99984ea8858bf95c96bc3
2021-06-15 10:29:20 +02:00
Slawek Kaplonski 062336e59b Set system_scope='all' in elevated context
In case when enforce_new_defaults is set to True and new policy rules
are used, context.is_admin flag isn't really working as it was with old
rules.
But in case when elevated context is needed, it means that we need
context which has full rights to the system. So we should also set
"system_scope" parameter to "all" to be sure that system scope queries
can be done with such elevated context always.

It is needed e.g. when elevated context is used to get some data from
db. In such case we need to have db query which will not be scoped to
the single project_id and with new defaults to achieve that system_scope
has to be set to "all".

Proper fix for that should be done in neutron-lib and it is proposed
in [1] already but as we are have frozen neutron-lib version for
stable/wallaby already this patch for neutron is temporary fix for that
issue.
We can revert that patch as soon as we will be in Xena development cycle
and [1] will be merged and released.

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

Related-Bug: #1920001
Change-Id: I0068c1de09f5c6fae5bb5cd0d6f26f451e701939
2021-03-19 12:05:56 +01:00
Brian Haley 08a60f7483 Remove usage of six.add_metaclass
With python 3.x, classes can use the metaclass= logic
to not require usage of the six library.

One step in removing all of six usage from neutron.

Change-Id: I2f815e412d9a96eb5faf2b3bb3a1e393a9db9309
2020-05-21 14:41:18 -04:00
Rodolfo Alonso Hernandez f2b52b5e8f Add "qos_network_policy_id" to port definition
Added "qos_network_policy_id" key to port dictionary.

Change-Id: I75713e0e3924ad4c9177e7c9b04c58882e292dc0
Closes-Bug: #1851362
2020-01-17 17:57:11 +00:00
Rodolfo Alonso Hernandez 51dd91df5b Switch to new engine facade for QoS
* QosCoreResourceExtension
* QoSPlugin

Partially-Implements blueprint: enginefacade-switch

Change-Id: I034cad8d5290b416e55acdaeea69c5a130308afe
2019-05-28 08:11:35 +00:00
Boden R 68fd13af40 remove neutron.common.exceptions
Today the neutron common exceptions already live in neutron-lib and are
shimmed from neutron. This patch removes the neutron.common.exceptions
module and changes neutron's imports over to use their respective
neutron-lib exception module instead.

NeutronLibImpact

Change-Id: I9704f20eb21da85d2cf024d83338b3d94593671e
2019-02-01 14:35:00 -07:00
Boden R f4a684cdcb use autonested_transaction from neutron-lib
A publically consumed db api is available in neutron-lib. This patch
consumes the autonested_transaction by removing it's def from neutron
and replacing all such usages to now use neutron-lib's version of
autonested_transaction.

NeutronLibImpact

Change-Id: I8d7cbb9b90151d252959e9fce8937f3e4e456811
2018-07-26 07:41:34 -06:00
LIU Yulong a034e8e0f8 Refactor duplicated implementation of _get_policy_obj
This patch moves the implementation of the function
_get_policy_obj to the policy object code scope.

Change-Id: I7057558a5ec32a55a37a6b93dabc997d69abfb98
2018-06-20 09:51:02 +08:00
Boden R 1b8664f8e1 use qos constants from neutron-lib
neutron-lib contains the QoS constants. This patch removes them from
neutron and replaces all such uses to lib's QoS constants.

NeutronLibImpact

Change-Id: I6ed379b178a2b79fd14385a1d1e87d87eb04bfb9
2017-10-26 19:57:19 +00:00
Boden R 95f1e03446 use plugin constants from neutron-lib
neutron-lib contains a number of the plugin related constants from
neutron.plugins.common.constants. This patch consumes those constants
from neutron-lib and removes them from neutron. In addition the notion
of the dummy plugin service type is moved strictly into the test
package of neutron since it's not a real service plugin.

NeutronLibImpact

Change-Id: I767c626f3fe6159ab3abd6a7ae3cb9893b79bf66
2017-10-16 09:32:20 -06:00
Hirofumi Ichihara 95bbb7385b Fix default qos policy when creating network
In _create_network_policy(), policy object is passed into _get_policy_obj()
although it expects to be passed policy id. This patch passes policy id
instead of policy object and adds a unit test and API tests.

Change-Id: Ic4c755c54d93d7ca3312b432b7c1e6770f25c359
Closes-bug: #1712278
2017-08-23 13:03:18 +00:00
Rodolfo Alonso Hernandez 9d69822e43 Add "default" behaviour to QoS policies
This patch implements the "default" behaviour for QoS policies.
If this flag is enabled for a QoS policy in a project, all
new networks created will have this QoS policy assigned by default.

If a new QoS policy is created or updated with this flag and another
QoS policy in the same project is set as the default policy, the new
one won't be created or updated. To set another QoS policy as default,
the current one must be unset.

DocImpact: A "default" flag is introduced for QoS policies. If this flag
           is enabled in a QoS policy (attached to a project), then all
           networks created in this project would have this QoS policy
           assigned, unless an explicit policy is specified.
APIImpact

Closes-Bug: #1639220
Change-Id: If5ff2b00fa828f93aa089e275ddbd1ff542b79d4
2017-05-26 23:31:36 +00:00
Armando Migliaccio 17563a802e Adopt neutron-lib plugin directory
Neutron Manager is loaded at the very startup of the neutron
server process and with it plugins are loaded and stored for
lookup purposes as their references are widely used across the
entire neutron codebase.

Rather than holding these references directly in NeutronManager
this patch refactors the code so that these references are held
by a plugin directory.

This allows subprojects and other parts of the Neutron codebase
to use the directory in lieu of the manager. The result is a
leaner, cleaner, and more decoupled code.

Usage pattern [1,2] can be translated to [3,4] respectively.

[1] manager.NeutronManager.get_service_plugins()[FOO]
[2] manager.NeutronManager.get_plugin()
[3] directory.get_plugin(FOO)
[4] directory.get_plugin()

The more entangled part is in the neutron unit tests, where the
use of the manager can be simplified as mocking is typically
replaced by a call to the directory add_plugin() method. This is
safe as each test case gets its own copy of the plugin directory.
That said, unit tests that look more like API tests and that rely on
the entire plugin machinery, need some tweaking to avoid stumbling
into plugin loading failures.

Due to the massive use of the manager, deprecation warnings are
considered impractical as they cause logs to bloat out of proportion.

Follow-up patches that show how to adopt the directory in neutron
subprojects are tagged with topic:plugin-directory.

NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I7331e914234c5f0b7abe836604fdd7e4067551cf
2016-11-23 04:45:33 -07:00
Tong Li 4ec6932c93 Respond negatively to tenant detachment of enforced QoS policies
Currently when the tenant attempts to detach an enforced QoS policy
for a port or network set by admin, the attempt fails but the API
feedback indicates that it was successful.  This change will
fix the API response so the failure is accurately signalled
to the tenant.

Co-Authored-By: litong01 <litong01@us.ibm.com>
Co-Authored-By: gong yong sheng <gong.yongsheng@99cloud.net>
Co-Authored-By: Nate Johnston <Nate_Johnston@cable.comcast.com>
Co-Authored-By: Margaret Frances <margaret_frances@cable.comcast.com>

Change-Id: I977feecc6cce378abc1e6092afbaf9f2681b2ec6
Closes-bug: #1486607
2016-05-16 21:54:15 +00:00
Artur Korzeniewski 4b227c3771 Objects DB api: added composite key to handle multiple primary key
Moving CRUD DB operation for objects from db/api.py to objects/db/api.py
Renaming object get_by_id(id) to get_object(**kwargs)

Many models in Neutron DB have complex primary keys, concatenated from
a few properties. This patch adds ability to define multiple primary keys
in NeutronDbObject, which are automatically evaluated into DB query
when performing operations.

Partial-Bug: #1541928
Change-Id: I0f63a62418db76415ddd40c30c778ff7541b93dc
2016-03-01 17:05:11 +00:00
John Schwarz bb1546df15 Forbid attaching rules if policy isn't accessible
Following up patch If06de416dfe0eb7115fd4be9feb461fae8e8358d, this patch
continues to make sure all access to QoS policies are attempted safely -
if the policy doesn't exist or it's not accessible (for tenant_id
reasons), then an exception will be raised instead.

Change-Id: Id7e64c745cdd63d650a3f69572635dc10197259c
Partially-Implements: quantum-qos-api
2015-08-12 09:52:33 +00:00
Ihar Hrachyshka 5f5be37899 QoS core extension: fixed dict extension when QoS policy is unset
Previously, if QoS policy was detached from a core resource, core
resource extension didn't update the resource dict with the new QoS
policy value (None), and that resulted in no notification sent to the
agent about the change, so QoS rules were not flushed from the affected
ports.

Change-Id: I22397af3a43254d146abaa4a4429ac654b4c3c50
Partially-Implements: quantum-qos-api
2015-08-08 15:44:27 +02:00
Ihar Hrachyshka d148e68b71 Introduce base interface for core resource extensions
The interface can be found in neutron.core_extensions.base.

Adopted the interface in qos core resource extension.

Alos moved qos_extension under neutron.core_extensions.qos. Partially,
this is to avoid confusion around the fact that the module does not
really contain a neutron API extension but core resource extension.

Change-Id: I6f6976aa49694f7ef17afa4e93bc769cd0069f65
Partially-Implements: blueprint quantum-qos-api
2015-08-07 21:36:15 +02:00