- @type vgname: C{string}
- @param vgname: the name of the volume group to ask for disk space information
- @type hypervisor_type: C{str}
- @param hypervisor_type: the name of the hypervisor to ask for
- memory information
- @rtype: C{dict}
- @return: dictionary with the following keys:
- - vg_size is the size of the configured volume group in MiB
- - vg_free is the free size of the volume group in MiB
- - memory_dom0 is the memory allocated for domain0 in MiB
- - memory_free is the currently available (free) ram in MiB
- - memory_total is the total number of ram in MiB
- - hv_version: the hypervisor version, if available
+ """
+ # TODO: GetVGInfo supports returning information for multiple VGs at once
+ vginfo = bdev.LogicalVolume.GetVGInfo([name])
+ if vginfo:
+ vg_free = int(round(vginfo[0][0], 0))
+ vg_size = int(round(vginfo[0][1], 0))
+ else:
+ vg_free = None
+ vg_size = None
+
+ return {
+ "name": name,
+ "vg_free": vg_free,
+ "vg_size": vg_size,
+ }
+
+
+def _GetHvInfo(name):
+ """Retrieves node information from a hypervisor.
+
+ The information returned depends on the hypervisor. Common items:
+
+ - vg_size is the size of the configured volume group in MiB
+ - vg_free is the free size of the volume group in MiB
+ - memory_dom0 is the memory allocated for domain0 in MiB
+ - memory_free is the currently available (free) ram in MiB
+ - memory_total is the total number of ram in MiB
+ - hv_version: the hypervisor version, if available
+
+ """
+ return hypervisor.GetHypervisor(name).GetNodeInfo()
+
+
+def _GetNamedNodeInfo(names, fn):
+ """Calls C{fn} for all names in C{names} and returns a dictionary.
+
+ @rtype: None or dict