]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: fix migration for networks without a subnet
authorarmando-migliaccio <armamig@gmail.com>
Tue, 29 Apr 2014 03:24:18 +0000 (20:24 -0700)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 15:06:54 +0000 (23:06 +0800)
In case the network is without a subnet, calling the validation
logic during the report phase leads to an error because the LSN
would have been already allocated during the migration phase.

Bypass the issue by calling the plugin directly, which is what
the validation logic does in the first place.

Closes-bug: #1313997

Change-Id: I14f77ae3b0cc147c4ea1c79e56bdd809de7c76a0
(cherry picked from commit 47e51e7521784f6a2edcfbf71a9aac0237e76e42)

neutron/plugins/vmware/dhcp_meta/migration.py
neutron/tests/unit/vmware/test_dhcpmeta.py

index cda14c5743c865cd534b6651910c19124b31bcd4..992a88346b771255a05dd817c6d4a3fc5a6e8589 100644 (file)
@@ -155,10 +155,11 @@ class MigrationManager(object):
             lsn_id, lsn_port_id = self.manager.lsn_port_get(
                 context, network_id, subnet_id, raise_on_err=False)
         else:
-            subnet = self.validate(context, network_id)
-            if subnet:
+            filters = {'network_id': [network_id]}
+            subnets = self.plugin.get_subnets(context, filters=filters)
+            if subnets:
                 lsn_id, lsn_port_id = self.manager.lsn_port_get(
-                    context, network_id, subnet['id'], raise_on_err=False)
+                    context, network_id, subnets[0]['id'], raise_on_err=False)
             else:
                 lsn_id = self.manager.lsn_get(context, network_id,
                                               raise_on_err=False)
index 66079d75a3b77a554c6daf513697b6cefcda8680..8005da942d78abc07c4c2293672005ee0f0dcf15 100644 (file)
@@ -219,7 +219,7 @@ class MigrationManagerTestCase(base.BaseTestCase):
                            'services': ['foo_lsn_id'], 'type': 'lsn'})
 
     def _test_report_for_lsn_without_subnet(self, validated_subnet):
-        with mock.patch.object(self.manager, 'validate',
+        with mock.patch.object(self.manager.plugin, 'get_subnets',
                                return_value=validated_subnet):
             self.manager.manager.lsn_port_get.return_value = (
                 ('foo_lsn_id', 'foo_lsn_port_id'))
@@ -231,7 +231,7 @@ class MigrationManagerTestCase(base.BaseTestCase):
             self.assertEqual(expected, report)
 
     def test_report_for_lsn_without_subnet_subnet_found(self):
-        self._test_report_for_lsn_without_subnet({'id': self.subnet_id})
+        self._test_report_for_lsn_without_subnet([{'id': self.subnet_id}])
 
     def test_report_for_lsn_without_subnet_subnet_not_found(self):
         self.manager.manager.lsn_get.return_value = 'foo_lsn_id'