Skip to content

Commit

Permalink
Merge pull request #1201 from yaacov/add-disk-count-to-vm-migration-list
Browse files Browse the repository at this point in the history
feet: Add disk count coloun indicating the completed disks transfered
  • Loading branch information
yaacov authored Jun 6, 2024
2 parents baf3888 + 7a85e54 commit 598222e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
"Description": "Description",
"Details": "Details",
"Determines the frequency with which the system checks the status of snapshot creation or removal during oVirt warm migration. The default value is 10 seconds.": "Determines the frequency with which the system checks the status of snapshot creation or removal during oVirt warm migration. The default value is 10 seconds.",
"Disk Transfer": "Disk Transfer",
"Disk counter": "Disk counter",
"Disk transfer": "Disk transfer",
"Do not try to preserve the static IPs of VMs with Windows guest operating system from vSphere.": "Do not try to preserve the static IPs of VMs with Windows guest operating system from vSphere.",
"Domain": "Domain",
"Domain name": "Domain name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,20 @@ const fieldsMetadataFactory: ResourceFieldFactory = (t) => [
? diskTransfer?.progress?.completed / diskTransfer?.progress?.total
: 0;
},
label: t('Disk Transfer'),
label: t('Disk transfer'),
isVisible: true,
sortable: true,
},
{
resourceFieldId: 'diskCounter',
jsonPath: (obj: VMData) => {
const diskTransfer = obj.statusVM?.pipeline.find((p) => p.name === 'DiskTransfer');

return diskTransfer && diskTransfer?.progress?.total
? diskTransfer?.progress?.completed / diskTransfer?.progress?.total
: 0;
},
label: t('Disk counter'),
isVisible: true,
sortable: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,26 @@ const cellRenderers: Record<string, React.FC<PlanVMsCellProps>> = {
p?.name?.startsWith('DiskTransfer'),
);
const annotations: { unit: string } = diskTransfer?.annotations as undefined;
const { completed, total } = getTransferProgress(diskTransfer);

return annotations?.unit ? (
<>
{diskTransfer?.progress?.completed || '-'} / {diskTransfer?.progress?.total || '-'}{' '}
{annotations?.unit || '-'}
{completed} / {total} {annotations?.unit || '-'}
</>
) : (
<>-</>
);
},
diskCounter: (props: PlanVMsCellProps) => {
const diskTransfer = props.data.statusVM?.pipeline.find((p) =>
p?.name?.startsWith('DiskTransfer'),
);

const { totalTasks, completedTasks } = countTasks(diskTransfer);

return totalTasks ? (
<>
{completedTasks || '-'} / {totalTasks || '-'} Discs
</>
) : (
<>-</>
Expand Down Expand Up @@ -200,3 +215,26 @@ export const getIcon: GetIconType = (p) => {
return undefined;
}
};

const countTasks = (diskTransfer: V1beta1PlanStatusMigrationVmsPipeline) => {
if (!diskTransfer || !Array.isArray(diskTransfer?.tasks)) {
return { totalTasks: 0, completedTasks: 0 };
}

const totalTasks = diskTransfer.tasks.length;
const completedTasks = diskTransfer.tasks.filter((task) => task.phase === 'Completed').length;

return { totalTasks, completedTasks };
};

const getTransferProgress = (diskTransfer) => {
if (!diskTransfer || !diskTransfer.progress) {
return { completed: '-', total: '-' };
}

const { completed, total } = diskTransfer.progress;
return {
completed: completed !== undefined ? completed : '-',
total: total !== undefined ? total : '-',
};
};

0 comments on commit 598222e

Please sign in to comment.