rbd

package
v0.0.0-...-750fe18 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package rbd contains a set of wrappers around Ceph's librbd API.

Index

Constants

View Source
const (
	// RBD image options.
	RbdImageOptionFormat            = C.RBD_IMAGE_OPTION_FORMAT
	RbdImageOptionFeatures          = C.RBD_IMAGE_OPTION_FEATURES
	RbdImageOptionOrder             = C.RBD_IMAGE_OPTION_ORDER
	RbdImageOptionStripeUnit        = C.RBD_IMAGE_OPTION_STRIPE_UNIT
	RbdImageOptionStripeCount       = C.RBD_IMAGE_OPTION_STRIPE_COUNT
	RbdImageOptionJournalOrder      = C.RBD_IMAGE_OPTION_JOURNAL_ORDER
	RbdImageOptionJournalSplayWidth = C.RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH
	RbdImageOptionJournalPool       = C.RBD_IMAGE_OPTION_JOURNAL_POOL
	RbdImageOptionFeaturesSet       = C.RBD_IMAGE_OPTION_FEATURES_SET
	RbdImageOptionFeaturesClear     = C.RBD_IMAGE_OPTION_FEATURES_CLEAR
	RbdImageOptionDataPool          = C.RBD_IMAGE_OPTION_DATA_POOL
)
View Source
const (
	// RBD features.
	RbdFeatureLayering      = C.RBD_FEATURE_LAYERING
	RbdFeatureStripingV2    = C.RBD_FEATURE_STRIPINGV2
	RbdFeatureExclusiveLock = C.RBD_FEATURE_EXCLUSIVE_LOCK
	RbdFeatureObjectMap     = C.RBD_FEATURE_OBJECT_MAP
	RbdFeatureFastDiff      = C.RBD_FEATURE_FAST_DIFF
	RbdFeatureDeepFlatten   = C.RBD_FEATURE_DEEP_FLATTEN
	RbdFeatureJournaling    = C.RBD_FEATURE_JOURNALING
	RbdFeatureDataPool      = C.RBD_FEATURE_DATA_POOL

	RbdFeaturesDefault = C.RBD_FEATURES_DEFAULT

	// Features that make an image inaccessible for read or write by clients that don't understand
	// them.
	RbdFeaturesIncompatible = C.RBD_FEATURES_INCOMPATIBLE

	// Features that make an image unwritable by clients that don't understand them.
	RbdFeaturesRwIncompatible = C.RBD_FEATURES_RW_INCOMPATIBLE

	// Features that may be dynamically enabled or disabled.
	RbdFeaturesMutable = C.RBD_FEATURES_MUTABLE

	// Features that only work when used with a single client using the image for writes.
	RbdFeaturesSingleClient = C.RBD_FEATURES_SINGLE_CLIENT
)

Variables

View Source
var (
	RbdErrorNoIOContext    = errors.New("RBD image does not have an IOContext")
	RbdErrorNoName         = errors.New("RBD image does not have a name")
	RbdErrorSnapshotNoName = errors.New("RBD snapshot does not have a name")
	RbdErrorImageNotOpen   = errors.New("RBD image not open")
	RbdErrorNotFound       = errors.New("RBD image not found")
)

Functions

func GetError

func GetError(err C.int) error

func GetImageNames

func GetImageNames(ioctx *rados.IOContext) (names []string, err error)

GetImageNames returns the list of current RBD images.

func TrashRemove

func TrashRemove(ioctx *rados.IOContext, id string, force bool) error

TrashRemove permanently deletes the trashed RBD with the specified id.

func TrashRestore

func TrashRestore(ioctx *rados.IOContext, id, name string) error

TrashRestore restores the trashed RBD with the specified id back to the pool from whence it came, with the specified new name.

func Version

func Version() (int, int, int)

Types

type Image

type Image struct {
	io.Reader
	io.Writer
	io.Seeker
	io.ReaderAt
	io.WriterAt
	// contains filtered or unexported fields
}

func Create

func Create(ioctx *rados.IOContext, name string, size uint64, order int,
	args ...uint64) (image *Image, err error)

int rbd_create(rados_ioctx_t io, const char *name, uint64_t size, int *order);

But also (for backward compability): int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size,

uint64_t features, int *order);

int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size,

uint64_t features, int *order,
uint64_t stripe_unit, uint64_t stripe_count);

func Create2

func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64,
	order int) (image *Image, err error)

int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size,

uint64_t features, int *order);

func Create3

func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64,
	order int, stripe_unit uint64, stripe_count uint64) (image *Image, err error)

int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size,

uint64_t features, int *order,
uint64_t stripe_unit, uint64_t stripe_count);

func Create4

func Create4(ioctx *rados.IOContext, name string, size uint64, rio *RbdImageOptions) (image *Image, err error)

int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size,

rbd_image_options_t opts);

func GetImage

func GetImage(ioctx *rados.IOContext, name string) *Image

func (*Image) BreakLock

func (image *Image) BreakLock(client string, cookie string) error

int rbd_break_lock(rbd_image_t image, const char *client, const char *cookie);

func (*Image) Clone

func (image *Image) Clone(snapname string, c_ioctx *rados.IOContext, c_name string, features uint64, order int) (*Image, error)

int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,

const char *p_snapname, rados_ioctx_t c_ioctx,
const char *c_name, uint64_t features, int *c_order);

int rbd_clone2(rados_ioctx_t p_ioctx, const char *p_name,

const char *p_snapname, rados_ioctx_t c_ioctx,
const char *c_name, uint64_t features, int *c_order,
uint64_t stripe_unit, int stripe_count);

func (*Image) Close

func (image *Image) Close() error

int rbd_close(rbd_image_t image);

func (*Image) Copy

func (image *Image) Copy(args ...interface{}) error

int rbd_copy(rbd_image_t image, rados_ioctx_t dest_io_ctx, const char *destname); int rbd_copy2(rbd_image_t src, rbd_image_t dest); int rbd_copy_with_progress(rbd_image_t image, rados_ioctx_t dest_p, const char *destname,

librbd_progress_fn_t cb, void *cbdata);

int rbd_copy_with_progress2(rbd_image_t src, rbd_image_t dest,

librbd_progress_fn_t cb, void *cbdata);

func (*Image) CreateSnapshot

func (image *Image) CreateSnapshot(snapname string) (*Snapshot, error)

int rbd_snap_create(rbd_image_t image, const char *snapname);

func (*Image) Discard

func (image *Image) Discard(ofs uint64, length uint64) error

int rbd_discard(rbd_image_t image, uint64_t ofs, uint64_t len);

func (*Image) Flatten

func (image *Image) Flatten() error

int rbd_flatten(rbd_image_t image);

func (*Image) Flush

func (image *Image) Flush() error

int rbd_flush(rbd_image_t image);

func (*Image) GetFeatures

func (image *Image) GetFeatures() (features uint64, err error)

int rbd_get_features(rbd_image_t image, uint64_t *features);

func (*Image) GetOverlap

func (image *Image) GetOverlap() (overlap uint64, err error)

int rbd_get_overlap(rbd_image_t image, uint64_t *overlap);

func (*Image) GetParentInfo

func (image *Image) GetParentInfo(p_pool, p_name, p_snapname []byte) error

int rbd_get_parent_info(rbd_image_t image,

char *parent_pool_name, size_t ppool_namelen, char *parent_name,
size_t pnamelen, char *parent_snap_name, size_t psnap_namelen)

func (*Image) GetSize

func (image *Image) GetSize() (size uint64, err error)

int rbd_size(rbd_image_t image, uint64_t *size);

func (*Image) GetSnapshot

func (image *Image) GetSnapshot(snapname string) *Snapshot

func (*Image) GetSnapshotNames

func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error)

int rbd_snap_list(rbd_image_t image, rbd_snap_info_t *snaps, int *max_snaps); void rbd_snap_list_end(rbd_snap_info_t *snaps);

func (*Image) GetStripeCount

func (image *Image) GetStripeCount() (stripe_count uint64, err error)

int rbd_get_stripe_count(rbd_image_t image, uint64_t *stripe_count);

func (*Image) GetStripeUnit

func (image *Image) GetStripeUnit() (stripe_unit uint64, err error)

int rbd_get_stripe_unit(rbd_image_t image, uint64_t *stripe_unit);

func (*Image) IsOldFormat

func (image *Image) IsOldFormat() (old_format bool, err error)

int rbd_get_old_format(rbd_image_t image, uint8_t *old);

func (*Image) ListChildren

func (image *Image) ListChildren() (pools []string, images []string, err error)

ssize_t rbd_list_children(rbd_image_t image, char *pools, size_t *pools_len,

char *images, size_t *images_len);

func (*Image) ListLockers

func (image *Image) ListLockers() (tag string, lockers []Locker, err error)

ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive,

char *tag, size_t *tag_len,
char *clients, size_t *clients_len,
char *cookies, size_t *cookies_len,
char *addrs, size_t *addrs_len);

func (*Image) LockExclusive

func (image *Image) LockExclusive(cookie string) error

int rbd_lock_exclusive(rbd_image_t image, const char *cookie);

func (*Image) LockShared

func (image *Image) LockShared(cookie string, tag string) error

int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag);

func (*Image) Open

func (image *Image) Open(args ...interface{}) error

int rbd_open(rados_ioctx_t io, const char *name, rbd_image_t *image, const char *snap_name); int rbd_open_read_only(rados_ioctx_t io, const char *name, rbd_image_t *image,

const char *snap_name);

func (*Image) Read

func (image *Image) Read(data []byte) (n int, err error)

ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf); TODO: int64_t rbd_read_iterate(rbd_image_t image, uint64_t ofs, size_t len,

int (*cb)(uint64_t, size_t, const char *, void *), void *arg);

TODO: int rbd_read_iterate2(rbd_image_t image, uint64_t ofs, uint64_t len,

int (*cb)(uint64_t, size_t, const char *, void *), void *arg);

TODO: int rbd_diff_iterate(rbd_image_t image,

const char *fromsnapname,
uint64_t ofs, uint64_t len,
int (*cb)(uint64_t, size_t, int, void *), void *arg);

func (*Image) ReadAt

func (image *Image) ReadAt(data []byte, off int64) (n int, err error)

func (*Image) Remove

func (image *Image) Remove() error

int rbd_remove(rados_ioctx_t io, const char *name); int rbd_remove_with_progress(rados_ioctx_t io, const char *name,

librbd_progress_fn_t cb, void *cbdata);

func (*Image) Rename

func (image *Image) Rename(destname string) error

int rbd_rename(rados_ioctx_t src_io_ctx, const char *srcname, const char *destname);

func (*Image) Resize

func (image *Image) Resize(size uint64) error

int rbd_resize(rbd_image_t image, uint64_t size);

func (*Image) Seek

func (image *Image) Seek(offset int64, whence int) (int64, error)

func (*Image) Stat

func (image *Image) Stat() (info *ImageInfo, err error)

int rbd_stat(rbd_image_t image, rbd_image_info_t *info, size_t infosize);

func (*Image) Trash

func (image *Image) Trash(delay time.Duration) error

Trash will move an image into the RBD trash, where it will be protected (i.e., salvageable) for at least the specified delay.

func (*Image) Unlock

func (image *Image) Unlock(cookie string) error

int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag);

func (*Image) Write

func (image *Image) Write(data []byte) (n int, err error)

ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len, const char *buf);

func (*Image) WriteAt

func (image *Image) WriteAt(data []byte, off int64) (n int, err error)

type ImageInfo

type ImageInfo struct {
	Size              uint64
	Obj_size          uint64
	Num_objs          uint64
	Order             int
	Block_name_prefix string
	Parent_pool       int64
	Parent_name       string
}

type Locker

type Locker struct {
	Client string
	Cookie string
	Addr   string
}

type RBDError

type RBDError int

func (RBDError) Error

func (e RBDError) Error() string

type RbdImageOption

type RbdImageOption C.int

type RbdImageOptions

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

func NewRbdImageOptions

func NewRbdImageOptions() *RbdImageOptions

func (*RbdImageOptions) Clear

func (rio *RbdImageOptions) Clear()

func (*RbdImageOptions) Destroy

func (rio *RbdImageOptions) Destroy()

func (*RbdImageOptions) GetString

func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error)

func (*RbdImageOptions) GetUint64

func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error)

func (*RbdImageOptions) IsEmpty

func (rio *RbdImageOptions) IsEmpty() bool

func (*RbdImageOptions) IsSet

func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error)

func (*RbdImageOptions) SetString

func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error

func (*RbdImageOptions) SetUint64

func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error

func (*RbdImageOptions) Unset

func (rio *RbdImageOptions) Unset(option RbdImageOption) error

type SnapInfo

type SnapInfo struct {
	Id   uint64
	Size uint64
	Name string
}

type Snapshot

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

func (*Snapshot) IsProtected

func (snapshot *Snapshot) IsProtected() (bool, error)

int rbd_snap_is_protected(rbd_image_t image, const char *snap_name,

int *is_protected);

func (*Snapshot) Protect

func (snapshot *Snapshot) Protect() error

int rbd_snap_protect(rbd_image_t image, const char *snap_name);

func (*Snapshot) Remove

func (snapshot *Snapshot) Remove() error

int rbd_snap_remove(rbd_image_t image, const char *snapname);

func (*Snapshot) Rollback

func (snapshot *Snapshot) Rollback() error

int rbd_snap_rollback(rbd_image_t image, const char *snapname); int rbd_snap_rollback_with_progress(rbd_image_t image, const char *snapname,

librbd_progress_fn_t cb, void *cbdata);

func (*Snapshot) Set

func (snapshot *Snapshot) Set() error

int rbd_snap_set(rbd_image_t image, const char *snapname);

func (*Snapshot) Unprotect

func (snapshot *Snapshot) Unprotect() error

int rbd_snap_unprotect(rbd_image_t image, const char *snap_name);

type TrashInfo

type TrashInfo struct {
	Id               string    // Id string, required to remove / restore trashed RBDs.
	Name             string    // Original name of trashed RBD.
	DeletionTime     time.Time // Date / time at which the RBD was moved to the trash.
	DefermentEndTime time.Time // Date / time after which the trashed RBD may be permanently deleted.
}

TrashInfo contains information about trashed RBDs.

func GetTrashList

func GetTrashList(ioctx *rados.IOContext) ([]TrashInfo, error)

GetTrashList returns a slice of TrashInfo structs, containing information about all RBD images currently residing in the trash.

Jump to

Keyboard shortcuts

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