diff --git a/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py b/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py index 0d54090e5fb..f578e8bf9e1 100644 --- a/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py +++ b/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py @@ -64,6 +64,9 @@ class MacvtapMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): # The only safe way to detect a migration is to look into the binding # profiles 'migrating_to' attribute, which is set by Nova since patch # https://review.openstack.org/#/c/275073/. + if not context.original: + # new port + return False port_profile = context.original.get(portbindings.PROFILE) if port_profile and port_profile.get('migrating_to', None): LOG.debug("Live migration with profile %s detected.", port_profile) diff --git a/neutron/tests/unit/plugins/ml2/_test_mech_agent.py b/neutron/tests/unit/plugins/ml2/_test_mech_agent.py index 3e4efdc49bd..addfb67f950 100644 --- a/neutron/tests/unit/plugins/ml2/_test_mech_agent.py +++ b/neutron/tests/unit/plugins/ml2/_test_mech_agent.py @@ -59,7 +59,7 @@ class FakePortContext(api.PortContext): @property def original(self): - return self._original or {} + return self._original @property def status(self): diff --git a/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py b/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py index 5d145a1b9d1..0c5c30cddfc 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py +++ b/neutron/tests/unit/plugins/ml2/drivers/macvtap/mech_driver/test_mech_macvtap.py @@ -71,6 +71,9 @@ class MacvtapMechanismMigrationTestCase(object): def test__is_live_migration_false(self): self._test__is_live_migration(False, {}) + def test__is_live_migration_false_None_original(self): + self._test__is_live_migration(False, None) + def _test__is_live_migration(self, expected, original): context = base.FakePortContext(self.AGENT_TYPE, self.AGENTS,