Ryan Harper has uploaded a new change for review.
Change subject: vdsm/storage/misc.py: Convert uuid input to string before validating ......................................................................
vdsm/storage/misc.py: Convert uuid input to string before validating
When abusing the createVolume() method by passing numeric values as UUIDs, the validation regex needs a string to process and throws an exception when it isn't:
Traceback (most recent call last): File "/usr/share/vdsm/storage/task.py", line 861, in _run return fn(*args, **kargs) File "/usr/share/vdsm/logUtils.py", line 38, in wrapper res = f(*args, **kwargs) File "/usr/share/vdsm/storage/hsm.py", line 1206, in createVolume misc.validateUUID(imgUUID, 'imgUUID') File "/usr/share/vdsm/storage/misc.py", line 525, in validateUUID m = UUID_REGEX.match(uuid) TypeError: expected string or buffer
And on the client side, I get a less than useful error:
Traceback (most recent call last): File "create_a_vm.py", line 98, in <module> BLANK_UUID, BLANK_UUID)) File "create_a_vm.py", line 19, in vdsOK raise Exception(str(d)) Exception: {'status': {'message': "Error creating a new volume: ('sdUUID=99d43d50-5946-4451-8e12-9d85cb426e19, spUUID=150e55ab-e68c-411c-af30-587071905216, imgUUID=4194304, size=4, volFormat=2, preallocate=rootfs, diskType=7bdf7b4b-4909-41ce-a9c0-9bc06ba045fe, volUUID=00000000-0000-0000-0000-000000000000, desc=00000000-0000-0000-0000-000000000000, srcImgUUID=00000000-0000-0000-0000-000000000000, srcVolUUID=00000000-0000-0000-0000-000000000000',)", 'code': 205}}
However, if we convert the input to a string first then we can fail the REGEX and raise the more useful invalid parameter exception:
Now, I get:
Traceback (most recent call last): File "create_a_vm.py", line 98, in <module> BLANK_UUID, BLANK_UUID)) File "create_a_vm.py", line 19, in vdsOK raise Exception(str(d)) Exception: {'status': {'message': "Invalid parameter: 'imgUUID=4194304'", 'code': 1000}}
Which explains to me my error quite well.
Change-Id: If16466e88a50d3af03ae7830d4d8148ebf69d0d9 Signed-off-by: Ryan Harper ryanh@us.ibm.com --- M vdsm/storage/misc.py 1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/87/3687/1 -- To view, visit http://gerrit.ovirt.org/3687 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: If16466e88a50d3af03ae7830d4d8148ebf69d0d9 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ryan Harper ryanh@us.ibm.com