curveservice

package
v0.0.0-...-ed02bd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCurveNbd

func InitCurveNbd()

Types

type CancelSnapshotResp

type CancelSnapshotResp SnapshotCommonResp

type CleanCloneTaskResp

type CleanCloneTaskResp SnapshotCommonResp

type CloneResp

type CloneResp struct {
	SnapshotCommonResp
	UUID string `json:"UUID,omitempty"`
}

type CreateSnapshotResp

type CreateSnapshotResp struct {
	SnapshotCommonResp
	UUID string `json:"UUID,omitempty"`
}

type CurveVolume

type CurveVolume struct {
	FileName string `json:"filename"`
	FilePath string `json:"filepath"`
	DirPath  string `json:"dirpath"`
	User     string `json:"user"`
	SizeGiB  int    `json:"size"`
}

func NewCurveVolume

func NewCurveVolume(user, volName string, sizeGiB int) *CurveVolume

func (*CurveVolume) Create

func (cv *CurveVolume) Create(ctx context.Context) error

curve create file, mkdir the dir if not exists

func (*CurveVolume) Delete

func (cv *CurveVolume) Delete(ctx context.Context) error

curve delete [-h] --user USER --filename FILENAME

func (*CurveVolume) Extend

func (cv *CurveVolume) Extend(ctx context.Context, newSizeGiB int) error

curve extend [-h] --user USER --filename FILENAME --length LENGTH

func (*CurveVolume) Map

func (cv *CurveVolume) Map(ctx context.Context, disableInUseChecks bool) (string, error)

curve-nbd map cbd:<user>/<filename_full_path>_<user>_

func (*CurveVolume) Stat

curve stat [-h] --user USER --filename FILENAME

func (*CurveVolume) UnMap

func (cv *CurveVolume) UnMap(ctx context.Context) error

curve-nbd unmap

type CurveVolumeDetail

type CurveVolumeDetail struct {
	Id         string            `param:"id"`
	ParentId   string            `param:"parentid"`
	FileType   string            `param:"filetype"`
	LengthGiB  int               `param:"length(GB)"`
	CreateTime string            `param:"createtime"`
	User       string            `param:"user"`
	FileName   string            `param:"filename"`
	FileStatus CurveVolumeStatus `param:"fileStatus"`
}

type CurveVolumeStatus

type CurveVolumeStatus string
const (

	// curve file status
	CurveVolumeStatusNotExist      CurveVolumeStatus = "kFileNotExists"
	CurveVolumeStatusExist         CurveVolumeStatus = "kFileExists"
	CurveVolumeStatusCreated       CurveVolumeStatus = "Created"
	CurveVolumeStatusOwnerAuthFail CurveVolumeStatus = "kOwnerAuthFail"
	CurveVolumeStatusClonedLazy    CurveVolumeStatus = "CloneMetaInstalled"
	CurveVolumeStatusBeingCloned   CurveVolumeStatus = "BeingCloned"
	CurveVolumeStatusUnknown       CurveVolumeStatus = "Unknown"
)

type DeleteSnapshotResp

type DeleteSnapshotResp SnapshotCommonResp

type FlattenResp

type FlattenResp SnapshotCommonResp

type GetCloneTaskResp

type GetCloneTaskResp struct {
	SnapshotCommonResp
	TotalCount int        `json:"TotalCount,omitempty"`
	TaskInfos  []TaskInfo `json:"TaskInfos,omitempty"`
}

also use as recover task

type GetSnapshotResp

type GetSnapshotResp struct {
	SnapshotCommonResp
	TotalCount int        `json:"TotalCount,omitempty"`
	Snapshots  []Snapshot `json:"Snapshots,omitempty"`
}

type RecoverResp

type RecoverResp struct {
	SnapshotCommonResp
	UUID string `json:"UUID,omitempty"`
}

type RespCode

type RespCode string
const (
	ExecSuccess   RespCode = "0"
	FileNotExists RespCode = "-8"
)

type Snapshot

type Snapshot struct {
	UUID       string         `json:"UUID"`
	User       string         `json:"User"`
	File       string         `json:"File"`
	SeqNum     uint32         `json:"SeqNum"`
	Name       string         `json:"Name"`
	Time       int64          `json:"Time"`
	FileLength uint64         `json:"FileLength"` //unit Byte
	Status     SnapshotStatus `json:"Status"`
	Progress   uint8          `json:"Progress"`
}

type SnapshotCommonResp

type SnapshotCommonResp struct {
	Code      RespCode `json:"Code"`
	Message   string   `json:"Message"`
	RequestId string   `json:"RequestId"`
}

type SnapshotServer

type SnapshotServer struct {
	URL      string `json:"server"`
	User     string `json:"user"`
	FilePath string `json:"filepath"`
}

func NewSnapshotServer

func NewSnapshotServer(server, user, volName string) *SnapshotServer

func (*SnapshotServer) CancelSnapshot

func (cs *SnapshotServer) CancelSnapshot(ctx context.Context, uuid string) error

CancelSnapshot cancels a snapshot

func (*SnapshotServer) CleanCloneTask

func (cs *SnapshotServer) CleanCloneTask(ctx context.Context, uuid string) error

Clean a clone task, flatten if it is unfinished.

func (*SnapshotServer) Clone

func (cs *SnapshotServer) Clone(ctx context.Context, source, destination string, lazy bool) (string, error)

Clone a volume from source to destination

func (*SnapshotServer) CreateSnapshot

func (cs *SnapshotServer) CreateSnapshot(ctx context.Context, snapName string) (string, error)

CreateSnapshot creates a snapshot and returns the uuid

func (*SnapshotServer) DeleteSnapshot

func (cs *SnapshotServer) DeleteSnapshot(ctx context.Context, uuid string) error

DeleteSnapshot detetes a snapshot

func (*SnapshotServer) EnsureTaskFromSourceDone

func (cs *SnapshotServer) EnsureTaskFromSourceDone(ctx context.Context, source string) error

func (*SnapshotServer) Flatten

func (cs *SnapshotServer) Flatten(ctx context.Context, uuid string) error

func (*SnapshotServer) GetCloneTaskOfDestination

func (cs *SnapshotServer) GetCloneTaskOfDestination(ctx context.Context, destination string) (TaskInfo, error)

Get task with specific destination

func (*SnapshotServer) GetCloneTaskOfId

func (cs *SnapshotServer) GetCloneTaskOfId(ctx context.Context, uuid string) (TaskInfo, error)

Get task with specific uuid

func (*SnapshotServer) GetFileSnapshotOfId

func (cs *SnapshotServer) GetFileSnapshotOfId(ctx context.Context, uuid string) (Snapshot, error)

GetSnapshotById gets the snapshot with specific uuid

func (*SnapshotServer) GetFileSnapshotOfName

func (cs *SnapshotServer) GetFileSnapshotOfName(ctx context.Context, snapName string) (Snapshot, error)

GetSnapshotByName gets the snapshot with specific name

func (*SnapshotServer) WaitForCloneTaskDone

func (cs *SnapshotServer) WaitForCloneTaskDone(ctx context.Context, destination string) error

func (*SnapshotServer) WaitForCloneTaskReady

func (cs *SnapshotServer) WaitForCloneTaskReady(ctx context.Context, destination string) error

Wait for the task ready: Done or MetaInstalled

func (*SnapshotServer) WaitForSnapshotDone

func (cs *SnapshotServer) WaitForSnapshotDone(ctx context.Context, uuid string) (Snapshot, error)

Wait for the snapshot ready

type SnapshotStatus

type SnapshotStatus uint8
const (
	SnapshotStatusDone SnapshotStatus = iota
	SnapshotStatusPending
	SnapshotStatusDeleteing
	SnapshotStatusErrorDeleting
	SnapshotStatusCanceling
	SnapshotStatusError
)

SnapshotStatus:

(0:done, 1:pending, 2:deleteing, 3:errorDeleting, 4:canceling, 5:error)

type TaskFileType

type TaskFileType uint8
const (
	TaskFileTypeSrcFile TaskFileType = iota
	TaskFileTypeSrcSnapshot
)

TaskFileType: (0:SrcFile 1:SrcSnapshot)

type TaskInfo

type TaskInfo struct {
	File         string       `json:"File"`
	TaskFileType TaskFileType `json:"FileType,omitempty"`
	IsLazy       bool         `json:"IsLazy,omitempty"`
	Progress     uint8        `json:"Progress,omitempty"`
	Src          string       `json:"Src,omitempty"`
	TaskStatus   TaskStatus   `json:"TaskStatus"`
	TaskType     TaskType     `json:"TaskType"`
	Time         int64        `json:"Time"`
	UUID         string       `json:"UUID"`
	User         string       `json:"User"`
}

type TaskStatus

type TaskStatus uint8
const (
	TaskStatusDone TaskStatus = iota
	TaskStatusCloning
	TaskStatusRecovering
	TaskStatusCleaning
	TaskStatusErrorCleaning
	TaskStatusError
	TaskStatusRetrying
	TaskStatusMetaInstalled
)

TaskStatus

(0:done, 1:cloning, 2:recovering, 3:cleaning, 4:errorCleaning, 5:error,6:retrying, 7:metaInstalled)

type TaskType

type TaskType uint8
const (
	TaskTypeClone TaskType = iota
	TaskTypeRecover
)

TaskType: (0:clone, 1:recover)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL