Skip to content

Commit

Permalink
fix rebuild sha1 not string error
Browse files Browse the repository at this point in the history
fixes bug #889164
The sha1() parameter is converted to a string
before calling the funcion.

(cherry picked from commit 17ae2d2)

Change-Id: I9cb6ff43c106c214e027d3bdacb795b4b0269f94
  • Loading branch information
David Subiros authored and markmc committed Dec 8, 2011
1 parent 1e3b88b commit ce4ea1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions nova/tests/test_libvirt.py
Expand Up @@ -926,7 +926,10 @@ def fake_none(self, instance):
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()
Expand All @@ -939,7 +942,10 @@ def fake_none(self, instance):
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'))
Expand Down
2 changes: 1 addition & 1 deletion nova/virt/libvirt/connection.py
Expand Up @@ -866,7 +866,7 @@ def basepath(fname='', suffix=suffix):
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']
Expand Down

0 comments on commit ce4ea1f

Please sign in to comment.