]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use 'port' instead of 'ports' to reference port from IPAllocation
authorOleg Bondarev <obondarev@mirantis.com>
Fri, 10 Apr 2015 09:03:09 +0000 (12:03 +0300)
committerOleg Bondarev <obondarev@mirantis.com>
Wed, 15 Apr 2015 09:00:26 +0000 (12:00 +0300)
'ports' is just confusing as IPAllocation can be associated
with only one port.

Closes-Bug: #1442527
Change-Id: I36bfa65956f54e4b290bb7568499a47eca7c126f

neutron/db/models_v2.py
neutron/plugins/ml2/plugin.py

index 5067f8ae3304199761c12a0eb5c8dccdb0a299a7..a93676198dbff06cdbaa8db5717d4e702bd57f50 100644 (file)
@@ -132,7 +132,7 @@ class Port(model_base.BASEV2, HasId, HasTenant):
     name = sa.Column(sa.String(attr.NAME_MAX_LEN))
     network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
                            nullable=False)
-    fixed_ips = orm.relationship(IPAllocation, backref='ports', lazy='joined')
+    fixed_ips = orm.relationship(IPAllocation, backref='port', lazy='joined')
     mac_address = sa.Column(sa.String(32), nullable=False)
     admin_state_up = sa.Column(sa.Boolean(), nullable=False)
     status = sa.Column(sa.String(16), nullable=False)
index f3f8b2ab38c651d705e3819f6568fce013e2fe23..6656a88d2907209c10d17c27d7ccbf5fbd5cffd3 100644 (file)
@@ -884,7 +884,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                                          "having IP allocation on subnet "
                                          "%(subnet)s, cannot delete"),
                                      {'ip': user_alloc.ip_address,
-                                      'port_id': user_alloc.ports.id,
+                                      'port_id': user_alloc.port_id,
                                       'subnet': id})
                             raise exc.SubnetInUse(subnet_id=id)
                         else:
@@ -915,7 +915,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                     data = {attributes.PORT:
                             {'fixed_ips': [{'subnet_id': ip.subnet_id,
                                             'ip_address': ip.ip_address}
-                                           for ip in a.ports.fixed_ips
+                                           for ip in a.port.fixed_ips
                                            if ip.subnet_id != id]}}
                     try:
                         self.update_port(context, a.port_id, data)