rebase: use go-ceph v0.3.0

v0.3.0 adds support for rbd.FeatureSet that can be used to parse the
features of an RBD image. This will be used in the followup commit that
adds rbdVolume.getImageInfo().

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2020-05-08 16:07:31 +02:00
committed by mergify[bot]
parent 323cc0e3bb
commit 772d1dfa77
23 changed files with 990 additions and 375 deletions

View File

@ -12,34 +12,93 @@ import (
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
// ImageOptionFormat is the representation of RBD_IMAGE_OPTION_FORMAT from
// librbd
ImageOptionFormat = C.RBD_IMAGE_OPTION_FORMAT
// ImageOptionFeatures is the representation of RBD_IMAGE_OPTION_FEATURES
// from librbd
ImageOptionFeatures = C.RBD_IMAGE_OPTION_FEATURES
// ImageOptionOrder is the representation of RBD_IMAGE_OPTION_ORDER from
// librbd
ImageOptionOrder = C.RBD_IMAGE_OPTION_ORDER
// ImageOptionStripeUnit is the representation of
// RBD_IMAGE_OPTION_STRIPE_UNIT from librbd
ImageOptionStripeUnit = C.RBD_IMAGE_OPTION_STRIPE_UNIT
// ImageOptionStripeCount is the representation of
// RBD_IMAGE_OPTION_STRIPE_COUNT from librbd
ImageOptionStripeCount = C.RBD_IMAGE_OPTION_STRIPE_COUNT
// ImageOptionJournalOrder is the representation of
// RBD_IMAGE_OPTION_JOURNAL_ORDER from librbd
ImageOptionJournalOrder = C.RBD_IMAGE_OPTION_JOURNAL_ORDER
// ImageOptionJournalSplayWidth is the representation of
// RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH from librbd
ImageOptionJournalSplayWidth = C.RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH
// ImageOptionJournalPool is the representation of
// RBD_IMAGE_OPTION_JOURNAL_POOL from librbd
ImageOptionJournalPool = C.RBD_IMAGE_OPTION_JOURNAL_POOL
// ImageOptionFeaturesSet is the representation of
// RBD_IMAGE_OPTION_FEATURES_SET from librbd
ImageOptionFeaturesSet = C.RBD_IMAGE_OPTION_FEATURES_SET
// ImageOptionFeaturesClear is the representation of
// RBD_IMAGE_OPTION_FEATURES_CLEAR from librbd
ImageOptionFeaturesClear = C.RBD_IMAGE_OPTION_FEATURES_CLEAR
// ImageOptionDataPool is the representation of RBD_IMAGE_OPTION_DATA_POOL
// from librbd
ImageOptionDataPool = C.RBD_IMAGE_OPTION_DATA_POOL
// RbdImageOptionFormat deprecated alias for ImageOptionFormat
RbdImageOptionFormat = ImageOptionFormat
// RbdImageOptionFeatures deprecated alias for ImageOptionFeatures
RbdImageOptionFeatures = ImageOptionFeatures
// RbdImageOptionOrder deprecated alias for ImageOptionOrder
RbdImageOptionOrder = ImageOptionOrder
// RbdImageOptionStripeUnit deprecated alias for ImageOptionStripeUnit
RbdImageOptionStripeUnit = ImageOptionStripeUnit
// RbdImageOptionStripeCount deprecated alias for ImageOptionStripeCount
RbdImageOptionStripeCount = ImageOptionStripeCount
// RbdImageOptionJournalOrder deprecated alias for ImageOptionJournalOrder
RbdImageOptionJournalOrder = ImageOptionJournalOrder
// RbdImageOptionJournalSplayWidth deprecated alias for
RbdImageOptionJournalSplayWidth = ImageOptionJournalSplayWidth
// RbdImageOptionJournalPool deprecated alias for ImageOptionJournalPool
RbdImageOptionJournalPool = ImageOptionJournalPool
// RbdImageOptionFeaturesSet deprecated alias for ImageOptionFeaturesSet
RbdImageOptionFeaturesSet = ImageOptionFeaturesSet
// RbdImageOptionFeaturesClear deprecated alias for ImageOptionFeaturesClear
RbdImageOptionFeaturesClear = ImageOptionFeaturesClear
// RbdImageOptionDataPool deprecated alias for ImageOptionDataPool
RbdImageOptionDataPool = ImageOptionDataPool
// introduced with Ceph Mimic
//RbdImageOptionFlatten = C.RBD_IMAGE_OPTION_FLATTEN
)
type RbdImageOptions struct {
// ImageOptions represents a group of configurable image options.
type ImageOptions struct {
options C.rbd_image_options_t
}
type RbdImageOption C.int
// ImageOption values are unique keys for configurable options.
type ImageOption C.int
// revive:disable:exported Deprecated aliases
// RbdImageOptions deprecated alias for ImageOptions
type RbdImageOptions = ImageOptions
// RbdImageOption is a deprecated alias for ImageOption
type RbdImageOption = ImageOption
//revive:enable:exported
// NewRbdImageOptions creates a new RbdImageOptions struct. Call
// RbdImageOptions.Destroy() to free the resources.
//
// Implements:
// void rbd_image_options_create(rbd_image_options_t* opts)
func NewRbdImageOptions() *RbdImageOptions {
rio := &RbdImageOptions{}
func NewRbdImageOptions() *ImageOptions {
rio := &ImageOptions{}
C.rbd_image_options_create(&rio.options)
return rio
}
@ -48,7 +107,7 @@ func NewRbdImageOptions() *RbdImageOptions {
//
// Implements:
// void rbd_image_options_destroy(rbd_image_options_t opts);
func (rio *RbdImageOptions) Destroy() {
func (rio *ImageOptions) Destroy() {
C.rbd_image_options_destroy(rio.options)
}
@ -57,7 +116,7 @@ func (rio *RbdImageOptions) Destroy() {
// Implements:
// int rbd_image_options_set_string(rbd_image_options_t opts, int optname,
// const char* optval);
func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error {
func (rio *ImageOptions) SetString(option ImageOption, value string) error {
c_value := C.CString(value)
defer C.free(unsafe.Pointer(c_value))
@ -75,7 +134,7 @@ func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error
// Implements:
// int rbd_image_options_get_string(rbd_image_options_t opts, int optname,
// char* optval, size_t maxlen);
func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error) {
func (rio *ImageOptions) GetString(option ImageOption) (string, error) {
value := make([]byte, 4096)
ret := C.rbd_image_options_get_string(rio.options, C.int(option),
@ -93,7 +152,7 @@ func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error) {
// Implements:
// int rbd_image_options_set_uint64(rbd_image_options_t opts, int optname,
// const uint64_t optval);
func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error {
func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error {
c_value := C.uint64_t(value)
ret := C.rbd_image_options_set_uint64(rio.options, C.int(option), c_value)
@ -110,7 +169,7 @@ func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error
// Implements:
// int rbd_image_options_get_uint64(rbd_image_options_t opts, int optname,
// uint64_t* optval);
func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error) {
func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) {
var c_value C.uint64_t
ret := C.rbd_image_options_get_uint64(rio.options, C.int(option), &c_value)
@ -126,7 +185,7 @@ func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error) {
// Implements:
// int rbd_image_options_is_set(rbd_image_options_t opts, int optname,
// bool* is_set);
func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error) {
func (rio *ImageOptions) IsSet(option ImageOption) (bool, error) {
var c_set C.bool
ret := C.rbd_image_options_is_set(rio.options, C.int(option), &c_set)
@ -141,7 +200,7 @@ func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error) {
//
// Implements:
// int rbd_image_options_unset(rbd_image_options_t opts, int optname)
func (rio *RbdImageOptions) Unset(option RbdImageOption) error {
func (rio *ImageOptions) Unset(option ImageOption) error {
ret := C.rbd_image_options_unset(rio.options, C.int(option))
if ret != 0 {
return fmt.Errorf("%v, could not unset option %v", getError(ret), option)
@ -154,7 +213,7 @@ func (rio *RbdImageOptions) Unset(option RbdImageOption) error {
//
// Implements:
// void rbd_image_options_clear(rbd_image_options_t opts)
func (rio *RbdImageOptions) Clear() {
func (rio *ImageOptions) Clear() {
C.rbd_image_options_clear(rio.options)
}
@ -163,7 +222,7 @@ func (rio *RbdImageOptions) Clear() {
//
// Implements:
// int rbd_image_options_is_empty(rbd_image_options_t opts)
func (rio *RbdImageOptions) IsEmpty() bool {
func (rio *ImageOptions) IsEmpty() bool {
ret := C.rbd_image_options_is_empty(rio.options)
return ret != 0
}