Work around DbBasePluginCommon._get_subnet removal

The upstream commit [0] removed the _get_subnet method
from the common DB plugin. However, this method is still
in use by the group-based-policy project. As a workaround,
we re-add this method to our specialization of the core
plugin. This should be replaced at some point by a method
that follows upstream.

[0]: //review.opendev.org/c/openstack/neutron/+/742829.

Change-Id: I64615d499cca206a840a6d70477513132077fd50
This commit is contained in:
sayalinaval 2024-02-29 18:36:38 -08:00 committed by Thomas Bachman
parent efafb2124e
commit 43ed4d4ce1
1 changed files with 14 additions and 0 deletions

View File

@ -35,11 +35,14 @@ from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import constants as n_const
from neutron_lib.db import model_query
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions
from neutron_lib.plugins import directory
from oslo_log import log
from oslo_utils import excutils
from sqlalchemy.orm import exc
from gbpservice.neutron.db import api as db_api
from gbpservice.neutron.db import implicitsubnetpool_db
@ -632,6 +635,17 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
return result
# REVISIT: workaround due to the change in
# https://review.opendev.org/c/openstack/neutron/+/742829.
def _get_subnet(self, context, id):
# TODO(slaweq): remove this method when all will be switched to use OVO
# objects only
try:
subnet = model_query.get_by_id(context, models_v2.Subnet, id)
except exc.NoResultFound:
raise exceptions.SubnetNotFound(subnet_id=id)
return subnet
@db_api.retry_if_session_inactive()
def get_subnets(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None,