neutron/neutron/tests/unit/db
Rodolfo Alonso Hernandez 78027da56c Remove the publish patch in SG rule BEFORE_DELETE and BEFORE_CREATE
The method ``delete_security_group_rule`` is publishing the
BEFORE_DELETE event before starting the security group rule deletion.
This event is published using a wrap method called
``SecurityGroupDbMixin._registry_publish``. This method is capturing
any ``CallbackFailure`` exception and raising a
``SecurityGroupRuleInUse`` one. That makes no sense because:
* We are hidding the real cause of the callback failure.
* The BEFORE_DELETE is not checking that the security group rule is
  being used (NOTE 1).
* If any new implementation makes this check, the corresponding callback
  should return explicitly this exception.

The method ``_create_security_group_rule`` is publishing the
BEFORE_CREATE event before starting the security group rule creation.
The same argument applies here: the callback manager should return the
exception raise by the callback method (NOTE 2).

In a follow-up patch, this events will be captured to check the
permissions related to the user creating or deleting the security group
rule. In case of error, it will be needed to raise a ``NotAuthorized``
derived exception, instead of a ``InUse`` one.

NOTE 1: this is the current use of BEFORE_DELETE event in the
OpenStack repository:
* [2] Omni project had no activity for the last 4 years.
* [3] networking-arista: the method ``run_cmds_on_all_switches``, that
  calls ``run_openstack_sg_cmds``, returns its own exceptions.
* [4] networking-opencontrail: same justification.
* [5] The ML2/OVN mechanism driver, that will raise an exception if the
  OVN ACL deletion doesn't succeed.

NOTE 2: this is the current use of BEFORE_DELETE event in the
OpenStack repository:
* [2] Omni project had no activity for the last 4 years.

[1]https://codesearch.openstack.org/?q=%5C.SECURITY_GROUP_RULE&i=nope&literal=nope&files=&excludeFiles=&repos=
[2]https://opendev.org/x/omni/src/branch/master/neutron/neutron/plugins/ml2/drivers/aws/callbacks.py
[3]https://opendev.org/x/networking-arista/src/branch/master/networking_arista/ml2/security_groups/arista_security_groups.py
[4]https://opendev.org/x/networking-opencontrail/src/branch/master/networking_opencontrail/ml2/opencontrail_sg_callback.py
[5]https://opendev.org/openstack/neutron/src/branch/master/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

Partial-Bug: #2019960

Change-Id: I8d5f5392fb7a6ab9b20e9222c143f4e67c925cae
2023-10-09 14:11:43 +00:00
..
metering [S-RBAC] Switch to new policies by default 2023-04-21 16:22:42 +02:00
quota Create a single method to set the quota usage dirty bit 2023-07-06 06:06:23 +00:00
__init__.py Empty files should not contain copyright or license 2014-10-20 00:50:32 +00:00
test__utils.py ``Session.autocommit`` parameter is removed 2022-08-10 17:15:04 +02:00
test_agents_db.py ovs-agent: React to DB down just like to server down 2023-07-25 12:10:14 +02:00
test_agentschedulers_db.py [S-RBAC] Switch to new policies by default 2023-04-21 16:22:42 +02:00
test_allowedaddresspairs_db.py Switch to new engine facade in test_allowedaddresspairs_db module 2020-03-20 02:18:04 +01:00
test_db_base_plugin_common.py Replace to_dict() calls with a function decorator 2015-08-03 11:42:25 +03:00
test_db_base_plugin_v2.py [S-RBAC] Add service role in neutron policy 2023-10-06 07:55:05 +00:00
test_dvr_mac_db.py [S-RBAC] Switch to new policies by default 2023-04-21 16:22:42 +02:00
test_extraroute_db.py Use payloads for ROUTER AFTER_ callbacks 2021-08-09 14:13:28 +00:00
test_ipam_backend_mixin.py [S-RBAC] Switch to new policies by default 2023-04-21 16:22:42 +02:00
test_ipam_pluggable_backend.py [S-RBAC] Switch to new policies by default 2023-04-21 16:22:42 +02:00
test_l3_db.py Prevent internal IP change for floating IP 2023-08-25 11:17:24 +08:00
test_l3_dvr_db.py [OVN] Prevent Trunk creation/deletion with parent port bound 2023-06-30 14:51:27 +00:00
test_l3_extra_gws_db.py Allow Multiple External Gateways 2023-05-24 20:40:59 +03:00
test_l3_hamode_db.py [UT] Reduce the binding retry loop in ``L3HATestFramework`` 2023-08-30 15:13:43 +00:00
test_migration.py [UT] Adjust autogen_process_directives for alembic-1.12.0+ 2023-09-04 08:42:44 +00:00
test_ovn_hash_ring_db.py [OVN] Cleanup old Hash Ring node entries 2023-08-29 12:09:00 +01:00
test_ovn_revision_numbers_db.py [S-RBAC] Switch to new policies by default 2023-04-21 16:22:42 +02:00
test_portsecurity_db.py Remove the dependency on the "mock" package 2020-04-28 18:05:37 -04:00
test_portsecurity_db_common.py Remove the dependency on the "mock" package 2020-04-28 18:05:37 -04:00
test_provisioning_blocks.py Remove the dependency on the "mock" package 2020-04-28 18:05:37 -04:00
test_rbac_db_mixin.py Initialize config in DietTestCase class 2023-07-19 12:58:58 +02:00
test_securitygroups_db.py Remove the publish patch in SG rule BEFORE_DELETE and BEFORE_CREATE 2023-10-09 14:11:43 +00:00
test_segments_db.py Remove the dependency on the "mock" package 2020-04-28 18:05:37 -04:00