summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2011-12-21 19:57:48 +0000
committerGerrit Code Review <review@openstack.org>2011-12-21 19:57:48 +0000
commitfedbce7d7139ca0c9fcd2de8103f2f9f7c1f0058 (patch)
tree7ad8f58712620918d867596af55e11a5d4ce95cb
parentf41eb95e4ea459d883acfec6d63010dbbe4c0ea7 (diff)
parentce4ea1f35c2d73b644498f4f06b46c75abd9b08d (diff)
downloadnova-fedbce7d7139ca0c9fcd2de8103f2f9f7c1f0058.tar.gz
Merge "fix rebuild sha1 not string error" into stable/diablo
-rw-r--r--nova/tests/test_libvirt.py10
-rw-r--r--nova/virt/libvirt/connection.py2
2 files changed, 9 insertions, 3 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index f59b2f7259..b44bde2619 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -926,7 +926,10 @@ class LibvirtConnTestCase(test.TestCase):
return
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()
@@ -939,7 +942,10 @@ class LibvirtConnTestCase(test.TestCase):
try:
conn.spawn(self.context, instance, network_info)
except Exception, e:
- count = (0 <= str(e.message).find('Unexpected method call'))
+ # assert that no exception is raised due to sha1 receiving an int
+ self.assertEqual(-1, str(e).find('must be string or buffer'
+ ', not int'))
+ count = (0 <= str(e).find('Unexpected method call'))
shutil.rmtree(os.path.join(FLAGS.instances_path, instance.name))
shutil.rmtree(os.path.join(FLAGS.instances_path, '_base'))
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index ba1dc86d67..333ae49c3e 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -866,7 +866,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']