add lock icon in VM list page

This commit is contained in:
andy.lee
2024-10-23 17:01:29 +02:00
committed by Francesco Torchia
parent d06f0ec989
commit 6ce99fad1f
5 changed files with 54 additions and 15 deletions
@@ -214,11 +214,7 @@ export default class HciPv extends HarvesterResource {
}
get isEncrypted() {
const inStore = this.$rootGetters['currentProduct'].inStore;
const longhornVolume = this.$rootGetters[`${ inStore }/all`](LONGHORN.VOLUMES).find(v => v.metadata?.name === this.spec?.volumeName);
return longhornVolume?.spec.encrypted || false;
return this.relatedPV?.spec.csi.volumeAttributes.encrypted || false;
}
get longhornVolume() {
@@ -574,6 +574,29 @@ 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() {
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).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) ;
}
get isError() {
const conditions = get(this.vmi, 'status.conditions');
const vmiFailureCond = findBy(conditions, 'type', 'Failure');