Merge "Macvtap: Check for no original port in is_live_migration" into stable/newton

This commit is contained in:
Jenkins 2017-06-15 04:39:06 +00:00 committed by Gerrit Code Review
commit 76d95b8b9c
3 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -59,7 +59,7 @@ class FakePortContext(api.PortContext):
@property
def original(self):
return self._original or {}
return self._original
@property
def status(self):

View File

@ -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,