]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
python: fix pep8 E302, add missing lines
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Sun, 1 Mar 2015 20:08:32 +0000 (21:08 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 3 Mar 2015 11:59:30 +0000 (12:59 +0100)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/pybind/ceph_argparse.py
src/pybind/ceph_rest_api.py
src/pybind/cephfs.py
src/pybind/rados.py
src/pybind/rbd.py
src/script/perf-watch.py

index 3d202da5bcdefe9fc867b5f870905a7636a6f03a..6976f2e978dccfdc03f211c718e327aa0d9997bf 100644 (file)
@@ -20,48 +20,56 @@ import sys
 import types
 import uuid
 
+
 class ArgumentError(Exception):
     """
     Something wrong with arguments
     """
     pass
 
+
 class ArgumentNumber(ArgumentError):
     """
     Wrong number of a repeated argument
     """
     pass
 
+
 class ArgumentFormat(ArgumentError):
     """
     Argument value has wrong format
     """
     pass
 
+
 class ArgumentValid(ArgumentError):
     """
     Argument value is otherwise invalid (doesn't match choices, for instance)
     """
     pass
 
+
 class ArgumentTooFew(ArgumentError):
     """
     Fewer arguments than descriptors in signature; may mean to continue
     the search, so gets a special exception type
     """
 
+
 class ArgumentPrefix(ArgumentError):
     """
     Special for mismatched prefix; less severe, don't report by default
     """
     pass
 
+
 class JsonFormat(Exception):
     """
     some syntactic or semantic issue with the JSON
     """
     pass
 
+
 class CephArgtype(object):
     """
     Base class for all Ceph argument types
@@ -110,6 +118,7 @@ class CephArgtype(object):
         """
         return '<{0}>'.format(self.__class__.__name__)
 
+
 class CephInt(CephArgtype):
     """
     range-limited integers, [+|-][0-9]+ or 0x[0-9a-f]+
@@ -178,6 +187,7 @@ class CephFloat(CephArgtype):
             r = '[{0}-{1}]'.format(self.range[0], self.range[1])
         return '<float{0}>'.format(r)
 
+
 class CephString(CephArgtype):
     """
     String; pretty generic.  goodchars is a RE char class of valid chars
@@ -207,6 +217,7 @@ class CephString(CephArgtype):
             b += '(goodchars {0})'.format(self.goodchars)
         return '<string{0}>'.format(b)
 
+
 class CephSocketpath(CephArgtype):
     """
     Admin socket path; check that it's readable and S_ISSOCK
@@ -220,6 +231,7 @@ class CephSocketpath(CephArgtype):
     def __str__(self):
         return '<admin-socket-path>'
 
+
 class CephIPAddr(CephArgtype):
     """
     IP address (v4 or v6) with optional port
@@ -273,6 +285,7 @@ class CephIPAddr(CephArgtype):
     def __str__(self):
         return '<IPaddr[:port]>'
 
+
 class CephEntityAddr(CephIPAddr):
     """
     EntityAddress, that is, IP address[/nonce]
@@ -300,6 +313,7 @@ class CephEntityAddr(CephIPAddr):
     def __str__(self):
         return '<EntityAddr>'
 
+
 class CephPoolname(CephArgtype):
     """
     Pool name; very little utility
@@ -307,6 +321,7 @@ class CephPoolname(CephArgtype):
     def __str__(self):
         return '<poolname>'
 
+
 class CephObjectname(CephArgtype):
     """
     Object name.  Maybe should be combined with Pool name as they're always
@@ -315,6 +330,7 @@ class CephObjectname(CephArgtype):
     def __str__(self):
         return '<objectname>'
 
+
 class CephPgid(CephArgtype):
     """
     pgid, in form N.xxx (N = pool number, xxx = hex pgnum)
@@ -334,6 +350,7 @@ class CephPgid(CephArgtype):
     def __str__(self):
         return '<pgid>'
 
+
 class CephName(CephArgtype):
     """
     Name (type.id) where:
@@ -369,6 +386,7 @@ class CephName(CephArgtype):
     def __str__(self):
         return '<name (type.id)>'
 
+
 class CephOsdName(CephArgtype):
     """
     Like CephName, but specific to osds: allow <id> alone
@@ -401,6 +419,7 @@ class CephOsdName(CephArgtype):
     def __str__(self):
         return '<osdname (id|osd.id)>'
 
+
 class CephChoices(CephArgtype):
     """
     Set of string literals; init with valid choices
@@ -429,6 +448,7 @@ class CephChoices(CephArgtype):
         else:
             return '{0}'.format('|'.join(self.strings))
 
+
 class CephFilepath(CephArgtype):
     """
     Openable file
@@ -444,6 +464,7 @@ class CephFilepath(CephArgtype):
     def __str__(self):
         return '<outfilename>'
 
+
 class CephFragment(CephArgtype):
     """
     'Fragment' ??? XXX
@@ -588,12 +609,14 @@ class argdesc(object):
             s = '{' + s + '}'
         return s
 
+
 def concise_sig(sig):
     """
     Return string representation of sig useful for syntax reference in help
     """
     return ' '.join([d.helpstr() for d in sig])
 
+
 def descsort(sh1, sh2):
     """
     sort descriptors by prefixes, defined as the concatenation of all simple
@@ -601,6 +624,7 @@ def descsort(sh1, sh2):
     """
     return cmp(concise_sig(sh1['sig']), concise_sig(sh2['sig']))
 
+
 def parse_funcsig(sig):
     """
     parse a single descriptor (array of strings or dicts) into a
@@ -693,6 +717,7 @@ def parse_json_funcsigs(s, consumer):
         sigdict[cmdtag] = cmd
     return sigdict
 
+
 def validate_one(word, desc, partial=False):
     """
     validate_one(word, desc, partial=False)
@@ -707,6 +732,7 @@ def validate_one(word, desc, partial=False):
     if desc.N:
         desc.n = desc.numseen + 1
 
+
 def matchnum(args, signature, partial=False):
     """
     matchnum(s, signature, partial=False)
@@ -748,6 +774,7 @@ def matchnum(args, signature, partial=False):
             matchcnt += 1
     return matchcnt
 
+
 def get_next_arg(desc, args):
     '''
     Get either the value matching key 'desc.name' or the next arg in
@@ -773,6 +800,7 @@ def get_next_arg(desc, args):
             arg = arg[0]
     return arg
 
+
 def store_arg(desc, d):
     '''
     Store argument described by, and held in, thanks to valid(),
@@ -797,6 +825,7 @@ def store_arg(desc, d):
         # if first CephPrefix or any other type, just set it
         d[desc.name] = desc.instance.val
 
+
 def validate(args, signature, partial=False):
     """
     validate(args, signature, partial=False)
@@ -891,11 +920,13 @@ def validate(args, signature, partial=False):
     # Finally, success
     return d
 
+
 def cmdsiglen(sig):
     sigdict = sig.values()
     assert len(sigdict) == 1
     return len(sig.values()[0]['sig'])
 
+
 def validate_command(sigdict, args, verbose=False):
     """
     turn args into a valid dictionary ready to be sent off as JSON,
@@ -976,6 +1007,7 @@ def validate_command(sigdict, args, verbose=False):
 
         return valid_dict
 
+
 def find_cmd_target(childargs):
     """
     Using a minimal validation, figure out whether the command
@@ -1043,6 +1075,7 @@ def find_cmd_target(childargs):
 
     return 'mon', ''
 
+
 def send_command(cluster, target=('mon', ''), cmd=None, inbuf='', timeout=0,
                  verbose=False):
     """
@@ -1121,6 +1154,7 @@ def send_command(cluster, target=('mon', ''), cmd=None, inbuf='', timeout=0,
 
     return ret, outbuf, outs
 
+
 def json_command(cluster, target=('mon', ''), prefix=None, argdict=None,
                  inbuf='', timeout=0, verbose=False):
     """
@@ -1164,4 +1198,3 @@ def json_command(cluster, target=('mon', ''), prefix=None, argdict=None,
 
     return ret, outbuf, outs
 
-
index 77adbe7f9dc88f80cfe121aacca852f7b99f0715..0e1473ab95e2d3e19108989e60eb6b8acccf6d21 100755 (executable)
@@ -41,6 +41,7 @@ LOGLEVELS = {
     'debug':logging.DEBUG,
 }
 
+
 def find_up_osd(app):
     '''
     Find an up OSD.  Return the last one that's up.
@@ -62,6 +63,7 @@ def find_up_osd(app):
 
 METHOD_DICT = {'r':['GET'], 'w':['PUT', 'DELETE']}
 
+
 def api_setup(app, conf, cluster, clientname, clientid, args):
     '''
     This is done globally, and cluster connection kept open for
@@ -247,7 +249,6 @@ def generate_url_and_params(app, sig, flavor):
 #
 # end setup (import-time) functions, begin request-time functions
 #
-
 def concise_sig_for_uri(sig, flavor):
     '''
     Return a generic description of how one would send a REST request for sig
@@ -267,6 +268,7 @@ def concise_sig_for_uri(sig, flavor):
         ret += '?' + '&'.join(args)
     return ret
 
+
 def show_human_help(prefix):
     '''
     Dump table showing commands matching prefix
@@ -301,6 +303,7 @@ def show_human_help(prefix):
     else:
         return ''
 
+
 @app.before_request
 def log_request():
     '''
@@ -309,10 +312,12 @@ def log_request():
     app.logger.info(flask.request.url + " from " + flask.request.remote_addr + " " + flask.request.user_agent.string)
     app.logger.debug("Accept: %s", flask.request.accept_mimetypes.values())
 
+
 @app.route('/')
 def root_redir():
     return flask.redirect(app.ceph_baseurl)
 
+
 def make_response(fmt, output, statusmsg, errorcode):
     '''
     If formatted output, cobble up a response object that contains the
@@ -356,6 +361,7 @@ def make_response(fmt, output, statusmsg, errorcode):
 
     return flask.make_response(response, errorcode)
 
+
 def handler(catchall_path=None, fmt=None, target=None):
     '''
     Main endpoint handler; generic for every endpoint, including catchall.
@@ -488,6 +494,7 @@ def handler(catchall_path=None, fmt=None, target=None):
     response.headers['Content-Type'] = contenttype
     return response
 
+
 #
 # Main entry point from wrapper/WSGI server: call with cmdline args,
 # get back the WSGI app entry point
index 574846fdc017ac1b4520e2adc7e1454a4781b07a..b452be0d0b381bf69599766ae94e9ad153e380db 100644 (file)
@@ -6,33 +6,43 @@ from ctypes import CDLL, c_char_p, c_size_t, c_void_p, c_int, c_long, c_uint, c_
 from ctypes.util import find_library
 import errno
 
+
 class Error(Exception):
     pass
 
+
 class PermissionError(Error):
     pass
 
+
 class ObjectNotFound(Error):
     pass
 
+
 class NoData(Error):
     pass
 
+
 class ObjectExists(Error):
     pass
 
+
 class IOError(Error):
     pass
 
+
 class NoSpace(Error):
     pass
 
+
 class IncompleteWriteError(Error):
     pass
 
+
 class LibCephFSStateError(Error):
     pass
 
+
 def make_ex(ret, msg):
     """
     Translate a libcephfs return code into an exception.
@@ -58,6 +68,7 @@ def make_ex(ret, msg):
     else:
         return Error(msg + (": error code %d" % ret))
 
+
 class cephfs_statvfs(Structure):
     _fields_ = [("f_bsize", c_uint),
                 ("f_frsize", c_uint),
@@ -71,6 +82,7 @@ class cephfs_statvfs(Structure):
                 ("f_flag", c_uint),
                 ("f_namemax", c_uint)]
 
+
 # struct timespec {
 #   long int tv_sec;
 #   long int tv_nsec;
@@ -79,6 +91,7 @@ class cephfs_timespec(Structure):
     _fields_ = [('tv_sec', c_long),
                 ('tv_nsec', c_long)]
 
+
 # struct stat {
 #   unsigned long st_dev;
 #   unsigned long st_ino;
@@ -115,6 +128,7 @@ class cephfs_stat(Structure):
                 ('__unused2', c_long),
                 ('__unused3', c_long) ]
 
+
 def load_libcephfs():
     """
     Load the libcephfs shared library.
@@ -130,6 +144,7 @@ def load_libcephfs():
     except OSError as e:
         raise EnvironmentError("Unable to load libcephfs: %s" % e)
 
+
 class LibCephFS(object):
     """libcephfs python wrapper"""
     def require_state(self, *args):
index 4caa269392651d2b9cd29dd9047b72e7c6d439a7..d66d8763700f2f72382e72e3b85422497b0506d8 100644 (file)
@@ -23,66 +23,82 @@ LIBRADOS_OP_FLAG_FADVISE_WILLNEED   = 0x10
 LIBRADOS_OP_FLAG_FADVISE_DONTNEED   = 0x20
 LIBRADOS_OP_FLAG_FADVISE_NOCACHE    = 0x40
 
+
 class Error(Exception):
     """ `Error` class, derived from `Exception` """
     pass
 
+
 class InterruptedOrTimeoutError(Error):
     """ `InterruptedOrTimeoutError` class, derived from `Error` """
     pass
 
+
 class PermissionError(Error):
     """ `PermissionError` class, derived from `Error` """
     pass
 
+
 class ObjectNotFound(Error):
     """ `ObjectNotFound` class, derived from `Error` """
     pass
 
+
 class NoData(Error):
     """ `NoData` class, derived from `Error` """
     pass
 
+
 class ObjectExists(Error):
     """ `ObjectExists` class, derived from `Error` """
     pass
 
+
 class ObjectBusy(Error):
     """ `ObjectBusy` class, derived from `Error` """
     pass
 
+
 class IOError(Error):
     """ `IOError` class, derived from `Error` """
     pass
 
+
 class NoSpace(Error):
     """ `NoSpace` class, derived from `Error` """
     pass
 
+
 class IncompleteWriteError(Error):
     """ `IncompleteWriteError` class, derived from `Error` """
     pass
 
+
 class RadosStateError(Error):
     """ `RadosStateError` class, derived from `Error` """
     pass
 
+
 class IoctxStateError(Error):
     """ `IoctxStateError` class, derived from `Error` """
     pass
 
+
 class ObjectStateError(Error):
     """ `ObjectStateError` class, derived from `Error` """
     pass
 
+
 class LogicError(Error):
     """ `` class, derived from `Error` """
     pass
 
+
 class TimedOut(Error):
     """ `TimedOut` class, derived from `Error` """
     pass
 
+
 def make_ex(ret, msg):
     """
     Translate a librados return code into an exception.
@@ -111,6 +127,7 @@ def make_ex(ret, msg):
     else:
         return Error(msg + (": errno %s" % errno.errorcode[ret]))
 
+
 class rados_pool_stat_t(Structure):
     """ Usage information for a pool """
     _fields_ = [("num_bytes", c_uint64),
@@ -126,6 +143,7 @@ class rados_pool_stat_t(Structure):
                 ("num_wr", c_uint64),
                 ("num_wr_kb", c_uint64)]
 
+
 class rados_cluster_stat_t(Structure):
     """ Cluster-wide usage information """
     _fields_ = [("kb", c_uint64),
@@ -133,6 +151,7 @@ class rados_cluster_stat_t(Structure):
                 ("kb_avail", c_uint64),
                 ("num_objects", c_uint64)]
 
+
 class timeval(Structure):
     _fields_ = [("tv_sec", c_long), ("tv_usec", c_long)]
 
@@ -147,6 +166,7 @@ class Version(object):
     def __str__(self):
         return "%d.%d.%d" % (self.major, self.minor, self.extra)
 
+
 class RadosThread(threading.Thread):
     def __init__(self, target, args=None):
         self.args = args
@@ -159,6 +179,7 @@ class RadosThread(threading.Thread):
 # time in seconds between each call to t.join() for child thread
 POLL_TIME_INCR = 0.5
 
+
 def run_in_thread(target, args, timeout=0):
     interrupt = False
 
@@ -194,6 +215,7 @@ def run_in_thread(target, args, timeout=0):
         t.retval = -errno.EINTR
     return t.retval
 
+
 class Rados(object):
     """librados python wrapper"""
     def require_state(self, *args):
@@ -784,6 +806,7 @@ Rados object in state %s." % self.state)
         if ret < 0:
             raise make_ex(ret, "error blacklisting client '%s'" % client_address)
 
+
 class ObjectIterator(object):
     """rados.Ioctx Object iterator"""
     def __init__(self, ioctx):
@@ -817,6 +840,7 @@ class ObjectIterator(object):
     def __del__(self):
         run_in_thread(self.ioctx.librados.rados_nobjects_list_close, (self.ctx,))
 
+
 class XattrIterator(object):
     """Extended attribute iterator"""
     def __init__(self, ioctx, it, oid):
@@ -851,6 +875,7 @@ in '%s'" % self.oid)
     def __del__(self):
         run_in_thread(self.ioctx.librados.rados_getxattrs_end, (self.it,))
 
+
 class SnapIterator(object):
     """Snapshot iterator"""
     def __init__(self, ioctx):
@@ -900,6 +925,7 @@ ioctx '%s'" % self.ioctx.name)
         self.cur_snap = self.cur_snap + 1
         return snap
 
+
 class Snap(object):
     """Snapshot object"""
     def __init__(self, ioctx, name, snap_id):
@@ -925,6 +951,7 @@ class Snap(object):
             raise make_ex(ret, "rados_ioctx_snap_get_stamp error")
         return datetime.fromtimestamp(snap_time.value)
 
+
 class Completion(object):
     """completion object"""
     def __init__(self, ioctx, rados_comp, oncomplete, onsafe,
@@ -1020,6 +1047,7 @@ class Completion(object):
 
 RADOS_CB = CFUNCTYPE(c_int, c_void_p, c_void_p)
 
+
 class Ioctx(object):
     """rados.Ioctx object"""
     def __init__(self, name, librados, io):
@@ -1922,7 +1950,6 @@ returned %d, but should return zero on success." % (self.name, ret))
             raise make_ex(ret, "Ioctx.rados_lock_exclusive(%s): failed to set lock %s on %s" % (self.name, name, key))
 
 
-
 def set_object_locator(func):
     def retfunc(self, *args, **kwargs):
         if self.locator_key is not None:
@@ -1935,6 +1962,7 @@ def set_object_locator(func):
             return func(self, *args, **kwargs)
     return retfunc
 
+
 def set_object_namespace(func):
     def retfunc(self, *args, **kwargs):
         if self.nspace is None:
@@ -1946,6 +1974,7 @@ def set_object_namespace(func):
         return retval
     return retfunc
 
+
 class Object(object):
     """Rados object wrapper, makes the object look like a file"""
     def __init__(self, ioctx, key, locator_key=None, nspace=None):
index 334e4c750103c6d9889be8dc5c92f28683d06f68..8ce6adad50ab75a2993253e43bb74330913da291 100644 (file)
@@ -31,54 +31,71 @@ RBD_FEATURE_EXCLUSIVE_LOCK = 4
 
 RBD_FLAG_OBJECT_MAP_INVALID = 1
 
+
 class Error(Exception):
     pass
 
+
 class PermissionError(Error):
     pass
 
+
 class ImageNotFound(Error):
     pass
 
+
 class ImageExists(Error):
     pass
 
+
 class IOError(Error):
     pass
 
+
 class NoSpace(Error):
     pass
 
+
 class IncompleteWriteError(Error):
     pass
 
+
 class InvalidArgument(Error):
     pass
 
+
 class LogicError(Error):
     pass
 
+
 class ReadOnlyImage(Error):
     pass
 
+
 class ImageBusy(Error):
     pass
 
+
 class ImageHasSnapshots(Error):
     pass
 
+
 class FunctionNotSupported(Error):
     pass
 
+
 class ArgumentOutOfRange(Error):
     pass
 
+
 class ConnectionShutdown(Error):
     pass
 
+
 class Timeout(Error):
     pass
 
+
 def make_ex(ret, msg):
     """
     Translate a librbd return code into an exception.
@@ -110,6 +127,7 @@ def make_ex(ret, msg):
     else:
         return Error(msg + (": error code %d" % ret))
 
+
 class rbd_image_info_t(Structure):
     _fields_ = [("size", c_uint64),
                 ("obj_size", c_uint64),
@@ -119,11 +137,13 @@ class rbd_image_info_t(Structure):
                 ("parent_pool", c_int64),
                 ("parent_name", c_char * 96)]
 
+
 class rbd_snap_info_t(Structure):
     _fields_ = [("id", c_uint64),
                 ("size", c_uint64),
                 ("name", c_char_p)]
 
+
 def load_librbd():
     """
     Load the librbd shared library.
@@ -139,6 +159,7 @@ def load_librbd():
     except OSError as e:
         raise EnvironmentError("Unable to load librbd: %s" % e)
 
+
 class RBD(object):
     """
     This class wraps librbd CRUD functions.
@@ -320,6 +341,7 @@ class RBD(object):
         if ret != 0:
             raise make_ex(ret, 'error renaming image')
 
+
 class Image(object):
     """
     This class represents an RBD image. It is used to perform I/O on
@@ -980,6 +1002,7 @@ written." % (self.name, ret, length))
         if ret < 0:
             raise make_ex(ret, 'error unlocking image')
 
+
 class DiffIterateCB(object):
     def __init__(self, cb):
         self.cb = cb
@@ -988,6 +1011,7 @@ class DiffIterateCB(object):
         self.cb(offset, length, exists == 1)
         return 0
 
+
 class SnapIterator(object):
     """
     Iterator over snapshot info for an image.
index 826d4a499d7fea88efcfd2bb6e264ee7f0017027..0add1a9edd115e55b9dd805c53096a77493a90f4 100755 (executable)
@@ -6,6 +6,7 @@ import logging
 import time
 import commands
 
+
 def parse_args():
     parser = argparse.ArgumentParser(description='watch ceph perf')
     parser.add_argument(