diff options
| author | Russell Bryant <rbryant@redhat.com> | 2013-03-04 20:35:27 -0500 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2013-03-04 20:45:42 -0500 |
| commit | 5d83d23cb7f7e95fedbd339405d93bc3841049ea (patch) | |
| tree | c22411e3587cf3f3ada2154f6d12ac6bf75c950c | |
| parent | a246cb90d229aea5cf70d886ad76061d5ad59010 (diff) | |
| download | nova-5d83d23cb7f7e95fedbd339405d93bc3841049ea.tar.gz nova-5d83d23cb7f7e95fedbd339405d93bc3841049ea.tar.xz nova-5d83d23cb7f7e95fedbd339405d93bc3841049ea.zip | |
Bump instance updated_at on network change.
Update add-fixed-ip and remove-fixed-ip code paths to update the
updated_at field of the instance, since from the user's perspective
through the API, they have made a change to the instance's
configuration. In that case, it makes sense to expect that the
updated_at field gets changed.
Fix bug 1143466.
Change-Id: Icfd7d0b1b556795d94a22c1719727f8c9fc744f0
| -rwxr-xr-x | nova/compute/manager.py | 8 | ||||
| -rw-r--r-- | nova/conductor/manager.py | 4 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 24 |
3 files changed, 34 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index d9e8435cc..4024b0e59 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2351,6 +2351,10 @@ class ComputeManager(manager.SchedulerDependentManager): network_info = self._inject_network_info(context, instance=instance) self.reset_network(context, instance) + # NOTE(russellb) We just want to bump updated_at. See bug 1143466. + self._instance_update(context, instance['uuid'], + updated_at=timeutils.utcnow()) + self._notify_about_instance_usage( context, instance, "create_ip.end", network_info=network_info) @@ -2372,6 +2376,10 @@ class ComputeManager(manager.SchedulerDependentManager): instance=instance) self.reset_network(context, instance) + # NOTE(russellb) We just want to bump updated_at. See bug 1143466. + self._instance_update(context, instance['uuid'], + updated_at=timeutils.utcnow()) + self._notify_about_instance_usage( context, instance, "delete_ip.end", network_info=network_info) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 9d6ac31e7..2a0853491 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -39,11 +39,11 @@ allowed_updates = ['task_state', 'vm_state', 'expected_task_state', 'instance_type_id', 'root_device_name', 'launched_on', 'progress', 'vm_mode', 'default_ephemeral_device', 'default_swap_device', 'root_device_name', - 'system_metadata', + 'system_metadata', 'updated_at' ] # Fields that we want to convert back into a datetime object. -datetime_fields = ['launched_at', 'terminated_at'] +datetime_fields = ['launched_at', 'terminated_at', 'updated_at'] class ConductorManager(manager.SchedulerDependentManager): diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 7869b76cc..e5a5c8b4b 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3756,6 +3756,30 @@ class ComputeTestCase(BaseTestCase): self.mox.ReplayAll() self.compute._instance_usage_audit(self.context) + def test_add_remove_fixed_ip_updates_instance_updated_at(self): + def _noop(*args, **kwargs): + pass + + self.stubs.Set(self.compute.network_api, + 'add_fixed_ip_to_instance', _noop) + self.stubs.Set(self.compute.network_api, + 'remove_fixed_ip_from_instance', _noop) + + instance = self._create_fake_instance() + updated_at_1 = instance['updated_at'] + + self.compute.add_fixed_ip_to_instance(self.context, 'fake', instance) + instance = db.instance_get_by_uuid(self.context, instance['uuid']) + updated_at_2 = instance['updated_at'] + + self.compute.remove_fixed_ip_from_instance(self.context, 'fake', + instance) + instance = db.instance_get_by_uuid(self.context, instance['uuid']) + updated_at_3 = instance['updated_at'] + + updated_ats = (updated_at_1, updated_at_2, updated_at_3) + self.assertEqual(len(updated_ats), len(set(updated_ats))) + class ComputeAPITestCase(BaseTestCase): |
