QemuImgInfo: Skip deprecation warning when output is not passed

Change 73eb0673f6 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
This commit is contained in:
Takashi Kajinami 2021-07-06 22:00:43 +09:00
parent 4dc538d1c0
commit 75c4abd909
1 changed files with 6 additions and 5 deletions

View File

@ -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')