Comment 91 for bug 1546507

Revision history for this message
Feilong Wang (flwang) wrote :

I just improved my patch based on the different location formats of RBD.

And I found a small bug in Mike's patch, at below code. pieces[3] is 'snap', not the image id. Here should be pieces[2].

+ # There are 2 types of 'rbd' urls:
+ # 'rbd://image' and 'rbd://fsid/pool/image/snapshot'
+ # First one is forbidden, second is okay
+ pieces = url[len(prefix):].split('/')
+ if len(pieces) == 4 and pieces[3] == image_id:
+ return True
+ return False

>>> url="rbd://b0849a66-357e-4428-a84c-f5ccd277c076/images/3c9e8443-8331-4415-aa48-55e7ac95b7c0/snap"
>>> prefix="rbd://"
>>> pieces = url[len(prefix):].split('/')
>>> pieces
['b0849a66-357e-4428-a84c-f5ccd277c076', 'images', '3c9e8443-8331-4415-aa48-55e7ac95b7c0', 'snap']