]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/fs/upgrade/volume_client
buildsys: switch source download to quincy
[ceph.git] / ceph / qa / workunits / fs / upgrade / volume_client
1 #!/bin/bash
2
3 set -ex
4
5 PYTHON="python3"
6
7 function run_payload {
8 local payload="$1"
9 sudo "$PYTHON" <<EOF
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
14 import logging
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")
19 vc.connect()
20 ${payload}
21 vc.disconnect()
22 EOF
23 }
24
25 function import_key {
26 local client="$1"
27 if [ -n "$2" ]; then
28 local keyring="$2"
29 else
30 local keyring="/etc/ceph/ceph.client.${client}.keyring"
31 fi
32 local T=$(mktemp)
33 tee "$T" >&2
34 sudo touch -- "$keyring"
35 sudo ceph-authtool "$keyring" --import-keyring "$T"
36 rm -f -- "$T"
37 }
38
39 function conf_keys {
40 local client="$1"
41 ls /etc/ceph >&2
42 ceph auth get-or-create "client.manila" mds 'allow *' osd 'allow rw' mon 'allow *' | import_key "$client" /etc/ceph/ceph.keyring
43 }
44
45 function create_data_isolated {
46 local PAYLOAD='
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"])
51 '
52
53 run_payload "$PAYLOAD" | import_key "vol_data_isolated"
54 }
55
56 function create_default {
57 local PAYLOAD='
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"])
62 '
63 run_payload "$PAYLOAD" | import_key "vol_default"
64 }
65
66 function create {
67 create_data_isolated
68 create_default
69 }
70
71 function populate {
72 pwd
73 df -h .
74 ls -l
75 cp -a /usr/bin .
76 }
77
78 function verify_data_isolated {
79 ceph fs subvolume getpath cephfs vol_isolated
80 stat bin
81 ls bin | tail
82 }
83
84 function verify_default {
85 ceph fs subvolume getpath cephfs vol_default
86 stat bin
87 ls bin | tail
88 }
89
90 function verify {
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)')
92 verify_data_isolated
93 verify_default
94 }
95
96 function main {
97 if [ "$1" = create ]; then
98 conf_keys
99 create
100 elif [ "$1" = populate ]; then
101 populate
102 elif [ "$1" = verify ]; then
103 # verify (sub)volumes still exist and are configured correctly
104 verify
105 else
106 exit 1
107 fi
108 }
109
110 main "$ACTION"