diff options
| author | David Subiros <david.perez5@hp.com> | 2011-10-04 13:12:40 +0100 |
|---|---|---|
| committer | David Subiros <david.perez5@hp.com> | 2011-11-11 15:57:04 +0000 |
| commit | 17ae2d2662ca9af6eee0cf96fe48d3951593dc6b (patch) | |
| tree | 54eca07a5b03b8bc8d75240745f663b711764743 | |
| parent | 59dfaf9e02ff0064a6844c9c986737267317776f (diff) | |
fix rebuild sha1 not string error
fixes bug #889164
The sha1() parameter is converted to a string
before calling the funcion.
Change-Id: I9cb6ff43c106c214e027d3bdacb795b4b0269f94
| -rw-r--r-- | nova/tests/test_libvirt.py | 8 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 72ba84d7f..6420aa01c 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -942,7 +942,10 @@ class LibvirtConnTestCase(test.TestCase): # create_fake_libvirt_mock() mocks utils.import_class(). network_info = _fake_network_info(self.stubs, 1) self.create_fake_libvirt_mock() - instance = db.instance_create(self.context, self.test_instance) + + instance_ref = self.test_instance + instance_ref['image_ref'] = 123456 # we send an int to test sha1 call + instance = db.instance_create(self.context, instance_ref) # Start test self.mox.ReplayAll() @@ -957,6 +960,9 @@ class LibvirtConnTestCase(test.TestCase): try: conn.spawn(self.context, instance, None, network_info) except Exception, e: + # assert that no exception is raised due to sha1 receiving an int + self.assertEqual(-1, str(e.message).find('must be string or buffer' + ', not int')) count = (0 <= str(e.message).find('Unexpected method call')) shutil.rmtree(os.path.join(FLAGS.instances_path, instance.name)) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 28e351771..fc03ea67b 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -896,7 +896,7 @@ class LibvirtConnection(driver.ComputeDriver): user_id=inst['user_id'], project_id=inst['project_id']) - root_fname = hashlib.sha1(disk_images['image_id']).hexdigest() + root_fname = hashlib.sha1(str(disk_images['image_id'])).hexdigest() size = FLAGS.minimum_root_size inst_type_id = inst['instance_type_id'] |
