@@ -322,3 +322,86 @@ func (rvgs *rbdVolumeGroupSnapshot) ValidateResourcesForDelete() error {
322322
323323 return nil
324324}
325+
326+ type nvmeofVolumeGroupSnapshot struct {
327+ * volumeGroupSnapshotterBase
328+ }
329+
330+ var _ VolumeGroupSnapshotter = & nvmeofVolumeGroupSnapshot {}
331+
332+ func newNVMeOFVolumeGroupSnapshot (f * framework.Framework , namespace ,
333+ storageClass string ,
334+ blockPVC bool ,
335+ timeout , totalPVCCount , additionalVGSnapshotCount int ,
336+ ) (VolumeGroupSnapshotter , error ) {
337+ base , err := newVolumeGroupSnapshotBase (f , namespace , storageClass , blockPVC ,
338+ timeout , totalPVCCount , additionalVGSnapshotCount )
339+ if err != nil {
340+ return nil , fmt .Errorf ("failed to create volumeGroupSnapshotterBase: %w" , err )
341+ }
342+
343+ return & nvmeofVolumeGroupSnapshot {
344+ volumeGroupSnapshotterBase : base ,
345+ }, nil
346+ }
347+
348+ func (nvgs * nvmeofVolumeGroupSnapshot ) TestVolumeGroupSnapshot () error {
349+ return nvgs .volumeGroupSnapshotterBase .testVolumeGroupSnapshot (nvgs )
350+ }
351+
352+ func (nvgs * nvmeofVolumeGroupSnapshot ) GetVolumeGroupSnapshotClass () (
353+ * groupsnapapi.VolumeGroupSnapshotClass , error ,
354+ ) {
355+ vgscPath := fmt .Sprintf ("%s/%s" , nvmeofExamplePath , "groupsnapshotclass.yaml" )
356+ vgsc := & groupsnapapi.VolumeGroupSnapshotClass {}
357+ err := unmarshal (vgscPath , vgsc )
358+ if err != nil {
359+ return nil , fmt .Errorf ("failed to unmarshal VolumeGroupSnapshotClass: %w" , err )
360+ }
361+
362+ vgsc .Parameters ["csi.storage.k8s.io/group-snapshotter-secret-namespace" ] = cephCSINamespace
363+ vgsc .Parameters ["csi.storage.k8s.io/group-snapshotter-secret-name" ] = nvmeofProvisionerSecretName
364+ vgsc .Parameters ["pool" ] = nvmeofPool
365+
366+ fsID , err := getClusterID (nvgs .framework )
367+ if err != nil {
368+ return nil , fmt .Errorf ("failed to get clusterID: %w" , err )
369+ }
370+ vgsc .Parameters ["clusterID" ] = fsID
371+
372+ return vgsc , nil
373+ }
374+
375+ func (nvgs * nvmeofVolumeGroupSnapshot ) ValidateResourcesForCreate (
376+ vgs * groupsnapapi.VolumeGroupSnapshot ,
377+ ) error {
378+ vgsc , err := nvgs .groupclient .VolumeGroupSnapshotContents ().Get (
379+ context .TODO (),
380+ * vgs .Status .BoundVolumeGroupSnapshotContentName ,
381+ metav1.GetOptions {})
382+ if err != nil {
383+ return fmt .Errorf ("failed to get VolumeGroupSnapshotContent: %w" , err )
384+ }
385+
386+ sourcePVCCount := len (vgsc .Status .VolumeSnapshotInfoList )
387+ clonePVCCount := len (vgsc .Status .VolumeSnapshotInfoList )
388+ totalPVCCount := sourcePVCCount + clonePVCCount
389+
390+ validateOmapCount (nvgs .framework , totalPVCCount , rbdType , nvmeofPool , volumesType )
391+
392+ return nil
393+ }
394+
395+ func (nvgs * nvmeofVolumeGroupSnapshot ) ValidateResourcesForDelete () error {
396+ validateOmapCount (nvgs .framework , 0 , rbdType , nvmeofPool , volumesType )
397+ validateOmapCount (nvgs .framework , 0 , rbdType , nvmeofPool , snapsType )
398+ validateOmapCount (nvgs .framework , 0 , rbdType , nvmeofPool , groupSnapsType )
399+ validateRBDImageCount (nvgs .framework , 0 , nvmeofPool )
400+
401+ err := waitToRemoveImagesFromTrash (nvgs .framework , nvmeofPool , deployTimeout )
402+ if err != nil {
403+ return err
404+ }
405+
406+ return nil
407+ }
0 commit comments