]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.in: Move daemonperf to its own function
authorDan Mick <dan.mick@redhat.com>
Fri, 14 Apr 2017 03:20:30 +0000 (20:20 -0700)
committerDan Mick <dan.mick@redhat.com>
Tue, 25 Apr 2017 23:19:02 +0000 (16:19 -0700)
Signed-off-by: Dan Mick <dan.mick@redhat.com>
src/ceph.in

index 8b447122ea7a322491e5bd3a037128879459e6e3..1068167d66bbd5e926a22ea4873c33eb01daceed 100755 (executable)
@@ -600,23 +600,7 @@ def maybe_daemon_command(parsed_args, childargs):
             return True, errno.EINVAL
 
     if sockpath and daemon_perf:
-        interval = 1
-        count = None
-        if len(childargs) > 0:
-            try:
-                interval = float(childargs[0])
-                if interval < 0:
-                    raise ValueError
-            except ValueError:
-                print('daemonperf: interval should be a positive number', file=sys.stderr)
-                return True, errno.EINVAL
-        if len(childargs) > 1:
-            if not childargs[1].isdigit():
-                print('daemonperf: count should be a positive integer', file=sys.stderr)
-                return True, errno.EINVAL
-            count = int(childargs[1])
-        DaemonWatcher(sockpath).run(interval, count)
-        return True, 0
+        return True, daemonperf(childargs, sockpath)
     elif sockpath:
         try:
             raw_write(admin_socket(sockpath, childargs, parsed_args.output_format))
@@ -627,6 +611,27 @@ def maybe_daemon_command(parsed_args, childargs):
 
     return False, 0
 
+
+def daemonperf(childargs, sockpath):
+    """ Handle daemonperf command; returns errno or 0 """
+    interval = 1
+    count = None
+    if len(childargs) > 0:
+        try:
+            interval = float(childargs[0])
+            if interval < 0:
+                raise ValueError
+        except ValueError:
+            print('daemonperf: interval should be a positive number', file=sys.stderr)
+            return errno.EINVAL
+    if len(childargs) > 1:
+        if not childargs[1].isdigit():
+            print('daemonperf: count should be a positive integer', file=sys.stderr)
+            return errno.EINVAL
+        count = int(childargs[1])
+    DaemonWatcher(sockpath).run(interval, count)
+    return 0
+
 ###
 # main
 ###