@@ -479,6 +479,12 @@ func (c Client) newVolumeFromGCNVVolume(ctx context.Context, volume *netapppb.Vo
479479 }
480480 }
481481
482+ cPool := c .capacityPool (volume .StoragePool )
483+ storagePoolType := ""
484+ if cPool != nil {
485+ storagePoolType = cPool .PoolType
486+ }
487+
482488 result := & Volume {
483489 Name : volumeName ,
484490 CreationToken : volume .ShareName ,
@@ -488,7 +494,8 @@ func (c Client) newVolumeFromGCNVVolume(ctx context.Context, volume *netapppb.Vo
488494 CapacityPool : volume .StoragePool ,
489495 NetworkName : network ,
490496 NetworkFullName : volume .Network ,
491- ServiceLevel : ServiceLevelFromCapacityPool (c .capacityPool (volume .StoragePool )),
497+ ServiceLevel : ServiceLevelFromCapacityPool (cPool ),
498+ StoragePoolType : storagePoolType ,
492499 SizeBytes : volume .CapacityGib * GiBBytes ,
493500 ExportPolicy : c .exportPolicyImport (volume .ExportPolicy ),
494501 ProtocolTypes : protocolTypes ,
@@ -651,14 +658,38 @@ func (c Client) Volumes(ctx context.Context) (*[]*Volume, error) {
651658}
652659
653660// Volume uses a volume config record to fetch a volume by the most efficient means.
661+ func gcnvVolumeFallbackNames (volConfig * storage.VolumeConfig ) (string , string ) {
662+ primary := volConfig .InternalName
663+ secondary := strings .ReplaceAll (volConfig .Name , "-" , "_" )
664+ if secondary == primary {
665+ secondary = ""
666+ }
667+ return primary , secondary
668+ }
669+
654670func (c Client ) Volume (ctx context.Context , volConfig * storage.VolumeConfig ) (* Volume , error ) {
655671 // When we know the internal ID, use that as it is vastly more efficient
656672 if volConfig .InternalID != "" {
657673 return c .VolumeByID (ctx , volConfig .InternalID )
658674 }
659675
660- // Fall back to the name
661- return c .VolumeByName (ctx , volConfig .InternalName )
676+ primaryName , secondaryName := gcnvVolumeFallbackNames (volConfig )
677+
678+ // Fall back to the creation token.
679+ volume , err := c .VolumeByName (ctx , primaryName )
680+ if err == nil {
681+ return volume , nil
682+ }
683+ if ! errors .IsNotFoundError (err ) {
684+ return nil , err
685+ }
686+
687+ // For UNIFIED naming, also try underscore-normalized display name.
688+ if secondaryName == "" {
689+ return nil , err
690+ }
691+
692+ return c .VolumeByName (ctx , secondaryName )
662693}
663694
664695func (c Client ) VolumeByName (ctx context.Context , name string ) (* Volume , error ) {
@@ -734,8 +765,23 @@ func (c Client) VolumeExists(ctx context.Context, volConfig *storage.VolumeConfi
734765 if volConfig .InternalID != "" {
735766 return c .VolumeExistsByID (ctx , volConfig .InternalID )
736767 }
737- // Fall back to the creation token
738- return c .VolumeExistsByName (ctx , volConfig .InternalName )
768+ primaryName , secondaryName := gcnvVolumeFallbackNames (volConfig )
769+
770+ // Fall back to the creation token.
771+ exists , volume , err := c .VolumeExistsByName (ctx , primaryName )
772+ if err != nil {
773+ return false , nil , err
774+ }
775+ if exists {
776+ return true , volume , nil
777+ }
778+
779+ // For UNIFIED naming, also try underscore-normalized display name.
780+ if secondaryName == "" {
781+ return false , nil , nil
782+ }
783+
784+ return c .VolumeExistsByName (ctx , secondaryName )
739785}
740786
741787// VolumeByID returns a volume based on its full GCNV-style resource ID.
0 commit comments