cephfs/volumeidentifier: changed volume ID scheme

volumes have "csi-cephfs-dyn-" prefix when they are provisioned dynamically (provisionVolume=true)
and have "csi-cephfs-sta-" prefix when they are provisioned statically by the user (provisionVolume=false)
This commit is contained in:
gman 2018-04-13 14:24:40 +02:00
parent 374176c6ce
commit 69ecce1e75

View File

@ -21,6 +21,12 @@ import (
"github.com/pborman/uuid"
)
const (
dynamicallyProvisionedVolumePrefix = "csi-cephfs-dyn-"
staticallyProvisionedVolumePrefix = "csi-cephfs-sta-"
volumePrefixLen = len(dynamicallyProvisionedVolumePrefix)
)
type volumeIdentifier struct {
name, uuid, id string
}
@ -31,7 +37,24 @@ func newVolumeIdentifier(volOptions *volumeOptions, req *csi.CreateVolumeRequest
uuid: uuid.NewUUID().String(),
}
volId.id = "csi-cephfs-" + volId.uuid
prefix := staticallyProvisionedVolumePrefix
if volOptions.ProvisionVolume {
prefix = dynamicallyProvisionedVolumePrefix
}
volId.id = prefix + volId.uuid
return &volId
}
func uuidFromVolumeId(volId string) string {
return volId[volumePrefixLen:]
}
func isDynProvision(volId string) bool {
if len(volId) <= volumePrefixLen {
return false
}
return volId[:volumePrefixLen] == dynamicallyProvisionedVolumePrefix
}