Update to version 1.1.0

This commit is contained in:
chihyuwu
2022-04-25 11:10:19 +00:00
parent f0066b40ca
commit ebe7c1d97c
32 changed files with 2197 additions and 445 deletions

View File

@@ -2,6 +2,10 @@
package models
import (
"fmt"
)
const (
K8sCsiName = "Kubernetes CSI"
@@ -15,8 +19,30 @@ const (
LunTypeBlunThick = "BLUN_THICK" // thick provision, mapped to type 259
MaxIqnLen = 128
// Share definitions
MaxShareLen = 32
MaxShareDescLen = 64
UserGroupTypeLocalUser = "local_user"
UserGroupTypeLocalGroup = "local_group"
UserGroupTypeSystem = "system"
// CSI definitions
TargetPrefix = "k8s-csi"
LunPrefix = "k8s-csi"
IqnPrefix = "iqn.2000-01.com.synology:"
)
TargetPrefix = "k8s-csi"
LunPrefix = "k8s-csi"
IqnPrefix = "iqn.2000-01.com.synology:"
SharePrefix = "k8s-csi"
ShareSnapshotDescPrefix = "(Do not change)"
)
func GenLunName(volName string) string {
return fmt.Sprintf("%s-%s", LunPrefix, volName)
}
func GenShareName(volName string) string {
shareName := fmt.Sprintf("%s-%s", SharePrefix, volName)
if len(shareName) > MaxShareLen {
return shareName[:MaxShareLen]
}
return shareName
}

View File

@@ -3,6 +3,8 @@
package models
import (
"fmt"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/SynologyOpenSource/synology-csi/pkg/dsm/webapi"
)
@@ -10,21 +12,43 @@ type CreateK8sVolumeSpec struct {
DsmIp string
K8sVolumeName string
LunName string
ShareName string
Location string
Size int64
Type string
ThinProvisioning bool
TargetName string
TargetIqn string
MultipleSession bool
SourceSnapshotId string
SourceVolumeId string
Protocol string
}
type ListK8sVolumeRespSpec struct {
DsmIp string
Lun webapi.LunInfo
Target webapi.TargetInfo
type K8sVolumeRespSpec struct {
DsmIp string
VolumeId string
SizeInBytes int64
Location string
Name string
Source string
Lun webapi.LunInfo
Target webapi.TargetInfo
Share webapi.ShareInfo
Protocol string
}
type K8sSnapshotRespSpec struct {
DsmIp string
Name string
Uuid string
ParentName string
ParentUuid string
Status string
SizeInBytes int64
CreateTime int64
Time string // only for share snapshot delete
RootPath string
Protocol string
}
type CreateK8sVolumeSnapshotSpec struct {
@@ -33,4 +57,24 @@ type CreateK8sVolumeSnapshotSpec struct {
Description string
TakenBy string
IsLocked bool
}
}
type NodeStageVolumeSpec struct {
VolumeId string
StagingTargetPath string
VolumeCapability *csi.VolumeCapability
Dsm string
Source string
}
type ByVolumeId []*K8sVolumeRespSpec
func (a ByVolumeId) Len() int { return len(a) }
func (a ByVolumeId) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByVolumeId) Less(i, j int) bool { return a[i].VolumeId < a[j].VolumeId }
type BySnapshotAndParentUuid []*K8sSnapshotRespSpec
func (a BySnapshotAndParentUuid) Len() int { return len(a) }
func (a BySnapshotAndParentUuid) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a BySnapshotAndParentUuid) Less(i, j int) bool {
return fmt.Sprintf("%s/%s", a[i].ParentUuid, a[i].Uuid) < fmt.Sprintf("%s/%s", a[j].ParentUuid, a[j].Uuid)
}