The return value of rbd_discard() is the number of bytes that have been
discarded, or in case of an error, a negative errno value.
It seems Image.Discard() never can have worked as intended, unless the
error was disregarded. Just like Image.Write(), Image.Discard() should
return a tuple of the number of bytes discarded and an error.
Fixes: ceph/go-ceph#123
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Keeping the _test.go code in the same package allows for the testing
of private functions. AFAWK it is more conventional as well.
See-also: ceph/go-ceph#135
Signed-off-by: Niels de Vos <ndevos@redhat.com>
We recently created errors in the rbd that match the golang convention
but left aliases for external code. Switch the test code to use the
newer more standard form instead of the "aliases."
Signed-off-by: John Mulligan <jmulligan@redhat.com>
A recent PR added new error values that were similar to the existing
naming convention but were not the normal go convention. Change all the
errors to match typical convention but leave the older names as aliases
such that older code will continue to work (for now).
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Translate the return value (errno) from the C rbd_*() functions into the
standardized strerror() error message.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Make it possible to easily validate the *Image and *Snapshot objects
before using them. This makes the use of go-ceph for RBD functions more
stable, and it is less likely that incorrect use causes Go panics.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This allows to set additional options while creating RBD images.
Ceph-CSI will initially consume this to configure an optionally
different pool for data.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
The C library offers rbd_create2() and rbd_create3() and does not try to
cover all options with rbd_create(). For users that are familiar with
the C API, the Create2() and Create3() functions have been added.
The existing Create() API still handles the complete set of
rbd_create*() functions, so backwards compatibility is covered.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Previously, the tests were shelling out to run 'uuidgen' which
is not particularly efficient and a bit ugly. Switch this test
to use the same uuid library already in use by the rados test code.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This change replaces a couple of functions from the "assert" package
with the corresponding functions from the "require", where the
following code relies on a non-nil object.
Signed-off-by: Sven Anderson <sven@redhat.com>