From: Chris Glass Date: Sat, 19 Apr 2014 12:03:19 +0000 (+0200) Subject: Simple mechanical cleanups X-Git-Tag: v0.81~109^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1699%2Fhead;p=ceph.git Simple mechanical cleanups * Removed trailing and useless whitespaces * Removed useless imports. Signed-off-by: Christopher Glass --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 8f2eb8f25def..9873061c8589 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -829,7 +829,7 @@ def validate(args, signature, partial=False): break # out of arguments for a required param? - # Either return (if partial validation) or raise + # Either return (if partial validation) or raise if not myarg and desc.req: if desc.N and desc.numseen < 1: # wanted N, didn't even get 1 @@ -1013,7 +1013,7 @@ def find_cmd_target(childargs): return 'mon', '' -def send_command(cluster, target=('mon', ''), cmd=None, inbuf='', timeout=0, +def send_command(cluster, target=('mon', ''), cmd=None, inbuf='', timeout=0, verbose=False): """ Send a command to a daemon using librados's diff --git a/src/pybind/ceph_rest_api.py b/src/pybind/ceph_rest_api.py index 46d971edb2f2..59d1ba28ddef 100755 --- a/src/pybind/ceph_rest_api.py +++ b/src/pybind/ceph_rest_api.py @@ -361,7 +361,7 @@ def handler(catchall_path=None, fmt=None, target=None): Main endpoint handler; generic for every endpoint, including catchall. Handles the catchall, anything with <.fmt>, anything with embedded . Partial match or ?help cause the HTML-table - "show_human_help" output. + "show_human_help" output. ''' ep = catchall_path or flask.request.endpoint diff --git a/src/pybind/cephfs.py b/src/pybind/cephfs.py index 13a826254fce..60849aeb75e8 100644 --- a/src/pybind/cephfs.py +++ b/src/pybind/cephfs.py @@ -167,7 +167,7 @@ class LibCephFS(object): def shutdown(self): """ - Unmount and destroy the ceph mount handle. + Unmount and destroy the ceph mount handle. """ if self.state != "shutdown": self.libcephfs.ceph_shutdown(self.cluster) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index e5da0771771a..924b1bff50f1 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -144,7 +144,6 @@ class RadosThread(threading.Thread): POLL_TIME_INCR = 0.5 def run_in_thread(target, args, timeout=0): - import sys interrupt = False countdown = timeout @@ -182,7 +181,7 @@ def run_in_thread(target, args, timeout=0): class Rados(object): """librados python wrapper""" def require_state(self, *args): - """ + """ Checks if the Rados object is in a special state :raises: RadosStateError @@ -266,7 +265,7 @@ Rados object in state %s." % (self.state)) def version(self): """ Get the version number of the ``librados`` C library. - + :returns: a tuple of ``(major, minor, extra)`` components of the librados version """ @@ -422,14 +421,14 @@ Rados object in state %s." % (self.state)) def get_cluster_stats(self): """ Read usage info about the cluster - + This tells you total space, space used, space available, and number of objects. These are not updated immediately when data is written, they are eventually consistent. :returns: dict - contains the following keys: - - ``kb`` (int) - total space + - ``kb`` (int) - total space - ``kb_used`` (int) - space used @@ -521,7 +520,7 @@ Rados object in state %s." % (self.state)) The pool is removed from the cluster immediately, but the actual data is deleted in the background. - :param pool_name: name of the pool to delete + :param pool_name: name of the pool to delete :type pool_name: str :raises: :class:`TypeError`, :class:`Error` @@ -536,7 +535,7 @@ Rados object in state %s." % (self.state)) def list_pools(self): """ - Gets a list of pool names. + Gets a list of pool names. :returns: list - of pool names. """ @@ -573,13 +572,13 @@ Rados object in state %s." % (self.state)) Create an io context The io context allows you to perform operations within a particular - pool. + pool. - :param ioctx_name: name of the pool + :param ioctx_name: name of the pool :type ioctx_name: str :raises: :class:`TypeError`, :class:`Error` - :returns: Ioctx - Rados Ioctx object + :returns: Ioctx - Rados Ioctx object """ self.require_state("connected") if not isinstance(ioctx_name, str): @@ -596,7 +595,6 @@ Rados object in state %s." % (self.state)) mon_command[_target](cmd, inbuf, outbuf, outbuflen, outs, outslen) returns (int ret, string outbuf, string outs) """ - import sys self.require_state("connected") outbufp = pointer(pointer(c_char())) outbuflen = c_long() @@ -634,7 +632,6 @@ Rados object in state %s." % (self.state)) osd_command(osdid, cmd, inbuf, outbuf, outbuflen, outs, outslen) returns (int ret, string outbuf, string outs) """ - import sys self.require_state("connected") outbufp = pointer(pointer(c_char())) outbuflen = c_long() @@ -664,7 +661,6 @@ Rados object in state %s." % (self.state)) pg_command(pgid, cmd, inbuf, outbuf, outbuflen, outs, outslen) returns (int ret, string outbuf, string outs) """ - import sys self.require_state("connected") outbufp = pointer(pointer(c_char())) outbuflen = c_long() @@ -782,7 +778,7 @@ ioctx '%s'" % self.ioctx.name) """ Get the next Snapshot - :raises: :class:`Error`, StopIteration + :raises: :class:`Error`, StopIteration :returns: Snap - next snapshot """ if (self.cur_snap >= self.max_snap): @@ -872,8 +868,8 @@ class Completion(object): (self.rados_comp,)) def __del__(self): - """ - Release a completion + """ + Release a completion Call this when you no longer need the completion. It may not be freed immediately if the operation is not acked and committed. @@ -907,8 +903,8 @@ class Ioctx(object): self.close() def __aio_safe_cb(self, completion, _): - """ - Callback to onsafe() for asynchronous operations + """ + Callback to onsafe() for asynchronous operations """ cb = None with self.lock: @@ -918,8 +914,8 @@ class Ioctx(object): return 0 def __aio_complete_cb(self, completion, _): - """ - Callback to oncomplete() for asynchronous operations + """ + Callback to oncomplete() for asynchronous operations """ cb = None with self.lock: @@ -940,7 +936,7 @@ class Ioctx(object): :type onsafe: completion :raises: :class:`Error` - :returns: completion object + :returns: completion object """ completion = c_void_p(0) complete_cb = None @@ -983,7 +979,7 @@ class Ioctx(object): :type onsafe: completion :raises: :class:`Error` - :returns: completion object + :returns: completion object """ completion = self.__get_completion(oncomplete, onsafe) ret = run_in_thread(self.librados.rados_aio_write, @@ -1015,7 +1011,7 @@ class Ioctx(object): :type onsafe: completion :raises: :class:`Error` - :returns: completion object + :returns: completion object """ completion = self.__get_completion(oncomplete, onsafe) ret = run_in_thread(self.librados.rados_aio_write_full, @@ -1046,7 +1042,7 @@ class Ioctx(object): :type onsafe: completion :raises: :class:`Error` - :returns: completion object + :returns: completion object """ completion = self.__get_completion(oncomplete, onsafe) ret = run_in_thread(self.librados.rados_aio_append, @@ -1206,7 +1202,7 @@ class Ioctx(object): :raises: :class:`TypeError` :raises: :class:`LogicError` - :returns: int - number of bytes written + :returns: int - number of bytes written """ self.require_ioctx_open() if not isinstance(key, str): @@ -1298,7 +1294,7 @@ returned %d, but should return zero on success." % (self.name, ret)) :param key: name of the object :type key: str :param length: the number of bytes to read (default=8192) - :type length: int + :type length: int :param offset: byte offset in the object to begin reading at :type offset: int @@ -1405,7 +1401,7 @@ returned %d, but should return zero on success." % (self.name, ret)) :raises: :class:`Error` :returns: int - 0 on success, otherwise raises error """ - + self.require_ioctx_open() if not isinstance(key, str): raise TypeError('key must be a string') @@ -1418,7 +1414,7 @@ returned %d, but should return zero on success." % (self.name, ret)) def stat(self, key): """ Get object stats (size/mtime) - + :param key: the name of the object to get stats from :type key: str @@ -1442,7 +1438,7 @@ returned %d, but should return zero on success." % (self.name, ret)) def get_xattr(self, key, xattr_name): """ Get the value of an extended attribute on an object. - + :param key: the name of the object to get xattr from :type key: str :param xattr_name: which extended attribute to read @@ -1472,7 +1468,7 @@ returned %d, but should return zero on success." % (self.name, ret)) def get_xattrs(self, oid): """ Start iterating over xattrs on an object. - + :param oid: the name of the object to get xattrs from :type key: str @@ -1493,7 +1489,7 @@ returned %d, but should return zero on success." % (self.name, ret)) def set_xattr(self, key, xattr_name, xattr_value): """ Set an extended attribute on an object. - + :param key: the name of the object to set xattr to :type key: str :param xattr_name: which extended attribute to set @@ -1522,7 +1518,7 @@ returned %d, but should return zero on success." % (self.name, ret)) def rm_xattr(self, key, xattr_name): """ Removes an extended attribute on from an object. - + :param key: the name of the object to remove xattr from :type key: str :param xattr_name: which extended attribute to remove @@ -1545,7 +1541,7 @@ returned %d, but should return zero on success." % (self.name, ret)) return True def list_objects(self): - """ + """ Get ObjectIterator on rados.Ioctx object. :returns: ObjectIterator @@ -1554,7 +1550,7 @@ returned %d, but should return zero on success." % (self.name, ret)) return ObjectIterator(self) def list_snaps(self): - """ + """ Get SnapIterator on rados.Ioctx object. :returns: SnapIterator @@ -1712,7 +1708,7 @@ MONITOR_LEVELS = [ "debug", "info", "warn", "warning", - "err", "error", + "err", "error", "sec", ] diff --git a/src/pybind/rbd.py b/src/pybind/rbd.py index bf075769d8be..ef41454ecbbc 100644 --- a/src/pybind/rbd.py +++ b/src/pybind/rbd.py @@ -456,7 +456,7 @@ class Image(object): pool = create_string_buffer(size) name = create_string_buffer(size) snapname = create_string_buffer(size) - ret = self.librbd.rbd_get_parent_info(self.image, pool, len(pool), + ret = self.librbd.rbd_get_parent_info(self.image, pool, len(pool), name, len(name), snapname, len(snapname)) if ret == -errno.ERANGE: size *= 2