NSX: remove depracted DB warnings

A lot of DB models are being moved around in Neutron. This
addresses the current set of warnings.

Change-Id: I7ffc99e9d62e4ac4d739f711b14b97501140ccdf
This commit is contained in:
Gary Kotton 2016-10-20 07:29:40 -07:00
parent 2065418288
commit 09569a07d1
5 changed files with 31 additions and 26 deletions

View File

@ -25,8 +25,8 @@ from oslo_utils import timeutils
import six
from neutron import context
from neutron.db import external_net_db
from neutron.db import l3_db
from neutron.db.models import external_net as external_net_db
from neutron.db.models import l3 as l3_db
from neutron.db import models_v2
from neutron.extensions import l3

View File

@ -42,6 +42,7 @@ from neutron.db import extraroute_db
from neutron.db import l3_db
from neutron.db import l3_dvr_db
from neutron.db import l3_gwmode_db
from neutron.db.models import l3 as l3_db_models
from neutron.db.models import securitygroup as securitygroup_model # noqa
from neutron.db import models_v2
from neutron.db import portbindings_db
@ -143,8 +144,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
subnetpool=models_v2.SubnetPool,
security_group=securitygroup_model.SecurityGroup,
security_group_rule=securitygroup_model.SecurityGroupRule,
router=l3_db.Router,
floatingip=l3_db.FloatingIP)
router=l3_db_models.Router,
floatingip=l3_db_models.FloatingIP)
def __init__(self):
LOG.warning(_LW("The NSX-MH plugin is deprecated and may be removed "
"in the O or the P cycle"))
@ -1475,11 +1476,12 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Transaction nesting is needed to avoid foreign key violations
# when processing the distributed router binding
with context.session.begin(subtransactions=True):
router_db = l3_db.Router(id=neutron_router_id,
tenant_id=tenant_id,
name=r['name'],
admin_state_up=r['admin_state_up'],
status=lrouter['status'])
router_db = l3_db_models.Router(
id=neutron_router_id,
tenant_id=tenant_id,
name=r['name'],
admin_state_up=r['admin_state_up'],
status=lrouter['status'])
context.session.add(router_db)
self._process_extra_attr_router_create(context, router_db, r)
# Ensure neutron router is moved into the transaction's buffer
@ -1991,7 +1993,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def disassociate_floatingips(self, context, port_id):
try:
fip_qry = context.session.query(l3_db.FloatingIP)
fip_qry = context.session.query(l3_db_models.FloatingIP)
fip_dbs = fip_qry.filter_by(fixed_port_id=port_id)
for fip_db in fip_dbs:

View File

@ -16,6 +16,7 @@ import netaddr
from oslo_config import cfg
from neutron.db import l3_db
from neutron.db.models import l3 as l3_db_models
from neutron.db import models_v2
from neutron_lib.api import validators
from neutron_lib import constants
@ -117,7 +118,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
context, router_id)
def _get_router_next_hop(self, context, router_id):
router_qry = context.session.query(l3_db.Router)
router_qry = context.session.query(l3_db_models.Router)
router_db = router_qry.filter_by(id=router_id).one()
return self.plugin._get_external_attachment_info(
context, router_db)[2]
@ -206,7 +207,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
vnics_by_router = self._get_all_routers_vnic_indices(
context, router_ids)
for router_id in router_ids:
router_qry = context.session.query(l3_db.Router)
router_qry = context.session.query(l3_db_models.Router)
router = router_qry.filter_by(id=router_id).one()
if router.gw_port:
snat, dnat = self.plugin._get_nat_rules(context, router)
@ -246,7 +247,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
else:
ext_net_id = ext_net_ids[0]
for router_id in router_ids:
router_qry = context.session.query(l3_db.Router)
router_qry = context.session.query(l3_db_models.Router)
router = router_qry.filter_by(id=router_id).one()
addr, mask, nexthop = self.plugin._get_external_attachment_info(
context, router)
@ -275,7 +276,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
allow_external=True):
fake_fw_rules = []
for router_id in router_ids:
router_qry = context.session.query(l3_db.Router)
router_qry = context.session.query(l3_db_models.Router)
router = router_qry.filter_by(id=router_id).one()
subnet_cidrs = self.plugin._find_router_subnets_cidrs(
context, router['id'])
@ -344,7 +345,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
def _get_ext_net_ids(self, context, router_ids):
ext_net_ids = []
for router_id in router_ids:
router_qry = context.session.query(l3_db.Router)
router_qry = context.session.query(l3_db_models.Router)
router_db = router_qry.filter_by(id=router_id).one()
ext_net_id = router_db.gw_port_id and router_db.gw_port.network_id
if ext_net_id and ext_net_id not in ext_net_ids:
@ -353,7 +354,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
def _get_shared_routers(self, context):
shared_routers = []
routers_qry = context.session.query(l3_db.Router).all()
routers_qry = context.session.query(l3_db_models.Router).all()
for r in routers_qry:
nsx_attr = (context.session.query(
nsxv_models.NsxvRouterExtAttributes).filter_by(
@ -535,7 +536,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
"""
ext_net_id = self._get_external_network_id_by_router(context,
router_id)
routers = context.session.query(l3_db.Router).all()
routers = context.session.query(l3_db_models.Router).all()
optional_router_ids = []
conflict_router_ids = []

View File

@ -48,6 +48,7 @@ from neutron.db import external_net_db
from neutron.db import extraroute_db
from neutron.db import l3_db
from neutron.db import l3_gwmode_db
from neutron.db.models import l3 as l3_db_models
from neutron.db.models import securitygroup as securitygroup_model # noqa
from neutron.db import models_v2
from neutron.db import portbindings_db
@ -175,8 +176,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
subnetpool=models_v2.SubnetPool,
security_group=securitygroup_model.SecurityGroup,
security_group_rule=securitygroup_model.SecurityGroupRule,
router=l3_db.Router,
floatingip=l3_db.FloatingIP)
router=l3_db_models.Router,
floatingip=l3_db_models.FloatingIP)
def __init__(self):
super(NsxVPluginV2, self).__init__()
self.init_is_complete = False
@ -308,7 +309,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
return container_id
def _find_router_driver(self, context, router_id):
router_qry = context.session.query(l3_db.Router)
router_qry = context.session.query(l3_db_models.Router)
router_db = router_qry.filter_by(id=router_id).one()
return self._get_router_driver(context, router_db)
@ -2694,7 +2695,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
return cidrs
def _get_nat_rules(self, context, router):
fip_qry = context.session.query(l3_db.FloatingIP)
fip_qry = context.session.query(l3_db_models.FloatingIP)
fip_db = fip_qry.filter_by(router_id=router['id']).all()
snat = []
@ -2809,7 +2810,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context, router_id, interface_info)
def _get_floatingips_by_router(self, context, router_id):
fip_qry = context.session.query(l3_db.FloatingIP)
fip_qry = context.session.query(l3_db_models.FloatingIP)
fip_db = fip_qry.filter_by(router_id=router_id).all()
return [fip.floating_ip_address
for fip in fip_db if fip.fixed_port_id]
@ -2887,7 +2888,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def disassociate_floatingips(self, context, port_id):
router_id = None
try:
fip_qry = context.session.query(l3_db.FloatingIP)
fip_qry = context.session.query(l3_db_models.FloatingIP)
fip_db = fip_qry.filter_by(fixed_port_id=port_id)
for fip in fip_db:
if fip.router_id:

View File

@ -40,6 +40,7 @@ from neutron.db import extradhcpopt_db
from neutron.db import extraroute_db
from neutron.db import l3_db
from neutron.db import l3_gwmode_db
from neutron.db.models import l3 as l3_db_models
from neutron.db.models import securitygroup as securitygroup_model # noqa
from neutron.db import models_v2
from neutron.db import portbindings_db
@ -159,8 +160,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
subnetpool=models_v2.SubnetPool,
security_group=securitygroup_model.SecurityGroup,
security_group_rule=securitygroup_model.SecurityGroupRule,
router=l3_db.Router,
floatingip=l3_db.FloatingIP)
router=l3_db_models.Router,
floatingip=l3_db_models.FloatingIP)
def __init__(self):
super(NsxV3Plugin, self).__init__()
LOG.info(_LI("Starting NsxV3Plugin"))
@ -2837,7 +2838,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
return new_fip
def disassociate_floatingips(self, context, port_id):
fip_qry = context.session.query(l3_db.FloatingIP)
fip_qry = context.session.query(l3_db_models.FloatingIP)
fip_dbs = fip_qry.filter_by(fixed_port_id=port_id)
for fip_db in fip_dbs: