filer

package
v0.0.0-...-6d8787e Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package filer defines the interfaces for provisioning or updating a storage space on DCCN storage systems (a.k.a. filer) for a user or a project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDirEmpty

func IsDirEmpty(path string) (bool, error)

Common function to check if given directory is empty (i.e. contains no files or sub-directories).

Types

type APIError

type APIError struct {
	Error struct {
		Target    string `json:"target"`
		Arguments struct {
			Message string `json:"message"`
			Code    string `json:"code"`
		} `json:"arguments"`
	} `json:"error"`
}

APIError of the API request.

type APIJob

type APIJob struct {
	Job Job `json:"job"`
}

APIJob of the API request.

type Aggregate

type Aggregate struct {
	UUID  string `json:"uuid"`
	Name  string `json:"name"`
	State string `json:"state"`
	Space struct {
		BlockStorage Space `json:"block_storage"`
	} `json:"space"`
}

Aggregate of OnTAP

type Autosize

type Autosize struct {
	Mode string `json:"mode"`
}

Autosize defines the volume autosizing mode

type CephFs

type CephFs struct {
	// contains filtered or unexported fields
}

CephFs implement the filer interface specific for the Ceph filesystem.

func (CephFs) CreateHome

func (filer CephFs) CreateHome(username, groupname string, quotaGiB int) error

CreateHome always returns an error with "not supported" message, given that Ceph filesystem is not used for personal home directory.

func (CephFs) CreateProject

func (filer CephFs) CreateProject(projectID string, quotaGiB int) error

CreateProject creates a new project directory on the Ceph filesystem mounted under `CephFsConfig.GetProjectRoot()`.

func (CephFs) DeleteHome

func (filer CephFs) DeleteHome(username, groupname string) error

DeleteHome deletes a home directory as qtree `username` under the volume `groupname`.

func (CephFs) GetHomeQuotaInBytes

func (filer CephFs) GetHomeQuotaInBytes(username, groupname string) (int64, int64, error)

GetHomeQuotaInBytes always returns an error with "not supported" message, given that Ceph filesystem is not used for personal home directory.

func (CephFs) GetProjectQuotaInBytes

func (filer CephFs) GetProjectQuotaInBytes(projectID string) (int64, int64, error)

GetProjectQuotaInBytes gets the quota of the project `projectID` hosted on the Ceph filesystem.

func (CephFs) GetProjectRoot

func (filer CephFs) GetProjectRoot() string

GetProjectRoot returns the root path in which projects are hosted on the CephFS system.

func (CephFs) GetQuotaInBytes

func (filer CephFs) GetQuotaInBytes(path string) (int64, error)

GetQuotaInBytes gets the quota specified on the given `path` on the Ceph filesystem. It is done by retrieving the value of the extended attribute `cephfs.quota.max_bytes` from a path.

See [here](https://docs.ceph.com/docs/master/cephfs/quota/) for more detail.

func (CephFs) GetSystemSpaceInBytes

func (filer CephFs) GetSystemSpaceInBytes() (int64, int64, error)

GetSystemSpaceInBytes returns the total and used storage space in bytes

func (CephFs) GetUsageInBytes

func (filer CephFs) GetUsageInBytes(path string) (int64, error)

GetUsageInBytes gets the storage usage under the given `path` on the Ceph filesystem. It is done by retrieving the extended attribute `ceph.dir.rbytes` from the path.

See [here](https://blog.widodh.nl/2015/04/playing-with-cephfs-recursive-statistics/) for more detail.

func (CephFs) SetHomeQuota

func (filer CephFs) SetHomeQuota(username, groupname string, quotaGiB int) error

SetHomeQuota always returns an error with "not supported" message, given that Ceph filesystem is not used for personal home directory.

func (CephFs) SetProjectQuota

func (filer CephFs) SetProjectQuota(projectID string, quotaGiB int) error

SetProjectQuota sets or updates the project quota by setting a extended attribute `cephfs.quota.max_bytes` of the project directory on the Ceph filesystem.

See [here](https://docs.ceph.com/docs/master/cephfs/quota/) for more detail.

type CephFsConfig

type CephFsConfig struct {

	// ProjectRoot specifies the top-level CephFS path in which projects are located.
	ProjectRoot string

	// ProjectUser specifies the system username of the project directory owner.
	ProjectUser string

	// ProjectGroup specifies the system groupname of the project directory owner.
	ProjectGroup string
}

CephFsConfig implements the `Config` interface and extends it with configurations that are specific to the CephFS filesystem.

type Cluster

type Cluster struct {
	BlockStorage Space `json:"block_storage"`
}

Cluster of OnTAP

type Config

type Config interface {
}

Config defines interfaces for retriving configuration parameters that are common across different filer systems.

type ExportPolicy

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

ExportPolicy defines the export policy for a volume or a qtree.

type Filer

type Filer interface {
	CreateProject(projectID string, quotaGiB int) error
	CreateHome(username, groupname string, quotaGiB int) error
	DeleteHome(username, groupname string) error
	SetProjectQuota(projectID string, quotaGiB int) error
	SetHomeQuota(username, groupname string, quotaGiB int) error
	GetProjectQuotaInBytes(projectID string) (int64, int64, error)
	GetHomeQuotaInBytes(username, groupname string) (int64, int64, error)
	GetSystemSpaceInBytes() (int64, int64, error)
	GetProjectRoot() string
}

Filer defines the interfaces for provisioning and setting storage space for a project and a personal home directory.

func New

func New(system string, config Config) Filer

New function returns the corresponding File implementation based on the `system` name.

type FreeNas

type FreeNas struct {
	// contains filtered or unexported fields
}

FreeNas implements `Filer` for FreeNAS system.

func (FreeNas) CreateHome

func (filer FreeNas) CreateHome(username, groupname string, quotaGiB int) error

CreateHome is not supported on FreeNAS and therefore it always returns an error.

func (FreeNas) CreateProject

func (filer FreeNas) CreateProject(projectID string, quotaGiB int) error

CreateProject creates a new dataset on the FreeNAS system with the dataset size specified by `quotaGiB`.

func (FreeNas) DeleteHome

func (filer FreeNas) DeleteHome(username, groupname string) error

DeleteHome deletes a home directory as qtree `username` under the volume `groupname`.

func (FreeNas) GetHomeQuotaInBytes

func (filer FreeNas) GetHomeQuotaInBytes(username, groupname string) (int64, int64, error)

GetHomeQuotaInBytes is not supported on FreeNAS and therefore it always returns an error.

func (FreeNas) GetProjectQuotaInBytes

func (filer FreeNas) GetProjectQuotaInBytes(projectID string) (int64, int64, error)

GetProjectQuotaInBytes returns the size of the dataset for a specific project in the unit of byte.

func (FreeNas) GetProjectRoot

func (filer FreeNas) GetProjectRoot() string

GetProjectRoot returns the root path in which projects are hosted on the FreeNas system.

func (FreeNas) GetSystemSpaceInBytes

func (filer FreeNas) GetSystemSpaceInBytes() (int64, int64, error)

GetSystemSpaceInBytes returns the total and used storage space in bytes

func (FreeNas) SetHomeQuota

func (filer FreeNas) SetHomeQuota(username, groupname string, quotaGiB int) error

SetHomeQuota is not supported on FreeNAS and therefore it always returns an error.

func (FreeNas) SetProjectQuota

func (filer FreeNas) SetProjectQuota(projectID string, quotaGiB int) error

SetProjectQuota updates the size of the dataset for the specific dataset.

type FreeNasConfig

type FreeNasConfig struct {
	// ApiURL is the server URL of the OnTAP APIs.
	ApiURL string
	// ApiUser is the username for the basic authentication of the OnTAP API.
	ApiUser string
	// ApiPass is the password for the basic authentication of the OnTAP API.
	ApiPass string
	// ProjectRoot specifies the top-level NAS path in which projects are located.
	ProjectRoot string

	// ProjectUser specifies the system username for the owner of the project directory.
	ProjectUser string
	// ProjectGID specifies the system groupname for the owner of the project directory.
	ProjectGroup string

	// ZfsDatasetPrefix specifies the dataset prefix. It is usually started with the
	// zfs pool name followed by a top-level dataset name.  E.g. /zpool001/project.
	ZfsDatasetPrefix string
}

FreeNasConfig implements the `Config` interface and extends it with configurations that are specific to the FreeNas filer.

func (FreeNasConfig) GetAPIPass

func (c FreeNasConfig) GetAPIPass() string

GetAPIPass returns the password for the API basic authentication.

func (FreeNasConfig) GetAPIURL

func (c FreeNasConfig) GetAPIURL() string

GetAPIURL returns the server URL of the OnTAP API.

func (FreeNasConfig) GetAPIUser

func (c FreeNasConfig) GetAPIUser() string

GetAPIUser returns the username for the API basic authentication.

type Job

type Job struct {
	Link    *Link  `json:"_links"`
	UUID    string `json:"uuid"`
	State   string `json:"state,omitempty"`
	Message string `json:"message,omitempty"`
}

Job detail of the API request.

type Link struct {
	Self struct {
		Href string `json:"href"`
	} `json:"self"`
}

Link of an item for retriving the detail.

type Nas

type Nas struct {
	Path            string       `json:"path,omitempty"`
	UID             int          `json:"uid,omitempty"`
	GID             int          `json:"gid,omitempty"`
	SecurityStyle   string       `json:"security_style,omitempty"`
	UnixPermissions int          `json:"unix_permissions,omitempty"`
	ExportPolicy    ExportPolicy `json:"export_policy,omitempty"`
}

Nas related attribute of OnTAP.

type NetApp

type NetApp struct {
	// contains filtered or unexported fields
}

NetApp implements Filer interface for NetApp OnTAP cluster.

func (NetApp) CreateHome

func (filer NetApp) CreateHome(username, groupname string, quotaGiB int) error

CreateHome creates a home directory as qtree `username` under the volume `groupname`, and assigned the given `quotaGiB` to the qtree.

func (NetApp) CreateProject

func (filer NetApp) CreateProject(projectID string, quotaGiB int) error

CreateProject provisions a project space on the filer with the given quota.

func (NetApp) DeleteHome

func (filer NetApp) DeleteHome(username, groupname string) error

DeleteHome deletes a home directory as qtree `username` under the volume `groupname`.

func (NetApp) GetHomeQuotaInBytes

func (filer NetApp) GetHomeQuotaInBytes(username, groupname string) (quota, usage int64, err error)

GetHomeQuotaInBytes retrieves quota of a user home space in bytes.

func (NetApp) GetProjectQuotaInBytes

func (filer NetApp) GetProjectQuotaInBytes(projectID string) (quota, usage int64, err error)

GetProjectQuotaInBytes retrieves quota of a project in bytes.

func (NetApp) GetProjectRoot

func (filer NetApp) GetProjectRoot() string

GetProjectRoot returns the root path in which projects are hosted on the NetApp filer.

func (NetApp) GetSystemSpaceInBytes

func (filer NetApp) GetSystemSpaceInBytes() (int64, int64, error)

GetSystemSpaceInBytes returns the total and used storage space in bytes

func (NetApp) GetVolumeQuotaReports

func (filer NetApp) GetVolumeQuotaReports(volume string) (reports []*QuotaReport, err error)

GetVolumeQuotaReports returns a list of `QuotaReport`, each refers to the quota limit and usage per qtree.

func (NetApp) SetHomeQuota

func (filer NetApp) SetHomeQuota(username, groupname string, quotaGiB int) error

SetHomeQuota updates the quota of a home directory.

func (NetApp) SetProjectQuota

func (filer NetApp) SetProjectQuota(projectID string, quotaGiB int) error

SetProjectQuota updates the quota of a project space.

type NetAppConfig

type NetAppConfig struct {
	// ApiURL is the server URL of the OnTAP APIs.
	ApiURL string
	// ApiUser is the username for the basic authentication of the OnTAP API.
	ApiUser string
	// ApiPass is the password for the basic authentication of the OnTAP API.
	ApiPass string
	// ProjectRoot specifies the top-level NAS path in which projects are located.
	ProjectRoot string

	// ProjectMode specifies how the project space is allocated. Valid modes are
	// "volume" and "qtree".
	ProjectMode string

	// VolumeProjectQtrees specifies the (FlexGroup) volume name in which project
	// qtrees are located.
	VolumeProjectQtrees string

	// Vserver specifies the name of OnTAP SVM on which the filer APIs will perform.
	Vserver string
	// ProjectUID specifies the system UID of user `project`
	ProjectUID int
	// ProjectGID specifies the system GID of group `project_g`
	ProjectGID int

	// ExportPolicyHome specifies the export policy name of the user home
	ExportPolicyHome string

	// ExportPolicyProject specifies the export policy name of the project
	ExportPolicyProject string
}

NetAppConfig implements the `Config` interface and extends it with configurations that are specific to the NetApp filer.

func (NetAppConfig) GetAPIPass

func (c NetAppConfig) GetAPIPass() string

GetAPIPass returns the password for the API basic authentication.

func (NetAppConfig) GetAPIURL

func (c NetAppConfig) GetAPIURL() string

GetAPIURL returns the server URL of the OnTAP API.

func (NetAppConfig) GetAPIUser

func (c NetAppConfig) GetAPIUser() string

GetAPIUser returns the username for the API basic authentication.

type QTree

type QTree struct {
	ID              int          `json:"id,omitempty"`
	Name            string       `json:"name"`
	Path            string       `json:"path,omitempty"`
	SVM             Record       `json:"svm"`
	Volume          Record       `json:"volume"`
	ExportPolicy    ExportPolicy `json:"export_policy"`
	SecurityStyle   string       `json:"security_style"`
	UnixPermissions int          `json:"unix_permissions"`
	Link            *Link        `json:"_links,omitempty"`
}

QTree of OnTAP

type QoS

type QoS struct {
	Policy QoSPolicy `json:"policy"`
}

QoS contains a Qolity-of-Service policy.

type QoSPolicy

type QoSPolicy struct {
	MaxIOPS int    `json:"max_throughput_iops,omitempty"`
	MaxMBPS int    `json:"max_throughput_mbps,omitempty"`
	UUID    string `json:"uuid,omitempty"`
	Name    string `json:"name,omitempty"`
}

QoSPolicy defines the data structure of the QoS policy.

type QuotaLimit

type QuotaLimit struct {
	HardLimit int64 `json:"hard_limit,omitempty"`
}

QuotaLimit defines the quota limitation.

type QuotaReport

type QuotaReport struct {
	SVM    Record      `json:"svm"`
	Volume Record      `json:"volume"`
	QTree  *Record     `json:"qtree,omitempty"`
	Space  *QuotaUsage `json:"space,omitempty"`
}

QuotaReport defines the quota report

type QuotaRule

type QuotaRule struct {
	SVM    Record      `json:"svm"`
	Volume Record      `json:"volume"`
	QTree  *Record     `json:"qtree,omitempty"`
	Users  *Record     `json:"users,omitempty"`
	Group  *Record     `json:"group,omitempty"`
	Type   string      `json:"type"`
	Space  *QuotaLimit `json:"space,omitempty"`
	Files  *QuotaLimit `json:"files,omitempty"`
	Link   *Link       `json:"_links,omitempty"`
}

QuotaRule of OnTAP

type QuotaUsage

type QuotaUsage struct {
	HardLimit int64 `json:"hard_limit,omitempty"`
	Used      struct {
		Total int64 `json:"total"`
	} `json:"used,omitempty"`
}

QuotaUsage defines the quota limitation.

type Record

type Record struct {
	UUID string `json:"uuid,omitempty"`
	Name string `json:"name,omitempty"`
	Link *Link  `json:"_links,omitempty"`
}

Record of an item within an API namespace.

type Records

type Records struct {
	NumberOfRecords int      `json:"num_records"`
	Records         []Record `json:"records"`
}

Records of the items within an API namespace.

type SVM

type SVM struct {
	UUID       string   `json:"uuid"`
	Name       string   `json:"name"`
	State      string   `json:"state"`
	Aggregates []Record `json:"aggregates"`
}

SVM of OnTAP

type SnapshotConfig

type SnapshotConfig struct {
	ReservePercent int `json:"reserve_percent"`
}

SnapshotConfig of a OnTAP volume.

type Space

type Space struct {
	Size      int64           `json:"size,omitempty"`
	Available int64           `json:"available,omitempty"`
	Used      int64           `json:"used,omitempty"`
	Snapshot  *SnapshotConfig `json:"snapshot,omitempty"`
}

Space information of a OnTAP volume.

type Volume

type Volume struct {
	UUID           string    `json:"uuid,omitempty"`
	Name           string    `json:"name"`
	Type           string    `json:"type"`
	State          string    `json:"state"`
	Size           int64     `json:"size"`
	Style          string    `json:"style"`
	Space          *Space    `json:"space,omitempty"`
	Svm            Record    `json:"svm"`
	Aggregates     []Record  `json:"aggregates"`
	Nas            Nas       `json:"nas"`
	SnapshotPolicy Record    `json:"snapshot_policy"`
	QoS            *QoS      `json:"qos,omitempty"`
	Autosize       *Autosize `json:"autosize,omitempty"`
	Link           *Link     `json:"_links,omitempty"`
}

Volume of OnTAP.

Jump to

Keyboard shortcuts

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