From: Warren Usui Date: Fri, 14 Feb 2014 21:57:03 +0000 (-0800) Subject: Fix docstrings in radosgw-admin-rest.py X-Git-Tag: 1.1.0~1654^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ef97f0cda40b0ae773a5b6804c7389f79fb30608;p=teuthology.git Fix docstrings in radosgw-admin-rest.py Fixes: 6541 Signed-off-by: Warren Usui --- diff --git a/teuthology/task/radosgw-admin-rest.py b/teuthology/task/radosgw-admin-rest.py index 25b04a37d..43cf73539 100644 --- a/teuthology/task/radosgw-admin-rest.py +++ b/teuthology/task/radosgw-admin-rest.py @@ -1,9 +1,12 @@ -# The test cases in this file have been annotated for inventory. -# To extract the inventory (in csv format) use the command: -# -# grep '^ *# TESTCASE' | sed 's/^ *# TESTCASE //' -# +""" +Run a series of rgw admin commands through the rest interface. +The test cases in this file have been annotated for inventory. +To extract the inventory (in csv format) use the command: + + grep '^ *# TESTCASE' | sed 's/^ *# TESTCASE //' + +""" from cStringIO import StringIO import logging import json @@ -21,6 +24,10 @@ from teuthology import misc as teuthology log = logging.getLogger(__name__) def successful_ops(out): + """ + Extract successful operations + :param out: list + """ summary = out['summary'] if len(summary) == 0: return 0 @@ -28,6 +35,13 @@ def successful_ops(out): return entry['total']['successful_ops'] def rgwadmin(ctx, client, cmd): + """ + Perform rgw admin command + + :param client: client + :param cmd: command to execute. + :return: command exit status, json result. + """ log.info('radosgw-admin: %s' % cmd) testdir = teuthology.get_testdir(ctx) pre = [ @@ -60,6 +74,9 @@ def rgwadmin(ctx, client, cmd): def rgwadmin_rest(connection, cmd, params=None, headers=None, raw=False): + """ + perform a rest command + """ log.info('radosgw-admin-rest: %s %s' % (cmd, params)) put_cmds = ['create', 'link', 'add'] post_cmds = ['unlink', 'modify'] @@ -71,6 +88,10 @@ def rgwadmin_rest(connection, cmd, params=None, headers=None, raw=False): zone_sub_resources = ['pool', 'log', 'garbage'] def get_cmd_method_and_handler(cmd): + """ + Get the rest command and handler from information in cmd and + from the imported requests object. + """ if cmd[1] in put_cmds: return 'PUT', requests.put elif cmd[1] in delete_cmds: @@ -81,6 +102,9 @@ def rgwadmin_rest(connection, cmd, params=None, headers=None, raw=False): return 'GET', requests.get def get_resource(cmd): + """ + Get the name of the resource from information in cmd. + """ if cmd[0] == 'bucket' or cmd[0] in bucket_sub_resources: if cmd[0] == 'bucket': return 'bucket', '' @@ -99,11 +123,12 @@ def rgwadmin_rest(connection, cmd, params=None, headers=None, raw=False): else: return 'zone', cmd[0] - """ - Adapted from the build_request() method of boto.connection - """ def build_admin_request(conn, method, resource = '', headers=None, data='', query_args=None, params=None): + """ + Build an administative request adapted from the build_request() + method of boto.connection + """ path = conn.calling_format.build_path_base('admin', resource) auth_path = conn.calling_format.build_auth_path('admin', resource)