common

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CsiPluginName = "com.hammerspace.csi"

	// Directory on hosts where backing shares for file-backed volumes will be mounted
	// Must end with a "/"
	ShareStagingDir             = "/tmp"
	SharePathPrefix             = "/"
	DefaultBackingFileSizeBytes = 1073741824
	DefaultVolumeNameFormat     = "%s"

	// Topology keys
	TopologyKeyDataPortal = "topology.csi.hammerspace.com/is-data-portal"
)
View Source
const (
	// Validation errors
	EmptyVolumeId                 = "Volume ID cannot be empty"
	VolumeIdTooLong               = "Volume ID cannot be longer than %d characters"
	SnapshotIdTooLong             = "Shapshot ID cannot be longer than %d characters"
	ImproperlyFormattedSnapshotId = "Shapshot ID should be of the format <datetime>|<share export path>, received %s"
	EmptyTargetPath               = "Target path cannot be empty"
	EmptyStagingTargetPath        = "Staging target path cannot be empty"
	EmptyVolumePath               = "Volume Path cannot be empty"
	NoCapabilitiesSupplied        = "No capabilities supplied for volume %s" // volume id
	ConflictingCapabilities       = "Cannot request a volume to be both raw and a filesystem"
	InvalidDeleteDelay            = "deleteDelay parameter must be an Integer. Value received '%s'"
	InvalidComment                = "Failed to set comment, invalid value"
	InvalidShareNameSize          = "Share name cannot be longer than 80 characters"
	InvalidCommentSize            = "Share comment cannot be longer than 255 characters"
	EmptySnapshotId               = "Snapshot ID cannot be empty"
	MissingSnapshotSourceVolumeId = "Snapshot SourceVolumeId cannot be empty"
	MissingBlockBackingShareName  = "blockBackingShareName must be provided when creating BlockVolumes"
	MissingMountBackingShareName  = "mountBackingShareName must be provided when creating Filesystem volumes other than 'nfs'"
	BlockVolumeSizeNotSpecified   = "Capacity must be specified for block volumes"
	ShareNotMounted               = "Share is not in mounted state."

	InvalidExportOptions             = "Export options must consist of 3 values: subnet,access,rootSquash, received '%s'"
	InvalidRootSquash                = "rootSquash must be a bool. Value received '%s'"
	InvalidAdditionalMetadataTags    = "Extended Info must be of format key=value, received '%s'"
	InvalidObjectiveNameDoesNotExist = "Cannot find objective with the name %s"

	VolumeExistsSizeMismatch = "Requested volume exists, but has a different size. Existing: %d, Requested: %d"

	VolumeDeleteHasSnapshots = "Volumes with snapshots cannot be deleted, delete snapshots first"
	VolumeBeingDeleted       = "The specified volume is currently being deleted"

	// Not Found errors
	VolumeNotFound              = "Volume does not exist"
	FileNotFound                = "File does not exist"
	ShareNotFound               = "Share does not exist"
	BackingShareNotFound        = "Could not find specified backing share"
	SourceSnapshotNotFound      = "Could not find source snapshots"
	SourceSnapshotShareNotFound = "Could not find the share for the source snapshot"

	// Internal errors
	UnexpectedHSStatusCode    = "Unexpected HTTP response from Hammerspace API: recieved status code %d, expected %d"
	OutOfCapacity             = "Requested capacity %d exceeds available %d"
	LoopDeviceAttachFailed    = "Failed setting up loop device: device=%s, filePath=%s"
	TargetPathUnknownFiletype = "Target path exists but is not a block device nor directory"
	UnknownError              = "Unknown internal error"

	// CSI v0
	BlockVolumesUnsupported = "Block volumes are unsupported in CSI v0.3"
)

These are error messages that may be returned as responses via the gRPC API Convention is to be lowercase with no ending punctuation

Variables

View Source
var (
	// These should be set at compile time
	Version = "NONE"
	Githash = "NONE"

	CsiVersion = "1"

	// The list of export path prefixes to try to use, in order, when mounting to a data portal
	DefaultDataPortalMountPrefixes = [...]string{"/", "/mnt/data-portal", ""}
	DataPortalMountPrefix          = ""
	CommandExecTimeout             = 300 * time.Second // Seconds

	UseAnvil bool
)
View Source
var ExecCommand = execCommandHelper

Functions

func BindMountDevice

func BindMountDevice(sourcefile, destfile string) error

func DeleteFile

func DeleteFile(pathname string) error

func EnsureFreeLoopbackDeviceFile

func EnsureFreeLoopbackDeviceFile() (uint64, error)

EnsureFreeLoopbackDeviceFile finds the next available loop device under /dev/loop* If no free loop devices exist, a new one is created

func ExpandDeviceFileSize

func ExpandDeviceFileSize(pathname string, size int64) error

func ExpandFilesystem

func ExpandFilesystem(device, fsType string) error

func FormatDevice

func FormatDevice(device, fsType string) error

func GetCommonExtendedInfo

func GetCommonExtendedInfo() map[string]string

Extended info to be set on every share created by the driver

func GetDeviceMinorNumber

func GetDeviceMinorNumber(device string) (uint32, error)

func GetNFSExports

func GetNFSExports(address string) ([]string, error)

func IsShareMounted

func IsShareMounted(targetPath string) (bool, error)

func MakeEmptyRawFile

func MakeEmptyRawFile(pathname string, size int64) error

func MountFilesystem

func MountFilesystem(sourcefile, destfile, fsType string, mountFlags []string) error

func MountShare

func MountShare(sourcePath, targetPath string, mountFlags []string) error

func SetMetadataTags

func SetMetadataTags(localPath string, tags map[string]string) error

func UnmountFilesystem

func UnmountFilesystem(targetPath string) error

Types

type AppliedObjectiveResponse

type AppliedObjectiveResponse struct {
	Name string `json:"name"`
}

type Cluster

type Cluster struct {
	Name              string              `json:"name"`
	PortalFloatingIps []PortalFloatingIps `json:"portalFloatingIps"`
}

type ClusterObjectiveResponse

type ClusterObjectiveResponse struct {
	Name string `json:"name"`
}

type ClusterResponse

type ClusterResponse struct {
	Capacity map[string]int64 `json:"capacity"`
}

We must create separate req and response objects since the API does not allow specifying unused fields

type DataPortal

type DataPortal struct {
	OperState      string            `json:"operState"`      // We want 'UP'
	AdminState     string            `json:"adminState"`     // We want 'UP'
	DataPortalType string            `json:"dataPortalType"` // We want NFS_V3
	Exported       []string          `json:"exported"`
	Node           DataPortalNode    `json:"node"`
	Uoid           map[string]string `json:"uoid"`
}

type DataPortalNode

type DataPortalNode struct {
	Name          string                `json:"name"`
	MgmtIpAddress DataPortalNodeAddress `json:"mgmtIpAddress"` // do we want this or some data ip?
}

type DataPortalNodeAddress

type DataPortalNodeAddress struct {
	Address      string `json:"address"`
	PrefixLength int    `json:"prefixLength"`
}

type File

type File struct {
	Name string `json:"name"`
	Path string `json:"path"`
	Size int64  `json:"size,string"`
}

type FileSnapshot

type FileSnapshot struct {
	SourceFilename string `json:"sourceFilename"`
	Time           string `json:"time"`
}

type HSVolume

type HSVolume struct {
	DeleteDelay            int64
	ExportOptions          []ShareExportOptions
	Objectives             []string
	BlockBackingShareName  string
	MountBackingShareName  string
	Size                   int64
	Name                   string
	Path                   string
	VolumeMode             string
	SourceSnapPath         string
	FSType                 string
	Comment                string
	SourceSnapShareName    string
	AdditionalMetadataTags map[string]string
}

type HSVolumeParameters

type HSVolumeParameters struct {
	DeleteDelay            int64
	ExportOptions          []ShareExportOptions
	Objectives             []string
	BlockBackingShareName  string
	MountBackingShareName  string
	VolumeNameFormat       string
	FSType                 string
	Comment                string
	AdditionalMetadataTags map[string]string
}

Structures to hold information about a plugin created volume

type ObjectivesResponse

type ObjectivesResponse struct {
	Applied []AppliedObjectiveResponse `json:"appliedObjectives"`
}

type PortalFloatingIps

type PortalFloatingIps struct {
	Address      string `json:"address"`
	PrefixLength int    `json:"prefixLength"`
}

Portal Data Floating IPs are a cluster-wide resource

type ShareExportOptions

type ShareExportOptions struct {
	Subnet            string `json:"subnet"`
	AccessPermissions string `json:"accessPermissions"` // Must be "RO" or "RW"
	RootSquash        bool   `json:"rootSquash"`
}

type ShareInodesResponse

type ShareInodesResponse struct {
	Used      int64 `json:"used"`
	Total     int64 `json:"total"`
	Available int64 `json:"available"`
	Percent   int64 `json:"percent"`
}

type ShareRequest

type ShareRequest struct {
	Name          string               `json:"name"`
	ExportPath    string               `json:"path"`
	Comment       string               `json:"comment"`
	ExtendedInfo  map[string]string    `json:"extendedInfo"`
	Size          int64                `json:"shareSizeLimit,omitifempty"`
	ExportOptions []ShareExportOptions `json:"exportOptions,omitifempty"`
}

type ShareResponse

type ShareResponse struct {
	Name          string               `json:"name"`
	ExportPath    string               `json:"path"`
	Comment       string               `json:"comment"`
	ExtendedInfo  map[string]string    `json:"extendedInfo"`
	ShareState    string               `json:"shareState"`
	Size          int64                `json:"shareSizeLimit`
	ExportOptions []ShareExportOptions `json:"exportOptions"`
	Space         ShareSpaceResponse   `json:"space"`
	Inodes        ShareInodesResponse  `json:"inodes"`
	Objectives    ObjectivesResponse   `json:"objectives"`
}

type ShareSpaceResponse

type ShareSpaceResponse struct {
	Used      int64 `json:"used"`
	Total     int64 `json:"total"`
	Available int64 `json:"available"`
	Percent   int64 `json:"percent"`
}

type ShareUpdateRequest

type ShareUpdateRequest struct {
	Name         string            `json:"name"`
	Comment      string            `json:"comment"`
	ExtendedInfo map[string]string `json:"extendedInfo"`
}

type SnapshotResponse

type SnapshotResponse struct {
	Name     string `json:"name"`
	Created  string `json:"created"`
	Modified string `json:"modified"`
}

type Task

type Task struct {
	Uuid      string        `json:"uuid"`
	Action    string        `json:"name"`
	Status    string        `json:"status"`
	ExitValue string        `json:"exitValue"`
	ParamsMap TaskParamsMap `json:"paramsMap"`
}

type TaskParamsMap

type TaskParamsMap struct {
	CreatePath      string `json:"create-path"`
	CreatedBy       string `json:"created-by"`
	CreatedByName   string `json:"created-by-name"`
	Name            string `json:"name"`
	OverideMemCheck string `json:"override-mem-check"`
}

type VolumeResponse

type VolumeResponse struct {
	Name               string `json:"name"`
	Created            string `json:"created"`
	Modified           string `json:"modified"`
	OperatingState     string `json:"operState"`
	StorageVolumeState string `json:"storageVolumeState"`
	Capacity           string `json:"effectiveTotalCapacity"`
}

Jump to

Keyboard shortcuts

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