Browse Source

stop using common db mixin methods

All of the methods of common db mixin are available via neutron-lib
and the mixin will be removed before long.
This patch switches the code over to use neutron-lib's APIs rather
than those of the mixin.

Change-Id: Id4c5403f45c8b8f63b74c358200a4c82e0b88520
changes/15/635515/2
Boden R 2 years ago
parent
commit
76a2fd2058
  1. 10
      tricircle/network/central_plugin.py
  2. 4
      tricircle/network/central_trunk_driver.py
  3. 4
      tricircle/network/central_trunk_plugin.py
  4. 17
      tricircle/network/local_plugin.py

10
tricircle/network/central_plugin.py

@ -60,6 +60,7 @@ import neutron_lib.callbacks.resources as attributes
from neutron_lib import constants
from neutron_lib.db import api as lib_db_api
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions
from neutron_lib.exceptions import availability_zone as az_exc
from neutron_lib.plugins import directory
@ -1285,8 +1286,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
id_filters = filters.pop('id')
ports = self._get_ports(context, filters, None, sorts, limit,
marker, page_reverse)
ports = [super(TricirclePlugin,
self)._fields(
ports = [db_utils.resource_fields(
p, fields) for p in ports if p['id'] in id_filters]
for port in ports:
port['qos_policy_id'] = \
@ -1370,8 +1370,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
# _get_ports_from_pod_with_number already traverses all the pods
# to try to get ports equal to limit, so pod is transparent for
# controller.
return [super(TricirclePlugin,
self)._fields(p, fields) for p in res['ports']]
return [db_utils.resource_fields(p, fields) for p in res['ports']]
else:
ret = []
pods = db_api.list_pods(t_ctx)
@ -1405,8 +1404,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
ret = self._map_ports_from_bottom_to_top(ret, bottom_top_map)
ret.extend(self._get_ports_from_top(context, top_bottom_map,
filters))
return [super(TricirclePlugin,
self)._fields(p, fields) for p in ret]
return [db_utils.resource_fields(p, fields) for p in ret]
def create_router(self, context, router):
with context.session.begin(subtransactions=True):

4
tricircle/network/central_trunk_driver.py

@ -18,6 +18,7 @@ from oslo_log import log
from neutron.services.trunk import exceptions as trunk_exc
from neutron.services.trunk import plugin as trunk_plugin
from neutron_lib.db import utils as db_utils
import six
import tricircle.common.client as t_client
@ -276,8 +277,7 @@ class TricircleTrunkDriver(trunk_plugin.TrunkPlugin):
top_bottom_map, filters)
ret.extend(top_trunks)
return [super(TricircleTrunkDriver, self)._fields(trunk, fields)
for trunk in ret]
return [db_utils.resource_fields(trunk, fields) for trunk in ret]
def get_trunk_subports(self, context, filters=None):
ret = None

4
tricircle/network/central_trunk_plugin.py

@ -20,6 +20,7 @@ from oslo_log import log
from neutron.services.trunk import exceptions as trunk_exc
from neutron.services.trunk import plugin
from neutron_lib.db import utils as db_utils
from neutron_lib.plugins import directory
import tricircle.common.client as t_client
@ -269,8 +270,7 @@ class TricircleTrunkPlugin(plugin.TrunkPlugin):
top_bottom_map, filters)
ret.extend(top_trunks)
return [super(TricircleTrunkPlugin, self)._fields(trunk, fields)
for trunk in ret]
return [db_utils.resource_fields(trunk, fields) for trunk in ret]
def get_trunk_subports(self, context, filters=None):
ret = None

17
tricircle/network/local_plugin.py

@ -25,6 +25,7 @@ from neutron_lib.api import extensions
from neutron_lib.api import validators
from neutron_lib.callbacks import events
import neutron_lib.constants as q_constants
from neutron_lib.db import utils as db_utils
import neutron_lib.exceptions as q_exceptions
from neutron_lib.plugins import directory
from neutron_lib.plugins.ml2 import api
@ -306,7 +307,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
subnet_ids = self._ensure_subnet(context, t_network)
if subnet_ids:
b_network['subnets'] = subnet_ids
return self._fields(b_network, fields)
return db_utils.resource_fields(b_network, fields)
def get_networks(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False):
@ -325,7 +326,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
subnet_ids = self._ensure_subnet(context, b_network, False)
if subnet_ids:
b_network['subnets'] = subnet_ids
b_networks.append(self._fields(b_network, fields))
b_networks.append(db_utils.resource_fields(b_network, fields))
if len(b_networks) == len(filters['id']):
return b_networks
@ -366,7 +367,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
subnet_ids = self._ensure_subnet(context, network)
if subnet_ids:
b_network['subnets'] = subnet_ids
b_networks.append(self._fields(b_network, fields))
b_networks.append(db_utils.resource_fields(b_network, fields))
return b_networks
def create_subnet(self, context, subnet):
@ -424,7 +425,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
b_subnet = self._create_bottom_subnet(t_ctx, context, t_subnet)
if b_subnet['enable_dhcp']:
self._ensure_subnet_dhcp_port(t_ctx, context, b_subnet)
return self._fields(b_subnet, fields)
return db_utils.resource_fields(b_subnet, fields)
def get_subnets(self, context, filters=None, fields=None, sorts=None,
limit=None, marker=None, page_reverse=False):
@ -443,7 +444,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
for b_subnet in b_full_subnets:
if b_subnet['enable_dhcp']:
self._ensure_subnet_dhcp_port(t_ctx, context, b_subnet)
b_subnets.append(self._fields(b_subnet, fields))
b_subnets.append(db_utils.resource_fields(b_subnet, fields))
if len(b_subnets) == len(filters['id']):
return b_subnets
@ -467,7 +468,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
b_subnet = self._create_bottom_subnet(t_ctx, context, subnet)
if b_subnet['enable_dhcp']:
self._ensure_subnet_dhcp_port(t_ctx, context, b_subnet)
b_subnets.append(self._fields(b_subnet, fields))
b_subnets.append(db_utils.resource_fields(b_subnet, fields))
return b_subnets
def delete_subnet(self, context, _id):
@ -830,7 +831,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
b_port = self.core_plugin.create_port(context, {'port': t_port})
self._ensure_trunk(context, t_ctx, _id)
return self._fields(b_port, fields)
return db_utils.resource_fields(b_port, fields)
def get_ports(self, context, filters=None, fields=None, sorts=None,
limit=None, marker=None, page_reverse=False):
@ -873,7 +874,7 @@ class TricirclePlugin(plugin.Ml2Plugin):
port.pop('qos_policy_id', None)
b_port = self.core_plugin.create_port(context,
{'port': port})
b_ports.append(self._fields(b_port, fields))
b_ports.append(db_utils.resource_fields(b_port, fields))
return b_ports
def delete_port(self, context, _id, l3_port_check=True):

Loading…
Cancel
Save