d3cad92586
Eliminate the disable_transaction_guard decorator. ML2Plus REST API method wrappers that were only needed to disable transaction guards on inherited ML2 methods are removed, and the disable_transaction_guard decorator on each of the remaining ML2Plus REST API methods is replaced with the transaction_guard decorator. Calls by the AIM MD to get_bound_port_context, which should not be called from within transactions, are replaced with a new _make_port_context method that does not attempt to bind unbound ports, and this new method is also used in place of the monkey-patched get_locked_port_and_binding that has been eliminated in Neutron. Calls by the AIM MD to Neutron APIs to create or delete ports for SNAT and SVI IP address allocation are moved outside of transactions. The top-level transactions have been removed from the AIM L3 plugin's create_router, update_router, delete_router, add_router_interface and remove_router_interface API methods, and transaction_guard decorators have been added to them. These plugin methods no longer directly call AIM MD methods to perform these operations. Methods in the MD now receive CREATE_PRECOMMIT, UPDATE_PRECOMMIT, and DELETE_PRECOMMIT notifications for ROUTER resources, which are called within transactions. Router gateway and interface management for AIM is now done from the MD's port_create_precommit, port_update_precommit, and port_delete_precommit methods, when handling API calls made by the L3 DB layer on router gateway and interface ports. This approach keeps the AIM routing state transactionally consistent with the router interface port state, whose fixed_ips determine which subnets are attached as router interfaces. The top-level transactions have also been removed from the AIM L3 plugin's create_floatingip, update_floatingip and delete_floatingip methods, and the disable_transaction_guard decorators have been replaced with transaction_guard decorators. The only remaining cases were Neutron REST APIs are called within transactions are when the validation tool cleans up legacy resources. Transaction guards are disabled locally for these calls via a contextmanager setting the GUARD_TRANSACTION attribute on the plugin context used to make the calls to False. A future patch that adds validation that GBP resources map to the correct Neutron resources may revisit the tool's use of transactions and eliminate the need to locally disable transaction guards. A monkey-patch that turned off enforcement of session semantics in Neutron is updated to enforce the semantics unless the transaction guard is locally disabled. A follow-on patch will eliminate the queing of in-process callbacks until a transaction commits, which should no longer be necessary now that Neutron REST API methods are not called within transactions. Another follow-on patch will move the sending of AMQP notifications from AIM MD precommit methods to postcommit methods, eliminating the need to queue these until after transactions have been committed. Change-Id: I5c2b9e4118d6353d53f05f1f4ac7297046a20b69
23 lines
780 B
Python
23 lines
780 B
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
GBP_PLURALS = {}
|
|
|
|
|
|
def register_plurals(plural_mappings):
|
|
for plural, single in plural_mappings.items():
|
|
GBP_PLURALS[single] = plural
|
|
|
|
|
|
def get_plural(single):
|
|
return GBP_PLURALS.get(single)
|