summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kajinami <tkajinam@redhat.com>2021-07-06 22:00:43 +0900
committerTakashi Kajinami <tkajinam@redhat.com>2021-07-06 22:11:55 +0900
commit75c4abd909aa86f01e138329e89ffc31d53ef2d3 (patch)
tree4f9b54e0ec3dcb033df47449e45eb60cbae9f5cb
parent4dc538d1c024b94ab629c1ea478fd547f16e85bd (diff)
downloadoslo-utils-75c4abd909aa86f01e138329e89ffc31d53ef2d3.tar.gz
QemuImgInfo: Skip deprecation warning when output is not passed4.9.2
Change 73eb0673f627aad382e08a816191b637af436465 deprecated usage of the human format and introduced a deprecatipon warning message which is shown unless format is explicitly set to 'json'. To avoid the deprecation warning, all usage of QemuImgInfo requires explicit definition of format='json'. This means that we should add the format parameter to all existing usage of QemuImgInfo even if output is blank as is described in the following example. QemuImgInfo() QemuImgInfo(output=None) However later we should revert these implementations again when we deprecated or remove the format parameter. These steps are very redundant. This change suppresses the warning message when output is blank so that we can avoid deprecation warnings without redundant update and revert. Change-Id: If1ec42dae757fa3d74c740a52c346701ea19f1c9
-rw-r--r--oslo_utils/imageutils.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/oslo_utils/imageutils.py b/oslo_utils/imageutils.py
index 8a7fe6e..65292dc 100644
--- a/oslo_utils/imageutils.py
+++ b/oslo_utils/imageutils.py
@@ -66,11 +66,12 @@ class QemuImgInfo(object):
self.encrypted = details.get('encrypted')
self.format_specific = details.get('format-specific')
else:
- debtcollector.deprecate(
- 'The human format is deprecated and the format parameter '
- 'will be removed. Use explicitly json instead',
- version="xena",
- category=FutureWarning)
+ if cmd_output is not None:
+ debtcollector.deprecate(
+ 'The human format is deprecated and the format parameter '
+ 'will be removed. Use explicitly json instead',
+ version="xena",
+ category=FutureWarning)
details = self._parse(cmd_output or '')
self.image = details.get('image')
self.backing_file = details.get('backing_file')