10 from __future__ import print_function
11 from ceph_volume_client import CephFSVolumeClient, VolumePath
12 from sys import version_info as sys_version_info
13 from rados import OSError as rados_OSError
15 log = logging.getLogger("ceph_volume_client")
16 log.addHandler(logging.StreamHandler())
17 log.setLevel(logging.DEBUG)
18 vc = CephFSVolumeClient("manila", "/etc/ceph/ceph.conf", "ceph")
30 local keyring
="/etc/ceph/ceph.client.${client}.keyring"
34 sudo
touch -- "$keyring"
35 sudo ceph-authtool
"$keyring" --import-keyring "$T"
42 ceph auth get-or-create
"client.manila" mds
'allow *' osd
'allow rw' mon
'allow *' | import_key
"$client" /etc
/ceph
/ceph.keyring
45 function create_data_isolated
{
47 vp = VolumePath(None, "vol_isolated")
48 vc.create_volume(vp, (1<<33), data_isolated=True)
49 auth_result = vc.authorize(vp, "vol_data_isolated", tenant_id="test")
50 print("[client.vol_data_isolated]\n\tkey = ", auth_result["auth_key"])
53 run_payload
"$PAYLOAD" | import_key
"vol_data_isolated"
56 function create_default
{
58 vp = VolumePath(None, "vol_default")
59 vc.create_volume(vp, (1<<33))
60 auth_result = vc.authorize(vp, "vol_default", tenant_id="test")
61 print("[client.vol_default]\n\tkey = ", auth_result["auth_key"])
63 run_payload
"$PAYLOAD" | import_key
"vol_default"
78 function verify_data_isolated
{
79 ceph fs subvolume getpath cephfs vol_isolated
84 function verify_default
{
85 ceph fs subvolume getpath cephfs vol_default
91 diff <(ceph fs subvolume
ls cephfs | jq
-cS 'sort_by(.name)' |
tee /dev
/stderr
) <(printf '[{"name":"vol_isolated"},{"name":"vol_default"}]' | jq
-cS 'sort_by(.name)')
97 if [ "$1" = create
]; then
100 elif [ "$1" = populate
]; then
102 elif [ "$1" = verify
]; then
103 # verify (sub)volumes still exist and are configured correctly