Merge "Add image_name to create and rebuild notifications"
This commit is contained in:
commit
9468508efe
@ -470,9 +470,11 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
instance = self.db.instance_get_by_uuid(context, instance_uuid)
|
instance = self.db.instance_get_by_uuid(context, instance_uuid)
|
||||||
self._check_instance_not_already_created(context, instance)
|
self._check_instance_not_already_created(context, instance)
|
||||||
image_meta = self._check_image_size(context, instance)
|
image_meta = self._check_image_size(context, instance)
|
||||||
|
extra_usage_info = {"image_name": image_meta['name']}
|
||||||
self._start_building(context, instance)
|
self._start_building(context, instance)
|
||||||
self._notify_about_instance_usage(
|
self._notify_about_instance_usage(
|
||||||
context, instance, "create.start")
|
context, instance, "create.start",
|
||||||
|
extra_usage_info=extra_usage_info)
|
||||||
network_info = self._allocate_network(context, instance,
|
network_info = self._allocate_network(context, instance,
|
||||||
requested_networks)
|
requested_networks)
|
||||||
try:
|
try:
|
||||||
@ -494,8 +496,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
self._update_access_ip(context, instance, network_info)
|
self._update_access_ip(context, instance, network_info)
|
||||||
|
|
||||||
self._notify_about_instance_usage(context, instance,
|
self._notify_about_instance_usage(context, instance,
|
||||||
"create.end", network_info=network_info)
|
"create.end", network_info=network_info,
|
||||||
|
extra_usage_info=extra_usage_info)
|
||||||
except exception.InstanceNotFound:
|
except exception.InstanceNotFound:
|
||||||
LOG.warn(_("Instance not found."), instance_uuid=instance_uuid)
|
LOG.warn(_("Instance not found."), instance_uuid=instance_uuid)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -966,6 +968,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
|
|
||||||
instance = self.db.instance_get_by_uuid(context, instance_uuid)
|
instance = self.db.instance_get_by_uuid(context, instance_uuid)
|
||||||
|
|
||||||
|
image_meta = _get_image_meta(context, image_ref)
|
||||||
|
|
||||||
# This instance.exists message should contain the original
|
# This instance.exists message should contain the original
|
||||||
# image_ref, not the new one. Since the DB has been updated
|
# image_ref, not the new one. Since the DB has been updated
|
||||||
# to point to the new one... we have to override it.
|
# to point to the new one... we have to override it.
|
||||||
@ -975,8 +979,9 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
current_period=True, extra_usage_info=extra_usage_info)
|
current_period=True, extra_usage_info=extra_usage_info)
|
||||||
|
|
||||||
# This message should contain the new image_ref
|
# This message should contain the new image_ref
|
||||||
|
extra_usage_info = {'image_name': image_meta['name']}
|
||||||
self._notify_about_instance_usage(context, instance,
|
self._notify_about_instance_usage(context, instance,
|
||||||
"rebuild.start")
|
"rebuild.start", extra_usage_info=extra_usage_info)
|
||||||
|
|
||||||
current_power_state = self._get_power_state(context, instance)
|
current_power_state = self._get_power_state(context, instance)
|
||||||
self._instance_update(context,
|
self._instance_update(context,
|
||||||
@ -1005,8 +1010,6 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
instance.admin_pass = kwargs.get('new_pass',
|
instance.admin_pass = kwargs.get('new_pass',
|
||||||
utils.generate_password(FLAGS.password_length))
|
utils.generate_password(FLAGS.password_length))
|
||||||
|
|
||||||
image_meta = _get_image_meta(context, image_ref)
|
|
||||||
|
|
||||||
self.driver.spawn(context, instance, image_meta,
|
self.driver.spawn(context, instance, image_meta,
|
||||||
self._legacy_nw_info(network_info), device_info)
|
self._legacy_nw_info(network_info), device_info)
|
||||||
|
|
||||||
@ -1019,7 +1022,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
launched_at=timeutils.utcnow())
|
launched_at=timeutils.utcnow())
|
||||||
|
|
||||||
self._notify_about_instance_usage(context, instance, "rebuild.end",
|
self._notify_about_instance_usage(context, instance, "rebuild.end",
|
||||||
network_info=network_info)
|
network_info=network_info,
|
||||||
|
extra_usage_info=extra_usage_info)
|
||||||
|
|
||||||
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
|
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
|
||||||
@checks_instance_lock
|
@checks_instance_lock
|
||||||
|
@ -86,6 +86,7 @@ class CinderCloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show(meh, context, id):
|
def fake_show(meh, context, id):
|
||||||
return {'id': id,
|
return {'id': id,
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -518,6 +519,7 @@ class CinderCloudTestCase(test.TestCase):
|
|||||||
{'device_name': '/dev/sdc4', 'no_device': True}]
|
{'device_name': '/dev/sdc4', 'no_device': True}]
|
||||||
image1 = {
|
image1 = {
|
||||||
'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'type': 'machine',
|
'type': 'machine',
|
||||||
@ -532,6 +534,7 @@ class CinderCloudTestCase(test.TestCase):
|
|||||||
'snapshot_id': 01234567}]
|
'snapshot_id': 01234567}]
|
||||||
image2 = {
|
image2 = {
|
||||||
'id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
'id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
'kernel_id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
||||||
'type': 'machine',
|
'type': 'machine',
|
||||||
|
@ -97,6 +97,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show(meh, context, id):
|
def fake_show(meh, context, id):
|
||||||
return {'id': id,
|
return {'id': id,
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -1124,6 +1125,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_detail(meh, context, **kwargs):
|
def fake_detail(meh, context, **kwargs):
|
||||||
return [{'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return [{'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -1191,6 +1193,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
{'device_name': '/dev/sdc4', 'no_device': True}]
|
{'device_name': '/dev/sdc4', 'no_device': True}]
|
||||||
image1 = {
|
image1 = {
|
||||||
'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'type': 'machine',
|
'type': 'machine',
|
||||||
@ -1205,6 +1208,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
'snapshot_id': 01234567}]
|
'snapshot_id': 01234567}]
|
||||||
image2 = {
|
image2 = {
|
||||||
'id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
'id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
'kernel_id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
|
||||||
'type': 'machine',
|
'type': 'machine',
|
||||||
@ -1314,6 +1318,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show(meh, context, id):
|
def fake_show(meh, context, id):
|
||||||
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -1363,6 +1368,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
fake_metadata = {
|
fake_metadata = {
|
||||||
'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -1403,6 +1409,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
# NOTE(vish): We are mocking s3 so make sure we have converted
|
# NOTE(vish): We are mocking s3 so make sure we have converted
|
||||||
# to ids instead of uuids.
|
# to ids instead of uuids.
|
||||||
return {'id': 1,
|
return {'id': 1,
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 1,
|
'kernel_id': 1,
|
||||||
@ -1635,6 +1642,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show(self, context, id):
|
def fake_show(self, context, id):
|
||||||
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'type': 'machine'},
|
'type': 'machine'},
|
||||||
@ -1668,6 +1676,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show(self, context, id):
|
def fake_show(self, context, id):
|
||||||
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'type': 'machine'},
|
'type': 'machine'},
|
||||||
@ -1701,6 +1710,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show_no_state(self, context, id):
|
def fake_show_no_state(self, context, id):
|
||||||
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -1719,6 +1729,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show_decrypt(self, context, id):
|
def fake_show_decrypt(self, context, id):
|
||||||
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -1738,6 +1749,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show_stat_active(self, context, id):
|
def fake_show_stat_active(self, context, id):
|
||||||
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
return {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
|
'name': 'fake_name',
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'properties': {
|
'properties': {
|
||||||
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
@ -2483,6 +2495,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'id': id_,
|
'id': id_,
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': prop_base,
|
'properties': prop_base,
|
||||||
'container_format': 'ami',
|
'container_format': 'ami',
|
||||||
'status': 'active'}
|
'status': 'active'}
|
||||||
|
@ -126,6 +126,7 @@ class BaseTestCase(test.TestCase):
|
|||||||
|
|
||||||
def fake_show(meh, context, id):
|
def fake_show(meh, context, id):
|
||||||
return {'id': id, 'min_disk': None, 'min_ram': None,
|
return {'id': id, 'min_disk': None, 'min_ram': None,
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {'kernel_id': 'fake_kernel_id',
|
'properties': {'kernel_id': 'fake_kernel_id',
|
||||||
'ramdisk_id': 'fake_ramdisk_id',
|
'ramdisk_id': 'fake_ramdisk_id',
|
||||||
'something_else': 'meow'}}
|
'something_else': 'meow'}}
|
||||||
@ -883,12 +884,14 @@ class ComputeTestCase(BaseTestCase):
|
|||||||
inst_ref = db.instance_get_by_uuid(self.context, instance_uuid)
|
inst_ref = db.instance_get_by_uuid(self.context, instance_uuid)
|
||||||
msg = test_notifier.NOTIFICATIONS[0]
|
msg = test_notifier.NOTIFICATIONS[0]
|
||||||
self.assertEquals(msg['event_type'], 'compute.instance.create.start')
|
self.assertEquals(msg['event_type'], 'compute.instance.create.start')
|
||||||
|
self.assertEquals(msg['payload']['image_name'], 'fake_name')
|
||||||
# The last event is the one with the sugar in it.
|
# The last event is the one with the sugar in it.
|
||||||
msg = test_notifier.NOTIFICATIONS[1]
|
msg = test_notifier.NOTIFICATIONS[1]
|
||||||
self.assertEquals(msg['priority'], 'INFO')
|
self.assertEquals(msg['priority'], 'INFO')
|
||||||
self.assertEquals(msg['event_type'], 'compute.instance.create.end')
|
self.assertEquals(msg['event_type'], 'compute.instance.create.end')
|
||||||
payload = msg['payload']
|
payload = msg['payload']
|
||||||
self.assertEquals(payload['tenant_id'], self.project_id)
|
self.assertEquals(payload['tenant_id'], self.project_id)
|
||||||
|
self.assertEquals(payload['image_name'], 'fake_name')
|
||||||
self.assertEquals(payload['user_id'], self.user_id)
|
self.assertEquals(payload['user_id'], self.user_id)
|
||||||
self.assertEquals(payload['instance_id'], inst_ref.uuid)
|
self.assertEquals(payload['instance_id'], inst_ref.uuid)
|
||||||
self.assertEquals(payload['instance_type'], 'm1.tiny')
|
self.assertEquals(payload['instance_type'], 'm1.tiny')
|
||||||
@ -1125,11 +1128,13 @@ class ComputeTestCase(BaseTestCase):
|
|||||||
self.assertEquals(msg['event_type'],
|
self.assertEquals(msg['event_type'],
|
||||||
'compute.instance.rebuild.start')
|
'compute.instance.rebuild.start')
|
||||||
self.assertEquals(msg['payload']['image_ref_url'], new_image_ref_url)
|
self.assertEquals(msg['payload']['image_ref_url'], new_image_ref_url)
|
||||||
|
self.assertEquals(msg['payload']['image_name'], 'fake_name')
|
||||||
msg = test_notifier.NOTIFICATIONS[2]
|
msg = test_notifier.NOTIFICATIONS[2]
|
||||||
self.assertEquals(msg['event_type'],
|
self.assertEquals(msg['event_type'],
|
||||||
'compute.instance.rebuild.end')
|
'compute.instance.rebuild.end')
|
||||||
self.assertEquals(msg['priority'], 'INFO')
|
self.assertEquals(msg['priority'], 'INFO')
|
||||||
payload = msg['payload']
|
payload = msg['payload']
|
||||||
|
self.assertEquals(payload['image_name'], 'fake_name')
|
||||||
self.assertEquals(payload['tenant_id'], self.project_id)
|
self.assertEquals(payload['tenant_id'], self.project_id)
|
||||||
self.assertEquals(payload['user_id'], self.user_id)
|
self.assertEquals(payload['user_id'], self.user_id)
|
||||||
self.assertEquals(payload['instance_id'], inst_ref['uuid'])
|
self.assertEquals(payload['instance_id'], inst_ref['uuid'])
|
||||||
@ -2126,6 +2131,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
security_group_api=self.security_group_api)
|
security_group_api=self.security_group_api)
|
||||||
self.fake_image = {
|
self.fake_image = {
|
||||||
'id': 1,
|
'id': 1,
|
||||||
|
'name': 'fake_name',
|
||||||
'properties': {'kernel_id': 'fake_kernel_id',
|
'properties': {'kernel_id': 'fake_kernel_id',
|
||||||
'ramdisk_id': 'fake_ramdisk_id'},
|
'ramdisk_id': 'fake_ramdisk_id'},
|
||||||
}
|
}
|
||||||
@ -2192,6 +2198,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
img = copy.copy(self.fake_image)
|
img = copy.copy(self.fake_image)
|
||||||
img['min_ram'] = 2
|
img['min_ram'] = 2
|
||||||
img['min_disk'] = 2
|
img['min_disk'] = 2
|
||||||
|
img['name'] = 'fake_name'
|
||||||
return img
|
return img
|
||||||
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
||||||
|
|
||||||
@ -2237,7 +2244,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertEqual(sys_metadata,
|
self.assertEqual(sys_metadata,
|
||||||
{'image_kernel_id': 'fake_kernel_id',
|
{'image_kernel_id': 'fake_kernel_id',
|
||||||
'image_ramdisk_id': 'fake_ramdisk_id',
|
'image_ramdisk_id': 'fake_ramdisk_id',
|
||||||
'image_something_else': 'meow'})
|
'image_something_else': 'meow', })
|
||||||
finally:
|
finally:
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
db.instance_destroy(self.context, ref[0]['uuid'])
|
||||||
|
|
||||||
@ -2609,9 +2616,9 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
instance_uuid)
|
instance_uuid)
|
||||||
self.assertEqual(sys_metadata,
|
self.assertEqual(sys_metadata,
|
||||||
{'image_kernel_id': 'fake_kernel_id',
|
{'image_kernel_id': 'fake_kernel_id',
|
||||||
'image_ramdisk_id': 'fake_ramdisk_id',
|
'image_ramdisk_id': 'fake_ramdisk_id',
|
||||||
'image_something_else': 'meow',
|
'image_something_else': 'meow',
|
||||||
'preserved': 'preserve this!'})
|
'preserved': 'preserve this!'})
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
db.instance_destroy(self.context, instance['uuid'])
|
||||||
|
|
||||||
def test_reboot_soft(self):
|
def test_reboot_soft(self):
|
||||||
|
@ -174,3 +174,37 @@ class UsageInfoTestCase(test.TestCase):
|
|||||||
self.assertEquals(payload['image_meta'], {})
|
self.assertEquals(payload['image_meta'], {})
|
||||||
image_ref_url = "%s/images/1" % utils.generate_glance_url()
|
image_ref_url = "%s/images/1" % utils.generate_glance_url()
|
||||||
self.assertEquals(payload['image_ref_url'], image_ref_url)
|
self.assertEquals(payload['image_ref_url'], image_ref_url)
|
||||||
|
|
||||||
|
def test_notify_about_instance_usage(self):
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
instance = db.instance_get(self.context, instance_id)
|
||||||
|
# Set some system metadata
|
||||||
|
sys_metadata = {'image_md_key1': 'val1',
|
||||||
|
'image_md_key2': 'val2',
|
||||||
|
'other_data': 'meow'}
|
||||||
|
extra_usage_info = {'image_name': 'fake_name'}
|
||||||
|
db.instance_system_metadata_update(self.context, instance['uuid'],
|
||||||
|
sys_metadata, False)
|
||||||
|
compute_utils.notify_about_instance_usage(self.context, instance,
|
||||||
|
'create.start', extra_usage_info=extra_usage_info)
|
||||||
|
self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
|
||||||
|
msg = test_notifier.NOTIFICATIONS[0]
|
||||||
|
self.assertEquals(msg['priority'], 'INFO')
|
||||||
|
self.assertEquals(msg['event_type'], 'compute.instance.create.start')
|
||||||
|
payload = msg['payload']
|
||||||
|
self.assertEquals(payload['tenant_id'], self.project_id)
|
||||||
|
self.assertEquals(payload['user_id'], self.user_id)
|
||||||
|
self.assertEquals(payload['instance_id'], instance.uuid)
|
||||||
|
self.assertEquals(payload['instance_type'], 'm1.tiny')
|
||||||
|
type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']
|
||||||
|
self.assertEquals(str(payload['instance_type_id']), str(type_id))
|
||||||
|
for attr in ('display_name', 'created_at', 'launched_at',
|
||||||
|
'state', 'state_description', 'image_meta'):
|
||||||
|
self.assertTrue(attr in payload,
|
||||||
|
msg="Key %s not in payload" % attr)
|
||||||
|
self.assertEquals(payload['image_meta'],
|
||||||
|
{'md_key1': 'val1', 'md_key2': 'val2'})
|
||||||
|
self.assertEquals(payload['image_name'], 'fake_name')
|
||||||
|
image_ref_url = "%s/images/1" % utils.generate_glance_url()
|
||||||
|
self.assertEquals(payload['image_ref_url'], image_ref_url)
|
||||||
|
self.compute.terminate_instance(self.context, instance['uuid'])
|
||||||
|
Loading…
Reference in New Issue
Block a user