diff options
| author | Belmiro Moreira <moreira.belmiro.email.lists@gmail.com> | 2013-05-02 23:13:52 +0200 |
|---|---|---|
| committer | Belmiro Moreira <moreira.belmiro.email.lists@gmail.com> | 2013-05-09 01:20:22 +0200 |
| commit | 91516edd2c84e3588b0f36e4e07d9984a0d798e0 (patch) | |
| tree | 93610850abc80213f930fe51fad6e03e7a536291 | |
| parent | 8bb1cc2f82b0d1dcfb08777537584e5f574ae439 (diff) | |
| download | nova-91516edd2c84e3588b0f36e4e07d9984a0d798e0.tar.gz nova-91516edd2c84e3588b0f36e4e07d9984a0d798e0.tar.xz nova-91516edd2c84e3588b0f36e4e07d9984a0d798e0.zip | |
Architecture property updated in snapshot libvirt
During an instance snapshot if the architecture property is defined
in the image it is updated twice in the snapshot image.
The snapshot is created with the metadata values from the
"instance_system_metadata" table and then, if defined, the architecure
property is updated from the value in the base image in that moment.
There is no reason to treat this property differently from others.
Also, it didn't respect the "non_inheritable_image_properties" option.
This change removes the special behavior for the architecture property
in the libvirt driver during a snapshot.
Fixes: bug #1176173
Change-Id: Ic5b4e3d462c08df167e14522fa25a7cf857c6aad
| -rw-r--r-- | nova/tests/test_libvirt.py | 50 | ||||
| -rwxr-xr-x | nova/virt/libvirt/driver.py | 3 |
2 files changed, 50 insertions, 3 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index a955d2f38..6c8d6b04f 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1682,6 +1682,56 @@ class LibvirtConnTestCase(test.TestCase): self.assertEquals(snapshot['status'], 'active') self.assertEquals(snapshot['name'], snapshot_name) + def test_snapshot_metadata_image(self): + expected_calls = [ + {'args': (), + 'kwargs': + {'task_state': task_states.IMAGE_PENDING_UPLOAD}}, + {'args': (), + 'kwargs': + {'task_state': task_states.IMAGE_UPLOADING, + 'expected_state': task_states.IMAGE_PENDING_UPLOAD}}] + func_call_matcher = matchers.FunctionCallMatcher(expected_calls) + + self.flags(libvirt_snapshots_directory='./') + + image_service = nova.tests.image.fake.FakeImageService() + + # Assign an image with an architecture defined (x86_64) + test_instance = copy.deepcopy(self.test_instance) + test_instance["image_ref"] = 'a440c04b-79fa-479c-bed1-0b816eaec379' + + instance_ref = db.instance_create(self.context, test_instance) + properties = {'instance_id': instance_ref['id'], + 'user_id': str(self.context.user_id), + 'architecture': 'fake_arch', + 'key_a': 'value_a', + 'key_b': 'value_b'} + snapshot_name = 'test-snap' + sent_meta = {'name': snapshot_name, 'is_public': False, + 'status': 'creating', 'properties': properties} + recv_meta = image_service.create(context, sent_meta) + + self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver, '_conn') + libvirt_driver.LibvirtDriver._conn.lookupByName = self.fake_lookup + self.mox.StubOutWithMock(libvirt_driver.utils, 'execute') + libvirt_driver.utils.execute = self.fake_execute + + self.mox.ReplayAll() + + conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) + conn.snapshot(self.context, instance_ref, recv_meta['id'], + func_call_matcher.call) + + snapshot = image_service.show(context, recv_meta['id']) + self.assertIsNone(func_call_matcher.match()) + self.assertEquals(snapshot['properties']['image_state'], 'available') + self.assertEquals(snapshot['properties']['architecture'], 'fake_arch') + self.assertEquals(snapshot['properties']['key_a'], 'value_a') + self.assertEquals(snapshot['properties']['key_b'], 'value_b') + self.assertEquals(snapshot['status'], 'active') + self.assertEquals(snapshot['name'], snapshot_name) + def test_attach_invalid_volume_type(self): self.create_fake_libvirt_mock() libvirt_driver.LibvirtDriver._conn.lookupByName = self.fake_lookup diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index e8a0a46eb..126a3e0e1 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1117,9 +1117,6 @@ class LibvirtDriver(driver.ComputeDriver): 'ramdisk_id': instance['ramdisk_id'], } } - if 'architecture' in base.get('properties', {}): - arch = base['properties']['architecture'] - metadata['properties']['architecture'] = arch disk_path = libvirt_utils.find_disk(virt_dom) source_format = libvirt_utils.get_disk_type(disk_path) |
