From d051c80a74f37f9264a55480dfbab03769194b2f Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Fri, 20 Apr 2018 16:09:02 -0500 Subject: [PATCH] Stringify instance UUID oslo.versionedobjects merged a patch [1] resulting in the referenced bug. A second patch [2] was merged that was supposed to fix the issue If coerce's value arg is a unicode string, then the method will return unicode [3]. Subsequent checks for isinstance(str) [4] will fail and a TypeError will be raised trying to handle the uuid as an int in the else block. This change ensures that the uuid is an instance of str so that it is handled properly. This problem was fixed in pypowervm 1.1.15 [5] and the minimum version was bumped for master. However, we can't backport the pypowervm requirements bump to the stable branches so we have to fix it here. [1] https://review.openstack.org/#/c/559815/ [2] https://review.openstack.org/#/c/561674/ [3] https://review.openstack.org/#/c/561674/2/oslo_versionedobjects/fields.py@367 [4] https://github.com/powervm/pypowervm/blob/1.1.6/pypowervm/utils/uuid.py#L50-L56 [5] https://github.com/powervm/pypowervm/commit/d55b4c84 Related-Bug: #1766692 Change-Id: Ic3b11b071a055177bbcfb0555e2a391ba419d191 (cherry picked from commit 49330fcf28425cebfb281d0721a2d1d0bcf4d801) --- nova_powervm/virt/powervm/vm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nova_powervm/virt/powervm/vm.py b/nova_powervm/virt/powervm/vm.py index 0ba6b415..f6417ec9 100644 --- a/nova_powervm/virt/powervm/vm.py +++ b/nova_powervm/virt/powervm/vm.py @@ -754,7 +754,11 @@ def get_pvm_uuid(instance): :param instance: nova.objects.instance.Instance :return: pvm_uuid. """ - return pvm_uuid.convert_uuid_to_pvm(instance.uuid).upper() + # NOTE(esberglu): To work around bug ##1766692, we explicitly use str() + # rather than six.text_type here because of this pypowervm check for + # isinstance(..., str) at L50 of + # https://github.com/powervm/pypowervm/blob/1.1.6/pypowervm/utils/uuid.py + return pvm_uuid.convert_uuid_to_pvm(str(instance.uuid)).upper() def _uuid_set_high_bit(pvm_uuid):