]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/util/rgw.py
1 from cStringIO
import StringIO
6 from requests
.packages
.urllib3
import PoolManager
7 from requests
.packages
.urllib3
.util
import Retry
8 from urlparse
import urlparse
10 from teuthology
.orchestra
.connection
import split_user
11 from teuthology
import misc
as teuthology
13 log
= logging
.getLogger(__name__
)
15 def rgwadmin(ctx
, client
, cmd
, stdin
=StringIO(), check_status
=False,
16 format
='json', decode
=True, log_level
=logging
.DEBUG
):
17 log
.info('rgwadmin: {client} : {cmd}'.format(client
=client
,cmd
=cmd
))
18 testdir
= teuthology
.get_testdir(ctx
)
19 cluster_name
, daemon_type
, client_id
= teuthology
.split_role(client
)
20 client_with_id
= daemon_type
+ '.' + client_id
23 'ceph-coverage'.format(tdir
=testdir
),
24 '{tdir}/archive/coverage'.format(tdir
=testdir
),
25 'radosgw-admin'.format(tdir
=testdir
),
29 '--cluster', cluster_name
,
32 log
.log(log_level
, 'rgwadmin: cmd=%s' % pre
)
33 (remote
,) = ctx
.cluster
.only(client
).remotes
.iterkeys()
36 check_status
=check_status
,
42 out
= proc
.stdout
.getvalue()
46 if not r
and out
!= '':
49 log
.log(log_level
, ' json result: %s' % j
)
52 log
.log(log_level
, ' raw result: %s' % j
)
55 def get_user_summary(out
, user
):
56 """Extract the summary for a given user"""
58 for summary
in out
['summary']:
59 if summary
.get('user') == user
:
60 user_summary
= summary
63 raise AssertionError('No summary info found for user: %s' % user
)
67 def get_user_successful_ops(out
, user
):
68 summary
= out
['summary']
71 return get_user_summary(out
, user
)['total']['successful_ops']
73 def wait_for_radosgw(url
):
74 """ poll the given url until it starts accepting connections
76 add_daemon() doesn't wait until radosgw finishes startup, so this is used
77 to avoid racing with later tasks that expect radosgw to be up and listening
79 # use a connection pool with retry/backoff to poll until it starts listening
80 http
= PoolManager(retries
=Retry(connect
=8, backoff_factor
=1))
81 http
.request('GET', url
)