diff --git a/vmware_nsx/db/maclearning.py b/vmware_nsx/db/maclearning.py index f44acaaecd..6c4eaab196 100644 --- a/vmware_nsx/db/maclearning.py +++ b/vmware_nsx/db/maclearning.py @@ -16,6 +16,7 @@ from sqlalchemy.orm import exc from neutron.api.v2 import attributes +from neutron.db import _utils as db_utils from neutron.db import db_base_plugin_v2 from oslo_log import log as logging @@ -32,7 +33,7 @@ class MacLearningDbMixin(object): def _make_mac_learning_state_dict(self, port, fields=None): res = {'port_id': port['port_id'], mac.MAC_LEARNING: port[mac.MAC_LEARNING]} - return self._fields(res, fields) + return db_utils.resource_fields(res, fields) def _extend_port_mac_learning_state(self, port_res, port_db): state = port_db.mac_learning_state diff --git a/vmware_nsx/db/networkgw_db.py b/vmware_nsx/db/networkgw_db.py index 7f690bd58d..aadc3cc6fd 100644 --- a/vmware_nsx/db/networkgw_db.py +++ b/vmware_nsx/db/networkgw_db.py @@ -14,6 +14,7 @@ from sqlalchemy.orm import exc as sa_orm_exc +from neutron.db import _utils as db_utils from neutron.plugins.common import utils from neutron_lib import constants from neutron_lib import exceptions @@ -119,7 +120,7 @@ class NetworkGatewayMixin(networkgw.NetworkGatewayPluginBase): if not fields or 'ports' in fields: res['ports'] = [self._make_gw_connection_dict(conn) for conn in network_gateway.network_connections] - return self._fields(res, fields) + return db_utils.resource_fields(res, fields) def _set_mapping_info_defaults(self, mapping_info): if not mapping_info.get('segmentation_type'): @@ -390,7 +391,7 @@ class NetworkGatewayMixin(networkgw.NetworkGatewayPluginBase): if fields: fields.append('nsx_id') res['nsx_id'] = gateway_device['nsx_id'] - return self._fields(res, fields) + return db_utils.resource_fields(res, fields) def _get_gateway_device(self, context, device_id): try: diff --git a/vmware_nsx/db/qos_db.py b/vmware_nsx/db/qos_db.py index ded6483dc7..f40fc6dcaa 100644 --- a/vmware_nsx/db/qos_db.py +++ b/vmware_nsx/db/qos_db.py @@ -16,6 +16,7 @@ from sqlalchemy.orm import exc from neutron.api.v2 import attributes as attr +from neutron.db import _utils as db_utils from neutron.db import db_base_plugin_v2 from neutron.db import models_v2 @@ -147,17 +148,17 @@ class QoSDbMixin(qos.QueuePluginBase): 'max': queue.get('max'), 'qos_marking': queue.get('qos_marking'), 'dscp': queue.get('dscp')} - return self._fields(res, fields) + return db_utils.resource_fields(res, fields) def _make_port_queue_binding_dict(self, queue, fields=None): res = {'port_id': queue['port_id'], 'queue_id': queue['queue_id']} - return self._fields(res, fields) + return db_utils.resource_fields(res, fields) def _make_network_queue_binding_dict(self, queue, fields=None): res = {'network_id': queue['network_id'], 'queue_id': queue['queue_id']} - return self._fields(res, fields) + return db_utils.resource_fields(res, fields) def _check_for_queue_and_create(self, context, port): """Check for queue and create. diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index d6d0b01fde..c3bc20425d 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -19,6 +19,7 @@ from oslo_log import log as logging from oslo_utils import excutils from neutron.api import extensions as neutron_extensions +from neutron.db import _utils as db_utils from neutron.db import agentschedulers_db from neutron.db import allowedaddresspairs_db as addr_pair_db from neutron.db import db_base_plugin_v2 @@ -259,7 +260,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, net_result = self._make_network_dict(network, context=context) self._extend_network_dict_provider(context, net_result) - return self._fields(net_result, fields) + return db_utils.resource_fields(net_result, fields) def get_network(self, context, id, fields=None): return self._dvs_get_network(context, id, fields=None) @@ -276,7 +277,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, for net in networks: self._extend_network_dict_provider(context, net) return (networks if not fields else - [self._fields(network, fields) for network in networks]) + [db_utils.resource_fields(network, + fields) for network in networks]) def update_network(self, context, id, network): net_attrs = network['network'] diff --git a/vmware_nsx/plugins/nsx_mh/plugin.py b/vmware_nsx/plugins/nsx_mh/plugin.py index 209446580e..03ce8f644e 100644 --- a/vmware_nsx/plugins/nsx_mh/plugin.py +++ b/vmware_nsx/plugins/nsx_mh/plugin.py @@ -32,6 +32,7 @@ from neutron.api import extensions as neutron_extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base from neutron import context as q_context +from neutron.db import _utils as db_utils from neutron.db import agentschedulers_db from neutron.db import allowedaddresspairs_db as addr_pair_db from neutron.db import db_base_plugin_v2 @@ -1043,7 +1044,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, net_result = self._make_network_dict(network, context=context) self._extend_network_dict_provider(context, net_result) - return self._fields(net_result, fields) + return db_utils.resource_fields(net_result, fields) def get_networks(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, @@ -1057,7 +1058,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, for net in networks: self._extend_network_dict_provider(context, net) return (networks if not fields else - [self._fields(network, fields) for network in networks]) + [db_utils.resource_fields(network, + fields) for network in networks]) def update_network(self, context, id, network): pnet._raise_if_updates_provider_attributes(network['network']) diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index ed0f54a783..3edb5bb29c 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -39,6 +39,7 @@ from neutron.callbacks import resources from neutron.common import ipv6_utils from neutron.common import rpc as n_rpc from neutron import context as n_context +from neutron.db import _utils as db_utils from neutron.db import agents_db from neutron.db import allowedaddresspairs_db as addr_pair_db from neutron.db.availability_zone import router as router_az_db @@ -1181,7 +1182,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, net_result = self._make_network_dict(network, context=context) self._extend_get_network_dict_provider(context, net_result) - return self._fields(net_result, fields) + return db_utils.resource_fields(net_result, fields) def get_networks(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, @@ -1195,7 +1196,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, for net in networks: self._extend_get_network_dict_provider(context, net) return (networks if not fields else - [self._fields(network, fields) for network in networks]) + [db_utils.resource_fields(network, + fields) for network in networks]) def update_network(self, context, id, network): net_attrs = network['network'] @@ -1238,8 +1240,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, net_attrs[psec.PORTSECURITY]) except Exception: with excutils.save_and_reraise_exception(): - revert_update = self._fields(original_network, - ['shared', psec.PORTSECURITY]) + revert_update = db_utils.resource_fields( + original_network, ['shared', psec.PORTSECURITY]) self._process_network_port_security_update( context, revert_update, net_res) super(NsxVPluginV2, self).update_network( diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 49a7cc9842..0737f20fa3 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -29,6 +29,7 @@ from neutron.callbacks import resources from neutron.common import rpc as n_rpc from neutron.common import topics from neutron import context as q_context +from neutron.db import _utils as db_utils from neutron.db import agents_db from neutron.db import agentschedulers_db from neutron.db import allowedaddresspairs_db as addr_pair_db @@ -1280,7 +1281,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, # provider networks fields net = self._make_network_dict(network, context=context) self._extend_get_network_dict_provider(context, net) - return self._fields(net, fields) + return db_utils.resource_fields(net, fields) def get_networks(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, @@ -1296,7 +1297,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, for net in networks: self._extend_get_network_dict_provider(context, net) return (networks if not fields else - [self._fields(network, fields) for network in networks]) + [db_utils.resource_fields(network, + fields) for network in networks]) def _get_data_from_binding_profile(self, context, port): if (pbin.PROFILE not in port or @@ -2229,7 +2231,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, port = super(NsxV3Plugin, self).get_port(context, id, fields=None) self._extend_get_port_dict_binding(context, port) - return self._fields(port, fields) + return db_utils.resource_fields(port, fields) def get_ports(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, @@ -2244,7 +2246,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, for port in ports: self._extend_get_port_dict_binding(context, port) return (ports if not fields else - [self._fields(port, fields) for port in ports]) + [db_utils.resource_fields(port, fields) for port in ports]) def _extract_external_gw(self, context, router, is_extract=True): r = router['router']