Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disk "Used" value #1467

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/storagePools/storagePool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export const getStoragePoolRow = ({ storagePool, vms, onAddErrorNotification })
{ storagePool.name }
</span>
);
const allocation = parseFloat(convertToUnit(storagePool.allocation, units.B, units.GiB).toFixed(2));
const physical = parseFloat(convertToUnit(storagePool.physical, units.B, units.GiB).toFixed(2));
const capacity = parseFloat(convertToUnit(storagePool.capacity, units.B, units.GiB).toFixed(2));
const sizeLabel = String(cockpit.format("$0 / $1 GiB", allocation, capacity));
const sizeLabel = String(cockpit.format("$0 / $1 GiB", physical, capacity));
const size = (
<Progress value={Number(storagePool.allocation)}
<Progress value={Number(storagePool.physical)}
min={0}
max={Number(storagePool.capacity)}
label={sizeLabel}
Expand Down
4 changes: 2 additions & 2 deletions src/components/storagePools/storagePoolVolumesTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ export class StoragePoolVolumesTab extends React.Component {
const rows = volumes
.sort(sortFunction)
.map(volume => {
const allocation = parseFloat(convertToUnit(volume.allocation, units.B, units.GiB).toFixed(2));
const physical = parseFloat(convertToUnit(volume.physical, units.B, units.GiB).toFixed(2));
const capacity = parseFloat(convertToUnit(volume.capacity, units.B, units.GiB).toFixed(2));
const columns = [
{ title: <div id={`${storagePoolIdPrefix}-volume-${volume.name}-name`}>{volume.name}</div> },
{ title: <div id={`${storagePoolIdPrefix}-volume-${volume.name}-usedby`}>{(isVolumeUsed[volume.name] || []).join(', ')}</div>, },
{ title: <div id={`${storagePoolIdPrefix}-volume-${volume.name}-size`}>{`${allocation} / ${capacity} GB`}</div> },
{ title: <div id={`${storagePoolIdPrefix}-volume-${volume.name}-size`}>{`${physical} / ${capacity} GB`}</div> },
];
return { columns, selected: volume.selected, props: { key: volume.name } };
});
Expand Down
8 changes: 4 additions & 4 deletions src/components/vm/disks/vmDisksCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class VmDisksCardLibvirt extends React.Component {
if (!vm.disks[target] || (vm.disks[target].type !== 'volume' && !vm.disksStats[target])) {
return false; // not yet retrieved, can't decide about disk stats support
}
return vm.disks[target].type == 'volume' || !isNaN(vm.disksStats[target].capacity) || !isNaN(vm.disksStats[target].allocation);
return vm.disks[target].type == 'volume' || !isNaN(vm.disksStats[target].capacity) || !isNaN(vm.disksStats[target].physical);
});
}

Expand All @@ -104,11 +104,11 @@ export class VmDisksCardLibvirt extends React.Component {
prepareDiskData(disk, diskStats, idPrefix, storagePools) {
diskStats = diskStats || {};

let used = diskStats.allocation;
let used = diskStats.physical;
let capacity = diskStats.capacity;

/*
* For disks of type `volume` allocation and capacity stats are not
* For disks of type `volume` physical and capacity stats are not
* fetched with the virConnectGetAllDomainStats API so we need to get
* them from the volume.
*
Expand All @@ -125,7 +125,7 @@ export class VmDisksCardLibvirt extends React.Component {

if (volume) {
capacity = volume.capacity;
used = volume.allocation;
used = volume.physical;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/libvirt-xml-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,8 @@ export function parseStoragePoolDumpxml(connectionName, storagePoolXml, objPath)
result.capacity = storagePoolElem.getElementsByTagName('capacity')[0].childNodes[0].nodeValue;
result.available = storagePoolElem.getElementsByTagName('available')[0].childNodes[0].nodeValue;
result.allocation = storagePoolElem.getElementsByTagName('allocation')[0].childNodes[0].nodeValue;
const physicalElem = storagePoolElem.getElementsByTagName('physical')[0];
result.physical = physicalElem ? physicalElem.childNodes[0].nodeValue : NaN;

// Fetch path property if target is contained for this type of pool
if (['dir', 'fs', 'netfs', 'logical', 'disk', 'iscsi', 'scsi', 'mpath', 'zfs'].indexOf(result.type) > -1) {
Expand Down