admin

package
v1.0.1-0...-e84a606 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package admin is a convenience layer to support the administration of CephFS volumes, subvolumes, etc.

Unlike the cephfs package this API does not map to APIs provided by ceph libraries themselves. This API is not yet stable and is subject to change.

This package only supports ceph "nautilus" and "octopus" at this time.

Index

Constants

View Source
const (
	// ClonePending is the state of a pending clone.
	ClonePending = CloneState("pending")
	// CloneInProgress is the state of a clone in progress.
	CloneInProgress = CloneState("in-progress")
	// CloneComplete is the state of a complete clone.
	CloneComplete = CloneState("complete")
	// CloneFailed is the state of a failed clone.
	CloneFailed = CloneState("failed")
)
View Source
const (
	// SnapshotCloneFeature indicates a subvolume supports cloning.
	SnapshotCloneFeature = Feature("snapshot-clone")
	// SnapshotAutoprotectFeature indicates a subvolume does not require
	// manually protecting a subvolume before cloning.
	SnapshotAutoprotectFeature = Feature("snapshot-autoprotect")
	// SnapshotRetentionFeature indicates a subvolume supports retaining
	// snapshots on subvolume removal.
	SnapshotRetentionFeature = Feature("snapshot-retention")
)
View Source
const Infinite = specialSize("infinite")

Infinite is a special QuotaSize value that can be used to clear size limits on a subvolume.

View Source
const NoGroup = ""

NoGroup should be used when an optional subvolume group name is not specified.

Variables

View Source
var (
	// ErrStatusNotEmpty may be returned if a call should not have a status
	// string set but one is.
	ErrStatusNotEmpty = errors.New("response status not empty")
	// ErrBodyNotEmpty may be returned if a call should have an empty body but
	// a body value is present.
	ErrBodyNotEmpty = errors.New("response body not empty")
)

Functions

This section is empty.

Types

type ByteCount

type ByteCount uint64

ByteCount represents the size of a volume in bytes.

type CloneOptions

type CloneOptions struct {
	TargetGroup string
	PoolLayout  string
}

CloneOptions are used to specify optional values to be used when creating a new subvolume clone.

type CloneSource

type CloneSource struct {
	Volume    string `json:"volume"`
	Group     string `json:"group"`
	SubVolume string `json:"subvolume"`
	Snapshot  string `json:"snapshot"`
}

CloneSource contains values indicating the source of a clone.

type CloneState

type CloneState string

CloneState is used to define constant values used to determine the state of a clone.

type CloneStatus

type CloneStatus struct {
	State  CloneState  `json:"state"`
	Source CloneSource `json:"source"`
}

CloneStatus reports on the status of a subvolume clone.

type FSAdmin

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

FSAdmin is used to administrate CephFS within a ceph cluster.

func New

func New() (*FSAdmin, error)

New creates an FSAdmin automatically based on the default ceph configuration file. If more customization is needed, create a *rados.Conn as you see fit and use NewFromConn to use that connection with these administrative functions.

func NewFromConn

func NewFromConn(conn RadosCommander) *FSAdmin

NewFromConn creates an FSAdmin management object from a preexisting rados connection. The existing connection can be rados.Conn or any type implementing the RadosCommander interface. This may be useful if the calling layer needs to inject additional logging, error handling, fault injection, etc.

func (*FSAdmin) CancelClone

func (fsa *FSAdmin) CancelClone(volume, group, clone string) error

CancelClone stops the background processes that populate a clone. CancelClone does not delete the clone.

Similar To:

ceph fs clone cancel <volume> --group_name=<group> <clone>

func (*FSAdmin) CloneStatus

func (fsa *FSAdmin) CloneStatus(volume, group, clone string) (*CloneStatus, error)

CloneStatus returns data reporting the status of a subvolume clone.

Similar To:

ceph fs clone status <volume> --group_name=<group> <clone>

func (*FSAdmin) CloneSubVolumeSnapshot

func (fsa *FSAdmin) CloneSubVolumeSnapshot(volume, group, subvolume, snapshot, name string, o *CloneOptions) error

CloneSubVolumeSnapshot clones the specified snapshot from the subvolume. The group, subvolume, and snapshot parameters specify the source for the clone, and only the source. Additional properties of the clone, such as the subvolume group that the clone will be created in and the pool layout may be specified using the clone options parameter.

Similar To:

ceph fs subvolume snapshot clone <volume> --group_name=<group> <subvolume> <snapshot> <name> [...]

func (*FSAdmin) CreateSubVolume

func (fsa *FSAdmin) CreateSubVolume(volume, group, name string, o *SubVolumeOptions) error

CreateSubVolume sends a request to create a CephFS subvolume in a volume, belonging to an optional subvolume group.

Similar To:

ceph fs subvolume create <volume> --group-name=<group> <name> ...

func (*FSAdmin) CreateSubVolumeGroup

func (fsa *FSAdmin) CreateSubVolumeGroup(volume, name string, o *SubVolumeGroupOptions) error

CreateSubVolumeGroup sends a request to create a subvolume group in a volume.

Similar To:

ceph fs subvolumegroup create <volume> <group_name>  ...

func (*FSAdmin) CreateSubVolumeSnapshot

func (fsa *FSAdmin) CreateSubVolumeSnapshot(volume, group, source, name string) error

CreateSubVolumeSnapshot creates a new snapshot from the source subvolume.

Similar To:

ceph fs subvolume snapshot create <volume> --group-name=<group> <source> <name>

func (*FSAdmin) EnumerateVolumes

func (fsa *FSAdmin) EnumerateVolumes() ([]VolumeIdent, error)

EnumerateVolumes returns a list of volume-name volume-id pairs.

func (*FSAdmin) ForceRemoveSubVolume

func (fsa *FSAdmin) ForceRemoveSubVolume(volume, group, name string) error

ForceRemoveSubVolume will delete a CephFS subvolume in a volume and optional subvolume group.

Similar To:

ceph fs subvolume rm <volume> --group-name=<group> <name> --force

func (*FSAdmin) ForceRemoveSubVolumeGroup

func (fsa *FSAdmin) ForceRemoveSubVolumeGroup(volume, name string) error

ForceRemoveSubVolumeGroup will delete a subvolume group in a volume. Similar To:

ceph fs subvolumegroup rm <volume> <group_name> --force

func (*FSAdmin) ForceRemoveSubVolumeSnapshot

func (fsa *FSAdmin) ForceRemoveSubVolumeSnapshot(volume, group, subvolume, name string) error

ForceRemoveSubVolumeSnapshot removes the specified snapshot from the subvolume.

Similar To:

ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name> --force

func (*FSAdmin) ListFileSystems

func (fsa *FSAdmin) ListFileSystems() ([]FSPoolInfo, error)

ListFileSystems lists file systems along with the pools occupied by those file systems.

Similar To:

ceph fs ls

func (*FSAdmin) ListSubVolumeGroups

func (fsa *FSAdmin) ListSubVolumeGroups(volume string) ([]string, error)

ListSubVolumeGroups returns a list of subvolume groups belonging to the specified volume.

Similar To:

ceph fs subvolumegroup ls cephfs <volume>

func (*FSAdmin) ListSubVolumeSnapshots

func (fsa *FSAdmin) ListSubVolumeSnapshots(volume, group, name string) ([]string, error)

ListSubVolumeSnapshots returns a listing of snapshots for a given subvolume.

Similar To:

ceph fs subvolume snapshot ls <volume> --group-name=<group> <name>

func (*FSAdmin) ListSubVolumes

func (fsa *FSAdmin) ListSubVolumes(volume, group string) ([]string, error)

ListSubVolumes returns a list of subvolumes belonging to the volume and optional subvolume group.

Similar To:

ceph fs subvolume ls <volume> --group-name=<group>

func (*FSAdmin) ListVolumes

func (fsa *FSAdmin) ListVolumes() ([]string, error)

ListVolumes return a list of volumes in this Ceph cluster.

Similar To:

ceph fs volume ls

func (*FSAdmin) ProtectSubVolumeSnapshot

func (fsa *FSAdmin) ProtectSubVolumeSnapshot(volume, group, subvolume, name string) error

ProtectSubVolumeSnapshot protects the specified snapshot.

Similar To:

ceph fs subvolume snapshot protect <volume> --group-name=<group> <subvolume> <name>

func (*FSAdmin) RemoveSubVolume

func (fsa *FSAdmin) RemoveSubVolume(volume, group, name string) error

RemoveSubVolume will delete a CephFS subvolume in a volume and optional subvolume group.

Similar To:

ceph fs subvolume rm <volume> --group-name=<group> <name>

func (*FSAdmin) RemoveSubVolumeGroup

func (fsa *FSAdmin) RemoveSubVolumeGroup(volume, name string) error

RemoveSubVolumeGroup will delete a subvolume group in a volume. Similar To:

ceph fs subvolumegroup rm <volume> <group_name>

func (*FSAdmin) RemoveSubVolumeSnapshot

func (fsa *FSAdmin) RemoveSubVolumeSnapshot(volume, group, subvolume, name string) error

RemoveSubVolumeSnapshot removes the specified snapshot from the subvolume.

Similar To:

ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name>

func (*FSAdmin) RemoveSubVolumeWithFlags

func (fsa *FSAdmin) RemoveSubVolumeWithFlags(volume, group, name string, o SubVolRmFlags) error

RemoveSubVolumeWithFlags will delete a CephFS subvolume in a volume and optional subvolume group. This function accepts a SubVolRmFlags type that can be used to specify flags that modify the operations behavior. Equivalent to RemoveSubVolume with no flags set. Equivalent to ForceRemoveSubVolume if only the "Force" flag is set.

Similar To:

ceph fs subvolume rm <volume> --group-name=<group> <name> [...flags...]

func (*FSAdmin) ResizeSubVolume

func (fsa *FSAdmin) ResizeSubVolume(
	volume, group, name string,
	newSize QuotaSize, noShrink bool) (*SubVolumeResizeResult, error)

ResizeSubVolume will resize a CephFS subvolume. The newSize value may be a ByteCount or the special Infinite constant. Setting noShrink to true will prevent reducing the size of the volume below the current used size.

Similar To:

ceph fs subvolume resize <volume> --group-name=<group> <name> ...

func (*FSAdmin) SubVolumeGroupPath

func (fsa *FSAdmin) SubVolumeGroupPath(volume, name string) (string, error)

SubVolumeGroupPath returns the path to the subvolume from the root of the file system.

Similar To:

ceph fs subvolumegroup getpath <volume> <group_name>

func (*FSAdmin) SubVolumeInfo

func (fsa *FSAdmin) SubVolumeInfo(volume, group, name string) (*SubVolumeInfo, error)

SubVolumeInfo returns information about the specified subvolume.

Similar To:

ceph fs subvolume info <volume> --group-name=<group> <name>

func (*FSAdmin) SubVolumePath

func (fsa *FSAdmin) SubVolumePath(volume, group, name string) (string, error)

SubVolumePath returns the path to the subvolume from the root of the file system.

Similar To:

ceph fs subvolume getpath <volume> --group-name=<group> <name>

func (*FSAdmin) SubVolumeSnapshotInfo

func (fsa *FSAdmin) SubVolumeSnapshotInfo(volume, group, subvolume, name string) (*SubVolumeSnapshotInfo, error)

SubVolumeSnapshotInfo returns information about the specified subvolume snapshot.

Similar To:

ceph fs subvolume snapshot info <volume> --group-name=<group> <subvolume> <name>

func (*FSAdmin) UnprotectSubVolumeSnapshot

func (fsa *FSAdmin) UnprotectSubVolumeSnapshot(volume, group, subvolume, name string) error

UnprotectSubVolumeSnapshot removes protection from the specified snapshot.

Similar To:

ceph fs subvolume snapshot unprotect <volume> --group-name=<group> <subvolume> <name>

func (*FSAdmin) VolumeStatus

func (fsa *FSAdmin) VolumeStatus(name string) (*VolumeStatus, error)

VolumeStatus returns a VolumeStatus object for the given volume name.

Similar To:

ceph fs status cephfs <name>

type FSPoolInfo

type FSPoolInfo struct {
	Name           string   `json:"name"`
	MetadataPool   string   `json:"metadata_pool"`
	MetadataPoolID int      `json:"metadata_pool_id"`
	DataPools      []string `json:"data_pools"`
	DataPoolIDs    []int    `json:"data_pool_ids"`
}

FSPoolInfo contains the name of a file system as well as the metadata and data pools. Pool information is available by ID or by name.

type Feature

type Feature string

Feature is used to define constant values for optional features on subvolumes.

type NotImplementedError

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

NotImplementedError error values will be returned in the case that an API call is not available in the version of Ceph that is running in the target cluster.

func (NotImplementedError) End

func (r NotImplementedError) End() error

End returns an error if the response contains an error or nil, indicating that response is no longer needed for processing.

func (NotImplementedError) Error

func (e NotImplementedError) Error() string

Error implements the error interface.

func (NotImplementedError) Ok

func (r NotImplementedError) Ok() bool

Ok returns true if the response contains no error.

func (NotImplementedError) Status

func (r NotImplementedError) Status() string

Status returns the status string value.

func (NotImplementedError) Unwrap

func (r NotImplementedError) Unwrap() error

Unwrap returns the error this response contains.

type NotProtectedError

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

NotProtectedError error values will be returned by CloneSubVolumeSnapshot in the case that the source snapshot needs to be protected but is not. The requirement for a snapshot to be protected prior to cloning varies by Ceph version.

func (NotProtectedError) End

func (r NotProtectedError) End() error

End returns an error if the response contains an error or nil, indicating that response is no longer needed for processing.

func (NotProtectedError) Error

func (r NotProtectedError) Error() string

Error implements the error interface.

func (NotProtectedError) Ok

func (r NotProtectedError) Ok() bool

Ok returns true if the response contains no error.

func (NotProtectedError) Status

func (r NotProtectedError) Status() string

Status returns the status string value.

func (NotProtectedError) Unwrap

func (r NotProtectedError) Unwrap() error

Unwrap returns the error this response contains.

type QuotaSize

type QuotaSize interface {
	// contains filtered or unexported methods
}

QuotaSize interface values can be used to change the size of a volume.

type RadosCommander

type RadosCommander interface {
	MgrCommand(buf [][]byte) ([]byte, string, error)
	MonCommand(buf []byte) ([]byte, string, error)
}

RadosCommander provides an interface to execute JSON-formatted commands that allow the cephfs administrative functions to interact with the Ceph cluster.

type SubVolRmFlags

type SubVolRmFlags struct {
	Force           bool
	RetainSnapshots bool
}

SubVolRmFlags may be used to specify behavior modifying flags when removing sub volumes.

type SubVolumeGroupOptions

type SubVolumeGroupOptions struct {
	Uid        int
	Gid        int
	Mode       int
	PoolLayout string
}

SubVolumeGroupOptions are used to specify optional, non-identifying, values to be used when creating a new subvolume group.

type SubVolumeInfo

type SubVolumeInfo struct {
	Type          string    `json:"type"`
	Path          string    `json:"path"`
	Uid           int       `json:"uid"`
	Gid           int       `json:"gid"`
	Mode          int       `json:"mode"`
	BytesPercent  string    `json:"bytes_pcent"`
	BytesUsed     ByteCount `json:"bytes_used"`
	BytesQuota    QuotaSize `json:"-"`
	DataPool      string    `json:"data_pool"`
	PoolNamespace string    `json:"pool_namespace"`
	Atime         TimeStamp `json:"atime"`
	Mtime         TimeStamp `json:"mtime"`
	Ctime         TimeStamp `json:"ctime"`
	CreatedAt     TimeStamp `json:"created_at"`
	Features      []Feature `json:"features"`
}

SubVolumeInfo reports various informational values about a subvolume.

type SubVolumeOptions

type SubVolumeOptions struct {
	Size              ByteCount
	Uid               int
	Gid               int
	Mode              int
	PoolLayout        string
	NamespaceIsolated bool
}

SubVolumeOptions are used to specify optional, non-identifying, values to be used when creating a new subvolume.

type SubVolumeResizeResult

type SubVolumeResizeResult struct {
	BytesUsed    ByteCount `json:"bytes_used"`
	BytesQuota   ByteCount `json:"bytes_quota"`
	BytesPercent string    `json:"bytes_pcent"`
}

SubVolumeResizeResult reports the size values returned by the ResizeSubVolume function, as reported by Ceph.

type SubVolumeSnapshotInfo

type SubVolumeSnapshotInfo struct {
	CreatedAt        TimeStamp `json:"created_at"`
	DataPool         string    `json:"data_pool"`
	HasPendingClones string    `json:"has_pending_clones"`
	Protected        string    `json:"protected"`
	Size             ByteCount `json:"size"`
}

SubVolumeSnapshotInfo reports various informational values about a subvolume.

type TimeStamp

type TimeStamp struct {
	time.Time
}

TimeStamp abstracts some of the details about date+time stamps returned by ceph via JSON.

func (TimeStamp) String

func (ts TimeStamp) String() string

String returns a string representing the date+time as presented by ceph.

func (*TimeStamp) UnmarshalJSON

func (ts *TimeStamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json Unmarshaler interface.

type VolumeIdent

type VolumeIdent struct {
	Name string
	ID   int64
}

VolumeIdent contains a pair of file system identifying values: the volume name and the volume ID.

type VolumePool

type VolumePool struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	Available uint64 `json:"avail"`
	Used      uint64 `json:"used"`
}

VolumePool reports on the pool status for a CephFS volume.

type VolumeStatus

type VolumeStatus struct {
	MDSVersion string       `json:"mds_version"`
	Pools      []VolumePool `json:"pools"`
}

VolumeStatus reports various properties of a CephFS volume. TODO: Fill in.

Jump to

Keyboard shortcuts

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