def storage_allocated_gb(domain: libvirt.virDomain): capacity = 0 for device in storage_devices(domain): capacity += domain.blockInfo(device)[0] return round( capacity / 1024**3, 2 ) # convert bytes to gb and round to 2 digits precision after the decimal point.
def storage_used_gb(domain: libvirt.virDomain): allocation = 0 for device in storage_devices(domain): allocation += domain.blockInfo(device)[1] return round( allocation / 1024**3, 2 ) # convert bytes to gb and round to 2 digits precision after the decimal point.