admin

package
v0.0.0-...-4d7aede Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 10 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 (
	// StateUnset indicates a subvolume without any state.
	StateUnset = SubVolumeState("")
	// StateInit indicates that the subvolume is in initializing state.
	StateInit = SubVolumeState("init")
	// StatePending indicates that the subvolume is in pending state.
	StatePending = SubVolumeState("pending")
	// StateInProgress indicates that the subvolume is in in-progress state.
	StateInProgress = SubVolumeState("in-progress")
	// StateFailed indicates that the subvolume is in failed state.
	StateFailed = SubVolumeState("failed")
	// StateComplete indicates that the subvolume is in complete state.
	StateComplete = SubVolumeState("complete")
	// StateCanceled indicates that the subvolume is in canceled state.
	StateCanceled = SubVolumeState("canceled")
	// StateSnapRetained indicates that the subvolume is in
	// snapshot-retained state.
	StateSnapRetained = SubVolumeState("snapshot-retained")
)
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 is an alias for commands.ErrStatusNotEmpty
	ErrStatusNotEmpty = commands.ErrStatusNotEmpty
	// ErrBodyNotEmpty is an alias for commands.ErrBodyNotEmpty
	ErrBodyNotEmpty = commands.ErrBodyNotEmpty
)

Functions

This section is empty.

Types

type ByteCount

type ByteCount uint64

ByteCount represents the size of a volume in bytes.

type CloneFailure

type CloneFailure struct {
	Errno  string `json:"errno"`
	ErrStr string `json:"errstr"`
}

CloneFailure reports details of a failure after a subvolume clone failed.

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"`
	// contains filtered or unexported fields
}

CloneStatus reports on the status of a subvolume clone.

func (*CloneStatus) GetFailure

func (cs *CloneStatus) GetFailure() *CloneFailure

GetFailure returns details about the CloneStatus when in CloneFailed state.

Similar To:

Reading the .failure object from the JSON returned by "ceph fs subvolume
snapshot clone"

type DaemonID

type DaemonID uint

DaemonID represents the ID of a cephfs mirroring daemon.

type DaemonStatusFileSystemInfo

type DaemonStatusFileSystemInfo struct {
	FileSystemID   FileSystemID           `json:"filesystem_id"`
	Name           string                 `json:"name"`
	DirectoryCount int64                  `json:"directory_count"`
	Peers          []DaemonStatusPeerInfo `json:"peers"`
}

DaemonStatusFileSystemInfo represents information about a mirrored file system.

type DaemonStatusInfo

type DaemonStatusInfo struct {
	DaemonID    DaemonID                     `json:"daemon_id"`
	FileSystems []DaemonStatusFileSystemInfo `json:"filesystems"`
}

DaemonStatusInfo maps file system IDs to information about that file system.

type DaemonStatusPeer

type DaemonStatusPeer struct {
	ClientName  string `json:"client_name"`
	ClusterName string `json:"cluster_name"`
	FSName      string `json:"fs_name"`
}

DaemonStatusPeer contains fields detailing a remote peer.

type DaemonStatusPeerInfo

type DaemonStatusPeerInfo struct {
	UUID   PeerUUID              `json:"uuid"`
	Remote DaemonStatusPeer      `json:"remote"`
	Stats  DaemonStatusPeerStats `json:"stats"`
}

DaemonStatusPeerInfo contains fields representing information about a remote peer.

type DaemonStatusPeerStats

type DaemonStatusPeerStats struct {
	FailureCount  uint64 `json:"failure_count"`
	RecoveryCount uint64 `json:"recovery_count"`
}

DaemonStatusPeerStats contains fields detailing the a remote peer's stats.

type DaemonStatusResults

type DaemonStatusResults []DaemonStatusInfo

DaemonStatusResults maps mirroring daemon IDs to information about that mirroring daemon.

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) DisableMirroringModule

func (fsa *FSAdmin) DisableMirroringModule() error

DisableMirroringModule will disable the mirroring module for cephfs.

Similar To:

ceph mgr module disable mirroring

func (*FSAdmin) EnableMirroringModule

func (fsa *FSAdmin) EnableMirroringModule(force bool) error

EnableMirroringModule will enable the mirroring module for cephfs.

Similar To:

ceph mgr module enable mirroring [--force]

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) SnapshotMirror

func (fsa *FSAdmin) SnapshotMirror() *SnapshotMirrorAdmin

SnapshotMirror returns a new SnapshotMirrorAdmin to be used for the administration of snapshot mirroring features.

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 FileSystemID

type FileSystemID uint

FileSystemID represents the ID of a cephfs file system.

type NotImplementedError

type NotImplementedError = commands.NotImplementedError

NotImplementedError is an alias for commands.NotImplementedError.

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.

type PeerInfo

type PeerInfo struct {
	ClientName string `json:"client_name"`
	SiteName   string `json:"site_name"`
	FSName     string `json:"fs_name"`
	MonHost    string `json:"mon_host"`
}

PeerInfo includes information about a cephfs mirroring peer.

type PeerListResults

type PeerListResults map[PeerUUID]PeerInfo

PeerListResults maps a peer's UUID to information about that peer.

type PeerUUID

type PeerUUID string

PeerUUID represents the UUID of a cephfs mirroring peer.

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 = ccom.RadosCommander

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

type SnapshotMirrorAdmin

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

SnapshotMirrorAdmin helps administer the snapshot mirroring features of cephfs. Snapshot mirroring is only available in ceph pacific and later.

func (*SnapshotMirrorAdmin) Add

func (sma *SnapshotMirrorAdmin) Add(fsname, path string) error

Add a path in the file system to be mirrored.

Similar To:

ceph fs snapshot mirror add <fs_name> <path>

func (*SnapshotMirrorAdmin) CreatePeerBootstrapToken

func (sma *SnapshotMirrorAdmin) CreatePeerBootstrapToken(
	fsname, client, site string) (string, error)

CreatePeerBootstrapToken returns a token that can be used to create a peering association between this site an another site.

Similar To:

ceph fs snapshot mirror peer_bootstrap create <fs_name> <client_entity> <site-name>

func (*SnapshotMirrorAdmin) DaemonStatus

func (sma *SnapshotMirrorAdmin) DaemonStatus(fsname string) (
	DaemonStatusResults, error)

DaemonStatus returns information on the status of cephfs mirroring daemons associated with the given file system.

Similar To:

ceph fs snapshot mirror daemon status <fs_name>

func (*SnapshotMirrorAdmin) Disable

func (sma *SnapshotMirrorAdmin) Disable(fsname string) error

Disable snapshot mirroring for the given file system.

Similar To:

ceph fs snapshot mirror disable <fs_name>

func (*SnapshotMirrorAdmin) Enable

func (sma *SnapshotMirrorAdmin) Enable(fsname string) error

Enable snapshot mirroring for the given file system.

Similar To:

ceph fs snapshot mirror enable <fs_name>

func (*SnapshotMirrorAdmin) ImportPeerBoostrapToken

func (sma *SnapshotMirrorAdmin) ImportPeerBoostrapToken(fsname, token string) error

ImportPeerBoostrapToken creates an association between another site, one that has provided a token, with the current site.

Similar To:

ceph fs snapshot mirror peer_bootstrap import <fs_name> <token>

func (*SnapshotMirrorAdmin) PeerList

func (sma *SnapshotMirrorAdmin) PeerList(fsname string) (
	PeerListResults, error)

PeerList returns information about peers associated with the given file system.

Similar To:

ceph fs snapshot mirror peer_list <fs_name>

func (*SnapshotMirrorAdmin) Remove

func (sma *SnapshotMirrorAdmin) Remove(fsname, path string) error

Remove a path in the file system from mirroring.

Similar To:

ceph fs snapshot mirror remove <fs_name> <path>

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"`
	State         SubVolumeState `json:"state"`
	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 SubVolumeState

type SubVolumeState string

SubVolumeState is used to define constant value for the state of 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