show volume encryption in vm detail volume tab

Signed-off-by: andy.lee <andy.lee@suse.com>
This commit is contained in:
andy.lee
2024-10-23 17:01:31 +02:00
committed by Francesco Torchia
parent 958e97f769
commit db21093670
8 changed files with 90 additions and 37 deletions
@@ -214,7 +214,7 @@ export default class HciPv extends HarvesterResource {
}
get isEncrypted() {
return this.relatedPV?.spec.csi.volumeAttributes.encrypted || false;
return Boolean(this.relatedPV?.spec.csi.volumeAttributes.encrypted) || false;
}
get longhornVolume() {
@@ -574,27 +574,20 @@ export default class VirtVm extends HarvesterResource {
return vmis.find(VMI => VMI.id === this.id);
}
get isVMImageEncrypted() {
const inStore = this.productInStore;
const imageList = this.$rootGetters[`${ inStore }/all`](HCI.IMAGE);
const rootImage = imageList.find(image => this.rootImageId === image.id);
return rootImage?.isEncrypted || false;
}
get isVolumeEncrypted() {
get encryptedVolumeType() {
const inStore = this.productInStore;
const pvcs = this.$rootGetters[`${ inStore }/all`](PVC);
// filter out the root image PVC
const nonRootImagePVCs = pvcs.filter(pvc => !pvc.metadata.annotations[HCI_ANNOTATIONS.IMAGE_ID]);
const volumeClaimNames = this.spec.template.spec.volumes?.map(v => v.persistentVolumeClaim?.claimName).filter(v => !!v) || [];
const volumes = pvcs.filter(pvc => volumeClaimNames.includes(pvc.metadata.name));
const volumeClaimNames = this.spec.template.spec.volumes?.map(v => v.persistentVolumeClaim?.claimName).map(v => v) || [];
const pvcVolumes = nonRootImagePVCs.filter(pvc => volumeClaimNames.includes(pvc.metadata.name));
// if any non-rootImage PCV volume is encrypted, return true, otherwise return false
return pvcVolumes.some(pvcVol => pvcVol.isEncrypted) ;
if (volumes.every(vol => vol.isEncrypted)) {
return 'all';
} else if (volumes.some(vol => vol.isEncrypted)) {
return 'partial';
} else {
return 'none';
}
}
get isError() {