rebase: bump github.com/ceph/go-ceph from 0.20.0 to 0.21.0

Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.20.0 to 0.21.0.
- [Release notes](https://github.com/ceph/go-ceph/releases)
- [Changelog](https://github.com/ceph/go-ceph/blob/master/docs/release-process.md)
- [Commits](https://github.com/ceph/go-ceph/compare/v0.20.0...v0.21.0)

---
updated-dependencies:
- dependency-name: github.com/ceph/go-ceph
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot] 2023-04-26 07:05:57 +00:00 committed by mergify[bot]
parent c8f6878570
commit d05847ee73
64 changed files with 1255 additions and 488 deletions

2
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.18.6 github.com/aws/aws-sdk-go-v2/service/sts v1.18.6
github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000
// TODO: API for managing subvolume metadata and snapshot metadata requires `ceph_ci_untested` build-tag // TODO: API for managing subvolume metadata and snapshot metadata requires `ceph_ci_untested` build-tag
github.com/ceph/go-ceph v0.20.0 github.com/ceph/go-ceph v0.21.0
github.com/container-storage-interface/spec v1.8.0 github.com/container-storage-interface/spec v1.8.0
github.com/csi-addons/replication-lib-utils v0.2.0 github.com/csi-addons/replication-lib-utils v0.2.0
github.com/csi-addons/spec v0.2.0 github.com/csi-addons/spec v0.2.0

4
go.sum
View File

@ -195,8 +195,8 @@ github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8
github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE=
github.com/ceph/go-ceph v0.20.0 h1:weYE7zoVrIBk9bIVq8jS9z3RukGlnZwFGCth7Tu1ssU= github.com/ceph/go-ceph v0.21.0 h1:nx+6FARWQqQ3ctSVwljeeauh0wgyVvd17i23d75mpA8=
github.com/ceph/go-ceph v0.20.0/go.mod h1:/4iZyaN5wTpIFMEKO6GU3xX3vHnyvd2Fcdf05n9VuD0= github.com/ceph/go-ceph v0.21.0/go.mod h1:574HYNbG0RZV7lBemoCIxrQEUlo/1BzN42y5NgDr4vg=
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=

View File

@ -28,7 +28,8 @@ type CloneOptions struct {
// specified using the clone options parameter. // specified using the clone options parameter.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot clone <volume> --group_name=<group> <subvolume> <snapshot> <name> [...] //
// ceph fs subvolume snapshot clone <volume> --group_name=<group> <subvolume> <snapshot> <name> [...]
func (fsa *FSAdmin) CloneSubVolumeSnapshot(volume, group, subvolume, snapshot, name string, o *CloneOptions) error { func (fsa *FSAdmin) CloneSubVolumeSnapshot(volume, group, subvolume, snapshot, name string, o *CloneOptions) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot clone", "prefix": "fs subvolume snapshot clone",
@ -114,7 +115,8 @@ func parseCloneStatus(res response) (*CloneStatus, error) {
// CloneStatus returns data reporting the status of a subvolume clone. // CloneStatus returns data reporting the status of a subvolume clone.
// //
// Similar To: // Similar To:
// ceph fs clone status <volume> --group_name=<group> <clone> //
// ceph fs clone status <volume> --group_name=<group> <clone>
func (fsa *FSAdmin) CloneStatus(volume, group, clone string) (*CloneStatus, error) { func (fsa *FSAdmin) CloneStatus(volume, group, clone string) (*CloneStatus, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs clone status", "prefix": "fs clone status",
@ -132,7 +134,8 @@ func (fsa *FSAdmin) CloneStatus(volume, group, clone string) (*CloneStatus, erro
// CancelClone does not delete the clone. // CancelClone does not delete the clone.
// //
// Similar To: // Similar To:
// ceph fs clone cancel <volume> --group_name=<group> <clone> //
// ceph fs clone cancel <volume> --group_name=<group> <clone>
func (fsa *FSAdmin) CancelClone(volume, group, clone string) error { func (fsa *FSAdmin) CancelClone(volume, group, clone string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs clone cancel", "prefix": "fs clone cancel",

View File

@ -3,8 +3,9 @@ package admin
// GetFailure returns details about the CloneStatus when in CloneFailed state. // GetFailure returns details about the CloneStatus when in CloneFailed state.
// //
// Similar To: // Similar To:
// Reading the .failure object from the JSON returned by "ceph fs subvolume //
// snapshot clone" // Reading the .failure object from the JSON returned by "ceph fs subvolume
// snapshot clone"
func (cs *CloneStatus) GetFailure() *CloneFailure { func (cs *CloneStatus) GetFailure() *CloneFailure {
return cs.failure return cs.failure
} }

View File

@ -21,6 +21,9 @@ type FSAdmin struct {
// configuration file. If more customization is needed, create a // configuration file. If more customization is needed, create a
// *rados.Conn as you see fit and use NewFromConn to use that // *rados.Conn as you see fit and use NewFromConn to use that
// connection with these administrative functions. // connection with these administrative functions.
//
// Deprecated: Use NewFromConn instead of New. The New function does not expose
// the rados connection and therefore can not be deterministically cleaned up.
func New() (*FSAdmin, error) { func New() (*FSAdmin, error) {
conn, err := rados.NewConn() conn, err := rados.NewConn()
if err != nil { if err != nil {

View File

@ -7,7 +7,8 @@ package admin
// an optional subvolume group based on provided key name. // an optional subvolume group based on provided key name.
// //
// Similar To: // Similar To:
// ceph fs subvolume metadata get <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>] //
// ceph fs subvolume metadata get <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) GetMetadata(volume, group, subvolume, key string) (string, error) { func (fsa *FSAdmin) GetMetadata(volume, group, subvolume, key string) (string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume metadata get", "prefix": "fs subvolume metadata get",
@ -28,7 +29,8 @@ func (fsa *FSAdmin) GetMetadata(volume, group, subvolume, key string) (string, e
// an optional subvolume group as a key-value pair. // an optional subvolume group as a key-value pair.
// //
// Similar To: // Similar To:
// ceph fs subvolume metadata set <vol_name> <sub_name> <key_name> <value> [--group_name <subvol_group_name>] //
// ceph fs subvolume metadata set <vol_name> <sub_name> <key_name> <value> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) SetMetadata(volume, group, subvolume, key, value string) error { func (fsa *FSAdmin) SetMetadata(volume, group, subvolume, key, value string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume metadata set", "prefix": "fs subvolume metadata set",
@ -50,7 +52,8 @@ func (fsa *FSAdmin) SetMetadata(volume, group, subvolume, key, value string) err
// belonging to an optional subvolume group using the metadata key. // belonging to an optional subvolume group using the metadata key.
// //
// Similar To: // Similar To:
// ceph fs subvolume metadata rm <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>] //
// ceph fs subvolume metadata rm <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) RemoveMetadata(volume, group, subvolume, key string) error { func (fsa *FSAdmin) RemoveMetadata(volume, group, subvolume, key string) error {
return fsa.rmSubVolumeMetadata(volume, group, subvolume, key, commonRmFlags{}) return fsa.rmSubVolumeMetadata(volume, group, subvolume, key, commonRmFlags{})
} }
@ -60,7 +63,8 @@ func (fsa *FSAdmin) RemoveMetadata(volume, group, subvolume, key string) error {
// the metadata key. // the metadata key.
// //
// Similar To: // Similar To:
// ceph fs subvolume metadata rm <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>] --force //
// ceph fs subvolume metadata rm <vol_name> <sub_name> <key_name> [--group_name <subvol_group_name>] --force
func (fsa *FSAdmin) ForceRemoveMetadata(volume, group, subvolume, key string) error { func (fsa *FSAdmin) ForceRemoveMetadata(volume, group, subvolume, key string) error {
return fsa.rmSubVolumeMetadata(volume, group, subvolume, key, commonRmFlags{force: true}) return fsa.rmSubVolumeMetadata(volume, group, subvolume, key, commonRmFlags{force: true})
} }
@ -85,7 +89,8 @@ func (fsa *FSAdmin) rmSubVolumeMetadata(volume, group, subvolume, key string, o
// in a volume belonging to an optional subvolume group. // in a volume belonging to an optional subvolume group.
// //
// Similar To: // Similar To:
// ceph fs subvolume metadata ls <vol_name> <sub_name> [--group_name <subvol_group_name>] //
// ceph fs subvolume metadata ls <vol_name> <sub_name> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) ListMetadata(volume, group, subvolume string) (map[string]string, error) { func (fsa *FSAdmin) ListMetadata(volume, group, subvolume string) (map[string]string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume metadata ls", "prefix": "fs subvolume metadata ls",

View File

@ -9,7 +9,8 @@ const mirroring = "mirroring"
// EnableMirroringModule will enable the mirroring module for cephfs. // EnableMirroringModule will enable the mirroring module for cephfs.
// //
// Similar To: // Similar To:
// ceph mgr module enable mirroring [--force] //
// ceph mgr module enable mirroring [--force]
func (fsa *FSAdmin) EnableMirroringModule(force bool) error { func (fsa *FSAdmin) EnableMirroringModule(force bool) error {
mgradmin := manager.NewFromConn(fsa.conn) mgradmin := manager.NewFromConn(fsa.conn)
return mgradmin.EnableModule(mirroring, force) return mgradmin.EnableModule(mirroring, force)
@ -18,7 +19,8 @@ func (fsa *FSAdmin) EnableMirroringModule(force bool) error {
// DisableMirroringModule will disable the mirroring module for cephfs. // DisableMirroringModule will disable the mirroring module for cephfs.
// //
// Similar To: // Similar To:
// ceph mgr module disable mirroring //
// ceph mgr module disable mirroring
func (fsa *FSAdmin) DisableMirroringModule() error { func (fsa *FSAdmin) DisableMirroringModule() error {
mgradmin := manager.NewFromConn(fsa.conn) mgradmin := manager.NewFromConn(fsa.conn)
return mgradmin.DisableModule(mirroring) return mgradmin.DisableModule(mirroring)

View File

@ -20,7 +20,8 @@ func (fsa *FSAdmin) SnapshotMirror() *SnapshotMirrorAdmin {
// Enable snapshot mirroring for the given file system. // Enable snapshot mirroring for the given file system.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror enable <fs_name> //
// ceph fs snapshot mirror enable <fs_name>
func (sma *SnapshotMirrorAdmin) Enable(fsname string) error { func (sma *SnapshotMirrorAdmin) Enable(fsname string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs snapshot mirror enable", "prefix": "fs snapshot mirror enable",
@ -33,7 +34,8 @@ func (sma *SnapshotMirrorAdmin) Enable(fsname string) error {
// Disable snapshot mirroring for the given file system. // Disable snapshot mirroring for the given file system.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror disable <fs_name> //
// ceph fs snapshot mirror disable <fs_name>
func (sma *SnapshotMirrorAdmin) Disable(fsname string) error { func (sma *SnapshotMirrorAdmin) Disable(fsname string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs snapshot mirror disable", "prefix": "fs snapshot mirror disable",
@ -46,7 +48,8 @@ func (sma *SnapshotMirrorAdmin) Disable(fsname string) error {
// Add a path in the file system to be mirrored. // Add a path in the file system to be mirrored.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror add <fs_name> <path> //
// ceph fs snapshot mirror add <fs_name> <path>
func (sma *SnapshotMirrorAdmin) Add(fsname, path string) error { func (sma *SnapshotMirrorAdmin) Add(fsname, path string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs snapshot mirror add", "prefix": "fs snapshot mirror add",
@ -60,7 +63,8 @@ func (sma *SnapshotMirrorAdmin) Add(fsname, path string) error {
// Remove a path in the file system from mirroring. // Remove a path in the file system from mirroring.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror remove <fs_name> <path> //
// ceph fs snapshot mirror remove <fs_name> <path>
func (sma *SnapshotMirrorAdmin) Remove(fsname, path string) error { func (sma *SnapshotMirrorAdmin) Remove(fsname, path string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs snapshot mirror remove", "prefix": "fs snapshot mirror remove",
@ -79,7 +83,8 @@ type bootstrapTokenResponse struct {
// a peering association between this site an another site. // a peering association between this site an another site.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror peer_bootstrap create <fs_name> <client_entity> <site-name> //
// ceph fs snapshot mirror peer_bootstrap create <fs_name> <client_entity> <site-name>
func (sma *SnapshotMirrorAdmin) CreatePeerBootstrapToken( func (sma *SnapshotMirrorAdmin) CreatePeerBootstrapToken(
fsname, client, site string) (string, error) { fsname, client, site string) (string, error) {
m := map[string]string{ m := map[string]string{
@ -100,7 +105,8 @@ func (sma *SnapshotMirrorAdmin) CreatePeerBootstrapToken(
// that has provided a token, with the current site. // that has provided a token, with the current site.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror peer_bootstrap import <fs_name> <token> //
// ceph fs snapshot mirror peer_bootstrap import <fs_name> <token>
func (sma *SnapshotMirrorAdmin) ImportPeerBoostrapToken(fsname, token string) error { func (sma *SnapshotMirrorAdmin) ImportPeerBoostrapToken(fsname, token string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs snapshot mirror peer_bootstrap import", "prefix": "fs snapshot mirror peer_bootstrap import",
@ -170,7 +176,8 @@ func parseDaemonStatus(res response) (DaemonStatusResults, error) {
// associated with the given file system. // associated with the given file system.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror daemon status <fs_name> //
// ceph fs snapshot mirror daemon status <fs_name>
func (sma *SnapshotMirrorAdmin) DaemonStatus(fsname string) ( func (sma *SnapshotMirrorAdmin) DaemonStatus(fsname string) (
DaemonStatusResults, error) { DaemonStatusResults, error) {
// --- // ---
@ -204,7 +211,8 @@ func parsePeerList(res response) (PeerListResults, error) {
// PeerList returns information about peers associated with the given file system. // PeerList returns information about peers associated with the given file system.
// //
// Similar To: // Similar To:
// ceph fs snapshot mirror peer_list <fs_name> //
// ceph fs snapshot mirror peer_list <fs_name>
func (sma *SnapshotMirrorAdmin) PeerList(fsname string) ( func (sma *SnapshotMirrorAdmin) PeerList(fsname string) (
PeerListResults, error) { PeerListResults, error) {
// --- // ---

46
vendor/github.com/ceph/go-ceph/cephfs/admin/pin.go generated vendored Normal file
View File

@ -0,0 +1,46 @@
//go:build !nautilus && ceph_preview
// +build !nautilus,ceph_preview
package admin
// PinSubVolume pins subvolume to ranks according to policies. A valid pin
// setting value depends on the type of pin as described in the docs from
// https://docs.ceph.com/en/latest/cephfs/multimds/#cephfs-pinning and
// https://docs.ceph.com/en/latest/cephfs/multimds/#setting-subtree-partitioning-policies
//
// Similar To:
//
// ceph fs subvolume pin <vol_name> <sub_name> <pin_type> <pin_setting>
func (fsa *FSAdmin) PinSubVolume(volume, subvolume, pintype, pinsetting string) (string, error) {
m := map[string]string{
"prefix": "fs subvolume pin",
"format": "json",
"vol_name": volume,
"sub_name": subvolume,
"pin_type": pintype,
"pin_setting": pinsetting,
}
return parsePathResponse(fsa.marshalMgrCommand(m))
}
// PinSubVolumeGroup pins subvolume to ranks according to policies. A valid pin
// setting value depends on the type of pin as described in the docs from
// https://docs.ceph.com/en/latest/cephfs/multimds/#cephfs-pinning and
// https://docs.ceph.com/en/latest/cephfs/multimds/#setting-subtree-partitioning-policies
//
// Similar To:
//
// ceph fs subvolumegroup pin <vol_name> <group_name> <pin_type> <pin_setting>
func (fsa *FSAdmin) PinSubVolumeGroup(volume, group, pintype, pinsetting string) (string, error) {
m := map[string]string{
"prefix": "fs subvolumegroup pin",
"format": "json",
"vol_name": volume,
"group_name": group,
"pin_type": pintype,
"pin_setting": pinsetting,
}
return parsePathResponse(fsa.marshalMgrCommand(m))
}

View File

@ -7,7 +7,8 @@ package admin
// volume belonging to an optional subvolume group based on provided key name. // volume belonging to an optional subvolume group based on provided key name.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot metadata get <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>] //
// ceph fs subvolume snapshot metadata get <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) GetSnapshotMetadata(volume, group, subvolume, snapname, key string) (string, error) { func (fsa *FSAdmin) GetSnapshotMetadata(volume, group, subvolume, snapname, key string) (string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot metadata get", "prefix": "fs subvolume snapshot metadata get",
@ -29,7 +30,8 @@ func (fsa *FSAdmin) GetSnapshotMetadata(volume, group, subvolume, snapname, key
// volume belonging to an optional subvolume group as a key-value pair. // volume belonging to an optional subvolume group as a key-value pair.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot metadata set <vol_name> <sub_name> <snap_name> <key_name> <value> [--group_name <subvol_group_name>] //
// ceph fs subvolume snapshot metadata set <vol_name> <sub_name> <snap_name> <key_name> <value> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) SetSnapshotMetadata(volume, group, subvolume, snapname, key, value string) error { func (fsa *FSAdmin) SetSnapshotMetadata(volume, group, subvolume, snapname, key, value string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot metadata set", "prefix": "fs subvolume snapshot metadata set",
@ -53,7 +55,8 @@ func (fsa *FSAdmin) SetSnapshotMetadata(volume, group, subvolume, snapname, key,
// metadata key. // metadata key.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot metadata rm <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>] //
// ceph fs subvolume snapshot metadata rm <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) RemoveSnapshotMetadata(volume, group, subvolume, snapname, key string) error { func (fsa *FSAdmin) RemoveSnapshotMetadata(volume, group, subvolume, snapname, key string) error {
return fsa.rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key, commonRmFlags{}) return fsa.rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key, commonRmFlags{})
} }
@ -63,7 +66,8 @@ func (fsa *FSAdmin) RemoveSnapshotMetadata(volume, group, subvolume, snapname, k
// subvolume group using the metadata key. // subvolume group using the metadata key.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot metadata rm <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>] --force //
// ceph fs subvolume snapshot metadata rm <vol_name> <sub_name> <snap_name> <key_name> [--group_name <subvol_group_name>] --force
func (fsa *FSAdmin) ForceRemoveSnapshotMetadata(volume, group, subvolume, snapname, key string) error { func (fsa *FSAdmin) ForceRemoveSnapshotMetadata(volume, group, subvolume, snapname, key string) error {
return fsa.rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key, commonRmFlags{force: true}) return fsa.rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapname, key, commonRmFlags{force: true})
} }
@ -89,7 +93,8 @@ func (fsa *FSAdmin) rmSubVolumeSnapShotMetadata(volume, group, subvolume, snapna
// snapshot in a volume belonging to an optional subvolume group. // snapshot in a volume belonging to an optional subvolume group.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot metadata ls <vol_name> <sub_name> <snap_name> [--group_name <subvol_group_name>] //
// ceph fs subvolume snapshot metadata ls <vol_name> <sub_name> <snap_name> [--group_name <subvol_group_name>]
func (fsa *FSAdmin) ListSnapshotMetadata(volume, group, subvolume, snapname string) (map[string]string, error) { func (fsa *FSAdmin) ListSnapshotMetadata(volume, group, subvolume, snapname string) (map[string]string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot metadata ls", "prefix": "fs subvolume snapshot metadata ls",

View File

@ -53,7 +53,8 @@ const NoGroup = ""
// belonging to an optional subvolume group. // belonging to an optional subvolume group.
// //
// Similar To: // Similar To:
// ceph fs subvolume create <volume> --group-name=<group> <name> ... //
// ceph fs subvolume create <volume> --group-name=<group> <name> ...
func (fsa *FSAdmin) CreateSubVolume(volume, group, name string, o *SubVolumeOptions) error { func (fsa *FSAdmin) CreateSubVolume(volume, group, name string, o *SubVolumeOptions) error {
if o == nil { if o == nil {
o = &SubVolumeOptions{} o = &SubVolumeOptions{}
@ -66,7 +67,8 @@ func (fsa *FSAdmin) CreateSubVolume(volume, group, name string, o *SubVolumeOpti
// optional subvolume group. // optional subvolume group.
// //
// Similar To: // Similar To:
// ceph fs subvolume ls <volume> --group-name=<group> //
// ceph fs subvolume ls <volume> --group-name=<group>
func (fsa *FSAdmin) ListSubVolumes(volume, group string) ([]string, error) { func (fsa *FSAdmin) ListSubVolumes(volume, group string) ([]string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume ls", "prefix": "fs subvolume ls",
@ -83,7 +85,8 @@ func (fsa *FSAdmin) ListSubVolumes(volume, group string) ([]string, error) {
// subvolume group. // subvolume group.
// //
// Similar To: // Similar To:
// ceph fs subvolume rm <volume> --group-name=<group> <name> //
// ceph fs subvolume rm <volume> --group-name=<group> <name>
func (fsa *FSAdmin) RemoveSubVolume(volume, group, name string) error { func (fsa *FSAdmin) RemoveSubVolume(volume, group, name string) error {
return fsa.RemoveSubVolumeWithFlags(volume, group, name, SubVolRmFlags{}) return fsa.RemoveSubVolumeWithFlags(volume, group, name, SubVolRmFlags{})
} }
@ -92,7 +95,8 @@ func (fsa *FSAdmin) RemoveSubVolume(volume, group, name string) error {
// subvolume group. // subvolume group.
// //
// Similar To: // Similar To:
// ceph fs subvolume rm <volume> --group-name=<group> <name> --force //
// ceph fs subvolume rm <volume> --group-name=<group> <name> --force
func (fsa *FSAdmin) ForceRemoveSubVolume(volume, group, name string) error { func (fsa *FSAdmin) ForceRemoveSubVolume(volume, group, name string) error {
return fsa.RemoveSubVolumeWithFlags(volume, group, name, SubVolRmFlags{Force: true}) return fsa.RemoveSubVolumeWithFlags(volume, group, name, SubVolRmFlags{Force: true})
} }
@ -104,7 +108,8 @@ func (fsa *FSAdmin) ForceRemoveSubVolume(volume, group, name string) error {
// Equivalent to ForceRemoveSubVolume if only the "Force" flag is set. // Equivalent to ForceRemoveSubVolume if only the "Force" flag is set.
// //
// Similar To: // Similar To:
// ceph fs subvolume rm <volume> --group-name=<group> <name> [...flags...] //
// ceph fs subvolume rm <volume> --group-name=<group> <name> [...flags...]
func (fsa *FSAdmin) RemoveSubVolumeWithFlags(volume, group, name string, o SubVolRmFlags) error { func (fsa *FSAdmin) RemoveSubVolumeWithFlags(volume, group, name string, o SubVolRmFlags) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume rm", "prefix": "fs subvolume rm",
@ -141,7 +146,8 @@ type SubVolumeResizeResult struct {
// prevent reducing the size of the volume below the current used size. // prevent reducing the size of the volume below the current used size.
// //
// Similar To: // Similar To:
// ceph fs subvolume resize <volume> --group-name=<group> <name> ... //
// ceph fs subvolume resize <volume> --group-name=<group> <name> ...
func (fsa *FSAdmin) ResizeSubVolume( func (fsa *FSAdmin) ResizeSubVolume(
volume, group, name string, volume, group, name string,
newSize QuotaSize, noShrink bool) (*SubVolumeResizeResult, error) { newSize QuotaSize, noShrink bool) (*SubVolumeResizeResult, error) {
@ -166,7 +172,8 @@ func (fsa *FSAdmin) ResizeSubVolume(
// SubVolumePath returns the path to the subvolume from the root of the file system. // SubVolumePath returns the path to the subvolume from the root of the file system.
// //
// Similar To: // Similar To:
// ceph fs subvolume getpath <volume> --group-name=<group> <name> //
// ceph fs subvolume getpath <volume> --group-name=<group> <name>
func (fsa *FSAdmin) SubVolumePath(volume, group, name string) (string, error) { func (fsa *FSAdmin) SubVolumePath(volume, group, name string) (string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume getpath", "prefix": "fs subvolume getpath",
@ -258,7 +265,8 @@ func parseSubVolumeInfo(res response) (*SubVolumeInfo, error) {
// SubVolumeInfo returns information about the specified subvolume. // SubVolumeInfo returns information about the specified subvolume.
// //
// Similar To: // Similar To:
// ceph fs subvolume info <volume> --group-name=<group> <name> //
// ceph fs subvolume info <volume> --group-name=<group> <name>
func (fsa *FSAdmin) SubVolumeInfo(volume, group, name string) (*SubVolumeInfo, error) { func (fsa *FSAdmin) SubVolumeInfo(volume, group, name string) (*SubVolumeInfo, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume info", "prefix": "fs subvolume info",
@ -275,7 +283,8 @@ func (fsa *FSAdmin) SubVolumeInfo(volume, group, name string) (*SubVolumeInfo, e
// CreateSubVolumeSnapshot creates a new snapshot from the source subvolume. // CreateSubVolumeSnapshot creates a new snapshot from the source subvolume.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot create <volume> --group-name=<group> <source> <name> //
// ceph fs subvolume snapshot create <volume> --group-name=<group> <source> <name>
func (fsa *FSAdmin) CreateSubVolumeSnapshot(volume, group, source, name string) error { func (fsa *FSAdmin) CreateSubVolumeSnapshot(volume, group, source, name string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot create", "prefix": "fs subvolume snapshot create",
@ -293,7 +302,8 @@ func (fsa *FSAdmin) CreateSubVolumeSnapshot(volume, group, source, name string)
// RemoveSubVolumeSnapshot removes the specified snapshot from the subvolume. // RemoveSubVolumeSnapshot removes the specified snapshot from the subvolume.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name> //
// ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name>
func (fsa *FSAdmin) RemoveSubVolumeSnapshot(volume, group, subvolume, name string) error { func (fsa *FSAdmin) RemoveSubVolumeSnapshot(volume, group, subvolume, name string) error {
return fsa.rmSubVolumeSnapshot(volume, group, subvolume, name, commonRmFlags{}) return fsa.rmSubVolumeSnapshot(volume, group, subvolume, name, commonRmFlags{})
} }
@ -301,7 +311,8 @@ func (fsa *FSAdmin) RemoveSubVolumeSnapshot(volume, group, subvolume, name strin
// ForceRemoveSubVolumeSnapshot removes the specified snapshot from the subvolume. // ForceRemoveSubVolumeSnapshot removes the specified snapshot from the subvolume.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name> --force //
// ceph fs subvolume snapshot rm <volume> --group-name=<group> <subvolume> <name> --force
func (fsa *FSAdmin) ForceRemoveSubVolumeSnapshot(volume, group, subvolume, name string) error { func (fsa *FSAdmin) ForceRemoveSubVolumeSnapshot(volume, group, subvolume, name string) error {
return fsa.rmSubVolumeSnapshot(volume, group, subvolume, name, commonRmFlags{force: true}) return fsa.rmSubVolumeSnapshot(volume, group, subvolume, name, commonRmFlags{force: true})
} }
@ -324,7 +335,8 @@ func (fsa *FSAdmin) rmSubVolumeSnapshot(volume, group, subvolume, name string, o
// ListSubVolumeSnapshots returns a listing of snapshots for a given subvolume. // ListSubVolumeSnapshots returns a listing of snapshots for a given subvolume.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot ls <volume> --group-name=<group> <name> //
// ceph fs subvolume snapshot ls <volume> --group-name=<group> <name>
func (fsa *FSAdmin) ListSubVolumeSnapshots(volume, group, name string) ([]string, error) { func (fsa *FSAdmin) ListSubVolumeSnapshots(volume, group, name string) ([]string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot ls", "prefix": "fs subvolume snapshot ls",
@ -358,7 +370,8 @@ func parseSubVolumeSnapshotInfo(res response) (*SubVolumeSnapshotInfo, error) {
// SubVolumeSnapshotInfo returns information about the specified subvolume snapshot. // SubVolumeSnapshotInfo returns information about the specified subvolume snapshot.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot info <volume> --group-name=<group> <subvolume> <name> //
// ceph fs subvolume snapshot info <volume> --group-name=<group> <subvolume> <name>
func (fsa *FSAdmin) SubVolumeSnapshotInfo(volume, group, subvolume, name string) (*SubVolumeSnapshotInfo, error) { func (fsa *FSAdmin) SubVolumeSnapshotInfo(volume, group, subvolume, name string) (*SubVolumeSnapshotInfo, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot info", "prefix": "fs subvolume snapshot info",
@ -376,7 +389,8 @@ func (fsa *FSAdmin) SubVolumeSnapshotInfo(volume, group, subvolume, name string)
// ProtectSubVolumeSnapshot protects the specified snapshot. // ProtectSubVolumeSnapshot protects the specified snapshot.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot protect <volume> --group-name=<group> <subvolume> <name> //
// ceph fs subvolume snapshot protect <volume> --group-name=<group> <subvolume> <name>
func (fsa *FSAdmin) ProtectSubVolumeSnapshot(volume, group, subvolume, name string) error { func (fsa *FSAdmin) ProtectSubVolumeSnapshot(volume, group, subvolume, name string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot protect", "prefix": "fs subvolume snapshot protect",
@ -394,7 +408,8 @@ func (fsa *FSAdmin) ProtectSubVolumeSnapshot(volume, group, subvolume, name stri
// UnprotectSubVolumeSnapshot removes protection from the specified snapshot. // UnprotectSubVolumeSnapshot removes protection from the specified snapshot.
// //
// Similar To: // Similar To:
// ceph fs subvolume snapshot unprotect <volume> --group-name=<group> <subvolume> <name> //
// ceph fs subvolume snapshot unprotect <volume> --group-name=<group> <subvolume> <name>
func (fsa *FSAdmin) UnprotectSubVolumeSnapshot(volume, group, subvolume, name string) error { func (fsa *FSAdmin) UnprotectSubVolumeSnapshot(volume, group, subvolume, name string) error {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolume snapshot unprotect", "prefix": "fs subvolume snapshot unprotect",

View File

@ -40,7 +40,8 @@ func (s *SubVolumeGroupOptions) toFields(v, g string) *subVolumeGroupFields {
// CreateSubVolumeGroup sends a request to create a subvolume group in a volume. // CreateSubVolumeGroup sends a request to create a subvolume group in a volume.
// //
// Similar To: // Similar To:
// ceph fs subvolumegroup create <volume> <group_name> ... //
// ceph fs subvolumegroup create <volume> <group_name> ...
func (fsa *FSAdmin) CreateSubVolumeGroup(volume, name string, o *SubVolumeGroupOptions) error { func (fsa *FSAdmin) CreateSubVolumeGroup(volume, name string, o *SubVolumeGroupOptions) error {
if o == nil { if o == nil {
o = &SubVolumeGroupOptions{} o = &SubVolumeGroupOptions{}
@ -53,7 +54,8 @@ func (fsa *FSAdmin) CreateSubVolumeGroup(volume, name string, o *SubVolumeGroupO
// specified volume. // specified volume.
// //
// Similar To: // Similar To:
// ceph fs subvolumegroup ls cephfs <volume> //
// ceph fs subvolumegroup ls cephfs <volume>
func (fsa *FSAdmin) ListSubVolumeGroups(volume string) ([]string, error) { func (fsa *FSAdmin) ListSubVolumeGroups(volume string) ([]string, error) {
res := fsa.marshalMgrCommand(map[string]string{ res := fsa.marshalMgrCommand(map[string]string{
"prefix": "fs subvolumegroup ls", "prefix": "fs subvolumegroup ls",
@ -65,14 +67,16 @@ func (fsa *FSAdmin) ListSubVolumeGroups(volume string) ([]string, error) {
// RemoveSubVolumeGroup will delete a subvolume group in a volume. // RemoveSubVolumeGroup will delete a subvolume group in a volume.
// Similar To: // Similar To:
// ceph fs subvolumegroup rm <volume> <group_name> //
// ceph fs subvolumegroup rm <volume> <group_name>
func (fsa *FSAdmin) RemoveSubVolumeGroup(volume, name string) error { func (fsa *FSAdmin) RemoveSubVolumeGroup(volume, name string) error {
return fsa.rmSubVolumeGroup(volume, name, commonRmFlags{}) return fsa.rmSubVolumeGroup(volume, name, commonRmFlags{})
} }
// ForceRemoveSubVolumeGroup will delete a subvolume group in a volume. // ForceRemoveSubVolumeGroup will delete a subvolume group in a volume.
// Similar To: // Similar To:
// ceph fs subvolumegroup rm <volume> <group_name> --force //
// ceph fs subvolumegroup rm <volume> <group_name> --force
func (fsa *FSAdmin) ForceRemoveSubVolumeGroup(volume, name string) error { func (fsa *FSAdmin) ForceRemoveSubVolumeGroup(volume, name string) error {
return fsa.rmSubVolumeGroup(volume, name, commonRmFlags{force: true}) return fsa.rmSubVolumeGroup(volume, name, commonRmFlags{force: true})
} }
@ -91,7 +95,8 @@ func (fsa *FSAdmin) rmSubVolumeGroup(volume, name string, o commonRmFlags) error
// file system. // file system.
// //
// Similar To: // Similar To:
// ceph fs subvolumegroup getpath <volume> <group_name> //
// ceph fs subvolumegroup getpath <volume> <group_name>
func (fsa *FSAdmin) SubVolumeGroupPath(volume, name string) (string, error) { func (fsa *FSAdmin) SubVolumeGroupPath(volume, name string) (string, error) {
m := map[string]string{ m := map[string]string{
"prefix": "fs subvolumegroup getpath", "prefix": "fs subvolumegroup getpath",

View File

@ -14,7 +14,8 @@ var (
// ListVolumes return a list of volumes in this Ceph cluster. // ListVolumes return a list of volumes in this Ceph cluster.
// //
// Similar To: // Similar To:
// ceph fs volume ls //
// ceph fs volume ls
func (fsa *FSAdmin) ListVolumes() ([]string, error) { func (fsa *FSAdmin) ListVolumes() ([]string, error) {
res := fsa.rawMgrCommand(listVolumesCmd) res := fsa.rawMgrCommand(listVolumesCmd)
return parseListNames(res) return parseListNames(res)
@ -34,7 +35,8 @@ type FSPoolInfo struct {
// file systems. // file systems.
// //
// Similar To: // Similar To:
// ceph fs ls //
// ceph fs ls
func (fsa *FSAdmin) ListFileSystems() ([]FSPoolInfo, error) { func (fsa *FSAdmin) ListFileSystems() ([]FSPoolInfo, error) {
res := fsa.rawMonCommand(listFsCmd) res := fsa.rawMonCommand(listFsCmd)
return parseFsList(res) return parseFsList(res)
@ -168,7 +170,8 @@ func parseVolumeStatus(res response) (*volumeStatusResponse, error) {
// VolumeStatus returns a VolumeStatus object for the given volume name. // VolumeStatus returns a VolumeStatus object for the given volume name.
// //
// Similar To: // Similar To:
// ceph fs status cephfs <name> //
// ceph fs status cephfs <name>
func (fsa *FSAdmin) VolumeStatus(name string) (*VolumeStatus, error) { func (fsa *FSAdmin) VolumeStatus(name string) (*VolumeStatus, error) {
res := fsa.marshalMgrCommand(map[string]string{ res := fsa.marshalMgrCommand(map[string]string{
"fs": name, "fs": name,

View File

@ -0,0 +1,48 @@
//go:build !(nautilus || octopus) && ceph_preview
// +build !nautilus,!octopus,ceph_preview
package admin
// PoolInfo reports various properties of a pool.
type PoolInfo struct {
Available int `json:"avail"`
Name string `json:"name"`
Used int `json:"used"`
}
// PoolType indicates the type of pool related to a volume.
type PoolType struct {
DataPool []PoolInfo `json:"data"`
MetadataPool []PoolInfo `json:"metadata"`
}
// VolInfo holds various informational values about a volume.
type VolInfo struct {
MonAddrs []string `json:"mon_addrs"`
PendingSubvolDels int `json:"pending_subvolume_deletions"`
Pools PoolType `json:"pools"`
UsedSize int `json:"used_size"`
}
func parseVolumeInfo(res response) (*VolInfo, error) {
var info VolInfo
if err := res.NoStatus().Unmarshal(&info).End(); err != nil {
return nil, err
}
return &info, nil
}
// FetchVolumeInfo fetches the information of a CephFS volume.
//
// Similar To:
//
// ceph fs volume info <vol_name>
func (fsa *FSAdmin) FetchVolumeInfo(volume string) (*VolInfo, error) {
m := map[string]string{
"prefix": "fs volume info",
"vol_name": volume,
"format": "json",
}
return parseVolumeInfo(fsa.marshalMgrCommand(m))
}

View File

@ -7,7 +7,8 @@ import (
// EnableModule will enable the specified manager module. // EnableModule will enable the specified manager module.
// //
// Similar To: // Similar To:
// ceph mgr module enable <module> [--force] //
// ceph mgr module enable <module> [--force]
func (fsa *MgrAdmin) EnableModule(module string, force bool) error { func (fsa *MgrAdmin) EnableModule(module string, force bool) error {
m := map[string]string{ m := map[string]string{
"prefix": "mgr module enable", "prefix": "mgr module enable",
@ -25,7 +26,8 @@ func (fsa *MgrAdmin) EnableModule(module string, force bool) error {
// DisableModule will disable the specified manager module. // DisableModule will disable the specified manager module.
// //
// Similar To: // Similar To:
// ceph mgr module disable <module> //
// ceph mgr module disable <module>
func (fsa *MgrAdmin) DisableModule(module string) error { func (fsa *MgrAdmin) DisableModule(module string) error {
m := map[string]string{ m := map[string]string{
"prefix": "mgr module disable", "prefix": "mgr module disable",

View File

@ -135,7 +135,8 @@ func parseExportInfo(res commands.Response) (ExportInfo, error) {
// CreateCephFSExport will create a new NFS export for a CephFS file system. // CreateCephFSExport will create a new NFS export for a CephFS file system.
// //
// Similar To: // Similar To:
// ceph nfs export create cephfs //
// ceph nfs export create cephfs
func (nfsa *Admin) CreateCephFSExport(spec CephFSExportSpec) ( func (nfsa *Admin) CreateCephFSExport(spec CephFSExportSpec) (
*ExportResult, error) { *ExportResult, error) {
// --- // ---
@ -152,7 +153,8 @@ const delSucc = "Successfully deleted export"
// RemoveExport will remove an NFS export based on the pseudo-path of the export. // RemoveExport will remove an NFS export based on the pseudo-path of the export.
// //
// Similar To: // Similar To:
// ceph nfs export rm //
// ceph nfs export rm
func (nfsa *Admin) RemoveExport(clusterID, pseudoPath string) error { func (nfsa *Admin) RemoveExport(clusterID, pseudoPath string) error {
m := map[string]string{ m := map[string]string{
"prefix": "nfs export rm", "prefix": "nfs export rm",
@ -167,7 +169,8 @@ func (nfsa *Admin) RemoveExport(clusterID, pseudoPath string) error {
// ListDetailedExports will return a list of exports with details. // ListDetailedExports will return a list of exports with details.
// //
// Similar To: // Similar To:
// ceph nfs export ls --detailed //
// ceph nfs export ls --detailed
func (nfsa *Admin) ListDetailedExports(clusterID string) ([]ExportInfo, error) { func (nfsa *Admin) ListDetailedExports(clusterID string) ([]ExportInfo, error) {
/* /*
NOTE: there is no simple list because based on a quick reading of the code NOTE: there is no simple list because based on a quick reading of the code
@ -190,7 +193,8 @@ func (nfsa *Admin) ListDetailedExports(clusterID string) ([]ExportInfo, error) {
// pseudo-path. // pseudo-path.
// //
// Similar To: // Similar To:
// ceph nfs export info //
// ceph nfs export info
func (nfsa *Admin) ExportInfo(clusterID, pseudoPath string) (ExportInfo, error) { func (nfsa *Admin) ExportInfo(clusterID, pseudoPath string) (ExportInfo, error) {
m := map[string]string{ m := map[string]string{
"prefix": "nfs export info", "prefix": "nfs export info",

View File

@ -44,11 +44,12 @@ func (c *Conn) MonCommandWithInputBuffer(args, inputBuffer []byte) ([]byte, stri
// PGCommand sends a command to one of the PGs // PGCommand sends a command to one of the PGs
// //
// Implements: // Implements:
// int rados_pg_command(rados_t cluster, const char *pgstr, //
// const char **cmd, size_t cmdlen, // int rados_pg_command(rados_t cluster, const char *pgstr,
// const char *inbuf, size_t inbuflen, // const char **cmd, size_t cmdlen,
// char **outbuf, size_t *outbuflen, // const char *inbuf, size_t inbuflen,
// char **outs, size_t *outslen); // char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) PGCommand(pgid []byte, args [][]byte) ([]byte, string, error) { func (c *Conn) PGCommand(pgid []byte, args [][]byte) ([]byte, string, error) {
return c.PGCommandWithInputBuffer(pgid, args, nil) return c.PGCommandWithInputBuffer(pgid, args, nil)
} }
@ -56,11 +57,12 @@ func (c *Conn) PGCommand(pgid []byte, args [][]byte) ([]byte, string, error) {
// PGCommandWithInputBuffer sends a command to one of the PGs, with an input buffer // PGCommandWithInputBuffer sends a command to one of the PGs, with an input buffer
// //
// Implements: // Implements:
// int rados_pg_command(rados_t cluster, const char *pgstr, //
// const char **cmd, size_t cmdlen, // int rados_pg_command(rados_t cluster, const char *pgstr,
// const char *inbuf, size_t inbuflen, // const char **cmd, size_t cmdlen,
// char **outbuf, size_t *outbuflen, // const char *inbuf, size_t inbuflen,
// char **outs, size_t *outslen); // char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) PGCommandWithInputBuffer(pgid []byte, args [][]byte, inputBuffer []byte) ([]byte, string, error) { func (c *Conn) PGCommandWithInputBuffer(pgid []byte, args [][]byte, inputBuffer []byte) ([]byte, string, error) {
name := C.CString(string(pgid)) name := C.CString(string(pgid))
defer C.free(unsafe.Pointer(name)) defer C.free(unsafe.Pointer(name))
@ -92,11 +94,12 @@ func (c *Conn) MgrCommand(args [][]byte) ([]byte, string, error) {
// MgrCommandWithInputBuffer sends a command, with an input buffer, to a ceph-mgr. // MgrCommandWithInputBuffer sends a command, with an input buffer, to a ceph-mgr.
// //
// Implements: // Implements:
// int rados_mgr_command(rados_t cluster, const char **cmd, //
// size_t cmdlen, const char *inbuf, // int rados_mgr_command(rados_t cluster, const char **cmd,
// size_t inbuflen, char **outbuf, // size_t cmdlen, const char *inbuf,
// size_t *outbuflen, char **outs, // size_t inbuflen, char **outbuf,
// size_t *outslen); // size_t *outbuflen, char **outs,
// size_t *outslen);
func (c *Conn) MgrCommandWithInputBuffer(args [][]byte, inputBuffer []byte) ([]byte, string, error) { func (c *Conn) MgrCommandWithInputBuffer(args [][]byte, inputBuffer []byte) ([]byte, string, error) {
ci := cutil.NewCommandInput(args, inputBuffer) ci := cutil.NewCommandInput(args, inputBuffer)
defer ci.Free() defer ci.Free()
@ -126,11 +129,12 @@ func (c *Conn) OsdCommand(osd int, args [][]byte) ([]byte, string, error) {
// specified ceph OSD. // specified ceph OSD.
// //
// Implements: // Implements:
// int rados_osd_command(rados_t cluster, int osdid, //
// const char **cmd, size_t cmdlen, // int rados_osd_command(rados_t cluster, int osdid,
// const char *inbuf, size_t inbuflen, // const char **cmd, size_t cmdlen,
// char **outbuf, size_t *outbuflen, // const char *inbuf, size_t inbuflen,
// char **outs, size_t *outslen); // char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) OsdCommandWithInputBuffer( func (c *Conn) OsdCommandWithInputBuffer(
osd int, args [][]byte, inputBuffer []byte) ([]byte, string, error) { osd int, args [][]byte, inputBuffer []byte) ([]byte, string, error) {
@ -162,11 +166,12 @@ func (c *Conn) MonCommandTarget(name string, args [][]byte) ([]byte, string, err
// MonCommandTargetWithInputBuffer sends a command, with an input buffer, to a specified monitor. // MonCommandTargetWithInputBuffer sends a command, with an input buffer, to a specified monitor.
// //
// Implements: // Implements:
// int rados_mon_command_target(rados_t cluster, const char *name, //
// const char **cmd, size_t cmdlen, // int rados_mon_command_target(rados_t cluster, const char *name,
// const char *inbuf, size_t inbuflen, // const char **cmd, size_t cmdlen,
// char **outbuf, size_t *outbuflen, // const char *inbuf, size_t inbuflen,
// char **outs, size_t *outslen); // char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) MonCommandTargetWithInputBuffer( func (c *Conn) MonCommandTargetWithInputBuffer(
name string, args [][]byte, inputBuffer []byte) ([]byte, string, error) { name string, args [][]byte, inputBuffer []byte) ([]byte, string, error) {

View File

@ -95,8 +95,9 @@ func (c *Conn) ReadDefaultConfigFile() error {
// OpenIOContext creates and returns a new IOContext for the given pool. // OpenIOContext creates and returns a new IOContext for the given pool.
// //
// Implements: // Implements:
// int rados_ioctx_create(rados_t cluster, const char *pool_name, //
// rados_ioctx_t *ioctx); // int rados_ioctx_create(rados_t cluster, const char *pool_name,
// rados_ioctx_t *ioctx);
func (c *Conn) OpenIOContext(pool string) (*IOContext, error) { func (c *Conn) OpenIOContext(pool string) (*IOContext, error) {
cPool := C.CString(pool) cPool := C.CString(pool)
defer C.free(unsafe.Pointer(cPool)) defer C.free(unsafe.Pointer(cPool))
@ -200,8 +201,9 @@ func (c *Conn) GetClusterStats() (stat ClusterStat, err error) {
// argument vector. // argument vector.
// //
// Implements: // Implements:
// int rados_conf_parse_argv(rados_t cluster, int argc, //
// const char **argv); // int rados_conf_parse_argv(rados_t cluster, int argc,
// const char **argv);
func (c *Conn) ParseConfigArgv(argv []string) error { func (c *Conn) ParseConfigArgv(argv []string) error {
if c.cluster == nil { if c.cluster == nil {
return ErrNotConnected return ErrNotConnected

View File

@ -125,8 +125,9 @@ func (ioctx *IOContext) Pointer() unsafe.Pointer {
// Setting namespace to a empty or zero length string sets the pool to the default namespace. // Setting namespace to a empty or zero length string sets the pool to the default namespace.
// //
// Implements: // Implements:
// void rados_ioctx_set_namespace(rados_ioctx_t io, //
// const char *nspace); // void rados_ioctx_set_namespace(rados_ioctx_t io,
// const char *nspace);
func (ioctx *IOContext) SetNamespace(namespace string) { func (ioctx *IOContext) SetNamespace(namespace string) {
var cns *C.char var cns *C.char
if len(namespace) > 0 { if len(namespace) > 0 {
@ -139,8 +140,9 @@ func (ioctx *IOContext) SetNamespace(namespace string) {
// Create a new object with key oid. // Create a new object with key oid.
// //
// Implements: // Implements:
// void rados_write_op_create(rados_write_op_t write_op, int exclusive, //
// const char* category) // void rados_write_op_create(rados_write_op_t write_op, int exclusive,
// const char* category)
func (ioctx *IOContext) Create(oid string, exclusive CreateOption) error { func (ioctx *IOContext) Create(oid string, exclusive CreateOption) error {
op := CreateWriteOp() op := CreateWriteOp()
defer op.Release() defer op.Release()
@ -247,8 +249,9 @@ func (ioctx *IOContext) Destroy() {
// context. // context.
// //
// Implements: // Implements:
// int rados_ioctx_pool_stat(rados_ioctx_t io, //
// struct rados_pool_stat_t *stats); // int rados_ioctx_pool_stat(rados_ioctx_t io,
// struct rados_pool_stat_t *stats);
func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) { func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
cStat := C.struct_rados_pool_stat_t{} cStat := C.struct_rados_pool_stat_t{}
ret := C.rados_ioctx_pool_stat(ioctx.ioctx, &cStat) ret := C.rados_ioctx_pool_stat(ioctx.ioctx, &cStat)
@ -274,7 +277,8 @@ func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
// GetPoolID returns the pool ID associated with the I/O context. // GetPoolID returns the pool ID associated with the I/O context.
// //
// Implements: // Implements:
// int64_t rados_ioctx_get_id(rados_ioctx_t io) //
// int64_t rados_ioctx_get_id(rados_ioctx_t io)
func (ioctx *IOContext) GetPoolID() int64 { func (ioctx *IOContext) GetPoolID() int64 {
ret := C.rados_ioctx_get_id(ioctx.ioctx) ret := C.rados_ioctx_get_id(ioctx.ioctx)
return int64(ret) return int64(ret)
@ -328,7 +332,8 @@ func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error {
defer C.rados_object_list_cursor_free(ioctx.ioctx, finish) defer C.rados_object_list_cursor_free(ioctx.ioctx, finish)
for { for {
ret := C.rados_object_list(ioctx.ioctx, next, finish, pageResults, nil, filterLen, (*C.rados_object_list_item)(unsafe.Pointer(&results[0])), &next) res := (*C.rados_object_list_item)(unsafe.Pointer(&results[0]))
ret := C.rados_object_list(ioctx.ioctx, next, finish, pageResults, nil, filterLen, res, &next)
if ret < 0 { if ret < 0 {
return getError(ret) return getError(ret)
} }
@ -338,6 +343,7 @@ func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error {
item := results[i] item := results[i]
listFn(C.GoStringN(item.oid, (C.int)(item.oid_length))) listFn(C.GoStringN(item.oid, (C.int)(item.oid_length)))
} }
C.rados_object_list_free(C.size_t(ret), res)
if C.rados_object_list_is_end(ioctx.ioctx, next) == listEndSentinel { if C.rados_object_list_is_end(ioctx.ioctx, next) == listEndSentinel {
return nil return nil
@ -678,7 +684,8 @@ func (ioctx *IOContext) BreakLock(oid, name, client, cookie string) (int, error)
// written to. // written to.
// //
// Implements: // Implements:
// uint64_t rados_get_last_version(rados_ioctx_t io); //
// uint64_t rados_get_last_version(rados_ioctx_t io);
func (ioctx *IOContext) GetLastVersion() (uint64, error) { func (ioctx *IOContext) GetLastVersion() (uint64, error) {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return 0, err return 0, err
@ -690,8 +697,9 @@ func (ioctx *IOContext) GetLastVersion() (uint64, error) {
// GetNamespace gets the namespace used for objects within this IO context. // GetNamespace gets the namespace used for objects within this IO context.
// //
// Implements: // Implements:
// int rados_ioctx_get_namespace(rados_ioctx_t io, char *buf, //
// unsigned maxlen); // int rados_ioctx_get_namespace(rados_ioctx_t io, char *buf,
// unsigned maxlen);
func (ioctx *IOContext) GetNamespace() (string, error) { func (ioctx *IOContext) GetNamespace() (string, error) {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return "", err return "", err

View File

@ -13,7 +13,8 @@ import "C"
// or return EDQUOT or ENOSPC. // or return EDQUOT or ENOSPC.
// //
// Implements: // Implements:
// void rados_set_osdmap_full_try(rados_ioctx_t io); //
// void rados_set_osdmap_full_try(rados_ioctx_t io);
func (ioctx *IOContext) SetPoolFullTry() error { func (ioctx *IOContext) SetPoolFullTry() error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err
@ -25,7 +26,8 @@ func (ioctx *IOContext) SetPoolFullTry() error {
// UnsetPoolFullTry unsets the flag set by SetPoolFullTry() // UnsetPoolFullTry unsets the flag set by SetPoolFullTry()
// //
// Implements: // Implements:
// void rados_unset_osdmap_full_try(rados_ioctx_t io); //
// void rados_unset_osdmap_full_try(rados_ioctx_t io);
func (ioctx *IOContext) UnsetPoolFullTry() error { func (ioctx *IOContext) UnsetPoolFullTry() error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err

View File

@ -16,7 +16,8 @@ import "C"
// or return EDQUOT or ENOSPC. // or return EDQUOT or ENOSPC.
// //
// Implements: // Implements:
// void rados_set_pool_full_try(rados_ioctx_t io); //
// void rados_set_pool_full_try(rados_ioctx_t io);
func (ioctx *IOContext) SetPoolFullTry() error { func (ioctx *IOContext) SetPoolFullTry() error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err
@ -28,7 +29,8 @@ func (ioctx *IOContext) SetPoolFullTry() error {
// UnsetPoolFullTry unsets the flag set by SetPoolFullTry() // UnsetPoolFullTry unsets the flag set by SetPoolFullTry()
// //
// Implements: // Implements:
// void rados_unset_pool_full_try(rados_ioctx_t io); //
// void rados_unset_pool_full_try(rados_ioctx_t io);
func (ioctx *IOContext) UnsetPoolFullTry() error { func (ioctx *IOContext) UnsetPoolFullTry() error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err

View File

@ -11,7 +11,8 @@ import "C"
// alignment or not, use RequiresAlignment. // alignment or not, use RequiresAlignment.
// //
// Implements: // Implements:
// int rados_ioctx_pool_required_alignment2(rados_ioctx_t io, uint64_t *alignment) //
// int rados_ioctx_pool_required_alignment2(rados_ioctx_t io, uint64_t *alignment)
func (ioctx *IOContext) Alignment() (uint64, error) { func (ioctx *IOContext) Alignment() (uint64, error) {
var alignSizeBytes C.uint64_t var alignSizeBytes C.uint64_t
ret := C.rados_ioctx_pool_required_alignment2( ret := C.rados_ioctx_pool_required_alignment2(

View File

@ -11,7 +11,8 @@ import "C"
// Alignment to know how to get the stripe size for pools requiring it. // Alignment to know how to get the stripe size for pools requiring it.
// //
// Implements: // Implements:
// int rados_ioctx_pool_requires_alignment2(rados_ioctx_t io, int *req) //
// int rados_ioctx_pool_requires_alignment2(rados_ioctx_t io, int *req)
func (ioctx *IOContext) RequiresAlignment() (bool, error) { func (ioctx *IOContext) RequiresAlignment() (bool, error) {
var alignRequired C.int var alignRequired C.int
ret := C.rados_ioctx_pool_requires_alignment2( ret := C.rados_ioctx_pool_requires_alignment2(

View File

@ -16,11 +16,12 @@ import (
// the backend. // the backend.
// //
// Implements: // Implements:
// int rados_set_alloc_hint2(rados_ioctx_t io, //
// const char *o, // int rados_set_alloc_hint2(rados_ioctx_t io,
// uint64_t expected_object_size, // const char *o,
// uint64_t expected_write_size, // uint64_t expected_object_size,
// uint32_t flags); // uint64_t expected_write_size,
// uint32_t flags);
func (ioctx *IOContext) SetAllocationHint(oid string, expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags) error { func (ioctx *IOContext) SetAllocationHint(oid string, expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags) error {
coid := C.CString(oid) coid := C.CString(oid)
defer C.free(unsafe.Pointer(coid)) defer C.free(unsafe.Pointer(coid))

View File

@ -42,13 +42,13 @@ func (iter *Iter) Seek(token IterToken) {
// end of the iterator was reached, or the iterator received an error. // end of the iterator was reached, or the iterator received an error.
// //
// Example: // Example:
//
// iter := pool.Iter() // iter := pool.Iter()
// defer iter.Close() // defer iter.Close()
// for iter.Next() { // for iter.Next() {
// fmt.Printf("%v\n", iter.Value()) // fmt.Printf("%v\n", iter.Value())
// } // }
// return iter.Err() // return iter.Err()
//
func (iter *Iter) Next() bool { func (iter *Iter) Next() bool {
var cEntry *C.char var cEntry *C.char
var cNamespace *C.char var cNamespace *C.char

View File

@ -11,8 +11,9 @@ import "C"
// previously obtained with IOContext.GetLastVersion(). // previously obtained with IOContext.GetLastVersion().
// //
// Implements: // Implements:
// void rados_read_op_assert_version(rados_read_op_t read_op, //
// uint64_t ver) // void rados_read_op_assert_version(rados_read_op_t read_op,
// uint64_t ver)
func (r *ReadOp) AssertVersion(ver uint64) { func (r *ReadOp) AssertVersion(ver uint64) {
C.rados_read_op_assert_version(r.op, C.uint64_t(ver)) C.rados_read_op_assert_version(r.op, C.uint64_t(ver))
} }

View File

@ -15,7 +15,8 @@ import (
// To reset the locator, an empty string must be set. // To reset the locator, an empty string must be set.
// //
// Implements: // Implements:
// void rados_ioctx_locator_set_key(rados_ioctx_t io, const char *key); //
// void rados_ioctx_locator_set_key(rados_ioctx_t io, const char *key);
func (ioctx *IOContext) SetLocator(locator string) { func (ioctx *IOContext) SetLocator(locator string) {
if locator == "" { if locator == "" {
C.rados_ioctx_locator_set_key(ioctx.ioctx, nil) C.rados_ioctx_locator_set_key(ioctx.ioctx, nil)

View File

@ -11,8 +11,9 @@ import "C"
// previously obtained with IOContext.GetLastVersion(). // previously obtained with IOContext.GetLastVersion().
// //
// Implements: // Implements:
// void rados_read_op_assert_version(rados_read_op_t read_op, //
// uint64_t ver) // void rados_read_op_assert_version(rados_read_op_t read_op,
// uint64_t ver)
func (w *WriteOp) AssertVersion(ver uint64) { func (w *WriteOp) AssertVersion(ver uint64) {
C.rados_write_op_assert_version(w.op, C.uint64_t(ver)) C.rados_write_op_assert_version(w.op, C.uint64_t(ver))
} }

View File

@ -9,7 +9,8 @@ import "C"
// Remove object. // Remove object.
// //
// Implements: // Implements:
// void rados_write_op_remove(rados_write_op_t write_op) //
// void rados_write_op_remove(rados_write_op_t write_op)
func (w *WriteOp) Remove() { func (w *WriteOp) Remove() {
C.rados_write_op_remove(w.op) C.rados_write_op_remove(w.op)
} }

View File

@ -13,10 +13,11 @@ import (
// SetXattr sets an xattr. // SetXattr sets an xattr.
// //
// Implements: // Implements:
// void rados_write_op_setxattr(rados_write_op_t write_op, //
// const char * name, // void rados_write_op_setxattr(rados_write_op_t write_op,
// const char * value, // const char * name,
// size_t value_len) // const char * value,
// size_t value_len)
func (w *WriteOp) SetXattr(name string, value []byte) { func (w *WriteOp) SetXattr(name string, value []byte) {
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))

View File

@ -59,7 +59,8 @@ func (r *ReadOp) operateCompat(ioctx *IOContext, oid string) error {
// AssertExists assures the object targeted by the read op exists. // AssertExists assures the object targeted by the read op exists.
// //
// Implements: // Implements:
// void rados_read_op_assert_exists(rados_read_op_t read_op); //
// void rados_read_op_assert_exists(rados_read_op_t read_op);
func (r *ReadOp) AssertExists() { func (r *ReadOp) AssertExists() {
C.rados_read_op_assert_exists(r.op) C.rados_read_op_assert_exists(r.op)
} }

View File

@ -86,12 +86,13 @@ func (s *ReadOpOmapGetValsByKeysStep) Next() (*OmapKeyValue, error) {
// GetOmapValuesByKeys starts iterating over specific key/value pairs. // GetOmapValuesByKeys starts iterating over specific key/value pairs.
// //
// Implements: // Implements:
// void rados_read_op_omap_get_vals_by_keys2(rados_read_op_t read_op, //
// char const * const * keys, // void rados_read_op_omap_get_vals_by_keys2(rados_read_op_t read_op,
// size_t num_keys, // char const * const * keys,
// const size_t * key_lens, // size_t num_keys,
// rados_omap_iter_t * iter, // const size_t * key_lens,
// int * prval) // rados_omap_iter_t * iter,
// int * prval)
func (r *ReadOp) GetOmapValuesByKeys(keys []string) *ReadOpOmapGetValsByKeysStep { func (r *ReadOp) GetOmapValuesByKeys(keys []string) *ReadOpOmapGetValsByKeysStep {
s := newReadOpOmapGetValsByKeysStep() s := newReadOpOmapGetValsByKeysStep()
r.steps = append(r.steps, s) r.steps = append(r.steps, s)

View File

@ -48,12 +48,13 @@ func newReadOpReadStep() *ReadOpReadStep {
// buffer[:ReadOpReadStep.BytesRead] then contains object data. // buffer[:ReadOpReadStep.BytesRead] then contains object data.
// //
// Implements: // Implements:
// void rados_read_op_read(rados_read_op_t read_op, //
// uint64_t offset, // void rados_read_op_read(rados_read_op_t read_op,
// size_t len, // uint64_t offset,
// char * buffer, // size_t len,
// size_t * bytes_read, // char * buffer,
// int * prval) // size_t * bytes_read,
// int * prval)
func (r *ReadOp) Read(offset uint64, buffer []byte) *ReadOpReadStep { func (r *ReadOp) Read(offset uint64, buffer []byte) *ReadOpReadStep {
oe := newReadStep(buffer, offset) oe := newReadStep(buffer, offset)
readStep := newReadOpReadStep() readStep := newReadOpReadStep()

View File

@ -31,7 +31,8 @@ func (ioctx *IOContext) CreateSnap(snapName string) error {
// RemoveSnap deletes the pool snapshot. // RemoveSnap deletes the pool snapshot.
// //
// Implements: // Implements:
// int rados_ioctx_snap_remove(rados_ioctx_t io, const char *snapname) //
// int rados_ioctx_snap_remove(rados_ioctx_t io, const char *snapname)
func (ioctx *IOContext) RemoveSnap(snapName string) error { func (ioctx *IOContext) RemoveSnap(snapName string) error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err
@ -50,7 +51,8 @@ type SnapID C.rados_snap_t
// LookupSnap returns the ID of a pool snapshot. // LookupSnap returns the ID of a pool snapshot.
// //
// Implements: // Implements:
// int rados_ioctx_snap_lookup(rados_ioctx_t io, const char *name, rados_snap_t *id) //
// int rados_ioctx_snap_lookup(rados_ioctx_t io, const char *name, rados_snap_t *id)
func (ioctx *IOContext) LookupSnap(snapName string) (SnapID, error) { func (ioctx *IOContext) LookupSnap(snapName string) (SnapID, error) {
var snapID SnapID var snapID SnapID
@ -71,7 +73,8 @@ func (ioctx *IOContext) LookupSnap(snapName string) (SnapID, error) {
// GetSnapName returns the name of a pool snapshot with the given snapshot ID. // GetSnapName returns the name of a pool snapshot with the given snapshot ID.
// //
// Implements: // Implements:
// int rados_ioctx_snap_get_name(rados_ioctx_t io, rados_snap_t id, char *name, int maxlen) //
// int rados_ioctx_snap_get_name(rados_ioctx_t io, rados_snap_t id, char *name, int maxlen)
func (ioctx *IOContext) GetSnapName(snapID SnapID) (string, error) { func (ioctx *IOContext) GetSnapName(snapID SnapID) (string, error) {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return "", err return "", err
@ -103,7 +106,8 @@ func (ioctx *IOContext) GetSnapName(snapID SnapID) (string, error) {
// GetSnapStamp returns the time of the pool snapshot creation. // GetSnapStamp returns the time of the pool snapshot creation.
// //
// Implements: // Implements:
// int rados_ioctx_snap_get_stamp(rados_ioctx_t io, rados_snap_t id, time_t *t) //
// int rados_ioctx_snap_get_stamp(rados_ioctx_t io, rados_snap_t id, time_t *t)
func (ioctx *IOContext) GetSnapStamp(snapID SnapID) (time.Time, error) { func (ioctx *IOContext) GetSnapStamp(snapID SnapID) (time.Time, error) {
var cTime C.time_t var cTime C.time_t
@ -121,7 +125,8 @@ func (ioctx *IOContext) GetSnapStamp(snapID SnapID) (time.Time, error) {
// ListSnaps returns a slice containing the SnapIDs of existing pool snapshots. // ListSnaps returns a slice containing the SnapIDs of existing pool snapshots.
// //
// Implements: // Implements:
// int rados_ioctx_snap_list(rados_ioctx_t io, rados_snap_t *snaps, int maxlen) //
// int rados_ioctx_snap_list(rados_ioctx_t io, rados_snap_t *snaps, int maxlen)
func (ioctx *IOContext) ListSnaps() ([]SnapID, error) { func (ioctx *IOContext) ListSnaps() ([]SnapID, error) {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return nil, err return nil, err
@ -154,7 +159,8 @@ func (ioctx *IOContext) ListSnaps() ([]SnapID, error) {
// The contents of the object will be the same as when the snapshot was taken. // The contents of the object will be the same as when the snapshot was taken.
// //
// Implements: // Implements:
// int rados_ioctx_snap_rollback(rados_ioctx_t io, const char *oid, const char *snapname); //
// int rados_ioctx_snap_rollback(rados_ioctx_t io, const char *oid, const char *snapname);
func (ioctx *IOContext) RollbackSnap(oid, snapName string) error { func (ioctx *IOContext) RollbackSnap(oid, snapName string) error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err
@ -178,7 +184,8 @@ const SnapHead = SnapID(C.LIBRADOS_SNAP_HEAD)
// Pass SnapHead for no snapshot (i.e. normal operation). // Pass SnapHead for no snapshot (i.e. normal operation).
// //
// Implements: // Implements:
// void rados_ioctx_snap_set_read(rados_ioctx_t io, rados_snap_t snap); //
// void rados_ioctx_snap_set_read(rados_ioctx_t io, rados_snap_t snap);
func (ioctx *IOContext) SetReadSnap(snapID SnapID) error { func (ioctx *IOContext) SetReadSnap(snapID SnapID) error {
if err := ioctx.validate(); err != nil { if err := ioctx.validate(); err != nil {
return err return err

View File

@ -72,27 +72,28 @@ var (
// the NotifyEvents and Errors() receives all occuring errors. A typical code // the NotifyEvents and Errors() receives all occuring errors. A typical code
// creating a Watcher could look like this: // creating a Watcher could look like this:
// //
// watcher, err := ioctx.Watch(oid) // watcher, err := ioctx.Watch(oid)
// go func() { // event handler // go func() { // event handler
// for ne := range watcher.Events() { // for ne := range watcher.Events() {
// ... // ...
// ne.Ack([]byte("response data...")) // ne.Ack([]byte("response data..."))
// ... // ...
// } // }
// }() // }()
// go func() { // error handler // go func() { // error handler
// for err := range watcher.Errors() { // for err := range watcher.Errors() {
// ... handle err ... // ... handle err ...
// } // }
// }() // }()
// //
// CAUTION: the Watcher references the IOContext in which it has been created. // CAUTION: the Watcher references the IOContext in which it has been created.
// Therefore all watchers must be deleted with the Delete() method before the // Therefore all watchers must be deleted with the Delete() method before the
// IOContext is being destroyed. // IOContext is being destroyed.
// //
// Implements: // Implements:
// int rados_watch2(rados_ioctx_t io, const char* o, uint64_t* cookie, //
// rados_watchcb2_t watchcb, rados_watcherrcb_t watcherrcb, void* arg) // int rados_watch2(rados_ioctx_t io, const char* o, uint64_t* cookie,
// rados_watchcb2_t watchcb, rados_watcherrcb_t watcherrcb, void* arg)
func (ioctx *IOContext) Watch(obj string) (*Watcher, error) { func (ioctx *IOContext) Watch(obj string) (*Watcher, error) {
return ioctx.WatchWithTimeout(obj, 0) return ioctx.WatchWithTimeout(obj, 0)
} }
@ -101,9 +102,10 @@ func (ioctx *IOContext) Watch(obj string) (*Watcher, error) {
// different timeout than the default can be specified. // different timeout than the default can be specified.
// //
// Implements: // Implements:
// int rados_watch3(rados_ioctx_t io, const char *o, uint64_t *cookie, //
// rados_watchcb2_t watchcb, rados_watcherrcb_t watcherrcb, uint32_t timeout, // int rados_watch3(rados_ioctx_t io, const char *o, uint64_t *cookie,
// void *arg); // rados_watchcb2_t watchcb, rados_watcherrcb_t watcherrcb, uint32_t timeout,
// void *arg);
func (ioctx *IOContext) WatchWithTimeout(oid string, timeout time.Duration) (*Watcher, error) { func (ioctx *IOContext) WatchWithTimeout(oid string, timeout time.Duration) (*Watcher, error) {
cObj := C.CString(oid) cObj := C.CString(oid)
defer C.free(unsafe.Pointer(cObj)) defer C.free(unsafe.Pointer(cObj))
@ -158,7 +160,8 @@ func (w *Watcher) Errors() <-chan error {
// Watcher is no longer valid, and should be destroyed with the Delete() method. // Watcher is no longer valid, and should be destroyed with the Delete() method.
// //
// Implements: // Implements:
// int rados_watch_check(rados_ioctx_t io, uint64_t cookie) //
// int rados_watch_check(rados_ioctx_t io, uint64_t cookie)
func (w *Watcher) Check() (time.Duration, error) { func (w *Watcher) Check() (time.Duration, error) {
ret := C.rados_watch_check(w.ioctx.ioctx, C.uint64_t(w.id)) ret := C.rados_watch_check(w.ioctx.ioctx, C.uint64_t(w.id))
if ret < 0 { if ret < 0 {
@ -170,7 +173,8 @@ func (w *Watcher) Check() (time.Duration, error) {
// Delete the watcher. This closes both the event and error channel. // Delete the watcher. This closes both the event and error channel.
// //
// Implements: // Implements:
// int rados_unwatch2(rados_ioctx_t io, uint64_t cookie) //
// int rados_unwatch2(rados_ioctx_t io, uint64_t cookie)
func (w *Watcher) Delete() error { func (w *Watcher) Delete() error {
watchersMtx.Lock() watchersMtx.Lock()
_, ok := watchers[w.id] _, ok := watchers[w.id]
@ -204,8 +208,9 @@ func (ioctx *IOContext) Notify(obj string, data []byte) ([]NotifyAck, []NotifyTi
// default. // default.
// //
// Implements: // Implements:
// int rados_notify2(rados_ioctx_t io, const char* o, const char* buf, int buf_len, //
// uint64_t timeout_ms, char** reply_buffer, size_t* reply_buffer_len) // int rados_notify2(rados_ioctx_t io, const char* o, const char* buf, int buf_len,
// uint64_t timeout_ms, char** reply_buffer, size_t* reply_buffer_len)
func (ioctx *IOContext) NotifyWithTimeout(obj string, data []byte, timeout time.Duration) ([]NotifyAck, func (ioctx *IOContext) NotifyWithTimeout(obj string, data []byte, timeout time.Duration) ([]NotifyAck,
[]NotifyTimeout, error) { []NotifyTimeout, error) {
cObj := C.CString(obj) cObj := C.CString(obj)
@ -236,8 +241,9 @@ func (ioctx *IOContext) NotifyWithTimeout(obj string, data []byte, timeout time.
// blocks and eventiually times out. // blocks and eventiually times out.
// //
// Implements: // Implements:
// int rados_notify_ack(rados_ioctx_t io, const char *o, uint64_t notify_id, //
// uint64_t cookie, const char *buf, int buf_len) // int rados_notify_ack(rados_ioctx_t io, const char *o, uint64_t notify_id,
// uint64_t cookie, const char *buf, int buf_len)
func (ne *NotifyEvent) Ack(response []byte) error { func (ne *NotifyEvent) Ack(response []byte) error {
watchersMtx.RLock() watchersMtx.RLock()
w, ok := watchers[ne.WatcherID] w, ok := watchers[ne.WatcherID]
@ -265,7 +271,8 @@ func (ne *NotifyEvent) Ack(response []byte) error {
// WatcherFlush flushes all pending notifications of the cluster. // WatcherFlush flushes all pending notifications of the cluster.
// //
// Implements: // Implements:
// int rados_watch_flush(rados_t cluster) //
// int rados_watch_flush(rados_t cluster)
func (c *Conn) WatcherFlush() error { func (c *Conn) WatcherFlush() error {
if !c.connected { if !c.connected {
return ErrNotConnected return ErrNotConnected
@ -275,18 +282,19 @@ func (c *Conn) WatcherFlush() error {
} }
// decoder for this notify response format: // decoder for this notify response format:
// le32 num_acks //
// { // le32 num_acks
// le64 gid global id for the client (for client.1234 that's 1234) // {
// le64 cookie cookie for the client // le64 gid global id for the client (for client.1234 that's 1234)
// le32 buflen length of reply message buffer // le64 cookie cookie for the client
// u8 buflen payload // le32 buflen length of reply message buffer
// } num_acks // u8 buflen payload
// le32 num_timeouts // } num_acks
// { // le32 num_timeouts
// le64 gid global id for the client // {
// le64 cookie cookie for the client // le64 gid global id for the client
// } num_timeouts // le64 cookie cookie for the client
// } num_timeouts
// //
// NOTE: starting with pacific this is implemented as a C function and this can // NOTE: starting with pacific this is implemented as a C function and this can
// be replaced later // be replaced later

View File

@ -136,7 +136,8 @@ func (w *WriteOp) CleanOmap() {
// AssertExists assures the object targeted by the write op exists. // AssertExists assures the object targeted by the write op exists.
// //
// Implements: // Implements:
// void rados_write_op_assert_exists(rados_write_op_t write_op); //
// void rados_write_op_assert_exists(rados_write_op_t write_op);
func (w *WriteOp) AssertExists() { func (w *WriteOp) AssertExists() {
C.rados_write_op_assert_exists(w.op) C.rados_write_op_assert_exists(w.op)
} }
@ -144,10 +145,11 @@ func (w *WriteOp) AssertExists() {
// Write a given byte slice at the supplied offset. // Write a given byte slice at the supplied offset.
// //
// Implements: // Implements:
// void rados_write_op_write(rados_write_op_t write_op, //
// const char *buffer, // void rados_write_op_write(rados_write_op_t write_op,
// size_t len, // const char *buffer,
// uint64_t offset); // size_t len,
// uint64_t offset);
func (w *WriteOp) Write(b []byte, offset uint64) { func (w *WriteOp) Write(b []byte, offset uint64) {
oe := newWriteStep(b, 0, offset) oe := newWriteStep(b, 0, offset)
w.steps = append(w.steps, oe) w.steps = append(w.steps, oe)
@ -162,9 +164,10 @@ func (w *WriteOp) Write(b []byte, offset uint64) {
// atomically replacing it. // atomically replacing it.
// //
// Implements: // Implements:
// void rados_write_op_write_full(rados_write_op_t write_op, //
// const char *buffer, // void rados_write_op_write_full(rados_write_op_t write_op,
// size_t len); // const char *buffer,
// size_t len);
func (w *WriteOp) WriteFull(b []byte) { func (w *WriteOp) WriteFull(b []byte) {
oe := newWriteStep(b, 0, 0) oe := newWriteStep(b, 0, 0)
w.steps = append(w.steps, oe) w.steps = append(w.steps, oe)
@ -178,11 +181,12 @@ func (w *WriteOp) WriteFull(b []byte) {
// writeLen is satisfied. // writeLen is satisfied.
// //
// Implements: // Implements:
// void rados_write_op_writesame(rados_write_op_t write_op, //
// const char *buffer, // void rados_write_op_writesame(rados_write_op_t write_op,
// size_t data_len, // const char *buffer,
// size_t write_len, // size_t data_len,
// uint64_t offset); // size_t write_len,
// uint64_t offset);
func (w *WriteOp) WriteSame(b []byte, writeLen, offset uint64) { func (w *WriteOp) WriteSame(b []byte, writeLen, offset uint64) {
oe := newWriteStep(b, writeLen, offset) oe := newWriteStep(b, writeLen, offset)
w.steps = append(w.steps, oe) w.steps = append(w.steps, oe)

View File

@ -39,11 +39,12 @@ func newWriteOpCmpExtStep() *WriteOpCmpExtStep {
// CmpExt ensures that given object range (extent) satisfies comparison. // CmpExt ensures that given object range (extent) satisfies comparison.
// //
// Implements: // Implements:
// void rados_write_op_cmpext(rados_write_op_t write_op, //
// const char * cmp_buf, // void rados_write_op_cmpext(rados_write_op_t write_op,
// size_t cmp_len, // const char * cmp_buf,
// uint64_t off, // size_t cmp_len,
// int * prval); // uint64_t off,
// int * prval);
func (w *WriteOp) CmpExt(b []byte, offset uint64) *WriteOpCmpExtStep { func (w *WriteOp) CmpExt(b []byte, offset uint64) *WriteOpCmpExtStep {
oe := newWriteStep(b, 0, offset) oe := newWriteStep(b, 0, offset)
cmpExtStep := newWriteOpCmpExtStep() cmpExtStep := newWriteOpCmpExtStep()

View File

@ -12,10 +12,11 @@ import "C"
// the backend. // the backend.
// //
// Implements: // Implements:
// void rados_write_op_set_alloc_hint2(rados_write_op_t write_op, //
// uint64_t expected_object_size, // void rados_write_op_set_alloc_hint2(rados_write_op_t write_op,
// uint64_t expected_write_size, // uint64_t expected_object_size,
// uint32_t flags); // uint64_t expected_write_size,
// uint32_t flags);
func (w *WriteOp) SetAllocationHint(expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags) { func (w *WriteOp) SetAllocationHint(expectedObjectSize uint64, expectedWriteSize uint64, flags AllocHintFlags) {
C.rados_write_op_set_alloc_hint2( C.rados_write_op_set_alloc_hint2(
w.op, w.op,

View File

@ -40,7 +40,8 @@ func (ra *RBDAdmin) MirrorSnashotSchedule() *MirrorSnashotScheduleAdmin {
// level spec. // level spec.
// //
// Similar To: // Similar To:
// rbd mirror snapshot schedule add <level_spec> <interval> <start_time> //
// rbd mirror snapshot schedule add <level_spec> <interval> <start_time>
func (mss *MirrorSnashotScheduleAdmin) Add(l LevelSpec, i Interval, s StartTime) error { func (mss *MirrorSnashotScheduleAdmin) Add(l LevelSpec, i Interval, s StartTime) error {
m := map[string]string{ m := map[string]string{
"prefix": "rbd mirror snapshot schedule add", "prefix": "rbd mirror snapshot schedule add",
@ -59,7 +60,8 @@ func (mss *MirrorSnashotScheduleAdmin) Add(l LevelSpec, i Interval, s StartTime)
// List the snapshot schedules based on the supplied level spec. // List the snapshot schedules based on the supplied level spec.
// //
// Similar To: // Similar To:
// rbd mirror snapshot schedule list <level_spec> //
// rbd mirror snapshot schedule list <level_spec>
func (mss *MirrorSnashotScheduleAdmin) List(l LevelSpec) ([]SnapshotSchedule, error) { func (mss *MirrorSnashotScheduleAdmin) List(l LevelSpec) ([]SnapshotSchedule, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd mirror snapshot schedule list", "prefix": "rbd mirror snapshot schedule list",
@ -114,7 +116,8 @@ func parseMirrorSnapshotScheduleList(res commands.Response) (
// Remove a snapshot schedule matching the supplied arguments. // Remove a snapshot schedule matching the supplied arguments.
// //
// Similar To: // Similar To:
// rbd mirror snapshot schedule remove <level_spec> <interval> <start_time> //
// rbd mirror snapshot schedule remove <level_spec> <interval> <start_time>
func (mss *MirrorSnashotScheduleAdmin) Remove( func (mss *MirrorSnashotScheduleAdmin) Remove(
l LevelSpec, i Interval, s StartTime) error { l LevelSpec, i Interval, s StartTime) error {
@ -136,7 +139,8 @@ func (mss *MirrorSnashotScheduleAdmin) Remove(
// matching the supplied level spec. // matching the supplied level spec.
// //
// Similar To: // Similar To:
// rbd mirror snapshot schedule status <level_spec> //
// rbd mirror snapshot schedule status <level_spec>
func (mss *MirrorSnashotScheduleAdmin) Status(l LevelSpec) ([]ScheduledImage, error) { func (mss *MirrorSnashotScheduleAdmin) Status(l LevelSpec) ([]ScheduledImage, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd mirror snapshot schedule status", "prefix": "rbd mirror snapshot schedule status",

View File

@ -56,7 +56,8 @@ func parseTaskResponseList(res commands.Response) ([]TaskResponse, error) {
// supplied image spec. // supplied image spec.
// //
// Similar To: // Similar To:
// rbd task add flatten <image_spec> //
// rbd task add flatten <image_spec>
func (ta *TaskAdmin) AddFlatten(img ImageSpec) (TaskResponse, error) { func (ta *TaskAdmin) AddFlatten(img ImageSpec) (TaskResponse, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd task add flatten", "prefix": "rbd task add flatten",
@ -70,7 +71,8 @@ func (ta *TaskAdmin) AddFlatten(img ImageSpec) (TaskResponse, error) {
// image spec. // image spec.
// //
// Similar To: // Similar To:
// rbd task add remove <image_spec> //
// rbd task add remove <image_spec>
func (ta *TaskAdmin) AddRemove(img ImageSpec) (TaskResponse, error) { func (ta *TaskAdmin) AddRemove(img ImageSpec) (TaskResponse, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd task add remove", "prefix": "rbd task add remove",
@ -84,7 +86,8 @@ func (ta *TaskAdmin) AddRemove(img ImageSpec) (TaskResponse, error) {
// on the supplied image id spec. // on the supplied image id spec.
// //
// Similar To: // Similar To:
// rbd task add trash remove <image_id_spec> //
// rbd task add trash remove <image_id_spec>
func (ta *TaskAdmin) AddTrashRemove(img ImageSpec) (TaskResponse, error) { func (ta *TaskAdmin) AddTrashRemove(img ImageSpec) (TaskResponse, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd task add trash remove", "prefix": "rbd task add trash remove",
@ -97,7 +100,8 @@ func (ta *TaskAdmin) AddTrashRemove(img ImageSpec) (TaskResponse, error) {
// List pending or running asynchronous tasks. // List pending or running asynchronous tasks.
// //
// Similar To: // Similar To:
// rbd task list //
// rbd task list
func (ta *TaskAdmin) List() ([]TaskResponse, error) { func (ta *TaskAdmin) List() ([]TaskResponse, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd task list", "prefix": "rbd task list",
@ -109,7 +113,8 @@ func (ta *TaskAdmin) List() ([]TaskResponse, error) {
// GetTaskByID returns pending or running asynchronous task using id. // GetTaskByID returns pending or running asynchronous task using id.
// //
// Similar To: // Similar To:
// rbd task list <task_id> //
// rbd task list <task_id>
func (ta *TaskAdmin) GetTaskByID(taskID string) (TaskResponse, error) { func (ta *TaskAdmin) GetTaskByID(taskID string) (TaskResponse, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd task list", "prefix": "rbd task list",
@ -122,7 +127,8 @@ func (ta *TaskAdmin) GetTaskByID(taskID string) (TaskResponse, error) {
// Cancel a pending or running asynchronous task. // Cancel a pending or running asynchronous task.
// //
// Similar To: // Similar To:
// rbd task cancel <task_id> //
// rbd task cancel <task_id>
func (ta *TaskAdmin) Cancel(taskID string) (TaskResponse, error) { func (ta *TaskAdmin) Cancel(taskID string) (TaskResponse, error) {
m := map[string]string{ m := map[string]string{
"prefix": "rbd task cancel", "prefix": "rbd task cancel",

View File

@ -84,12 +84,13 @@ const (
// arguments to the callback and the return behavior. // arguments to the callback and the return behavior.
// //
// Implements: // Implements:
// int rbd_diff_iterate2(rbd_image_t image, //
// const char *fromsnapname, // int rbd_diff_iterate2(rbd_image_t image,
// uint64_t ofs, uint64_t len, // const char *fromsnapname,
// uint8_t include_parent, uint8_t whole_object, // uint64_t ofs, uint64_t len,
// int (*cb)(uint64_t, size_t, int, void *), // uint8_t include_parent, uint8_t whole_object,
// void *arg); // int (*cb)(uint64_t, size_t, int, void *),
// void *arg);
func (image *Image) DiffIterate(config DiffIterateConfig) error { func (image *Image) DiffIterate(config DiffIterateConfig) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err

View File

@ -91,10 +91,11 @@ func (opts EncryptionOptionsLUKS2) allocateEncryptionOptions() cEncryptionData {
// EncryptionFormat creates an encryption format header // EncryptionFormat creates an encryption format header
// //
// Implements: // Implements:
// int rbd_encryption_format(rbd_image_t image, //
// rbd_encryption_format_t format, // int rbd_encryption_format(rbd_image_t image,
// rbd_encryption_options_t opts, // rbd_encryption_format_t format,
// size_t opts_size); // rbd_encryption_options_t opts,
// size_t opts_size);
// //
// To issue an IO against the image, you need to mount the image // To issue an IO against the image, you need to mount the image
// with libvirt/qemu using the LUKS format, or make a call to // with libvirt/qemu using the LUKS format, or make a call to
@ -119,10 +120,11 @@ func (image *Image) EncryptionFormat(opts EncryptionOptions) error {
// EncryptionLoad enables IO on an open encrypted image // EncryptionLoad enables IO on an open encrypted image
// //
// Implements: // Implements:
// int rbd_encryption_load(rbd_image_t image, //
// rbd_encryption_format_t format, // int rbd_encryption_load(rbd_image_t image,
// rbd_encryption_options_t opts, // rbd_encryption_format_t format,
// size_t opts_size); // rbd_encryption_options_t opts,
// size_t opts_size);
func (image *Image) EncryptionLoad(opts EncryptionOptions) error { func (image *Image) EncryptionLoad(opts EncryptionOptions) error {
if image.image == nil { if image.image == nil {
return ErrImageNotOpen return ErrImageNotOpen

View File

@ -154,7 +154,8 @@ func (fs *FeatureSet) Names() []string {
// GetFeatures returns the features bitmask for the rbd image. // GetFeatures returns the features bitmask for the rbd image.
// //
// Implements: // Implements:
// int rbd_get_features(rbd_image_t image, uint64_t *features); //
// int rbd_get_features(rbd_image_t image, uint64_t *features);
func (image *Image) GetFeatures() (features uint64, err error) { func (image *Image) GetFeatures() (features uint64, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -170,8 +171,9 @@ func (image *Image) GetFeatures() (features uint64, err error) {
// UpdateFeatures updates the features on the Image. // UpdateFeatures updates the features on the Image.
// //
// Implements: // Implements:
// int rbd_update_features(rbd_image_t image, uint64_t features, //
// uint8_t enabled); // int rbd_update_features(rbd_image_t image, uint64_t features,
// uint8_t enabled);
func (image *Image) UpdateFeatures(features uint64, enabled bool) error { func (image *Image) UpdateFeatures(features uint64, enabled bool) error {
if image.image == nil { if image.image == nil {
return RbdErrorImageNotOpen return RbdErrorImageNotOpen

View File

@ -18,7 +18,8 @@ import (
// GroupCreate is used to create an image group. // GroupCreate is used to create an image group.
// //
// Implements: // Implements:
// int rbd_group_create(rados_ioctx_t p, const char *name); //
// int rbd_group_create(rados_ioctx_t p, const char *name);
func GroupCreate(ioctx *rados.IOContext, name string) error { func GroupCreate(ioctx *rados.IOContext, name string) error {
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))
@ -30,7 +31,8 @@ func GroupCreate(ioctx *rados.IOContext, name string) error {
// GroupRemove is used to remove an image group. // GroupRemove is used to remove an image group.
// //
// Implements: // Implements:
// int rbd_group_remove(rados_ioctx_t p, const char *name); //
// int rbd_group_remove(rados_ioctx_t p, const char *name);
func GroupRemove(ioctx *rados.IOContext, name string) error { func GroupRemove(ioctx *rados.IOContext, name string) error {
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))
@ -42,8 +44,9 @@ func GroupRemove(ioctx *rados.IOContext, name string) error {
// GroupRename will rename an existing image group. // GroupRename will rename an existing image group.
// //
// Implements: // Implements:
// int rbd_group_rename(rados_ioctx_t p, const char *src_name, //
// const char *dest_name); // int rbd_group_rename(rados_ioctx_t p, const char *src_name,
// const char *dest_name);
func GroupRename(ioctx *rados.IOContext, src, dest string) error { func GroupRename(ioctx *rados.IOContext, src, dest string) error {
cSrc := C.CString(src) cSrc := C.CString(src)
defer C.free(unsafe.Pointer(cSrc)) defer C.free(unsafe.Pointer(cSrc))
@ -57,7 +60,8 @@ func GroupRename(ioctx *rados.IOContext, src, dest string) error {
// GroupList returns a slice of image group names. // GroupList returns a slice of image group names.
// //
// Implements: // Implements:
// int rbd_group_list(rados_ioctx_t p, char *names, size_t *size); //
// int rbd_group_list(rados_ioctx_t p, char *names, size_t *size);
func GroupList(ioctx *rados.IOContext) ([]string, error) { func GroupList(ioctx *rados.IOContext) ([]string, error) {
var ( var (
buf []byte buf []byte
@ -89,10 +93,11 @@ func GroupList(ioctx *rados.IOContext) ([]string, error) {
// An io context must be supplied for both the group and image. // An io context must be supplied for both the group and image.
// //
// Implements: // Implements:
// int rbd_group_image_add(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_image_add(rados_ioctx_t group_p,
// rados_ioctx_t image_p, // const char *group_name,
// const char *image_name); // rados_ioctx_t image_p,
// const char *image_name);
func GroupImageAdd(groupIoctx *rados.IOContext, groupName string, func GroupImageAdd(groupIoctx *rados.IOContext, groupName string,
imageIoctx *rados.IOContext, imageName string) error { imageIoctx *rados.IOContext, imageName string) error {
@ -113,10 +118,11 @@ func GroupImageAdd(groupIoctx *rados.IOContext, groupName string,
// An io context must be supplied for both the group and image. // An io context must be supplied for both the group and image.
// //
// Implements: // Implements:
// int rbd_group_image_remove(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_image_remove(rados_ioctx_t group_p,
// rados_ioctx_t image_p, // const char *group_name,
// const char *image_name); // rados_ioctx_t image_p,
// const char *image_name);
func GroupImageRemove(groupIoctx *rados.IOContext, groupName string, func GroupImageRemove(groupIoctx *rados.IOContext, groupName string,
imageIoctx *rados.IOContext, imageName string) error { imageIoctx *rados.IOContext, imageName string) error {
@ -137,10 +143,11 @@ func GroupImageRemove(groupIoctx *rados.IOContext, groupName string,
// An io context must be supplied for both the group and image. // An io context must be supplied for both the group and image.
// //
// Implements: // Implements:
// CEPH_RBD_API int rbd_group_image_remove_by_id(rados_ioctx_t group_p, //
// const char *group_name, // CEPH_RBD_API int rbd_group_image_remove_by_id(rados_ioctx_t group_p,
// rados_ioctx_t image_p, // const char *group_name,
// const char *image_id); // rados_ioctx_t image_p,
// const char *image_id);
func GroupImageRemoveByID(groupIoctx *rados.IOContext, groupName string, func GroupImageRemoveByID(groupIoctx *rados.IOContext, groupName string,
imageIoctx *rados.IOContext, imageID string) error { imageIoctx *rados.IOContext, imageID string) error {
@ -178,11 +185,12 @@ type GroupImageInfo struct {
// images that are part of the named group. // images that are part of the named group.
// //
// Implements: // Implements:
// int rbd_group_image_list(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_image_list(rados_ioctx_t group_p,
// rbd_group_image_info_t *images, // const char *group_name,
// size_t group_image_info_size, // rbd_group_image_info_t *images,
// size_t *num_entries); // size_t group_image_info_size,
// size_t *num_entries);
func GroupImageList(ioctx *rados.IOContext, name string) ([]GroupImageInfo, error) { func GroupImageList(ioctx *rados.IOContext, name string) ([]GroupImageInfo, error) {
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))
@ -233,8 +241,9 @@ type GroupInfo struct {
// GetGroup returns group info for the group this image is part of. // GetGroup returns group info for the group this image is part of.
// //
// Implements: // Implements:
// int rbd_get_group(rbd_image_t image, rbd_group_info_t *group_info, //
// size_t group_info_size); // int rbd_get_group(rbd_image_t image, rbd_group_info_t *group_info,
// size_t group_info_size);
func (image *Image) GetGroup() (GroupInfo, error) { func (image *Image) GetGroup() (GroupInfo, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return GroupInfo{}, err return GroupInfo{}, err

View File

@ -29,9 +29,10 @@ import (
// GroupSnapCreate will create a group snapshot. // GroupSnapCreate will create a group snapshot.
// //
// Implements: // Implements:
// int rbd_group_snap_create(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_snap_create(rados_ioctx_t group_p,
// const char *snap_name); // const char *group_name,
// const char *snap_name);
func GroupSnapCreate(ioctx *rados.IOContext, group, snap string) error { func GroupSnapCreate(ioctx *rados.IOContext, group, snap string) error {
cGroupName := C.CString(group) cGroupName := C.CString(group)
defer C.free(unsafe.Pointer(cGroupName)) defer C.free(unsafe.Pointer(cGroupName))
@ -45,9 +46,10 @@ func GroupSnapCreate(ioctx *rados.IOContext, group, snap string) error {
// GroupSnapRemove removes an existing group snapshot. // GroupSnapRemove removes an existing group snapshot.
// //
// Implements: // Implements:
// int rbd_group_snap_remove(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_snap_remove(rados_ioctx_t group_p,
// const char *snap_name); // const char *group_name,
// const char *snap_name);
func GroupSnapRemove(ioctx *rados.IOContext, group, snap string) error { func GroupSnapRemove(ioctx *rados.IOContext, group, snap string) error {
cGroupName := C.CString(group) cGroupName := C.CString(group)
defer C.free(unsafe.Pointer(cGroupName)) defer C.free(unsafe.Pointer(cGroupName))
@ -61,10 +63,11 @@ func GroupSnapRemove(ioctx *rados.IOContext, group, snap string) error {
// GroupSnapRename will rename an existing group snapshot. // GroupSnapRename will rename an existing group snapshot.
// //
// Implements: // Implements:
// int rbd_group_snap_rename(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_snap_rename(rados_ioctx_t group_p,
// const char *old_snap_name, // const char *group_name,
// const char *new_snap_name); // const char *old_snap_name,
// const char *new_snap_name);
func GroupSnapRename(ioctx *rados.IOContext, group, src, dest string) error { func GroupSnapRename(ioctx *rados.IOContext, group, src, dest string) error {
cGroupName := C.CString(group) cGroupName := C.CString(group)
defer C.free(unsafe.Pointer(cGroupName)) defer C.free(unsafe.Pointer(cGroupName))
@ -98,11 +101,12 @@ type GroupSnapInfo struct {
// GroupSnapList returns a slice of snapshots in a group. // GroupSnapList returns a slice of snapshots in a group.
// //
// Implements: // Implements:
// int rbd_group_snap_list(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_snap_list(rados_ioctx_t group_p,
// rbd_group_snap_info_t *snaps, // const char *group_name,
// size_t group_snap_info_size, // rbd_group_snap_info_t *snaps,
// size_t *num_entries); // size_t group_snap_info_size,
// size_t *num_entries);
func GroupSnapList(ioctx *rados.IOContext, group string) ([]GroupSnapInfo, error) { func GroupSnapList(ioctx *rados.IOContext, group string) ([]GroupSnapInfo, error) {
cGroupName := C.CString(group) cGroupName := C.CString(group)
defer C.free(unsafe.Pointer(cGroupName)) defer C.free(unsafe.Pointer(cGroupName))
@ -147,9 +151,10 @@ func GroupSnapList(ioctx *rados.IOContext, group string) ([]GroupSnapInfo, error
// given snapshot. // given snapshot.
// //
// Implements: // Implements:
// int rbd_group_snap_rollback(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_snap_rollback(rados_ioctx_t group_p,
// const char *snap_name); // const char *group_name,
// const char *snap_name);
func GroupSnapRollback(ioctx *rados.IOContext, group, snap string) error { func GroupSnapRollback(ioctx *rados.IOContext, group, snap string) error {
cGroupName := C.CString(group) cGroupName := C.CString(group)
defer C.free(unsafe.Pointer(cGroupName)) defer C.free(unsafe.Pointer(cGroupName))
@ -174,11 +179,12 @@ var groupSnapRollbackCallbacks = callbacks.New()
// to report on the progress of the snapshot rollback. // to report on the progress of the snapshot rollback.
// //
// Implements: // Implements:
// int rbd_group_snap_rollback_with_progress(rados_ioctx_t group_p, //
// const char *group_name, // int rbd_group_snap_rollback_with_progress(rados_ioctx_t group_p,
// const char *snap_name, // const char *group_name,
// librbd_progress_fn_t cb, // const char *snap_name,
// void *cbdata); // librbd_progress_fn_t cb,
// void *cbdata);
func GroupSnapRollbackWithProgress( func GroupSnapRollbackWithProgress(
ioctx *rados.IOContext, group, snap string, ioctx *rados.IOContext, group, snap string,
cb GroupSnapRollbackCallback, data interface{}) error { cb GroupSnapRollbackCallback, data interface{}) error {

View File

@ -15,7 +15,8 @@ import (
// GetMetadata returns the metadata string associated with the given key. // GetMetadata returns the metadata string associated with the given key.
// //
// Implements: // Implements:
// int rbd_metadata_get(rbd_image_t image, const char *key, char *value, size_t *vallen) //
// int rbd_metadata_get(rbd_image_t image, const char *key, char *value, size_t *vallen)
func (image *Image) GetMetadata(key string) (string, error) { func (image *Image) GetMetadata(key string) (string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", err return "", err
@ -47,7 +48,8 @@ func (image *Image) GetMetadata(key string) (string, error) {
// SetMetadata updates the metadata string associated with the given key. // SetMetadata updates the metadata string associated with the given key.
// //
// Implements: // Implements:
// int rbd_metadata_set(rbd_image_t image, const char *key, const char *value) //
// int rbd_metadata_set(rbd_image_t image, const char *key, const char *value)
func (image *Image) SetMetadata(key string, value string) error { func (image *Image) SetMetadata(key string, value string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -69,7 +71,8 @@ func (image *Image) SetMetadata(key string, value string) error {
// RemoveMetadata clears the metadata associated with the given key. // RemoveMetadata clears the metadata associated with the given key.
// //
// Implements: // Implements:
// int rbd_metadata_remove(rbd_image_t image, const char *key) //
// int rbd_metadata_remove(rbd_image_t image, const char *key)
func (image *Image) RemoveMetadata(key string) error { func (image *Image) RemoveMetadata(key string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -89,8 +92,9 @@ func (image *Image) RemoveMetadata(key string) error {
// ListMetadata returns a map containing all metadata assigned to the RBD image. // ListMetadata returns a map containing all metadata assigned to the RBD image.
// //
// Implements: // Implements:
// int rbd_metadata_list(rbd_image_t image, const char *start, uint64_t max, //
// char *keys, size_t *key_len, char *values, size_t *vals_len); // int rbd_metadata_list(rbd_image_t image, const char *start, uint64_t max,
// char *keys, size_t *key_len, char *values, size_t *vals_len);
func (image *Image) ListMetadata() (map[string]string, error) { func (image *Image) ListMetadata() (map[string]string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err

View File

@ -62,12 +62,12 @@ type MigrationImageStatus struct {
// to source and making source read-only. // to source and making source read-only.
// //
// Implements: // Implements:
// int rbd_migration_prepare(rados_ioctx_t ioctx,
// const char *image_name,
// rados_ioctx_t dest_ioctx,
// const char *dest_image_name,
// rbd_image_options_t opts);
// //
// int rbd_migration_prepare(rados_ioctx_t ioctx,
// const char *image_name,
// rados_ioctx_t dest_ioctx,
// const char *dest_image_name,
// rbd_image_options_t opts);
func MigrationPrepare(ioctx *rados.IOContext, sourceImageName string, destIoctx *rados.IOContext, destImageName string, rio *ImageOptions) error { func MigrationPrepare(ioctx *rados.IOContext, sourceImageName string, destIoctx *rados.IOContext, destImageName string, rio *ImageOptions) error {
cSourceImageName := C.CString(sourceImageName) cSourceImageName := C.CString(sourceImageName)
cDestImageName := C.CString(destImageName) cDestImageName := C.CString(destImageName)
@ -90,11 +90,11 @@ func MigrationPrepare(ioctx *rados.IOContext, sourceImageName string, destIoctx
// from a specified source to a new target image. // from a specified source to a new target image.
// //
// Implements: // Implements:
// int rbd_migration_prepare_import(const char *source_spec,
// rados_ioctx_t dest_ioctx,
// const char *dest_image_name,
// rbd_image_options_t opts);
// //
// int rbd_migration_prepare_import(const char *source_spec,
// rados_ioctx_t dest_ioctx,
// const char *dest_image_name,
// rbd_image_options_t opts);
func MigrationPrepareImport(sourceSpec string, ioctx *rados.IOContext, destImageName string, rio *ImageOptions) error { func MigrationPrepareImport(sourceSpec string, ioctx *rados.IOContext, destImageName string, rio *ImageOptions) error {
cSourceSpec := C.CString(sourceSpec) cSourceSpec := C.CString(sourceSpec)
cDestImageName := C.CString(destImageName) cDestImageName := C.CString(destImageName)
@ -116,9 +116,9 @@ func MigrationPrepareImport(sourceSpec string, ioctx *rados.IOContext, destImage
// from the source image to the target image. // from the source image to the target image.
// //
// Implements: // Implements:
// int rbd_migration_execute(rados_ioctx_t ioctx,
// const char *image_name);
// //
// int rbd_migration_execute(rados_ioctx_t ioctx,
// const char *image_name);
func MigrationExecute(ioctx *rados.IOContext, name string) error { func MigrationExecute(ioctx *rados.IOContext, name string) error {
cName := C.CString(name) cName := C.CString(name)
@ -136,9 +136,9 @@ func MigrationExecute(ioctx *rados.IOContext, name string) error {
// breaking the relationship of image to the source. // breaking the relationship of image to the source.
// //
// Implements: // Implements:
// int rbd_migration_commit(rados_ioctx_t ioctx,
// const char *image_name);
// //
// int rbd_migration_commit(rados_ioctx_t ioctx,
// const char *image_name);
func MigrationCommit(ioctx *rados.IOContext, name string) error { func MigrationCommit(ioctx *rados.IOContext, name string) error {
cName := C.CString(name) cName := C.CString(name)
@ -156,9 +156,9 @@ func MigrationCommit(ioctx *rados.IOContext, name string) error {
// breaking the relationship of image to the source. // breaking the relationship of image to the source.
// //
// Implements: // Implements:
// int rbd_migration_abort(rados_ioctx_t ioctx,
// const char *image_name);
// //
// int rbd_migration_abort(rados_ioctx_t ioctx,
// const char *image_name);
func MigrationAbort(ioctx *rados.IOContext, name string) error { func MigrationAbort(ioctx *rados.IOContext, name string) error {
cName := C.CString(name) cName := C.CString(name)
@ -176,11 +176,11 @@ func MigrationAbort(ioctx *rados.IOContext, name string) error {
// for the specified image. // for the specified image.
// //
// Implements: // Implements:
// int rbd_migration_status(rados_ioctx_t ioctx,
// const char *image_name,
// rbd_image_migration_status_t *status,
// size_t status_size);
// //
// int rbd_migration_status(rados_ioctx_t ioctx,
// const char *image_name,
// rbd_image_migration_status_t *status,
// size_t status_size);
func MigrationStatus(ioctx *rados.IOContext, name string) (*MigrationImageStatus, error) { func MigrationStatus(ioctx *rados.IOContext, name string) (*MigrationImageStatus, error) {
cName := C.CString(name) cName := C.CString(name)

View File

@ -81,8 +81,9 @@ func (imm ImageMirrorMode) String() string {
// associated with the ioctx. // associated with the ioctx.
// //
// Implements: // Implements:
// int rbd_mirror_uuid_get(rados_ioctx_t io_ctx, char *uuid, size_t //
// *max_len); // int rbd_mirror_uuid_get(rados_ioctx_t io_ctx, char *uuid, size_t
// *max_len);
func GetMirrorUUID(ioctx *rados.IOContext) (string, error) { func GetMirrorUUID(ioctx *rados.IOContext) (string, error) {
var ( var (
err error err error
@ -109,8 +110,9 @@ func GetMirrorUUID(ioctx *rados.IOContext) (string, error) {
// an automatic or per-image behavior. // an automatic or per-image behavior.
// //
// Implements: // Implements:
// int rbd_mirror_mode_set(rados_ioctx_t io_ctx, //
// rbd_mirror_mode_t mirror_mode); // int rbd_mirror_mode_set(rados_ioctx_t io_ctx,
// rbd_mirror_mode_t mirror_mode);
func SetMirrorMode(ioctx *rados.IOContext, mode MirrorMode) error { func SetMirrorMode(ioctx *rados.IOContext, mode MirrorMode) error {
ret := C.rbd_mirror_mode_set( ret := C.rbd_mirror_mode_set(
cephIoctx(ioctx), cephIoctx(ioctx),
@ -121,8 +123,9 @@ func SetMirrorMode(ioctx *rados.IOContext, mode MirrorMode) error {
// GetMirrorMode is used to fetch the current mirroring mode for a pool. // GetMirrorMode is used to fetch the current mirroring mode for a pool.
// //
// Implements: // Implements:
// int rbd_mirror_mode_get(rados_ioctx_t io_ctx, //
// rbd_mirror_mode_t *mirror_mode); // int rbd_mirror_mode_get(rados_ioctx_t io_ctx,
// rbd_mirror_mode_t *mirror_mode);
func GetMirrorMode(ioctx *rados.IOContext) (MirrorMode, error) { func GetMirrorMode(ioctx *rados.IOContext) (MirrorMode, error) {
var mode C.rbd_mirror_mode_t var mode C.rbd_mirror_mode_t
@ -138,8 +141,9 @@ func GetMirrorMode(ioctx *rados.IOContext) (MirrorMode, error) {
// MirrorEnable will enable mirroring for an image using the specified mode. // MirrorEnable will enable mirroring for an image using the specified mode.
// //
// Implements: // Implements:
// int rbd_mirror_image_enable2(rbd_image_t image, //
// rbd_mirror_image_mode_t mode); // int rbd_mirror_image_enable2(rbd_image_t image,
// rbd_mirror_image_mode_t mode);
func (image *Image) MirrorEnable(mode ImageMirrorMode) error { func (image *Image) MirrorEnable(mode ImageMirrorMode) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -151,7 +155,8 @@ func (image *Image) MirrorEnable(mode ImageMirrorMode) error {
// MirrorDisable will disable mirroring for the image. // MirrorDisable will disable mirroring for the image.
// //
// Implements: // Implements:
// int rbd_mirror_image_disable(rbd_image_t image, bool force); //
// int rbd_mirror_image_disable(rbd_image_t image, bool force);
func (image *Image) MirrorDisable(force bool) error { func (image *Image) MirrorDisable(force bool) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -163,7 +168,8 @@ func (image *Image) MirrorDisable(force bool) error {
// MirrorPromote will promote the image to primary status. // MirrorPromote will promote the image to primary status.
// //
// Implements: // Implements:
// int rbd_mirror_image_promote(rbd_image_t image, bool force); //
// int rbd_mirror_image_promote(rbd_image_t image, bool force);
func (image *Image) MirrorPromote(force bool) error { func (image *Image) MirrorPromote(force bool) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -175,7 +181,8 @@ func (image *Image) MirrorPromote(force bool) error {
// MirrorDemote will demote the image to secondary status. // MirrorDemote will demote the image to secondary status.
// //
// Implements: // Implements:
// int rbd_mirror_image_demote(rbd_image_t image); //
// int rbd_mirror_image_demote(rbd_image_t image);
func (image *Image) MirrorDemote() error { func (image *Image) MirrorDemote() error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -188,7 +195,8 @@ func (image *Image) MirrorDemote() error {
// resynchronization. // resynchronization.
// //
// Implements: // Implements:
// int rbd_mirror_image_resync(rbd_image_t image); //
// int rbd_mirror_image_resync(rbd_image_t image);
func (image *Image) MirrorResync() error { func (image *Image) MirrorResync() error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -200,9 +208,10 @@ func (image *Image) MirrorResync() error {
// MirrorInstanceID returns a string naming the instance id for the image. // MirrorInstanceID returns a string naming the instance id for the image.
// //
// Implements: // Implements:
// int rbd_mirror_image_get_instance_id(rbd_image_t image, //
// char *instance_id, // int rbd_mirror_image_get_instance_id(rbd_image_t image,
// size_t *id_max_length); // char *instance_id,
// size_t *id_max_length);
func (image *Image) MirrorInstanceID() (string, error) { func (image *Image) MirrorInstanceID() (string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", err return "", err
@ -275,9 +284,10 @@ func convertMirrorImageInfo(cInfo *C.rbd_mirror_image_info_t) MirrorImageInfo {
// GetMirrorImageInfo fetches the mirroring status information of a RBD image. // GetMirrorImageInfo fetches the mirroring status information of a RBD image.
// //
// Implements: // Implements:
// int rbd_mirror_image_get_info(rbd_image_t image, //
// rbd_mirror_image_info_t *mirror_image_info, // int rbd_mirror_image_get_info(rbd_image_t image,
// size_t info_size) // rbd_mirror_image_info_t *mirror_image_info,
// size_t info_size)
func (image *Image) GetMirrorImageInfo() (*MirrorImageInfo, error) { func (image *Image) GetMirrorImageInfo() (*MirrorImageInfo, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err
@ -303,7 +313,8 @@ func (image *Image) GetMirrorImageInfo() (*MirrorImageInfo, error) {
// GetImageMirrorMode fetches the mirroring approach for an RBD image. // GetImageMirrorMode fetches the mirroring approach for an RBD image.
// //
// Implements: // Implements:
// int rbd_mirror_image_get_mode(rbd_image_t image, rbd_mirror_image_mode_t *mode); //
// int rbd_mirror_image_get_mode(rbd_image_t image, rbd_mirror_image_mode_t *mode);
func (image *Image) GetImageMirrorMode() (ImageMirrorMode, error) { func (image *Image) GetImageMirrorMode() (ImageMirrorMode, error) {
var mode C.rbd_mirror_image_mode_t var mode C.rbd_mirror_image_mode_t
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
@ -404,10 +415,11 @@ type siteArray [cutil.MaxIdx]C.rbd_mirror_image_site_status_t
// of the images's mirroring. // of the images's mirroring.
// //
// Implements: // Implements:
// int rbd_mirror_image_get_global_status( //
// rbd_image_t image, // int rbd_mirror_image_get_global_status(
// rbd_mirror_image_global_status_t *mirror_image_global_status, // rbd_image_t image,
// size_t status_size); // rbd_mirror_image_global_status_t *mirror_image_global_status,
// size_t status_size);
func (image *Image) GetGlobalMirrorStatus() (GlobalMirrorImageStatus, error) { func (image *Image) GetGlobalMirrorStatus() (GlobalMirrorImageStatus, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return GlobalMirrorImageStatus{}, err return GlobalMirrorImageStatus{}, err
@ -453,8 +465,9 @@ func newGlobalMirrorImageStatus(
// CreateMirrorSnapshot creates a snapshot for image propagation to mirrors. // CreateMirrorSnapshot creates a snapshot for image propagation to mirrors.
// //
// Implements: // Implements:
// int rbd_mirror_image_create_snapshot(rbd_image_t image, //
// uint64_t *snap_id); // int rbd_mirror_image_create_snapshot(rbd_image_t image,
// uint64_t *snap_id);
func (image *Image) CreateMirrorSnapshot() (uint64, error) { func (image *Image) CreateMirrorSnapshot() (uint64, error) {
var snapID C.uint64_t var snapID C.uint64_t
ret := C.rbd_mirror_image_create_snapshot( ret := C.rbd_mirror_image_create_snapshot(
@ -467,9 +480,10 @@ func (image *Image) CreateMirrorSnapshot() (uint64, error) {
// of images with said status. // of images with said status.
// //
// Implements: // Implements:
// int rbd_mirror_image_status_summary( //
// rados_ioctx_t io_ctx, rbd_mirror_image_status_state_t *states, int *counts, // int rbd_mirror_image_status_summary(
// size_t *maxlen); // rados_ioctx_t io_ctx, rbd_mirror_image_status_state_t *states, int *counts,
// size_t *maxlen);
func MirrorImageStatusSummary( func MirrorImageStatusSummary(
ioctx *rados.IOContext) (map[MirrorImageStatusState]uint, error) { ioctx *rados.IOContext) (map[MirrorImageStatusState]uint, error) {
// ideally, we already know the size of the arrays - they should be // ideally, we already know the size of the arrays - they should be
@ -513,8 +527,9 @@ func MirrorImageStatusSummary(
// cluster associated with the provided rados connection. // cluster associated with the provided rados connection.
// //
// Implements: // Implements:
// int rbd_mirror_site_name_set(rados_t cluster, //
// const char *name); // int rbd_mirror_site_name_set(rados_t cluster,
// const char *name);
func SetMirrorSiteName(conn *rados.Conn, name string) error { func SetMirrorSiteName(conn *rados.Conn, name string) error {
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))
@ -530,7 +545,8 @@ func SetMirrorSiteName(conn *rados.Conn, name string) error {
// //
// Implements: // Implements:
// int rbd_mirror_site_name_get(rados_t cluster, // int rbd_mirror_site_name_get(rados_t cluster,
// char *name, size_t *max_len); //
// char *name, size_t *max_len);
func GetMirrorSiteName(conn *rados.Conn) (string, error) { func GetMirrorSiteName(conn *rados.Conn) (string, error) {
var ( var (
@ -562,8 +578,9 @@ func GetMirrorSiteName(conn *rados.Conn) (string, error) {
// pools. // pools.
// //
// Implements: // Implements:
// int rbd_mirror_peer_bootstrap_create( //
// rados_ioctx_t io_ctx, char *token, size_t *max_len); // int rbd_mirror_peer_bootstrap_create(
// rados_ioctx_t io_ctx, char *token, size_t *max_len);
func CreateMirrorPeerBootstrapToken(ioctx *rados.IOContext) (string, error) { func CreateMirrorPeerBootstrapToken(ioctx *rados.IOContext) (string, error) {
var ( var (
cioctx = cephIoctx(ioctx) cioctx = cephIoctx(ioctx)
@ -606,9 +623,10 @@ const (
// source, destination, or both. // source, destination, or both.
// //
// Implements: // Implements:
// int rbd_mirror_peer_bootstrap_import( //
// rados_ioctx_t io_ctx, rbd_mirror_peer_direction_t direction, // int rbd_mirror_peer_bootstrap_import(
// const char *token); // rados_ioctx_t io_ctx, rbd_mirror_peer_direction_t direction,
// const char *token);
func ImportMirrorPeerBootstrapToken( func ImportMirrorPeerBootstrapToken(
ioctx *rados.IOContext, direction MirrorPeerDirection, token string) error { ioctx *rados.IOContext, direction MirrorPeerDirection, token string) error {
// instead of taking a length, rbd_mirror_peer_bootstrap_import assumes a // instead of taking a length, rbd_mirror_peer_bootstrap_import assumes a
@ -644,8 +662,9 @@ var iterBufSize = 64
// //
// Implements: // Implements:
// int rbd_mirror_image_status_list(rados_ioctx_t p, // int rbd_mirror_image_status_list(rados_ioctx_t p,
// const char *start_id, size_t max, char **image_ids, //
// rbd_mirror_image_status_t *images, size_t *len) // const char *start_id, size_t max, char **image_ids,
// rbd_mirror_image_status_t *images, size_t *len)
func MirrorImageGlobalStatusList( func MirrorImageGlobalStatusList(
ioctx *rados.IOContext, start string, max int) ([]GlobalMirrorImageIDAndStatus, error) { ioctx *rados.IOContext, start string, max int) ([]GlobalMirrorImageIDAndStatus, error) {
var ( var (
@ -781,10 +800,11 @@ type MirrorImageInfoItem struct {
// //
// Implements: // Implements:
// int rbd_mirror_image_info_list( // int rbd_mirror_image_info_list(
// rados_ioctx_t p, rbd_mirror_image_mode_t *mode_filter, //
// const char *start_id, size_t max, char **image_ids, // rados_ioctx_t p, rbd_mirror_image_mode_t *mode_filter,
// rbd_mirror_image_mode_t *mode_entries, // const char *start_id, size_t max, char **image_ids,
// rbd_mirror_image_info_t *info_entries, size_t *num_entries) // rbd_mirror_image_mode_t *mode_entries,
// rbd_mirror_image_info_t *info_entries, size_t *num_entries)
func MirrorImageInfoList( func MirrorImageInfoList(
ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter, start string, ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter, start string,
max int) ([]MirrorImageInfoItem, error) { max int) ([]MirrorImageInfoItem, error) {
@ -921,11 +941,12 @@ type MirrorImageInstanceIDItem struct {
// //
// Implements: // Implements:
// int rbd_mirror_image_instance_id_list( // int rbd_mirror_image_instance_id_list(
// rados_ioctx_t io_ctx, //
// const char *start_id, // rados_ioctx_t io_ctx,
// size_t max, char **image_ids, // const char *start_id,
// char **instance_ids, // size_t max, char **image_ids,
// size_t *len) // char **instance_ids,
// size_t *len)
func MirrorImageInstanceIDList( func MirrorImageInstanceIDList(
ioctx *rados.IOContext, start string, ioctx *rados.IOContext, start string,
max int) ([]MirrorImageInstanceIDItem, error) { max int) ([]MirrorImageInstanceIDItem, error) {

View File

@ -0,0 +1,71 @@
//go:build !nautilus && ceph_preview
// +build !nautilus,ceph_preview
package rbd
// #cgo LDFLAGS: -lrbd
// #include <stdlib.h>
// #include <rbd/librbd.h>
import "C"
import (
"encoding/json"
"strings"
)
// MirrorDescriptionReplayStatus contains information pertaining to the status
// of snapshot based RBD image mirroring.
type MirrorDescriptionReplayStatus struct {
ReplayState string `json:"replay_state"`
RemoteSnapshotTimestamp int64 `json:"remote_snapshot_timestamp"`
LocalSnapshotTimestamp int64 `json:"local_snapshot_timestamp"`
SyncingSnapshotTimestamp int64 `json:"syncing_snapshot_timestamp"`
SyncingPercent int `json:"syncing_percent"`
BytesPerSecond float64 `json:"bytes_per_second"`
BytesPerSnapshot float64 `json:"bytes_per_snapshot"`
LastSnapshotSyncSeconds int64 `json:"last_snapshot_sync_seconds"`
LastSnapshotBytes int64 `json:"last_snapshot_bytes"`
}
// extractDescriptionJSON will extract one string containing a JSON object from
// the description if one can be found.
func (s *SiteMirrorImageStatus) extractDescriptionJSON() (string, error) {
start := strings.Index(s.Description, "{")
if start == -1 {
return "", ErrNotExist
}
end := strings.LastIndex(s.Description, "}")
if end == -1 {
return "", ErrNotExist
}
if start >= end {
return "", ErrNotExist
}
return s.Description[start : end+1], nil
}
// UnmarshalDescriptionJSON parses an embedded JSON string that may be found in
// the description of the SiteMirrorImageStatus. It will store the result in
// the value pointed to by v. If no embedded JSON string is found an
// ErrNotExist error is returned. An error may also be returned if the contents
// can not be parsed.
func (s *SiteMirrorImageStatus) UnmarshalDescriptionJSON(v interface{}) error {
desc, err := s.extractDescriptionJSON()
if err != nil {
return err
}
return json.Unmarshal([]byte(desc), v)
}
// DescriptionReplayStatus parses a MirrorDescriptionReplayStatus result out of
// the image status description field if available. If the embedded status JSON
// is not found or fails to parse and error will be returned.
func (s *SiteMirrorImageStatus) DescriptionReplayStatus() (
*MirrorDescriptionReplayStatus, error) {
// ---
mdrs := MirrorDescriptionReplayStatus{}
if err := s.UnmarshalDescriptionJSON(&mdrs); err != nil {
return nil, err
}
return &mdrs, nil
}

View File

@ -35,7 +35,8 @@ const (
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_mode_get(rados_ioctx_t p, rbd_mirror_mode_t *mirror_mode) //
// int rbd_mirror_mode_get(rados_ioctx_t p, rbd_mirror_mode_t *mirror_mode)
func MirrorModeGet(ioctx *rados.IOContext) (MirrorMode, error) { func MirrorModeGet(ioctx *rados.IOContext) (MirrorMode, error) {
var rmm C.rbd_mirror_mode_t var rmm C.rbd_mirror_mode_t
@ -53,7 +54,8 @@ func MirrorModeGet(ioctx *rados.IOContext) (MirrorMode, error) {
// tag. // tag.
// //
// Implements: // Implements:
// rbd_mirror_mode_set(rados_ioctx_t p, rbd_mirror_mode_t mirror_mode) //
// rbd_mirror_mode_set(rados_ioctx_t p, rbd_mirror_mode_t mirror_mode)
func MirrorModeSet(ioctx *rados.IOContext, mode MirrorMode) error { func MirrorModeSet(ioctx *rados.IOContext, mode MirrorMode) error {
cMode := C.rbd_mirror_mode_t(mode) cMode := C.rbd_mirror_mode_t(mode)
@ -70,10 +72,11 @@ func MirrorModeSet(ioctx *rados.IOContext, mode MirrorMode) error {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_peer_add(rados_ioctx_t p, char *uuid, //
// size_t uuid_max_length, // int rbd_mirror_peer_add(rados_ioctx_t p, char *uuid,
// const char *cluster_name, // size_t uuid_max_length,
// const char *client_name) // const char *cluster_name,
// const char *client_name)
func MirrorPeerAdd(ioctx *rados.IOContext, clusterName, clientName string) (string, error) { func MirrorPeerAdd(ioctx *rados.IOContext, clusterName, clientName string) (string, error) {
// librbd uses 36-byte UUIDs with a trailing null. rbd_mirror_add_peer will // librbd uses 36-byte UUIDs with a trailing null. rbd_mirror_add_peer will
// return -E2BIG if we pass a UUID buffer smaller than 37 bytes. // return -E2BIG if we pass a UUID buffer smaller than 37 bytes.
@ -98,7 +101,8 @@ func MirrorPeerAdd(ioctx *rados.IOContext, clusterName, clientName string) (stri
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_peer_remove(rados_ioctx_t io_ctx, const char *uuid) //
// int rbd_mirror_peer_remove(rados_ioctx_t io_ctx, const char *uuid)
func MirrorPeerRemove(ioctx *rados.IOContext, uuid string) error { func MirrorPeerRemove(ioctx *rados.IOContext, uuid string) error {
cUUID := C.CString(uuid) cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID)) defer C.free(unsafe.Pointer(cUUID))
@ -121,9 +125,10 @@ type MirrorPeerInfo struct {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_peer_list(rados_ioctx_t io_ctx, //
// rbd_mirror_peer_list_t *peers, // int rbd_mirror_peer_list(rados_ioctx_t io_ctx,
// int *max_peers); // rbd_mirror_peer_list_t *peers,
// int *max_peers);
func MirrorPeerList(ioctx *rados.IOContext) ([]*MirrorPeerInfo, error) { func MirrorPeerList(ioctx *rados.IOContext) ([]*MirrorPeerInfo, error) {
var mpi []*MirrorPeerInfo var mpi []*MirrorPeerInfo
cMaxPeers := C.int(5) cMaxPeers := C.int(5)
@ -218,9 +223,10 @@ type MirrorImageInfo struct {
// tag. // tag.
// //
// Implements: // Implements:
// rbd_mirror_image_get_info(rbd_image_t image, //
// rbd_mirror_image_info_t *mirror_image_info, // rbd_mirror_image_get_info(rbd_image_t image,
// size_t info_size) // rbd_mirror_image_info_t *mirror_image_info,
// size_t info_size)
func (image *Image) MirrorGetImage() (*MirrorImageInfo, error) { func (image *Image) MirrorGetImage() (*MirrorImageInfo, error) {
err := image.validate(imageIsOpen) err := image.validate(imageIsOpen)
if err != nil { if err != nil {
@ -250,11 +256,12 @@ func (image *Image) MirrorGetImage() (*MirrorImageInfo, error) {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_image_status_list(rados_ioctx_t io_ctx, //
// const char *start_id, size_t max, // int rbd_mirror_image_status_list(rados_ioctx_t io_ctx,
// char **image_ids, // const char *start_id, size_t max,
// rbd_mirror_image_status_t *images, // char **image_ids,
// size_t *len) // rbd_mirror_image_status_t *images,
// size_t *len)
func MirrorImageList(ioctx *rados.IOContext) ([]*MirrorImageInfo, error) { func MirrorImageList(ioctx *rados.IOContext) ([]*MirrorImageInfo, error) {
imageInfos := make([]*MirrorImageInfo, 0) imageInfos := make([]*MirrorImageInfo, 0)
const cMaxIter C.size_t = 100 const cMaxIter C.size_t = 100
@ -327,7 +334,8 @@ func iterateImageList(ioctx *rados.IOContext, imageInfos *[]*MirrorImageInfo, st
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_image_enable(rbd_image_t image) //
// int rbd_mirror_image_enable(rbd_image_t image)
func (image *Image) MirrorEnable() error { func (image *Image) MirrorEnable() error {
err := image.validate(imageIsOpen) err := image.validate(imageIsOpen)
if err != nil { if err != nil {
@ -344,7 +352,8 @@ func (image *Image) MirrorEnable() error {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_image_disable(rbd_image_t image, bool force) //
// int rbd_mirror_image_disable(rbd_image_t image, bool force)
func (image *Image) MirrorDisable(force bool) error { func (image *Image) MirrorDisable(force bool) error {
err := image.validate(imageIsOpen) err := image.validate(imageIsOpen)
if err != nil { if err != nil {
@ -361,7 +370,8 @@ func (image *Image) MirrorDisable(force bool) error {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_image_promote(rbd_image_t image, bool force) //
// int rbd_mirror_image_promote(rbd_image_t image, bool force)
func (image *Image) MirrorPromote(force bool) error { func (image *Image) MirrorPromote(force bool) error {
err := image.validate(imageIsOpen) err := image.validate(imageIsOpen)
if err != nil { if err != nil {
@ -378,7 +388,8 @@ func (image *Image) MirrorPromote(force bool) error {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_image_demote(rbd_image_t image) //
// int rbd_mirror_image_demote(rbd_image_t image)
func (image *Image) MirrorDemote() error { func (image *Image) MirrorDemote() error {
err := image.validate(imageIsOpen) err := image.validate(imageIsOpen)
if err != nil { if err != nil {
@ -396,7 +407,8 @@ func (image *Image) MirrorDemote() error {
// tag. // tag.
// //
// Implements: // Implements:
// int rbd_mirror_image_resync(rbd_image_t image) //
// int rbd_mirror_image_resync(rbd_image_t image)
func (image *Image) MirrorResync() error { func (image *Image) MirrorResync() error {
err := image.validate(imageIsOpen) err := image.validate(imageIsOpen)
if err != nil { if err != nil {

255
vendor/github.com/ceph/go-ceph/rbd/mirror_peer_site.go generated vendored Normal file
View File

@ -0,0 +1,255 @@
//go:build !nautilus && ceph_preview
// +build !nautilus,ceph_preview
package rbd
// #cgo LDFLAGS: -lrbd
// #include <stdlib.h>
// #include <rbd/librbd.h>
import "C"
import (
"bytes"
"unsafe"
"github.com/ceph/go-ceph/internal/cutil"
"github.com/ceph/go-ceph/internal/retry"
"github.com/ceph/go-ceph/rados"
)
// AddMirrorPeerSite adds a peer site to the list of existing sites
//
// Implements:
//
// int rbd_mirror_peer_site_add(rados_ioctx_t p, char *uuid, size_t uuid_max_length,
// rbd_mirror_peer_direction_t direction,
// const char *site_name,
// const char *client_name);
func AddMirrorPeerSite(ioctx *rados.IOContext, siteName string, clientName string,
direction MirrorPeerDirection) (string, error) {
var (
err error
buf []byte
cSize C.size_t
)
cSiteName := C.CString(siteName)
defer C.free(unsafe.Pointer(cSiteName))
cClientName := C.CString(clientName)
defer C.free(unsafe.Pointer(cClientName))
retry.WithSizes(512, 1<<16, func(size int) retry.Hint {
cSize = C.size_t(size)
buf = make([]byte, cSize)
ret := C.rbd_mirror_peer_site_add(
cephIoctx(ioctx),
(*C.char)(unsafe.Pointer(&buf[0])),
cSize, C.rbd_mirror_peer_direction_t(direction),
cSiteName, cClientName)
err = getError(ret)
return retry.Size(int(cSize)).If(err != nil)
})
if err != nil {
return "", err
}
return string(bytes.Trim(buf[:cSize], "\x00")), nil
}
// RemoveMirrorPeerSite removes the site with the provided uuid
//
// Implements:
//
// int rbd_mirror_peer_site_remove(rados_ioctx_t p, const char *uuid)
func RemoveMirrorPeerSite(ioctx *rados.IOContext, uuid string) error {
cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID))
ret := C.rbd_mirror_peer_site_remove(cephIoctx(ioctx), cUUID)
return getError(ret)
}
// GetAttributesMirrorPeerSite fetches the list of key,value pair of attributes of a peer site
//
// Implements:
//
// int rbd_mirror_peer_site_get_attributes(rados_ioctx_t p, const char *uuid, char *keys,
// size_t *max_key_len, char *values, size_t *max_val_len,
// size_t *key_value_count);
func GetAttributesMirrorPeerSite(ioctx *rados.IOContext, uuid string) (map[string]string, error) {
var (
err error
keys []byte
vals []byte
keySize C.size_t
valSize C.size_t
count = C.size_t(0)
)
cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID))
retry.WithSizes(1024, 1<<16, func(size int) retry.Hint {
keySize = C.size_t(size)
valSize = C.size_t(size)
keys = make([]byte, keySize)
vals = make([]byte, valSize)
ret := C.rbd_mirror_peer_site_get_attributes(
cephIoctx(ioctx), cUUID, (*C.char)(unsafe.Pointer(&keys[0])),
&keySize, (*C.char)(unsafe.Pointer(&vals[0])), &valSize,
&count)
err = getErrorIfNegative(ret)
return retry.Size(int(keySize)).If(err == errRange)
})
if err != nil {
return nil, err
}
keyList := cutil.SplitBuffer(keys[:keySize])
valList := cutil.SplitBuffer(vals[:valSize])
attributes := map[string]string{}
for i := 0; i < int(len(keyList)); i++ {
attributes[keyList[i]] = valList[i]
}
return attributes, nil
}
// SetAttributesMirrorPeerSite sets the attributes for the site with the given uuid
//
// Implements:
//
// int rbd_mirror_peer_site_set_attributes(rados_ioctx_t p, const char *uuid,
// const char *keys, const char *values,
// size_t count) ;
func SetAttributesMirrorPeerSite(ioctx *rados.IOContext, uuid string, attributes map[string]string) error {
cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID))
var (
key string
val string
count = C.size_t(len(attributes))
)
for k, v := range attributes {
key += k + "\000"
val += v + "\000"
}
cKey := C.CString(key)
defer C.free(unsafe.Pointer(cKey))
cVal := C.CString(val)
defer C.free(unsafe.Pointer(cVal))
ret := C.rbd_mirror_peer_site_set_attributes(cephIoctx(ioctx), cUUID, cKey, cVal, count)
return getError(ret)
}
// MirrorPeerSite contains information about a mirroring peer site.
type MirrorPeerSite struct {
UUID string
Direction MirrorPeerDirection
SiteName string
MirrorUUID string
ClientName string
LastSeen C.time_t
}
// ListMirrorPeerSite returns the list of peer sites
//
// Implements:
//
// int rbd_mirror_peer_site_list(rados_ioctx_t p, rbd_mirror_peer_site_t *peers, int *max_peers)
func ListMirrorPeerSite(ioctx *rados.IOContext) ([]*MirrorPeerSite, error) {
var mps []*MirrorPeerSite
cMaxPeers := C.int(10)
var cSites []C.rbd_mirror_peer_site_t
for {
cSites = make([]C.rbd_mirror_peer_site_t, cMaxPeers)
ret := C.rbd_mirror_peer_site_list(cephIoctx(ioctx), &cSites[0], &cMaxPeers)
err := getError(ret)
if err == errRange {
// There are too many peer sites to fit in the list, and the number of peer sites has been
// returned in cMaxPeers. Try again with the returned value.
continue
}
if err != nil {
return nil, err
}
// ret == 0
break
}
defer C.rbd_mirror_peer_site_list_cleanup(&cSites[0], cMaxPeers)
cSites = cSites[:cMaxPeers]
for _, cSite := range cSites {
mps = append(mps, &MirrorPeerSite{
UUID: C.GoString(cSite.uuid),
Direction: MirrorPeerDirection(cSite.direction),
SiteName: C.GoString(cSite.site_name),
MirrorUUID: C.GoString(cSite.mirror_uuid),
ClientName: C.GoString(cSite.client_name),
})
}
return mps, nil
}
// SetMirrorPeerSiteClientName sets the client name for a mirror peer site
//
// Implements:
//
// int rbd_mirror_peer_site_set_client_name(rados_ioctx_t p, const char *uuid,
// const char *client_name);
func SetMirrorPeerSiteClientName(ioctx *rados.IOContext, uuid string, clientName string) error {
cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID))
cClientName := C.CString(clientName)
defer C.free(unsafe.Pointer(cClientName))
ret := C.rbd_mirror_peer_site_set_client_name(cephIoctx(ioctx), cUUID, cClientName)
return getError(ret)
}
// SetMirrorPeerSiteDirection sets the direction of a mirror peer site
//
// Implements:
//
// int rbd_mirror_peer_site_set_direction(rados_ioctx_t p, const char *uuid,
// rbd_mirror_peer_direction_t direction);
func SetMirrorPeerSiteDirection(ioctx *rados.IOContext, uuid string, direction MirrorPeerDirection) error {
cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID))
ret := C.rbd_mirror_peer_site_set_direction(cephIoctx(ioctx), cUUID,
C.rbd_mirror_peer_direction_t(direction))
return getError(ret)
}
// SetMirrorPeerSiteName sets the name of a mirror peer site
//
// Implements:
//
// int rbd_mirror_peer_site_set_name(rados_ioctx_t p, const char *uuid,
// const char *site_name);
func SetMirrorPeerSiteName(ioctx *rados.IOContext, uuid string, siteName string) error {
cUUID := C.CString(uuid)
defer C.free(unsafe.Pointer(cUUID))
cSiteName := C.CString(siteName)
defer C.free(unsafe.Pointer(cSiteName))
ret := C.rbd_mirror_peer_site_set_name(cephIoctx(ioctx), cUUID, cSiteName)
return getError(ret)
}

View File

@ -22,7 +22,8 @@ import (
// NamespaceCreate creates the namespace for a given Rados IOContext. // NamespaceCreate creates the namespace for a given Rados IOContext.
// //
// Implements: // Implements:
// int rbd_namespace_create(rados_ioctx_t io, const char *namespace_name); //
// int rbd_namespace_create(rados_ioctx_t io, const char *namespace_name);
func NamespaceCreate(ioctx *rados.IOContext, namespaceName string) error { func NamespaceCreate(ioctx *rados.IOContext, namespaceName string) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -40,7 +41,8 @@ func NamespaceCreate(ioctx *rados.IOContext, namespaceName string) error {
// NamespaceRemove removes a given namespace. // NamespaceRemove removes a given namespace.
// //
// Implements: // Implements:
// int rbd_namespace_remove(rados_ioctx_t io, const char *namespace_name); //
// int rbd_namespace_remove(rados_ioctx_t io, const char *namespace_name);
func NamespaceRemove(ioctx *rados.IOContext, namespaceName string) error { func NamespaceRemove(ioctx *rados.IOContext, namespaceName string) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -58,7 +60,8 @@ func NamespaceRemove(ioctx *rados.IOContext, namespaceName string) error {
// NamespaceExists checks whether a given namespace exists or not. // NamespaceExists checks whether a given namespace exists or not.
// //
// Implements: // Implements:
// int rbd_namespace_exists(rados_ioctx_t io, const char *namespace_name, bool *exists); //
// int rbd_namespace_exists(rados_ioctx_t io, const char *namespace_name, bool *exists);
func NamespaceExists(ioctx *rados.IOContext, namespaceName string) (bool, error) { func NamespaceExists(ioctx *rados.IOContext, namespaceName string) (bool, error) {
if ioctx == nil { if ioctx == nil {
return false, ErrNoIOContext return false, ErrNoIOContext
@ -77,7 +80,8 @@ func NamespaceExists(ioctx *rados.IOContext, namespaceName string) (bool, error)
// NamespaceList returns a slice containing the names of existing rbd namespaces. // NamespaceList returns a slice containing the names of existing rbd namespaces.
// //
// Implements: // Implements:
// int rbd_namespace_list(rados_ioctx_t io, char *namespace_names, size_t *size); //
// int rbd_namespace_list(rados_ioctx_t io, char *namespace_names, size_t *size);
func NamespaceList(ioctx *rados.IOContext) (names []string, err error) { func NamespaceList(ioctx *rados.IOContext) (names []string, err error) {
if ioctx == nil { if ioctx == nil {
return nil, ErrNoIOContext return nil, ErrNoIOContext

View File

@ -99,7 +99,8 @@ type RbdImageOption = ImageOption
// RbdImageOptions.Destroy() to free the resources. // RbdImageOptions.Destroy() to free the resources.
// //
// Implements: // Implements:
// void rbd_image_options_create(rbd_image_options_t* opts) //
// void rbd_image_options_create(rbd_image_options_t* opts)
func NewRbdImageOptions() *ImageOptions { func NewRbdImageOptions() *ImageOptions {
rio := &ImageOptions{} rio := &ImageOptions{}
C.rbd_image_options_create(&rio.options) C.rbd_image_options_create(&rio.options)
@ -109,7 +110,8 @@ func NewRbdImageOptions() *ImageOptions {
// Destroy a RbdImageOptions struct and free the associated resources. // Destroy a RbdImageOptions struct and free the associated resources.
// //
// Implements: // Implements:
// void rbd_image_options_destroy(rbd_image_options_t opts); //
// void rbd_image_options_destroy(rbd_image_options_t opts);
func (rio *ImageOptions) Destroy() { func (rio *ImageOptions) Destroy() {
C.rbd_image_options_destroy(rio.options) C.rbd_image_options_destroy(rio.options)
} }
@ -117,8 +119,9 @@ func (rio *ImageOptions) Destroy() {
// SetString sets the value of the RbdImageOption to the given string. // SetString sets the value of the RbdImageOption to the given string.
// //
// Implements: // Implements:
// int rbd_image_options_set_string(rbd_image_options_t opts, int optname, //
// const char* optval); // int rbd_image_options_set_string(rbd_image_options_t opts, int optname,
// const char* optval);
func (rio *ImageOptions) SetString(option ImageOption, value string) error { func (rio *ImageOptions) SetString(option ImageOption, value string) error {
cValue := C.CString(value) cValue := C.CString(value)
defer C.free(unsafe.Pointer(cValue)) defer C.free(unsafe.Pointer(cValue))
@ -135,8 +138,9 @@ func (rio *ImageOptions) SetString(option ImageOption, value string) error {
// GetString returns the string value of the RbdImageOption. // GetString returns the string value of the RbdImageOption.
// //
// Implements: // Implements:
// int rbd_image_options_get_string(rbd_image_options_t opts, int optname, //
// char* optval, size_t maxlen); // int rbd_image_options_get_string(rbd_image_options_t opts, int optname,
// char* optval, size_t maxlen);
func (rio *ImageOptions) GetString(option ImageOption) (string, error) { func (rio *ImageOptions) GetString(option ImageOption) (string, error) {
value := make([]byte, 4096) value := make([]byte, 4096)
@ -153,8 +157,9 @@ func (rio *ImageOptions) GetString(option ImageOption) (string, error) {
// SetUint64 sets the value of the RbdImageOption to the given uint64. // SetUint64 sets the value of the RbdImageOption to the given uint64.
// //
// Implements: // Implements:
// int rbd_image_options_set_uint64(rbd_image_options_t opts, int optname, //
// const uint64_t optval); // int rbd_image_options_set_uint64(rbd_image_options_t opts, int optname,
// const uint64_t optval);
func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error { func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error {
cValue := C.uint64_t(value) cValue := C.uint64_t(value)
@ -170,8 +175,9 @@ func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error {
// GetUint64 returns the uint64 value of the RbdImageOption. // GetUint64 returns the uint64 value of the RbdImageOption.
// //
// Implements: // Implements:
// int rbd_image_options_get_uint64(rbd_image_options_t opts, int optname, //
// uint64_t* optval); // int rbd_image_options_get_uint64(rbd_image_options_t opts, int optname,
// uint64_t* optval);
func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) { func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) {
var cValue C.uint64_t var cValue C.uint64_t
@ -186,8 +192,9 @@ func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) {
// IsSet returns a true if the RbdImageOption is set, false otherwise. // IsSet returns a true if the RbdImageOption is set, false otherwise.
// //
// Implements: // Implements:
// int rbd_image_options_is_set(rbd_image_options_t opts, int optname, //
// bool* is_set); // int rbd_image_options_is_set(rbd_image_options_t opts, int optname,
// bool* is_set);
func (rio *ImageOptions) IsSet(option ImageOption) (bool, error) { func (rio *ImageOptions) IsSet(option ImageOption) (bool, error) {
var cSet C.bool var cSet C.bool
@ -202,7 +209,8 @@ func (rio *ImageOptions) IsSet(option ImageOption) (bool, error) {
// Unset a given RbdImageOption. // Unset a given RbdImageOption.
// //
// Implements: // Implements:
// int rbd_image_options_unset(rbd_image_options_t opts, int optname) //
// int rbd_image_options_unset(rbd_image_options_t opts, int optname)
func (rio *ImageOptions) Unset(option ImageOption) error { func (rio *ImageOptions) Unset(option ImageOption) error {
ret := C.rbd_image_options_unset(rio.options, C.int(option)) ret := C.rbd_image_options_unset(rio.options, C.int(option))
if ret != 0 { if ret != 0 {
@ -215,7 +223,8 @@ func (rio *ImageOptions) Unset(option ImageOption) error {
// Clear all options in the RbdImageOptions. // Clear all options in the RbdImageOptions.
// //
// Implements: // Implements:
// void rbd_image_options_clear(rbd_image_options_t opts) //
// void rbd_image_options_clear(rbd_image_options_t opts)
func (rio *ImageOptions) Clear() { func (rio *ImageOptions) Clear() {
C.rbd_image_options_clear(rio.options) C.rbd_image_options_clear(rio.options)
} }
@ -224,7 +233,8 @@ func (rio *ImageOptions) Clear() {
// false otherwise. // false otherwise.
// //
// Implements: // Implements:
// int rbd_image_options_is_empty(rbd_image_options_t opts) //
// int rbd_image_options_is_empty(rbd_image_options_t opts)
func (rio *ImageOptions) IsEmpty() bool { func (rio *ImageOptions) IsEmpty() bool {
ret := C.rbd_image_options_is_empty(rio.options) ret := C.rbd_image_options_is_empty(rio.options)
return ret != 0 return ret != 0

View File

@ -20,7 +20,8 @@ import (
// GetPoolMetadata returns pool metadata associated with the given key. // GetPoolMetadata returns pool metadata associated with the given key.
// //
// Implements: // Implements:
// int rbd_pool_metadata_get(rados_ioctx_t io_ctx, const char *key, char *value, size_t *val_len); //
// int rbd_pool_metadata_get(rados_ioctx_t io_ctx, const char *key, char *value, size_t *val_len);
func GetPoolMetadata(ioctx *rados.IOContext, key string) (string, error) { func GetPoolMetadata(ioctx *rados.IOContext, key string) (string, error) {
if ioctx == nil { if ioctx == nil {
return "", ErrNoIOContext return "", ErrNoIOContext
@ -53,7 +54,8 @@ func GetPoolMetadata(ioctx *rados.IOContext, key string) (string, error) {
// SetPoolMetadata updates the pool metadata string associated with the given key. // SetPoolMetadata updates the pool metadata string associated with the given key.
// //
// Implements: // Implements:
// int rbd_pool_metadata_set(rados_ioctx_t io_ctx, const char *key, const char *value); //
// int rbd_pool_metadata_set(rados_ioctx_t io_ctx, const char *key, const char *value);
func SetPoolMetadata(ioctx *rados.IOContext, key, value string) error { func SetPoolMetadata(ioctx *rados.IOContext, key, value string) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -71,7 +73,8 @@ func SetPoolMetadata(ioctx *rados.IOContext, key, value string) error {
// RemovePoolMetadata removes the pool metadata value for a given pool metadata key. // RemovePoolMetadata removes the pool metadata value for a given pool metadata key.
// //
// Implements: // Implements:
// int rbd_pool_metadata_remove(rados_ioctx_t io_ctx, const char *key) //
// int rbd_pool_metadata_remove(rados_ioctx_t io_ctx, const char *key)
func RemovePoolMetadata(ioctx *rados.IOContext, key string) error { func RemovePoolMetadata(ioctx *rados.IOContext, key string) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -89,7 +92,8 @@ func RemovePoolMetadata(ioctx *rados.IOContext, key string) error {
// to host rbd images. // to host rbd images.
// //
// Implements: // Implements:
// int rbd_pool_init(rados_ioctx_t io, bool force) //
// int rbd_pool_init(rados_ioctx_t io, bool force)
func PoolInit(ioctx *rados.IOContext, force bool) error { func PoolInit(ioctx *rados.IOContext, force bool) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -107,7 +111,8 @@ type poolStats struct {
// poolStatsCreate creates a new poolStats struct. // poolStatsCreate creates a new poolStats struct.
// //
// Implements: // Implements:
// void rbd_pool_stats_create(rbd_pool_stats_t *stats) //
// void rbd_pool_stats_create(rbd_pool_stats_t *stats)
func poolStatsCreate() *poolStats { func poolStatsCreate() *poolStats {
poolstats := &poolStats{} poolstats := &poolStats{}
C.rbd_pool_stats_create(&poolstats.stats) C.rbd_pool_stats_create(&poolstats.stats)
@ -117,7 +122,8 @@ func poolStatsCreate() *poolStats {
// destroy a poolStats struct and free the associated resources. // destroy a poolStats struct and free the associated resources.
// //
// Implements: // Implements:
// void rbd_pool_stats_destroy(rbd_pool_stats_t stats) //
// void rbd_pool_stats_destroy(rbd_pool_stats_t stats)
func (poolstats *poolStats) destroy() { func (poolstats *poolStats) destroy() {
C.rbd_pool_stats_destroy(poolstats.stats) C.rbd_pool_stats_destroy(poolstats.stats)
@ -159,7 +165,8 @@ const (
// addPoolStatOption adds the given PoolStatOption to PoolStats. // addPoolStatOption adds the given PoolStatOption to PoolStats.
// //
// Implements: // Implements:
// int rbd_pool_stats_option_add_uint64(rbd_pool_stats_t stats, int stat_option, uint64_t* stat_val) //
// 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 { func (poolstats *poolStats) addPoolStatOption(option PoolStatOption, val *uint64) error {
ret := C.rbd_pool_stats_option_add_uint64( ret := C.rbd_pool_stats_option_add_uint64(
poolstats.stats, poolstats.stats,
@ -171,7 +178,8 @@ func (poolstats *poolStats) addPoolStatOption(option PoolStatOption, val *uint64
// GetAllPoolStats returns a map of all PoolStatOption(s) to their respective values. // GetAllPoolStats returns a map of all PoolStatOption(s) to their respective values.
// //
// Implements: // Implements:
// int rbd_pool_stats_get(rados_ioctx_t io, rbd_pool_stats_t stats); //
// int rbd_pool_stats_get(rados_ioctx_t io, rbd_pool_stats_t stats);
func GetAllPoolStats(ioctx *rados.IOContext) (map[PoolStatOption]uint64, error) { func GetAllPoolStats(ioctx *rados.IOContext) (map[PoolStatOption]uint64, error) {
var omap = make(map[PoolStatOption]uint64) var omap = make(map[PoolStatOption]uint64)
if ioctx == nil { if ioctx == nil {

View File

@ -145,14 +145,16 @@ func GetImage(ioctx *rados.IOContext, name string) *Image {
// Create a new rbd image. // Create a new rbd image.
// //
// Implements: // Implements:
// int rbd_create(rados_ioctx_t io, const char *name, uint64_t size, int *order); //
// int rbd_create(rados_ioctx_t io, const char *name, uint64_t size, int *order);
// //
// Also implements (for backward compatibility): // Also implements (for backward compatibility):
// int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size, //
// uint64_t features, int *order); // int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size,
// int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size, // uint64_t features, int *order);
// uint64_t features, int *order, // int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size,
// uint64_t stripe_unit, uint64_t stripe_count); // uint64_t features, int *order,
// uint64_t stripe_unit, uint64_t stripe_count);
func Create(ioctx *rados.IOContext, name string, size uint64, order int, func Create(ioctx *rados.IOContext, name string, size uint64, order int,
args ...uint64) (image *Image, err error) { args ...uint64) (image *Image, err error) {
var ret C.int var ret C.int
@ -188,8 +190,9 @@ func Create(ioctx *rados.IOContext, name string, size uint64, order int,
// Create2 creates a new rbd image using provided features. // Create2 creates a new rbd image using provided features.
// //
// Implements: // Implements:
// int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size, //
// uint64_t features, int *order); // int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size,
// uint64_t features, int *order);
func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64, func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64,
order int) (image *Image, err error) { order int) (image *Image, err error) {
var ret C.int var ret C.int
@ -215,9 +218,10 @@ func Create2(ioctx *rados.IOContext, name string, size uint64, features uint64,
// parameters. // parameters.
// //
// Implements: // Implements:
// int rbd_create3(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 stripe_unit, uint64_t stripe_count); // uint64_t features, int *order,
// uint64_t stripe_unit, uint64_t stripe_count);
func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64, func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64,
order int, stripeUnit uint64, stripeCount uint64) (image *Image, err error) { order int, stripeUnit uint64, stripeCount uint64) (image *Image, err error) {
var ret C.int var ret C.int
@ -243,9 +247,10 @@ func Create3(ioctx *rados.IOContext, name string, size uint64, features uint64,
// Clone a new rbd image from a snapshot. // Clone a new rbd image from a snapshot.
// //
// Implements: // Implements:
// int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name, //
// const char *p_snapname, rados_ioctx_t c_ioctx, // int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,
// const char *c_name, uint64_t features, int *c_order); // const char *p_snapname, rados_ioctx_t c_ioctx,
// const char *c_name, uint64_t features, int *c_order);
func (image *Image) Clone(snapname string, cIoctx *rados.IOContext, cName string, features uint64, order int) (*Image, error) { func (image *Image) Clone(snapname string, cIoctx *rados.IOContext, cName string, features uint64, order int) (*Image, error) {
if err := image.validate(imageNeedsIOContext); err != nil { if err := image.validate(imageNeedsIOContext); err != nil {
return nil, err return nil, err
@ -281,7 +286,8 @@ func (image *Image) Clone(snapname string, cIoctx *rados.IOContext, cName string
// Remove the specified rbd image. // Remove the specified rbd image.
// //
// Implements: // Implements:
// int rbd_remove(rados_ioctx_t io, const char *name); //
// int rbd_remove(rados_ioctx_t io, const char *name);
func (image *Image) Remove() error { func (image *Image) Remove() error {
if err := image.validate(imageNeedsIOContext | imageNeedsName | imageIsNotOpen); err != nil { if err := image.validate(imageNeedsIOContext | imageNeedsName | imageIsNotOpen); err != nil {
return err return err
@ -306,7 +312,8 @@ func (image *Image) Trash(delay time.Duration) error {
// Rename an rbd image. // Rename an rbd image.
// //
// Implements: // Implements:
// int rbd_rename(rados_ioctx_t src_io_ctx, const char *srcname, const char *destname); //
// int rbd_rename(rados_ioctx_t src_io_ctx, const char *srcname, const char *destname);
func (image *Image) Rename(destname string) error { func (image *Image) Rename(destname string) error {
if err := image.validate(imageNeedsIOContext | imageNeedsName); err != nil { if err := image.validate(imageNeedsIOContext | imageNeedsName); err != nil {
return err return err
@ -370,7 +377,8 @@ func (image *Image) Open(args ...interface{}) error {
// Close an open rbd image. // Close an open rbd image.
// //
// Implements: // Implements:
// int rbd_close(rbd_image_t image); //
// int rbd_close(rbd_image_t image);
func (image *Image) Close() error { func (image *Image) Close() error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -387,7 +395,8 @@ func (image *Image) Close() error {
// Resize an rbd image. // Resize an rbd image.
// //
// Implements: // Implements:
// int rbd_resize(rbd_image_t image, uint64_t size); //
// int rbd_resize(rbd_image_t image, uint64_t size);
func (image *Image) Resize(size uint64) error { func (image *Image) Resize(size uint64) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -399,7 +408,8 @@ func (image *Image) Resize(size uint64) error {
// Stat an rbd image. // Stat an rbd image.
// //
// Implements: // Implements:
// int rbd_stat(rbd_image_t image, rbd_image_info_t *info, size_t infosize); //
// int rbd_stat(rbd_image_t image, rbd_image_info_t *info, size_t infosize);
func (image *Image) Stat() (info *ImageInfo, err error) { func (image *Image) Stat() (info *ImageInfo, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err
@ -422,7 +432,8 @@ func (image *Image) Stat() (info *ImageInfo, err error) {
// IsOldFormat returns true if the rbd image uses the old format. // IsOldFormat returns true if the rbd image uses the old format.
// //
// Implements: // Implements:
// int rbd_get_old_format(rbd_image_t image, uint8_t *old); //
// int rbd_get_old_format(rbd_image_t image, uint8_t *old);
func (image *Image) IsOldFormat() (bool, error) { func (image *Image) IsOldFormat() (bool, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return false, err return false, err
@ -441,7 +452,8 @@ func (image *Image) IsOldFormat() (bool, error) {
// GetSize returns the size of the rbd image. // GetSize returns the size of the rbd image.
// //
// Implements: // Implements:
// int rbd_size(rbd_image_t image, uint64_t *size); //
// int rbd_size(rbd_image_t image, uint64_t *size);
func (image *Image) GetSize() (size uint64, err error) { func (image *Image) GetSize() (size uint64, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -457,7 +469,8 @@ func (image *Image) GetSize() (size uint64, err error) {
// GetStripeUnit returns the stripe-unit value for the rbd image. // GetStripeUnit returns the stripe-unit value for the rbd image.
// //
// Implements: // Implements:
// int rbd_get_stripe_unit(rbd_image_t image, uint64_t *stripe_unit); //
// int rbd_get_stripe_unit(rbd_image_t image, uint64_t *stripe_unit);
func (image *Image) GetStripeUnit() (uint64, error) { func (image *Image) GetStripeUnit() (uint64, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -474,7 +487,8 @@ func (image *Image) GetStripeUnit() (uint64, error) {
// GetStripeCount returns the stripe-count value for the rbd image. // GetStripeCount returns the stripe-count value for the rbd image.
// //
// Implements: // Implements:
// int rbd_get_stripe_count(rbd_image_t image, uint64_t *stripe_count); //
// int rbd_get_stripe_count(rbd_image_t image, uint64_t *stripe_count);
func (image *Image) GetStripeCount() (uint64, error) { func (image *Image) GetStripeCount() (uint64, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -492,7 +506,8 @@ func (image *Image) GetStripeCount() (uint64, error) {
// parent. // parent.
// //
// Implements: // Implements:
// int rbd_get_overlap(rbd_image_t image, uint64_t *overlap); //
// int rbd_get_overlap(rbd_image_t image, uint64_t *overlap);
func (image *Image) GetOverlap() (overlap uint64, err error) { func (image *Image) GetOverlap() (overlap uint64, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -508,7 +523,8 @@ func (image *Image) GetOverlap() (overlap uint64, err error) {
// Copy one rbd image to another. // Copy one rbd image to another.
// //
// Implements: // Implements:
// int rbd_copy(rbd_image_t image, rados_ioctx_t dest_io_ctx, const char *destname); //
// int rbd_copy(rbd_image_t image, rados_ioctx_t dest_io_ctx, const char *destname);
func (image *Image) Copy(ioctx *rados.IOContext, destname string) error { func (image *Image) Copy(ioctx *rados.IOContext, destname string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -528,7 +544,8 @@ func (image *Image) Copy(ioctx *rados.IOContext, destname string) error {
// Copy2 copies one rbd image to another, using an image handle. // Copy2 copies one rbd image to another, using an image handle.
// //
// Implements: // Implements:
// int rbd_copy2(rbd_image_t src, rbd_image_t dest); //
// int rbd_copy2(rbd_image_t src, rbd_image_t dest);
func (image *Image) Copy2(dest *Image) error { func (image *Image) Copy2(dest *Image) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -542,8 +559,9 @@ func (image *Image) Copy2(dest *Image) error {
// DeepCopy an rbd image to a new image with specific options. // DeepCopy an rbd image to a new image with specific options.
// //
// Implements: // Implements:
// int rbd_deep_copy(rbd_image_t src, rados_ioctx_t dest_io_ctx, //
// const char *destname, rbd_image_options_t dest_opts); // int rbd_deep_copy(rbd_image_t src, rados_ioctx_t dest_io_ctx,
// const char *destname, rbd_image_options_t dest_opts);
func (image *Image) DeepCopy(ioctx *rados.IOContext, destname string, rio *ImageOptions) error { func (image *Image) DeepCopy(ioctx *rados.IOContext, destname string, rio *ImageOptions) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -569,7 +587,8 @@ func (image *Image) DeepCopy(ioctx *rados.IOContext, destname string, rio *Image
// Flatten removes snapshot references from the image. // Flatten removes snapshot references from the image.
// //
// Implements: // Implements:
// int rbd_flatten(rbd_image_t image); //
// int rbd_flatten(rbd_image_t image);
func (image *Image) Flatten() error { func (image *Image) Flatten() error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -581,11 +600,12 @@ func (image *Image) Flatten() error {
// ListLockers returns a list of clients that have locks on the image. // ListLockers returns a list of clients that have locks on the image.
// //
// Impelemnts: // Impelemnts:
// ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive, //
// char *tag, size_t *tag_len, // ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive,
// char *clients, size_t *clients_len, // char *tag, size_t *tag_len,
// char *cookies, size_t *cookies_len, // char *clients, size_t *clients_len,
// char *addrs, size_t *addrs_len); // char *cookies, size_t *cookies_len,
// char *addrs, size_t *addrs_len);
func (image *Image) ListLockers() (tag string, lockers []Locker, err error) { func (image *Image) ListLockers() (tag string, lockers []Locker, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", nil, err return "", nil, err
@ -645,7 +665,8 @@ func (image *Image) ListLockers() (tag string, lockers []Locker, err error) {
// LockExclusive acquires an exclusive lock on the rbd image. // LockExclusive acquires an exclusive lock on the rbd image.
// //
// Implements: // Implements:
// int rbd_lock_exclusive(rbd_image_t image, const char *cookie); //
// int rbd_lock_exclusive(rbd_image_t image, const char *cookie);
func (image *Image) LockExclusive(cookie string) error { func (image *Image) LockExclusive(cookie string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -660,7 +681,8 @@ func (image *Image) LockExclusive(cookie string) error {
// LockShared acquires a shared lock on the rbd image. // LockShared acquires a shared lock on the rbd image.
// //
// Implements: // Implements:
// int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag); //
// int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag);
func (image *Image) LockShared(cookie string, tag string) error { func (image *Image) LockShared(cookie string, tag string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -677,7 +699,8 @@ func (image *Image) LockShared(cookie string, tag string) error {
// Unlock releases a lock on the image. // Unlock releases a lock on the image.
// //
// Implements: // Implements:
// int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag); //
// int rbd_lock_shared(rbd_image_t image, const char *cookie, const char *tag);
func (image *Image) Unlock(cookie string) error { func (image *Image) Unlock(cookie string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -692,7 +715,8 @@ func (image *Image) Unlock(cookie string) error {
// BreakLock forces the release of a lock held by another client. // BreakLock forces the release of a lock held by another client.
// //
// Implements: // Implements:
// int rbd_break_lock(rbd_image_t image, const char *client, const char *cookie); //
// int rbd_break_lock(rbd_image_t image, const char *client, const char *cookie);
func (image *Image) BreakLock(client string, cookie string) error { func (image *Image) BreakLock(client string, cookie string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -711,8 +735,9 @@ func (image *Image) BreakLock(client string, cookie string) error {
// offset which is not safe in concurrent code. Prefer ReadAt when possible. // offset which is not safe in concurrent code. Prefer ReadAt when possible.
// //
// Implements: // Implements:
// ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, //
// char *buf); // ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len,
// char *buf);
func (image *Image) Read(data []byte) (int, error) { func (image *Image) Read(data []byte) (int, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -745,8 +770,9 @@ func (image *Image) Read(data []byte) (int, error) {
// offset which is not safe in concurrent code. Prefer WriteAt when possible. // offset which is not safe in concurrent code. Prefer WriteAt when possible.
// //
// Implements: // Implements:
// ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len, //
// const char *buf); // ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len,
// const char *buf);
func (image *Image) Write(data []byte) (n int, err error) { func (image *Image) Write(data []byte) (n int, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -790,7 +816,8 @@ func (image *Image) Seek(offset int64, whence int) (int64, error) {
// space. // space.
// //
// Implements: // Implements:
// int rbd_discard(rbd_image_t image, uint64_t ofs, uint64_t len); //
// int rbd_discard(rbd_image_t image, uint64_t ofs, uint64_t len);
func (image *Image) Discard(ofs uint64, length uint64) (int, error) { func (image *Image) Discard(ofs uint64, length uint64) (int, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return 0, err return 0, err
@ -855,8 +882,9 @@ func (image *Image) WriteAt(data []byte, off int64) (n int, err error) {
// been written. // been written.
// //
// Implements: // Implements:
// ssize_t rbd_writesame(rbd_image_t image, uint64_t ofs, size_t len, //
// const char *buf, size_t data_len, int op_flags); // ssize_t rbd_writesame(rbd_image_t image, uint64_t ofs, size_t len,
// const char *buf, size_t data_len, int op_flags);
func (image *Image) WriteSame(ofs, n uint64, data []byte, flags rados.OpFlags) (int64, error) { func (image *Image) WriteSame(ofs, n uint64, data []byte, flags rados.OpFlags) (int64, error) {
var err error var err error
@ -884,7 +912,8 @@ func (image *Image) WriteSame(ofs, n uint64, data []byte, flags rados.OpFlags) (
// Flush all cached writes to storage. // Flush all cached writes to storage.
// //
// Implements: // Implements:
// int rbd_flush(rbd_image_t image); //
// int rbd_flush(rbd_image_t image);
func (image *Image) Flush() error { func (image *Image) Flush() error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -897,7 +926,8 @@ func (image *Image) Flush() error {
// associated with the rbd image. // associated with the rbd image.
// //
// Implements: // Implements:
// int rbd_snap_list(rbd_image_t image, rbd_snap_info_t *snaps, int *max_snaps); //
// int rbd_snap_list(rbd_image_t image, rbd_snap_info_t *snaps, int *max_snaps);
func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) { func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err
@ -929,7 +959,8 @@ func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
// GetId returns the internal image ID string. // GetId returns the internal image ID string.
// //
// Implements: // Implements:
// int rbd_get_id(rbd_image_t image, char *id, size_t id_len); //
// int rbd_get_id(rbd_image_t image, char *id, size_t id_len);
func (image *Image) GetId() (string, error) { func (image *Image) GetId() (string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", err return "", err
@ -964,7 +995,8 @@ func (image *Image) GetName() string {
// is the source of readable data. // is the source of readable data.
// //
// Implements: // Implements:
// int rbd_snap_set(rbd_image_t image, const char *snapname); //
// int rbd_snap_set(rbd_image_t image, const char *snapname);
func (image *Image) SetSnapshot(snapname string) error { func (image *Image) SetSnapshot(snapname string) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -1033,8 +1065,9 @@ func TrashRestore(ioctx *rados.IOContext, id, name string) error {
// snapName to explicitly indicate that no snapshot name is being provided. // snapName to explicitly indicate that no snapshot name is being provided.
// //
// Implements: // Implements:
// int rbd_open(rados_ioctx_t io, const char *name, //
// rbd_image_t *image, const char *snap_name); // int rbd_open(rados_ioctx_t io, const char *name,
// rbd_image_t *image, const char *snap_name);
func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error) { func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error) {
if ioctx == nil { if ioctx == nil {
return nil, ErrNoIOContext return nil, ErrNoIOContext
@ -1076,8 +1109,9 @@ func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error) {
// provided. // provided.
// //
// Implements: // Implements:
// int rbd_open_read_only(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 OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, error) { func OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, error) {
if ioctx == nil { if ioctx == nil {
return nil, ErrNoIOContext return nil, ErrNoIOContext
@ -1120,8 +1154,9 @@ func OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, e
// that fixes https://tracker.ceph.com/issues/43178 // that fixes https://tracker.ceph.com/issues/43178
// //
// Implements: // Implements:
// int rbd_open_by_id(rados_ioctx_t io, const char *id, //
// rbd_image_t *image, const char *snap_name); // int rbd_open_by_id(rados_ioctx_t io, const char *id,
// rbd_image_t *image, const char *snap_name);
func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error) { func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error) {
if ioctx == nil { if ioctx == nil {
return nil, ErrNoIOContext return nil, ErrNoIOContext
@ -1164,8 +1199,9 @@ func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error)
// that fixes https://tracker.ceph.com/issues/43178 // that fixes https://tracker.ceph.com/issues/43178
// //
// Implements: // Implements:
// int rbd_open_by_id_read_only(rados_ioctx_t io, const char *id, //
// rbd_image_t *image, const char *snap_name); // int rbd_open_by_id_read_only(rados_ioctx_t io, const char *id,
// rbd_image_t *image, const char *snap_name);
func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image, error) { func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image, error) {
if ioctx == nil { if ioctx == nil {
return nil, ErrNoIOContext return nil, ErrNoIOContext
@ -1203,8 +1239,9 @@ func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image,
// CreateImage creates a new rbd image using provided image options. // CreateImage creates a new rbd image using provided image options.
// //
// Implements: // Implements:
// int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size, //
// rbd_image_options_t opts); // int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size,
// rbd_image_options_t opts);
func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOptions) error { func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOptions) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -1227,7 +1264,8 @@ func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOpt
// RemoveImage removes the specified rbd image. // RemoveImage removes the specified rbd image.
// //
// Implements: // Implements:
// int rbd_remove(rados_ioctx_t io, const char *name); //
// int rbd_remove(rados_ioctx_t io, const char *name);
func RemoveImage(ioctx *rados.IOContext, name string) error { func RemoveImage(ioctx *rados.IOContext, name string) error {
if ioctx == nil { if ioctx == nil {
return ErrNoIOContext return ErrNoIOContext
@ -1245,9 +1283,10 @@ func RemoveImage(ioctx *rados.IOContext, name string) error {
// provided io-context with the given name and image options. // provided io-context with the given name and image options.
// //
// Implements: // Implements:
// int rbd_clone3(rados_ioctx_t p_ioctx, const char *p_name, //
// const char *p_snapname, rados_ioctx_t c_ioctx, // int rbd_clone3(rados_ioctx_t p_ioctx, const char *p_name,
// const char *c_name, rbd_image_options_t c_opts); // const char *p_snapname, rados_ioctx_t c_ioctx,
// const char *c_name, rbd_image_options_t c_opts);
func CloneImage(ioctx *rados.IOContext, parentName, snapName string, func CloneImage(ioctx *rados.IOContext, parentName, snapName string,
destctx *rados.IOContext, name string, rio *ImageOptions) error { destctx *rados.IOContext, name string, rio *ImageOptions) error {

View File

@ -48,7 +48,8 @@ func GetImageNames(ioctx *rados.IOContext) ([]string, error) {
// GetCreateTimestamp returns the time the rbd image was created. // GetCreateTimestamp returns the time the rbd image was created.
// //
// Implements: // Implements:
// int rbd_get_create_timestamp(rbd_image_t image, struct timespec *timestamp); //
// int rbd_get_create_timestamp(rbd_image_t image, struct timespec *timestamp);
func (image *Image) GetCreateTimestamp() (Timespec, error) { func (image *Image) GetCreateTimestamp() (Timespec, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return Timespec{}, err return Timespec{}, err
@ -66,7 +67,8 @@ func (image *Image) GetCreateTimestamp() (Timespec, error) {
// GetAccessTimestamp returns the time the rbd image was last accessed. // GetAccessTimestamp returns the time the rbd image was last accessed.
// //
// Implements: // Implements:
// int rbd_get_access_timestamp(rbd_image_t image, struct timespec *timestamp); //
// int rbd_get_access_timestamp(rbd_image_t image, struct timespec *timestamp);
func (image *Image) GetAccessTimestamp() (Timespec, error) { func (image *Image) GetAccessTimestamp() (Timespec, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return Timespec{}, err return Timespec{}, err
@ -84,7 +86,8 @@ func (image *Image) GetAccessTimestamp() (Timespec, error) {
// GetModifyTimestamp returns the time the rbd image was last modified. // GetModifyTimestamp returns the time the rbd image was last modified.
// //
// Implements: // Implements:
// int rbd_get_modify_timestamp(rbd_image_t image, struct timespec *timestamp); //
// int rbd_get_modify_timestamp(rbd_image_t image, struct timespec *timestamp);
func (image *Image) GetModifyTimestamp() (Timespec, error) { func (image *Image) GetModifyTimestamp() (Timespec, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return Timespec{}, err return Timespec{}, err
@ -104,7 +107,8 @@ func (image *Image) GetModifyTimestamp() (Timespec, error) {
// a power of two no less than 4096 and no larger than the image size. // a power of two no less than 4096 and no larger than the image size.
// //
// Implements: // Implements:
// int rbd_sparsify(rbd_image_t image, size_t sparse_size); //
// int rbd_sparsify(rbd_image_t image, size_t sparse_size);
func (image *Image) Sparsify(sparseSize uint) error { func (image *Image) Sparsify(sparseSize uint) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err

View File

@ -21,7 +21,8 @@ type Snapshot struct {
// a snapshot of the rbd image. // a snapshot of the rbd image.
// //
// Implements: // Implements:
// int rbd_snap_create(rbd_image_t image, const char *snapname); //
// int rbd_snap_create(rbd_image_t image, const char *snapname);
func (image *Image) CreateSnapshot(snapname string) (*Snapshot, error) { func (image *Image) CreateSnapshot(snapname string) (*Snapshot, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err
@ -66,7 +67,8 @@ func (image *Image) GetSnapshot(snapname string) *Snapshot {
// Remove the snapshot from the connected rbd image. // Remove the snapshot from the connected rbd image.
// //
// Implements: // Implements:
// int rbd_snap_remove(rbd_image_t image, const char *snapname); //
// int rbd_snap_remove(rbd_image_t image, const char *snapname);
func (snapshot *Snapshot) Remove() error { func (snapshot *Snapshot) Remove() error {
if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil { if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil {
return err return err
@ -81,7 +83,8 @@ func (snapshot *Snapshot) Remove() error {
// Rollback the image to the snapshot. // Rollback the image to the snapshot.
// //
// Implements: // Implements:
// int rbd_snap_rollback(rbd_image_t image, const char *snapname); //
// int rbd_snap_rollback(rbd_image_t image, const char *snapname);
func (snapshot *Snapshot) Rollback() error { func (snapshot *Snapshot) Rollback() error {
if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil { if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil {
return err return err
@ -96,7 +99,8 @@ func (snapshot *Snapshot) Rollback() error {
// Protect a snapshot from unwanted deletion. // Protect a snapshot from unwanted deletion.
// //
// Implements: // Implements:
// int rbd_snap_protect(rbd_image_t image, const char *snap_name); //
// int rbd_snap_protect(rbd_image_t image, const char *snap_name);
func (snapshot *Snapshot) Protect() error { func (snapshot *Snapshot) Protect() error {
if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil { if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil {
return err return err
@ -111,7 +115,8 @@ func (snapshot *Snapshot) Protect() error {
// Unprotect stops protecting the snapshot. // Unprotect stops protecting the snapshot.
// //
// Implements: // Implements:
// int rbd_snap_unprotect(rbd_image_t image, const char *snap_name); //
// int rbd_snap_unprotect(rbd_image_t image, const char *snap_name);
func (snapshot *Snapshot) Unprotect() error { func (snapshot *Snapshot) Unprotect() error {
if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil { if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil {
return err return err
@ -126,8 +131,9 @@ func (snapshot *Snapshot) Unprotect() error {
// IsProtected returns true if the snapshot is currently protected. // IsProtected returns true if the snapshot is currently protected.
// //
// Implements: // Implements:
// int rbd_snap_is_protected(rbd_image_t image, const char *snap_name, //
// int *is_protected); // int rbd_snap_is_protected(rbd_image_t image, const char *snap_name,
// int *is_protected);
func (snapshot *Snapshot) IsProtected() (bool, error) { func (snapshot *Snapshot) IsProtected() (bool, error) {
if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil { if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil {
return false, err return false, err
@ -153,7 +159,8 @@ func (snapshot *Snapshot) IsProtected() (bool, error) {
// Deprecated: use the SetSnapshot method of the Image type instead // Deprecated: use the SetSnapshot method of the Image type instead
// //
// Implements: // Implements:
// int rbd_snap_set(rbd_image_t image, const char *snapname); //
// int rbd_snap_set(rbd_image_t image, const char *snapname);
func (snapshot *Snapshot) Set() error { func (snapshot *Snapshot) Set() error {
if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil { if err := snapshot.validate(snapshotNeedsName | imageIsOpen); err != nil {
return err return err
@ -168,7 +175,8 @@ func (snapshot *Snapshot) Set() error {
// Check https://tracker.ceph.com/issues/47287 for details. // Check https://tracker.ceph.com/issues/47287 for details.
// //
// Implements: // Implements:
// int rbd_snap_get_timestamp(rbd_image_t image, uint64_t snap_id, struct timespec *timestamp) //
// int rbd_snap_get_timestamp(rbd_image_t image, uint64_t snap_id, struct timespec *timestamp)
func (image *Image) GetSnapTimestamp(snapID uint64) (Timespec, error) { func (image *Image) GetSnapTimestamp(snapID uint64) (Timespec, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return Timespec{}, err return Timespec{}, err

View File

@ -32,7 +32,8 @@ const (
// returns error on failure. // returns error on failure.
// //
// Implements: // Implements:
// int rbd_snap_get_namespace_type(rbd_image_t image, uint64_t snap_id, rbd_snap_namespace_type_t *namespace_type) //
// int rbd_snap_get_namespace_type(rbd_image_t image, uint64_t snap_id, rbd_snap_namespace_type_t *namespace_type)
func (image *Image) GetSnapNamespaceType(snapID uint64) (SnapNamespaceType, error) { func (image *Image) GetSnapNamespaceType(snapID uint64) (SnapNamespaceType, error) {
var nsType SnapNamespaceType var nsType SnapNamespaceType
@ -51,7 +52,8 @@ func (image *Image) GetSnapNamespaceType(snapID uint64) (SnapNamespaceType, erro
// function belongs to a snapshot already in the Trash. // function belongs to a snapshot already in the Trash.
// //
// Implements: // Implements:
// int rbd_snap_get_trash_namespace(rbd_image_t image, uint64_t snap_id, char *original_name, size_t max_length) //
// int rbd_snap_get_trash_namespace(rbd_image_t image, uint64_t snap_id, char *original_name, size_t max_length)
func (image *Image) GetSnapTrashNamespace(snapID uint64) (string, error) { func (image *Image) GetSnapTrashNamespace(snapID uint64) (string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", err return "", err

View File

@ -19,9 +19,10 @@ import (
// and snapshot-name in the byte-arrays that are passed as arguments. // and snapshot-name in the byte-arrays that are passed as arguments.
// //
// Implements: // Implements:
// int rbd_get_parent(rbd_image_t image, //
// rbd_linked_image_spec_t *parent_image, // int rbd_get_parent(rbd_image_t image,
// rbd_snap_spec_t *parent_snap) // rbd_linked_image_spec_t *parent_image,
// rbd_snap_spec_t *parent_snap)
func (image *Image) GetParentInfo(pool, name, snapname []byte) error { func (image *Image) GetParentInfo(pool, name, snapname []byte) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err
@ -123,8 +124,9 @@ func (image *Image) GetParent() (*ParentInfo, error) {
// used to link the two items together. // used to link the two items together.
// //
// Implements: // Implements:
// int rbd_list_children3(rbd_image_t image, rbd_linked_image_spec_t *images, //
// size_t *max_images); // int rbd_list_children3(rbd_image_t image, rbd_linked_image_spec_t *images,
// size_t *max_images);
func (image *Image) ListChildren() (pools []string, images []string, err error) { func (image *Image) ListChildren() (pools []string, images []string, err error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, nil, err return nil, nil, err
@ -162,7 +164,8 @@ func (image *Image) ListChildren() (pools []string, images []string, err error)
// is the source of readable data. // is the source of readable data.
// //
// Implements: // Implements:
// int rbd_snap_set_by_id(rbd_image_t image, uint64_t snap_id); //
// int rbd_snap_set_by_id(rbd_image_t image, uint64_t snap_id);
func (image *Image) SetSnapByID(snapID uint64) error { func (image *Image) SetSnapByID(snapID uint64) error {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return err return err

View File

@ -17,7 +17,8 @@ import (
// GetSnapID returns the snapshot ID for the given snapshot name. // GetSnapID returns the snapshot ID for the given snapshot name.
// //
// Implements: // Implements:
// int rbd_snap_get_id(rbd_image_t image, const char *snapname, uint64_t *snap_id) //
// int rbd_snap_get_id(rbd_image_t image, const char *snapname, uint64_t *snap_id)
func (image *Image) GetSnapID(snapName string) (uint64, error) { func (image *Image) GetSnapID(snapName string) (uint64, error) {
var snapID C.uint64_t var snapID C.uint64_t
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
@ -37,7 +38,8 @@ func (image *Image) GetSnapID(snapName string) (uint64, error) {
// GetSnapByID returns the snapshot name for the given snapshot ID. // GetSnapByID returns the snapshot name for the given snapshot ID.
// //
// Implements: // Implements:
// int rbd_snap_get_name(rbd_image_t image, uint64_t snap_id, char *snapname, size_t *name_len) //
// int rbd_snap_get_name(rbd_image_t image, uint64_t snap_id, char *snapname, size_t *name_len)
func (image *Image) GetSnapByID(snapID uint64) (string, error) { func (image *Image) GetSnapByID(snapID uint64) (string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", err return "", err

View File

@ -12,7 +12,8 @@ import (
// Rename a snapshot. // Rename a snapshot.
// //
// Implements: // Implements:
// int rbd_snap_rename(rbd_image_t image, const char *snapname, //
// int rbd_snap_rename(rbd_image_t image, const char *snapname,
// const char* dstsnapsname); // const char* dstsnapsname);
func (snapshot *Snapshot) Rename(destName string) error { func (snapshot *Snapshot) Rename(destName string) error {
if err := snapshot.validate(imageNeedsIOContext | imageIsOpen | imageNeedsName | snapshotNeedsName); err != nil { if err := snapshot.validate(imageNeedsIOContext | imageIsOpen | imageNeedsName | snapshotNeedsName); err != nil {

88
vendor/github.com/ceph/go-ceph/rbd/sparsify.go generated vendored Normal file
View File

@ -0,0 +1,88 @@
//go:build !nautilus && ceph_preview
// +build !nautilus,ceph_preview
package rbd
/*
#cgo LDFLAGS: -lrbd
#include <errno.h>
#include <stdlib.h>
#include <rbd/librbd.h>
extern int sparsifyCallback(uint64_t, uint64_t, uintptr_t);
// inline wrapper to cast uintptr_t to void*
static inline int wrap_rbd_sparsify_with_progress(
rbd_image_t image, size_t sparse_size, uintptr_t arg) {
return rbd_sparsify_with_progress(
image, sparse_size, (librbd_progress_fn_t)sparsifyCallback, (void*)arg);
};
*/
import "C"
import (
"github.com/ceph/go-ceph/internal/callbacks"
)
// SparsifyCallback defines the function signature needed for the
// SparsifyWithProgress callback.
//
// This callback will be called by SparsifyWithProgress when it wishes to
// report progress on sparse. The callback function will be called with the
// first argument containing the current offset within the image being made
// sparse and the second argument containing the total size of the image. The
// third argument is an opaque value that is passed to the SparsifyWithProgress
// function's data argument and every call to the callback will receive the
// same object. The sparsify operation will be aborted if the progress
// callback returns a non-zero value.
type SparsifyCallback func(uint64, uint64, interface{}) int
var sparsifyCallbacks = callbacks.New()
type sparsifyCallbackCtx struct {
callback SparsifyCallback
data interface{}
}
// SparsifyWithProgress makes an image sparse by deallocating runs of zeros.
// The sparseSize value will be used to find runs of zeros and must be
// a power of two no less than 4096 and no larger than the image size.
// The given progress callback will be called to report on the progress
// of sparse. The operation will be aborted if the progress callback returns
// a non-zero value.
//
// Implements:
//
// int rbd_sparsify_with_progress(rbd_image_t image, size_t sparse_size,
// librbd_progress_fn_t cb, void *cbdata);
func (image *Image) SparsifyWithProgress(
sparseSize uint, cb SparsifyCallback, data interface{}) error {
// the provided callback must be a real function
if cb == nil {
return rbdError(C.EINVAL)
}
if err := image.validate(imageIsOpen); err != nil {
return err
}
ctx := sparsifyCallbackCtx{
callback: cb,
data: data,
}
cbIndex := sparsifyCallbacks.Add(ctx)
defer diffIterateCallbacks.Remove(cbIndex)
ret := C.wrap_rbd_sparsify_with_progress(image.image, C.size_t(sparseSize), C.uintptr_t(cbIndex))
return getError(ret)
}
//export sparsifyCallback
func sparsifyCallback(
offset, total C.uint64_t, index uintptr) C.int {
v := sparsifyCallbacks.Lookup(index)
ctx := v.(sparsifyCallbackCtx)
return C.int(ctx.callback(uint64(offset), uint64(total), ctx.data))
}

View File

@ -31,11 +31,13 @@ type ImageWatcher struct {
// and an error are returned. // and an error are returned.
// //
// Note: // Note:
// Only supported in Ceph Mimic and newer. //
// Only supported in Ceph Mimic and newer.
// //
// Implements: // Implements:
// int rbd_watchers_list(rbd_image_t image, //
// rbd_image_watcher_t *watchers, size_t *max_watchers) // int rbd_watchers_list(rbd_image_t image,
// rbd_image_watcher_t *watchers, size_t *max_watchers)
func (image *Image) ListWatchers() ([]ImageWatcher, error) { func (image *Image) ListWatchers() ([]ImageWatcher, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err
@ -91,8 +93,9 @@ type Watch struct {
// image, returning a Watch object. // image, returning a Watch object.
// //
// Implements: // Implements:
// int rbd_update_watch(rbd_image_t image, uint64_t *handle, //
// rbd_update_callback_t watch_cb, void *arg); // int rbd_update_watch(rbd_image_t image, uint64_t *handle,
// rbd_update_callback_t watch_cb, void *arg);
func (image *Image) UpdateWatch(cb WatchCallback, data interface{}) (*Watch, error) { func (image *Image) UpdateWatch(cb WatchCallback, data interface{}) (*Watch, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return nil, err return nil, err
@ -120,7 +123,8 @@ func (image *Image) UpdateWatch(cb WatchCallback, data interface{}) (*Watch, err
// Unwatch un-registers the image watch. // Unwatch un-registers the image watch.
// //
// Implements: // Implements:
// int rbd_update_unwatch(rbd_image_t image, uint64_t handle); //
// int rbd_update_unwatch(rbd_image_t image, uint64_t handle);
func (w *Watch) Unwatch() error { func (w *Watch) Unwatch() error {
if w.image == nil { if w.image == nil {
return ErrImageNotOpen return ErrImageNotOpen

4
vendor/modules.txt vendored
View File

@ -119,8 +119,8 @@ github.com/cenkalti/backoff/v4
github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs
github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd
github.com/ceph/ceph-csi/api/deploy/ocp github.com/ceph/ceph-csi/api/deploy/ocp
# github.com/ceph/go-ceph v0.20.0 # github.com/ceph/go-ceph v0.21.0
## explicit; go 1.17 ## explicit; go 1.19
github.com/ceph/go-ceph/cephfs/admin github.com/ceph/go-ceph/cephfs/admin
github.com/ceph/go-ceph/common/admin/manager github.com/ceph/go-ceph/common/admin/manager
github.com/ceph/go-ceph/common/admin/nfs github.com/ceph/go-ceph/common/admin/nfs