3c5efdb74e
When an empty image is created through python-glanceclient using v2 APIs but updated using v1 APIs, python-glanceclient crashes with a "int() argument must be a string or a number, not 'NoneType'" message. This is because v1.images.ImageManager._format_image_meta_for_user expects the 'size' (and 'min_ram' and 'min_disk') field of an image to be convertible to 'int' but the server-side v2 APIs set it to 'None' for an empty image. Therefore the conversion to int fails with the message above. This fix modifies _format_image_meta_for_user to check whether or not a field can be converted to 'int' and, if not, returns 0 (zero) as the value instead. Tests have also been added. Change-Id: I86680bc06c8ce3ee492efeb3f32071da4f293bcd Closes-bug: #1258160