From 3b741bad7a961ad8f2ec9e52614d49fdf961bdb6 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Wed, 1 Feb 2012 00:02:03 +0000 Subject: [PATCH] Capture bandwidth usage data before resize. Since resize is really a migrate, we need to capture usage data before resizing. This fixes bug 925587 Change-Id: I999cb0e7c6b17beff542dddb4be09235e83313f0 --- nova/compute/manager.py | 1 + nova/tests/test_compute.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 8fc4f16a1fb9..57026d63530a 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1181,6 +1181,7 @@ class ComputeManager(manager.SchedulerDependentManager): instance_ref = self.db.instance_get_by_uuid(context, instance_uuid) + compute_utils.notify_usage_exists(instance_ref, current_period=True) self._notify_about_instance_usage(instance_ref, "resize.prep.start") same_host = instance_ref['host'] == FLAGS.host diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 54137a55c1f8..400e6949f214 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -1036,11 +1036,14 @@ class ComputeTestCase(BaseTestCase): instance_uuid, 'pre-migrating') - self.assertEquals(len(test_notifier.NOTIFICATIONS), 2) + self.assertEquals(len(test_notifier.NOTIFICATIONS), 3) msg = test_notifier.NOTIFICATIONS[0] self.assertEquals(msg['event_type'], - 'compute.instance.resize.prep.start') + 'compute.instance.exists') msg = test_notifier.NOTIFICATIONS[1] + self.assertEquals(msg['event_type'], + 'compute.instance.resize.prep.start') + msg = test_notifier.NOTIFICATIONS[2] self.assertEquals(msg['event_type'], 'compute.instance.resize.prep.end') self.assertEquals(msg['priority'], 'INFO')