summaryrefslogtreecommitdiff
path: root/ironic/common
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/common')
-rw-r--r--ironic/common/exception.py5
-rw-r--r--ironic/common/images.py16
2 files changed, 21 insertions, 0 deletions
diff --git a/ironic/common/exception.py b/ironic/common/exception.py
index c60d46577..dbe22d41d 100644
--- a/ironic/common/exception.py
+++ b/ironic/common/exception.py
@@ -440,6 +440,11 @@ class DracConfigJobCreationError(DracOperationError):
'Reason: %(error)s')
+class DracInvalidFilterDialect(DracOperationError):
+ message = _('Invalid filter dialect \'%(invalid_filter)s\'. '
+ 'Supported options are %(supported)s')
+
+
class FailedToGetSensorData(IronicException):
message = _("Failed to get sensor data for node %(node)s. "
"Error: %(error)s")
diff --git a/ironic/common/images.py b/ironic/common/images.py
index bceea1f11..37f2dce93 100644
--- a/ironic/common/images.py
+++ b/ironic/common/images.py
@@ -292,3 +292,19 @@ def download_size(context, image_href, image_service=None):
if not image_service:
image_service = service.Service(version=1, context=context)
return image_service.show(image_href)['size']
+
+
+def converted_size(path):
+ """Get size of converted raw image.
+
+ The size of image converted to raw format can be growing up to the virtual
+ size of the image.
+
+ :param path: path to the image file.
+ :returns: virtual size of the image or 0 if conversion not needed.
+
+ """
+ data = qemu_img_info(path)
+ if data.file_format == "raw" or not CONF.force_raw_images:
+ return 0
+ return data.virtual_size