Fix expected_attrs kwarg in server_external_events
The Instance.get_by_uuid method takes an expected_attrs kwarg which needs to be a list or tuple, not just any old iterable like a string. Because of how the underlying Instance object code massages this value, it's not a hard failure but does mean you don't join the columns you expect when getting the instance. This makes it a list and makes sure the stub in the unit tests is checking for valid values. Change-Id: I3ad85f9062b5cb19962d9e6a7af52440166def45 Closes-Bug: #1645479
This commit is contained in:
parent
6195408224
commit
cbcff11b6a
|
@ -69,7 +69,7 @@ class ServerExternalEventsController(wsgi.Controller):
|
|||
# because we need it later on
|
||||
instance = objects.Instance.get_by_uuid(
|
||||
context, event.instance_uuid,
|
||||
expected_attrs='migration_context')
|
||||
expected_attrs=['migration_context'])
|
||||
instances[event.instance_uuid] = instance
|
||||
except exception.InstanceNotFound:
|
||||
LOG.debug('Dropping event %(name)s:%(tag)s for unknown '
|
||||
|
|
|
@ -19,6 +19,7 @@ from nova.api.openstack.compute import server_external_events \
|
|||
as server_external_events_v21
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
|
||||
|
@ -38,6 +39,12 @@ MISSING_UUID = '00000000-0000-0000-0000-000000000005'
|
|||
|
||||
@classmethod
|
||||
def fake_get_by_uuid(cls, context, uuid, **kwargs):
|
||||
if 'expected_attrs' in kwargs:
|
||||
expected_attrs_set = set(kwargs['expected_attrs'])
|
||||
full_expected_attrs_set = set(instance_obj.INSTANCE_OPTIONAL_ATTRS)
|
||||
assert expected_attrs_set.issubset(full_expected_attrs_set), \
|
||||
('%s is not a subset of %s' % (expected_attrs_set,
|
||||
full_expected_attrs_set))
|
||||
try:
|
||||
return fake_instances[uuid]
|
||||
except KeyError:
|
||||
|
|
Loading…
Reference in New Issue