Commit Graph

301 Commits

Author SHA1 Message Date
John Mulligan 848b877686 rbd: fix naming convention violations in metadata.go
Fix up variable names that don't meet Go standards.

Command: gofmt -w -r 'c_key -> cKey' rbd/metadata.go
Command: gofmt -w -r 'c_value -> cValue' rbd/metadata.go

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-12 11:05:09 -04:00
Sven Anderson 3de317e39d rbd: export mirror image list functions
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-10 14:15:01 +00:00
Sven Anderson 6fe40e05fc rbd: deprecate Close() method of MirrorImageGlobalStatusIter
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-10 13:23:58 +00:00
Effi Ofer 5ff1efe3aa rbd: add EncryptionLoad api to support the rbd_encryption_load librbd api
Signed-off-by: Effi Ofer <effio@il.ibm.com>
2021-08-02 21:03:36 +00:00
Sven Anderson b968165e78 rbd: add tests for MirrorImageInfoList
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-02 16:39:39 +00:00
Sven Anderson 520f6bfe0d rbd: remove unnecessary type casts
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-02 16:39:39 +00:00
Sven Anderson ac895ae097 rbd: implement binding for rbd_mirror_image_info_list
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-02 16:39:39 +00:00
Sven Anderson 8cbfd1971a rbd: fix comment formatting
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-02 16:39:39 +00:00
John Mulligan dfd1e08fab rbd: remove build tag for luminous from watchers.go
go-ceph stopped supporting luminous in v0.6.0. There's no need to
keep the build tag for it any more.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
John Mulligan b59dda4061 rbd: rename watchers_mimic.go to watchers.go
Drop the _mimic from watchers go file and tests go file.
The mimic was not specific to the version supported, just the version
it was new for. Clean up the naming to reflect that.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
John Mulligan aca200e407 rbd: remove features_mimic.go
go-ceph stopped supporting mimic in v0.7.0. Separate go files for
feature flags added in mimic are no longer needed. Constants and
tests from these files have been moved into the appropriate files.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
John Mulligan b3ed5036f3 rbd: remove luminous and mimic build tags from options_octopus.go
These versions of ceph have not been supported for the last few
release of go-ceph.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
John Mulligan 29a94e03b5 rbd: remove options_mimic.go moving content to options.go
go-ceph stopped supporting mimic in v0.7.0. Keeping the constants
that were added in mimic in a standalone file is no longer needed.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
John Mulligan b201e01628 rbd: remove rbd_mimic.go
go-ceph stopped supporting mimic in v0.7.0. This file no longer is
needed.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
John Mulligan 5c0c0c94da rbd: remove snapshot_mimic.go
go-ceph stopped supporting mimic in v0.7.0. This file no longer is
needed.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-08-02 15:15:48 +00:00
Effi Ofer c15b97cf7c rbd: add image encryption format api
Signed-off-by: Effi Ofer <effio@il.ibm.com>
2021-07-26 15:48:33 +00:00
RAJAT SINGH 5c49aab11e rbd: add GetMirrorUUID function
* Add GetMirrorUUID implementing rbd_mirror_uuid_get

This function is be used to get the mirroring uuid for the pool.
Basic tests included.

Signed-off-by: RAJAT SINGH <rajasing@redhat.com>
2021-06-08 14:01:09 +00:00
John Mulligan 24eeb9512c rbd: add a MirrorImageGlobalStatusIter implementing rbd_mirror_image_global_status_list
This adds the function call in the style of an iterator, as the number
of mirrored images in the entire pool could be large. Tests are
included.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-08 12:20:53 +00:00
John Mulligan 2be2128e33 rbd: add CreateMirrorPeerBootstrapToken & ImportMirrorPeerBootstrapToken functions
* Add CreateMirrorPeerBootstrapToken implementing rbd_mirror_peer_bootstrap_create
* Add ImportMirrorPeerBootstrapToken implementing rbd_mirror_peer_bootstrap_import

These functions can be used to set up mirroring between pools. Basic tests
included. The tests only verify that functions work, not that they
actually mirror data. That is a job for another day.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-03 14:42:42 +00:00
Niels de Vos 92b808cbbe rbd: add DeepCopy()
With rbd_deep_copy() an image can be copied with selected options. This
can be used to create a copy and flatten the image in one go.

Updates: ceph/ceph-csi#2077
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2021-06-01 14:40:37 +00:00
John Mulligan e78058504d rbd admin: add a test to cover the Status function
This is a complex test as it requires the pool and an image before it
will return any (non empty) data.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 11:06:19 +00:00
John Mulligan 5a05449609 rbd admin: add tests for the simpler snap sched related functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 11:06:19 +00:00
John Mulligan cd69fc6031 rbd admin: add mirror snapshot scheduling functions
These are the functions that let one administrate the snapshot schedules
for mirrored pools and images.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 11:06:19 +00:00
John Mulligan ac2026b118 rbd admin: add tests for the LevelSpec type
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 11:06:19 +00:00
John Mulligan b242e6b449 rbd admin: add initial basic types
Adds types to work with the ceph cluster (the admin type) and a type
to work with the "level spec" - which is unfortunately not well
described in the ceph docs, but I think I worked it out well enough
by reading the ceph sources.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 11:06:19 +00:00
John Mulligan b6f36475b2 rbd admin: establish a new rbd/admin subpackage
This package will be used for issuing json commands to the mgr (or
mons, etc) that perform background tasks to administrate rbd pools,
images, etc.

This commit just adds a doc.go as a stub.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 11:06:19 +00:00
oct28-yjkim 8e4b8349aa rbd: add SetSnapshot (re)implementing rbd_snap_set
Signed-off-by: oct28.yjkim <oct28.yjkim@gmail.com>
2021-06-01 10:28:25 +00:00
John Mulligan 97eefba287 rbd: add SetMirrorSiteName and GetMirrorSiteName functions
* Add SetMirrorSiteName implementing rbd_mirror_site_name_set
* Add GetMirrorSiteName implementing rbd_mirror_site_name_get

These functions are used to set the name of the site (for an entire
cluster) for rbd mirroring purposes. It's a bit strange that it's
part of rdb and not rados, but such is life.

Tests included.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-06-01 09:56:02 +00:00
Sven Anderson c74cbb1dfe rbd: fix argument type of rbd_writesame call
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-05-19 13:38:06 +00:00
John Mulligan d37951f7cd rbd: add MirrorImageStatusSummary implementing rbd_mirror_image_status_summary
The MirrorImageStatusSummary returns a map of image mirroring states to
the number of images in those states or an error.
Tests of both the basic conditions and actual mirrored images are added.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-05-03 16:55:10 +00:00
Sven Anderson c45fa95b32 rados: remove pointer arithmetic on C-buffers
This change uses slices on top of C allocated array memory in order
to have a simple (no pointer arithmetic) and safe (boundary-checked)
access to its elements.

Signed-off-by: Sven Anderson <sven@redhat.com>
2021-05-03 16:20:34 +00:00
John Mulligan 5964821ec0 rbd: update build tags from "octopus" to "not nautilus"
Unless these apis are deprecated in the (far?) future it is safer to say
"not nautilus" rather than explicitly tag all current and future ceph
release codenames.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-04-30 15:23:40 +02:00
John Mulligan 40e1224871 rbd: add tests for GetGlobalMirrorStatus based on two ceph clusters
With the infrastructure for running two ceph clusters now available,
we add tests to ensure the functionality of GetGlobalMirrorStatus in
the more typical case, when one or more mirroring clusters exist,

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-04-13 09:47:43 +00:00
John Mulligan de9505f862 rbd: add a test helper to get a conn for a given cluster by config
This function can be used to connect to a non-default ceph cluster,
in a simple, convenient way similar to the function we have for
connecting to the default cluster.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-04-13 09:47:43 +00:00
John Mulligan f84140356a rbd: add CreateMirrorSnapshot implementing rbd_mirror_image_create_snapshot
This function is used to "manually" trigger a snapshot for snapshot
based mirroring. It is needed as a pre-req to test actual cross-cluster
mirroring and the full functionality of GetGlobalMirrorStatus.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-04-13 09:47:43 +00:00
John Mulligan 5c537e20ad rbd: add GetGlobalMirrorStatus implementing rbd_mirror_image_get_global_status
This function is added, along with required return types and some helper
functions, to support fetching the global mirroring status component
that makes up a major part of `rbd mirror image status` command's
output.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-04-13 09:47:43 +00:00
John Mulligan 51885f0875 rbd: add test case for Stringer supporting mirroring constants
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan b614e93b9d rbd: add String method for MirrorImageState
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan 741e7d43bd rbd: add String method for ImageMirrorMode
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan 406868763c rbd: add String method for MirrorMode
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-03-19 11:23:37 +00:00
John Mulligan 1286e0d4d0 rbd: add GroupSnapRollbackWithProgress function
* Add GroupSnapRollbackWithProgress implementing rbd_group_snap_rollback_with_progress

This has supporting code basically the same as our other existing
callback functions.
Tests too.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan 8e6dfe4259 rbd: add GroupSnapRollback implementing rbd_group_snap_rollback
* Add GroupSnapRollback implementing rbd_group_snap_rollback

Adds tests for the above.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan ffeabf1436 rbd: add GroupSnapList implementing rbd_group_snap_list
* Add GroupSnapList implementing rbd_group_snap_list

Adds tests for the above.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan fd08e791cc rbd: add GroupSnapCreate, GroupSnapRemove, & GroupSnapRename funcs
* Add GroupSnapCreate implementing rbd_group_snap_create
* Add GroupSnapRemove implementing rbd_group_snap_remove
* Add GroupSnapRename implementing rbd_group_snap_rename

And tests for the above.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-08 15:29:11 +00:00
John Mulligan 0b4ed9dbe8 rbd: add GetGroup implementing rbd_get_group
This method is useful to determine what group an image is part of.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-02 15:48:00 +00:00
John Mulligan cbf2a51698 rbd: add GroupImageList implementing rbd_group_image_list
This function can be used to list the images in a group.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-02 15:48:00 +00:00
John Mulligan cd0a5bfe01 rbd: add GroupImageAdd, GroupImageRemove, and GroupImageRemoveByID
* Add GroupImageAdd implementing rbd_group_image_add
* Add GroupImageRemove implementing rbd_group_image_remove
* Add GroupImageRemoveByID implementing rbd_group_image_remove_by_id

These functions allow managing the images that are part of a group.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-02 15:48:00 +00:00
John Mulligan 1748ad781c rbd: test that cephIoctx helper panics when fed invalid inputs
As per go-ceph issue #427, and a discussion in #399 this change and
test ensure that the cephIoctx helper function, that extracts the
C.rados_ioctx_t from a Go rados.IOContext, never returns a nil/null
C type.
As these are always "programming errors" panicking is reasonable
behavior for this case.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-02-01 15:31:17 +00:00
Niels de Vos 05a8b48688 rbd: Add TestWriteSame/zerofill test case
Using WriteSame() to implement a zerofill function is less straight
forward than expected. `rbd_discard_on_zeroed_write_same` is a Ceph
option than affects the behaviour of WriteSame(). By default the option
is enabled, causing WriteSame() to call discard instead of writing
zeros.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2021-01-28 16:04:12 +00:00
Mudit Agarwal 3032c539a0 rbd: add GetImageMirrorMode() to get the mirroing mode of a RBD image
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2021-01-25 20:35:15 +00:00
Mudit Agarwal 6ff40f828f rbd: add function to fetch mirror status of a RBD image.
Add GetMirrorImageInfo() to fetch the mirror status of a RBD image.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2021-01-25 20:35:15 +00:00
John Mulligan 25a5086184 rbd: fix typo in comment & improve comment consistency
RBD was misspelled as RDB. While I was there I made the comments
for both constants more consistently worded.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-25 14:38:39 +00:00
John Mulligan 1e3b9a2cd9 rbd: add an initial set of basic mirroring functions
Add functions:
* SetMirrorMode implementing rbd_mirror_mode_set
* GetMirrorMode implementing rbd_mirror_mode_get
* MirrorEnable implementing rbd_mirror_image_enable2
* MirrorDisable implementing rbd_mirror_image_disable
* MirrorPromote implementing rbd_mirror_image_promote
* MirrorDemote implementing rbd_mirror_image_demote
* MirrorResync implementing rbd_mirror_image_resync
* MirrorInstanceId implementing rbd_mirror_image_get_instance_id

For now, these mirroring related functions are only supported on octopus
builds. Right now the demand is for snapshot based mirroring, which is
new in octopus. We can always relax this in the future and add the
necessary support for nautilus, for journaling only based mirroring.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-22 09:27:06 -05:00
John Mulligan a40638e947 rbd: add GroupList implementing rbd_group_list
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-22 08:13:20 +00:00
John Mulligan 7eeb5f79ab rbd: add GroupCreate, GroupRemove, & GroupRename functions
Add GroupCreate implementing rbd_group_create
Add GroupRemove implementing rbd_group_remove
Add GroupRename implementing rbd_group_rename

Naming was <noun><verb> to better match other functions in rbd
like NamespaceCreate, etc. even though I don't prefer that
ordering ;-).

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-22 08:13:20 +00:00
John Mulligan 76bca17e43 rbd: enable test cases with ceph issues that have been fixed
Ceph issue https://tracker.ceph.com/issues/43178 has been fixed for
a while with backports. No reason not to enable these test cases now.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-01-21 21:40:20 +00:00
Niels de Vos 0afcf98b34 Add rbd_writesame()
In order to provide the ability to do thick provisioning of RBD images,
Image.WriteSame() can be used. The `rbd` commandline utility calls the
rbd_writesame() function when an image is created with the
`--thick-provision` option.

See-also: ceph/ceph-csi#1675
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-11-12 12:50:03 +00:00
Sven Anderson c8f26a841b rbd: eliminate invalid unsafe.Pointers
Although it seems to be stable with the current Go versions,
unsafe.Pointers that are created by applying arithmetic on nil
pointers are explicitly not allowed[1], and could potentially lead to
panics by the garbage collector.  To be on the safe side, this change
goes back to minimal inline wrappers for the callback registrations,
which should be zero-cost.  For the callbacks themselves fortunately
no wrappers are required, because CGo happily converts void* to
uintptr arguments.  The potentially problematic VoidPtr helper is
removed again.

[1] https://golang.org/pkg/unsafe/#Pointer

Signed-off-by: Sven Anderson <sven@redhat.com>
2020-11-09 08:58:22 +00:00
John Mulligan e7791c9e06 rbd: add ListMetadata implementing rbd_metadata_list
The function is named ListMetadata but returns a map of all
the metadata assigned to the rbd image. It is named ListMetadata to
match the C librbd api call.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-11-04 14:01:51 +00:00
John Mulligan 6bc6c7c3b1 rbd: move TestImageMetadata function to a new test file
Like the metadata functions were recently moved to a separate file,
move TestImageMetadata to a matching metadata_test.go file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-11-04 14:01:51 +00:00
John Mulligan eb84f5aba1 rbd: move image metadata functions to new go file
As rbd.go is very long, and the get-/set-/remove- metadata functions in
rbd.go make a nice logical unit, move them to a new metadata.go file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-11-04 14:01:51 +00:00
Mudit Agarwal 736858ca7d rbd: add wrapper for rbd_snap_set_by_id()
Added wrapper for rbd_snap_set_by_id() function

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-24 14:03:01 -04:00
Mudit Agarwal 2f0905b585 rbd: add wrapper for rbd_snap_get_timestamp()
Added a wrapper for rbd_snap_get_timestamp() function.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-24 14:03:01 -04:00
Mudit Agarwal 0e09cd4370 rbd: add snapshot ID related functions
added wrappers for rbd_snap_get_name() and rbd_snap_get_id()

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-24 14:03:01 -04:00
Mudit Agarwal 34cab3407f rbd: add a new version of GetParentInfo()
GetParentInfo() currently requires the caller to specify the
string length for various attributes it returns. If the
specified string length is less than required, it can return
ERANGE error. Replacing it with a new function which avoids
this.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-09-21 11:19:38 -04:00
Sven Anderson 4706453428 rbd: remove unnecessary C wrapper functions
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-08-28 09:51:06 -04:00
John Mulligan dbf20aea0a rbd: add Sparsify implementing rbd_sparsify
The sparsify function can be used to make an image sparse by replacing
runs of zeros with holes. This change adds a wrapper for the basic
rbd_sparsify function and accompanying tests.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-27 14:22:52 -04:00
Sven Anderson 176a163c3c callbacks: use uintptr instead of int as index
Since the index of the registered callbacks is basically only used as
void*/unsafe.Pointer, it makes more sense and code simpler, if
the index type is uintptr instead of a simple int.

Signed-off-by: Sven Anderson <sven@redhat.com>
2020-08-27 10:26:12 -04:00
John Mulligan 849fc3c1f3 rbd: use FormatErrorCode for formatting rbd errors
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-10 13:03:24 -04:00
John Mulligan ab49935b5b rbd: rename error type's Errno method to ErrorCode
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-10 13:03:24 -04:00
John Mulligan d6e928993b rbd: fix naming of internal watch callback item type
This patch changes the name to the as-agreed-upon naming from a call.
I forgot to fix this in the original patches before merging things.
Oops.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-07 08:38:15 -04:00
John Mulligan aa29fad715 rbd: simplify callback mechanism in diff_iterate and watchers
Previously, the code that set up the callbacks was doing a pretty
direct translation of go-function to c-function. It turns out this
is not needed due to the way we set up the "dynamic" go callbacks
via an integer based callback "registry". Instead, we can stay within
the C layer entirely for the C callback, passing it only the index
value and then return to the go layer through a static C function
that only needs the index value.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-08-07 08:38:15 -04:00
Mudit Agarwal 7a387654c5 rbd: remove deprecated fields from ImageInfo struct
Corresponding fields for Parent_pool and Parent_name have been deprecated from
ceph's rbd_image_info_t stuct, removing the same from go-ceph's ImageInfo struct.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 12:48:01 -04:00
Sven Anderson 085e2049b3 tests: add tests for the Errno() methods of numeric error types
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-07-24 23:14:20 +02:00
Mudit Agarwal 2bb1b9bffc rbd: add constants for pool stat options and wrapper for rbd_pool_stats_get()
Added pool stat options constants.
Also implemented GetAllPoolStats() function to introduce
the functionality of rbd_pool_stats_option_add_uint64() and rbd_pool_stats_get()

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:35:57 -04:00
Mudit Agarwal fec47ac9a9 rbd: add wrapper for unexported pool stat functions.
Added wrappers for rbd_pool_stats_create() and rbd_pool_stats_destroy() functions.
Right now, keeping these unexported.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:35:57 -04:00
Mudit Agarwal 0cd2b21224 rbd: add wrapper for rbd_pool_init() function
Added PoolInit function implementing rbd_pool_init which sets the
application tag to rbd.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:35:57 -04:00
Mudit Agarwal 0ffebd1f25 rbd: moved ImageOptionCloneFormat to rbd/options_mimic.go
RBD_IMAGE_OPTION_CLONE_FORMAT was added in Ceph Mimic but fix for issue #295 added
it only for Ceph Nautilus, moving it to rbd/options_mimic.go

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:20:27 -04:00
Mudit Agarwal 982a3975a9 rbd: add wrapper for function rbd_snap_get_trash_namespace()
Added a wrapper for function rbd_snap_get_trash_namespace() which
returns the original name of the snapshot which was moved to Trash.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:20:27 -04:00
Mudit Agarwal a5da5e308b rbd: add functions and constants related to snapshot namespace.
Added few constants used for determining snapshot namespace.
Added wrapper for function rbd_snap_get_namespace_type() which returns namespace type for a given snapshot.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-07-24 10:20:27 -04:00
John Mulligan bfe4adfd2d rbd: convert ListChildren for mimic to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 2a62588181 rbd: convert NamespaceList for nautilus to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 4d2d6493af rbd: convert GetImageNames for mimic to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 3d5741301d rbd: convert uses of split function to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 97732ac885 rbd: add a UpdateWatch test case with multiple watches and go channels
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 13:19:57 -04:00
John Mulligan f3f2180e66 rbd: add Watch type and watch callbacks support
Add UpdateWatch function implementing rbd_update_watch.
Add Unwatch function implementing rbd_update_unwatch.
Add a higher level Watch type to encapsulate watching
the image and the watch handle.
Add basic tests to validate the callback behavior.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 13:19:57 -04:00
Sven Anderson 6c944e8b65 rbd: make RBDError type unexported
In order to avoid external dependencies on implementation details,
this change replaces RBDError with the unexported rbdError. In case
some application really needs access to the integer value, it can use
the pattern
  var errno interface{ Errno() int }
  if errors.As(err, errno) { ... errno.Errno() ... }

Signed-off-by: Sven Anderson <sven@redhat.com>
2020-07-17 13:47:32 -04:00
Niels de Vos d4440eb8c2 rbd: add simple test for Image.GetModifyTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 491f7827a8 rbd: add Image.GetModifyTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 048ed11e63 rbd: add simple test for Image.GetAccessTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 0d9f802732 rbd: add Image.GetAccessTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 8ef910e0c5 rbd: add simple test for Image.GetCreateTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 5b45db6803 rbd: add Image.GetCreateTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Mudit Agarwal 3c416e264a rbd: minor fixes in error.go
1. Generalize the message for ErrNoIOContext
2. Fixed a typo

Signed-off-by: Mudit Agarwal muagarwa@redhat.com
2020-06-15 13:43:26 -04:00
Mudit Agarwal 5b6c599176 rbd: add wrapper for rbd_namespace_list() function.
Added wrapper for rbd_namespace_list() function which returns the names of all the namespaces
present for a given IOContext.

Signed-off-by: Mudit Agarwal muagarwa@redhat.com
2020-06-15 13:43:26 -04:00
Mudit Agarwal 08536b9d93 rbd: add wrappers for rbd_namespace_create(), rbd_namespace_exists() and rbd_namespace_remove().
rbd_namespace_create() function creates namespace for a given iocontext.
rbd_namespace_exists() function checks whether the given namespace exists or not.
rbd_namespace_remove() function removes the given namespace.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-15 13:43:26 -04:00
Mudit Agarwal 7be8bbfe81 rbd: additional error checking in GetPoolMetadata, SetPoolMetadata and RemovePoolMetadata
added a check to validate ioctx in all the three *PoolMetadata functions

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-15 13:20:37 -04:00
Niels de Vos ec822aa3a9 rbd: add error checking in CreateImage()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Niels de Vos 3fc893bc0f rbd: add error checking in RemoveImage()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Niels de Vos 9e7a1c444f rbd: add error checking in OpenImage*() functions
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00