virt.volume_infos: output disk format

Since the format of a volume may be of interest and could help to tell
if two volumes are similar, output this information in the
virt.volume_infos function.
This commit is contained in:
Cédric Bosdonnat 2020-04-15 16:30:50 +02:00 committed by Daniel Wozniak
parent 9b2d180e46
commit 1a45660920
2 changed files with 12 additions and 0 deletions

View file

@ -6245,6 +6245,8 @@ def volume_infos(pool=None, volume=None, **kwargs):
else None,
}
format_node = vol_xml.find("./target/format")
# If we have a path, check its use.
used_by = []
if vol.path():
@ -6267,6 +6269,7 @@ def volume_infos(pool=None, volume=None, **kwargs):
"allocation": infos[2],
"used_by": used_by,
"backing_store": backing_store,
"format": format_node.get("type") if format_node is not None else None,
}
pools = [

View file

@ -4083,6 +4083,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"allocation": 1234,
"used_by": [],
"backing_store": None,
"format": "qcow2",
},
"vol2": {
"type": "file",
@ -4095,6 +4096,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"path": "/path/to/vol0.qcow2",
"format": "qcow2",
},
"format": "qcow2",
},
}
},
@ -4115,6 +4117,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"path": "/path/to/vol0.qcow2",
"format": "qcow2",
},
"format": "qcow2",
}
}
},
@ -4146,6 +4149,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"allocation": 1234,
"used_by": [],
"backing_store": None,
"format": "qcow2",
},
"vol2": {
"type": "file",
@ -4158,6 +4162,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"path": "/path/to/vol0.qcow2",
"format": "qcow2",
},
"format": "qcow2",
},
}
},
@ -4178,6 +4183,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"path": "/path/to/vol0.qcow2",
"format": "qcow2",
},
"format": "qcow2",
}
}
},
@ -4210,6 +4216,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"allocation": 1234,
"used_by": [],
"backing_store": None,
"format": "qcow2",
},
"vol2": {
"type": "file",
@ -4222,6 +4229,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"path": "/path/to/vol0.qcow2",
"format": "qcow2",
},
"format": "qcow2",
},
}
},
@ -4242,6 +4250,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
"path": "/path/to/vol0.qcow2",
"format": "qcow2",
},
"format": "qcow2",
}
}
},