mirror of
https://github.com/ceph/go-ceph
synced 2024-12-23 22:53:47 +00:00
cephfs: allow creating mount with an id
The ceph api function supports passing a string to identify the client doing the mount. Expose that aspect of the api with a new function CreateMountWithId. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
dfabc3db54
commit
c433abf787
@ -38,16 +38,28 @@ type MountInfo struct {
|
|||||||
mount *C.struct_ceph_mount_info
|
mount *C.struct_ceph_mount_info
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMount creates a mount handle for interacting with Ceph.
|
func createMount(id *C.char) (*MountInfo, error) {
|
||||||
func CreateMount() (*MountInfo, error) {
|
|
||||||
mount := &MountInfo{}
|
mount := &MountInfo{}
|
||||||
ret := C.ceph_create(&mount.mount, nil)
|
ret := C.ceph_create(&mount.mount, id)
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return nil, getError(ret)
|
return nil, getError(ret)
|
||||||
}
|
}
|
||||||
return mount, nil
|
return mount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateMount creates a mount handle for interacting with Ceph.
|
||||||
|
func CreateMount() (*MountInfo, error) {
|
||||||
|
return createMount(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMountWithId creates a mount handle for interacting with Ceph.
|
||||||
|
// The caller can specify a unique id that will identify this client.
|
||||||
|
func CreateMountWithId(id string) (*MountInfo, error) {
|
||||||
|
cid := C.CString(id)
|
||||||
|
defer C.free(unsafe.Pointer(cid))
|
||||||
|
return createMount(cid)
|
||||||
|
}
|
||||||
|
|
||||||
// CreateFromRados creates a mount handle using an existing rados cluster
|
// CreateFromRados creates a mount handle using an existing rados cluster
|
||||||
// connection.
|
// connection.
|
||||||
//
|
//
|
||||||
|
@ -221,3 +221,18 @@ func TestCreateFromRados(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, mount)
|
assert.NotNil(t, mount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateMountWithId(t *testing.T) {
|
||||||
|
// TODO: the entity_id is visible w/in the 'session ls' output
|
||||||
|
// of mds. Consider running the equivalent api call and checking
|
||||||
|
// that the string is set.
|
||||||
|
mount, err := CreateMountWithId("bob")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotNil(t, mount)
|
||||||
|
|
||||||
|
err = mount.ReadDefaultConfigFile()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = mount.Mount()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user