use str names rather than classes for orm relationships

In Rocky we are going to start working on decoupling neutron db. This
will be a long effort, so from a vmware-nsx POV we can hopefully pick
away at it as we go.

This patch changes to use of class references to fully qulified class
names when defining ORM relationships. This allows us to remove a few
of the neutron db related imports in vmware-nsx.

Change-Id: I1df4cb3eec59488a5b35fac9f943bbfdbb44df63
changes/87/550187/2
Boden R 5 years ago committed by Adit Sarfaty
parent 02f4ccb6bb
commit dec28f6d2b
  1. 2
      vmware_nsx/db/extended_security_group.py
  2. 3
      vmware_nsx/db/extended_security_group_rule.py
  3. 6
      vmware_nsx/db/nsx_models.py
  4. 10
      vmware_nsx/db/nsxv_models.py

@ -55,7 +55,7 @@ class NsxExtendedSecurityGroupProperties(model_base.BASEV2):
nullable=False)
policy = sa.Column(sa.String(36))
security_group = orm.relationship(
securitygroups_db.SecurityGroup,
'neutron.db.models.securitygroup.SecurityGroup',
backref=orm.backref('ext_properties', lazy='joined',
uselist=False, cascade='delete'))

@ -19,7 +19,6 @@ from sqlalchemy import orm
from neutron.db import _resource_extend as resource_extend
from neutron.db import api as db_api
from neutron.db.models import securitygroup
from neutron.extensions import securitygroup as ext_sg
from neutron_lib.api import validators
from neutron_lib import exceptions as nexception
@ -47,7 +46,7 @@ class NsxExtendedSecurityGroupRuleProperties(model_base.BASEV2):
local_ip_prefix = sa.Column(sa.String(255), nullable=False)
rule = orm.relationship(
securitygroup.SecurityGroupRule,
'neutron.db.models.securitygroup.SecurityGroupRule',
backref=orm.backref('ext_properties', lazy='joined',
uselist=False, cascade='delete'))

@ -261,7 +261,7 @@ class MacLearningState(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the Port model using the backref attribute.
# This will instruct SQLAlchemy to eagerly load this association.
port = orm.relationship(
models_v2.Port,
'neutron.db.models_v2.Port',
backref=orm.backref("mac_learning_state", lazy='joined',
uselist=False, cascade='delete'))
@ -318,7 +318,7 @@ class PortQueueMapping(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the Port model adding a backref which will
# allow SQLAlchemy for eagerly load the queue binding
port = orm.relationship(
models_v2.Port,
'neutron.db.models_v2.Port',
backref=orm.backref("qos_queue", uselist=False,
cascade='delete', lazy='joined'))
@ -334,7 +334,7 @@ class NetworkQueueMapping(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the Network model adding a backref which will
# allow SQLAlcremy for eagerly load the queue binding
network = orm.relationship(
models_v2.Network,
'neutron.db.models_v2.Network',
backref=orm.backref("qos_queue", uselist=False,
cascade='delete', lazy='joined'))

@ -19,8 +19,6 @@ from neutron_lib.db import model_base
import sqlalchemy as sa
from sqlalchemy import orm
from neutron.db.models import l3 as l3_db
from neutron.db import models_v2
from oslo_db.sqlalchemy import models
from vmware_nsx.common import nsxv_constants
@ -164,7 +162,7 @@ class NsxvRouterExtAttributes(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the Router model in order to instruct
# SQLAlchemy to eagerly load this association
router = orm.relationship(
l3_db.Router,
'neutron.db.models.l3.Router',
backref=orm.backref("nsx_attributes", lazy='joined',
uselist=False, cascade='delete'))
@ -218,7 +216,7 @@ class NsxvPortIndexMapping(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the Port model in order to instruct SQLAlchemy to
# eagerly read port vnic-index
port = orm.relationship(
models_v2.Port,
'neutron.db.models_v2.Port',
backref=orm.backref("vnic_index", lazy='joined',
uselist=False, cascade='delete'))
@ -344,7 +342,7 @@ class NsxvSubnetExtAttributes(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the Subnet model in order to instruct
# SQLAlchemy to eagerly load this association
subnet = orm.relationship(
models_v2.Subnet,
'neutron.db.models_v2.Subnet',
backref=orm.backref("nsxv_subnet_attributes", lazy='joined',
uselist=False, cascade='delete'))
@ -363,7 +361,7 @@ class NsxvPortExtAttributes(model_base.BASEV2, models.TimestampMixin):
# Add a relationship to the port model in order to instruct
# SQLAlchemy to eagerly load this association
port = orm.relationship(
models_v2.Port,
'neutron.db.models_v2.Port',
backref=orm.backref("nsx_port_attributes", lazy='joined',
uselist=False, cascade='delete'))

Loading…
Cancel
Save