diff --git a/ocp_resources/datavolume.py b/ocp_resources/datavolume.py index 351a590ba4..e7f4e16676 100644 --- a/ocp_resources/datavolume.py +++ b/ocp_resources/datavolume.py @@ -252,13 +252,9 @@ def pvc(self): @property def scratch_pvc(self): - pvc_metadata = self.pvc.instance.metadata scratch_pvc_prefix = ( - f"prime-{pvc_metadata.uid}" - if pvc_metadata.annotations.get( - f"{self.ApiGroup.CDI_KUBEVIRT_IO}/storage.usePopulator" - ) - == "true" + f"prime-{self.pvc.instance.metadata.uid}" + if self.pvc.use_populator else self.name ) return PersistentVolumeClaim( diff --git a/ocp_resources/persistent_volume_claim.py b/ocp_resources/persistent_volume_claim.py index a8456b7f55..de5db04598 100644 --- a/ocp_resources/persistent_volume_claim.py +++ b/ocp_resources/persistent_volume_claim.py @@ -108,3 +108,12 @@ def selected_node(self): return self.instance.metadata.annotations.get( "volume.kubernetes.io/selected-node" ) + + @property + def use_populator(self): + return ( + self.instance.metadata.annotations.get( + f"{self.ApiGroup.CDI_KUBEVIRT_IO}/storage.usePopulator" + ) + == "true" + )