mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update go-ceph to v0.5.0
as go-ceph is 0.5.0 is released updating the dependency to latest release. more info about release at https://github.com/ceph/go-ceph/releases/tag/v0.5.0 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
5f6fec5f0a
commit
2808d526bb
131
vendor/github.com/ceph/go-ceph/rbd/pool_nautilus.go
generated
vendored
131
vendor/github.com/ceph/go-ceph/rbd/pool_nautilus.go
generated
vendored
@ -84,3 +84,134 @@ func RemovePoolMetadata(ioctx *rados.IOContext, key string) error {
|
||||
ret := C.rbd_pool_metadata_remove(cephIoctx(ioctx), cKey)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
// PoolInit initializes a pool for use by rbd.
|
||||
// This function does not create new pools, rather it prepares the pool
|
||||
// to host rbd images.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_pool_init(rados_ioctx_t io, bool force)
|
||||
func PoolInit(ioctx *rados.IOContext, force bool) error {
|
||||
if ioctx == nil {
|
||||
return ErrNoIOContext
|
||||
}
|
||||
|
||||
ret := C.rbd_pool_init(cephIoctx(ioctx), C.bool(force))
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
// poolStats represents RBD pool stats variable.
|
||||
type poolStats struct {
|
||||
stats C.rbd_pool_stats_t
|
||||
}
|
||||
|
||||
// poolStatsCreate creates a new poolStats struct.
|
||||
//
|
||||
// Implements:
|
||||
// void rbd_pool_stats_create(rbd_pool_stats_t *stats)
|
||||
func poolStatsCreate() *poolStats {
|
||||
poolstats := &poolStats{}
|
||||
C.rbd_pool_stats_create(&poolstats.stats)
|
||||
return poolstats
|
||||
}
|
||||
|
||||
// destroy a poolStats struct and free the associated resources.
|
||||
//
|
||||
// Implements:
|
||||
// void rbd_pool_stats_destroy(rbd_pool_stats_t stats)
|
||||
func (poolstats *poolStats) destroy() {
|
||||
C.rbd_pool_stats_destroy(poolstats.stats)
|
||||
|
||||
if poolstats.stats != nil {
|
||||
poolstats.stats = nil
|
||||
}
|
||||
}
|
||||
|
||||
// PoolStatOption represents a group of configurable pool stat options.
|
||||
type PoolStatOption C.rbd_pool_stat_option_t
|
||||
|
||||
const (
|
||||
// PoolStatOptionImages is the representation of
|
||||
// RBD_POOL_STAT_OPTION_IMAGES from librbd.
|
||||
PoolStatOptionImages = PoolStatOption(C.RBD_POOL_STAT_OPTION_IMAGES)
|
||||
// PoolStatOptionImageProvisionedBytes is the representation of
|
||||
// RBD_POOL_STAT_OPTION_IMAGE_PROVISIONED_BYTES from librbd.
|
||||
PoolStatOptionImageProvisionedBytes = PoolStatOption(C.RBD_POOL_STAT_OPTION_IMAGE_PROVISIONED_BYTES)
|
||||
// PoolStatOptionImageMaxProvisionedBytes is the representation of
|
||||
// RBD_POOL_STAT_OPTION_IMAGE_MAX_PROVISIONED_BYTES from librbd.
|
||||
PoolStatOptionImageMaxProvisionedBytes = PoolStatOption(C.RBD_POOL_STAT_OPTION_IMAGE_MAX_PROVISIONED_BYTES)
|
||||
// PoolStatOptionImageSnapshots is the representation of
|
||||
// RBD_POOL_STAT_OPTION_IMAGE_SNAPSHOTS from librbd.
|
||||
PoolStatOptionImageSnapshots = PoolStatOption(C.RBD_POOL_STAT_OPTION_IMAGE_SNAPSHOTS)
|
||||
// PoolStatOptionTrashImages is the representation of
|
||||
// RBD_POOL_STAT_OPTION_TRASH_IMAGES from librbd.
|
||||
PoolStatOptionTrashImages = PoolStatOption(C.RBD_POOL_STAT_OPTION_TRASH_IMAGES)
|
||||
// PoolStatOptionTrashProvisionedBytes is the representation of
|
||||
// RBD_POOL_STAT_OPTION_TRASH_PROVISIONED_BYTES from librbd.
|
||||
PoolStatOptionTrashProvisionedBytes = PoolStatOption(C.RBD_POOL_STAT_OPTION_TRASH_PROVISIONED_BYTES)
|
||||
// PoolStatOptionTrashMaxProvisionedBytes is the representation of
|
||||
// RBD_POOL_STAT_OPTION_TRASH_MAX_PROVISIONED_BYTES from librbd.
|
||||
PoolStatOptionTrashMaxProvisionedBytes = PoolStatOption(C.RBD_POOL_STAT_OPTION_TRASH_MAX_PROVISIONED_BYTES)
|
||||
// PoolStatOptionTrashSnapshots is the representation of
|
||||
// RBD_POOL_STAT_OPTION_TRASH_SNAPSHOTS from librbd.
|
||||
PoolStatOptionTrashSnapshots = PoolStatOption(C.RBD_POOL_STAT_OPTION_TRASH_SNAPSHOTS)
|
||||
)
|
||||
|
||||
// addPoolStatOption adds the given PoolStatOption to PoolStats.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_pool_stats_option_add_uint64(rbd_pool_stats_t stats, int stat_option, uint64_t* stat_val)
|
||||
func (poolstats *poolStats) addPoolStatOption(option PoolStatOption, val *uint64) error {
|
||||
ret := C.rbd_pool_stats_option_add_uint64(
|
||||
poolstats.stats,
|
||||
C.int(option),
|
||||
(*C.uint64_t)(val))
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
// GetAllPoolStats returns a map of all PoolStatOption(s) to their respective values.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_pool_stats_get(rados_ioctx_t io, rbd_pool_stats_t stats);
|
||||
func GetAllPoolStats(ioctx *rados.IOContext) (map[PoolStatOption]uint64, error) {
|
||||
var omap = make(map[PoolStatOption]uint64)
|
||||
if ioctx == nil {
|
||||
return omap, ErrNoIOContext
|
||||
}
|
||||
|
||||
poolstats := poolStatsCreate()
|
||||
defer func() {
|
||||
poolstats.destroy()
|
||||
}()
|
||||
|
||||
var keys [8]PoolStatOption
|
||||
|
||||
keys[0] = PoolStatOptionImages
|
||||
keys[1] = PoolStatOptionImageProvisionedBytes
|
||||
keys[2] = PoolStatOptionImageMaxProvisionedBytes
|
||||
keys[3] = PoolStatOptionImageSnapshots
|
||||
keys[4] = PoolStatOptionTrashImages
|
||||
keys[5] = PoolStatOptionTrashProvisionedBytes
|
||||
keys[6] = PoolStatOptionTrashMaxProvisionedBytes
|
||||
keys[7] = PoolStatOptionTrashSnapshots
|
||||
|
||||
ovalArray := make([]uint64, len(keys))
|
||||
|
||||
// add option with the address where the respective value would be stored.
|
||||
for i, key := range keys {
|
||||
err := poolstats.addPoolStatOption(key, &ovalArray[i])
|
||||
if err != nil {
|
||||
return omap, err
|
||||
}
|
||||
}
|
||||
|
||||
ret := C.rbd_pool_stats_get(cephIoctx(ioctx), poolstats.stats)
|
||||
if ret < 0 {
|
||||
return omap, getError(ret)
|
||||
}
|
||||
|
||||
for j, key := range keys {
|
||||
omap[key] = ovalArray[j]
|
||||
}
|
||||
return omap, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user