summaryrefslogtreecommitdiffstats
path: root/qa/workunits/mon/auth_key_rotation.sh
blob: 1a53bab6d8aa5bc15d7b4a46e2e738f16df8babe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/bash -ex

function expect_false()
{
	set -x
	if "$@"; then return 1; else return 0; fi
}


ceph auth export
ceph auth rm client.rot

ceph auth get-or-create client.rot mon 'allow rwx'
ceph auth export client.rot | grep key
ceph auth export client.rot | expect_false grep pending.key

ceph auth get-or-create-pending client.rot
ceph auth export client.rot | grep key
ceph auth export client.rot | grep pending.key

ceph auth clear-pending client.rot
ceph auth export client.rot | expect_false grep pending.key

ceph auth get-or-create-pending client.rot
ceph auth export client.rot | grep key
ceph auth export client.rot | grep pending.key
K=$(ceph auth export client.rot | grep 'key = ' | head -n 1 | awk '{print $3}')
PK=$(ceph auth export client.rot | grep pending.key | awk '{print $4}')
echo "K is $K"
echo "PK is $PK"
ceph -n client.rot --key $K -s

ceph auth commit-pending client.rot
ceph auth export client.rot | expect_false grep pending.key
ceph auth export client.rot | grep key | grep $PK

ceph auth get-or-create-pending client.rot
ceph auth export client.rot | grep key
ceph auth export client.rot | grep pending.key
K=$(ceph auth export client.rot | grep 'key = ' | head -n 1 | awk '{print $3}')
PK=$(ceph auth export client.rot | grep pending.key | awk '{print $4}')
echo "2, K is $K"
echo "2, PK is $PK"

ceph auth export client.rot

while ceph -n client.rot --key $K -s ; do
    ceph auth export client.rot
    ceph -n client.rot --key $PK -s
    sleep 1
done

ceph auth export client.rot | expect_false grep pending.key
ceph auth export client.rot | grep key | grep $PK

ceph -n client.rot --key $PK -s

echo ok