]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: use conf_parse_argv to deal with nonspecial Ceph args
authorDan Mick <dan.mick@inktank.com>
Fri, 31 May 2013 00:03:13 +0000 (17:03 -0700)
committerDan Mick <dan.mick@inktank.com>
Tue, 4 Jun 2013 00:30:58 +0000 (17:30 -0700)
This means parsing argv only once now, so pass arg lists to
new_style_command().  A little cleanup/commenting too.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
src/ceph

index 201b7d5a4c6a6a448c8a938b50301eaf0a4f67e0..a85f01c3f33475c6e0c7c5dd1d87d69c69bcc919 100755 (executable)
--- a/src/ceph
+++ b/src/ceph
@@ -1147,7 +1147,7 @@ def ceph_conf(field, name):
         raise RuntimeError('unable to get conf option %s for %s: %s' % (field, name, errdata))
     return outdata.rstrip()
 
-def new_style_command(target, sigdict, inbuf, verbose):
+def new_style_command(parsed_args, childargs, target, sigdict, inbuf, verbose):
     """
     Do new-style command dance.
     target: daemon to receive command: mon (any) or osd.N
@@ -1155,8 +1155,6 @@ def new_style_command(target, sigdict, inbuf, verbose):
     inbuf - any -i input file data
     verbose - bool
     """
-
-    parsed_args, cmdargs = parse_cmdargs(target=target)
     if verbose:
         for cmdtag in sorted(sigdict.keys()):
             cmd = sigdict[cmdtag]
@@ -1301,15 +1299,11 @@ def complete(sigdict, args, target):
 def main():
     global cluster
 
-    # we have to parse twice, because we have to collect early
-    # options to be able to run the "get_command_descriptions" command.
-    parsed_args, childargs = parse_cmdargs(first=True)
+    parsed_args, childargs = parse_cmdargs(first=False)
 
     global verbose
     verbose = parsed_args.verbose
 
-    extraconf = {}
-
     # pass on --id, --name, -k, -c
     name = None
     if parsed_args.client_id:
@@ -1324,10 +1318,6 @@ def main():
     conffile = ''
     if parsed_args.cephconf:
         conffile = parsed_args.cephconf
-
-    if len(extraconf) == 0:
-        extraconf = None
-
     # For now, --admin-daemon is handled as usual.  Try it
     # first in case we can't connect() to the cluster
     if parsed_args.admin_socket:
@@ -1348,9 +1338,14 @@ def main():
             print >> sys.stderr, 'Daemon requires at least 2 arguments'
             return 1
 
+    # handle any 'generic' ceph arguments that we didn't parse here
+    global cluster
+    cluster = rados.Rados(rados_id=name, conffile='')
+    retargs = cluster.conf_parse_argv(childargs)
+    childargs = retargs[:]
+
     try:
-        cluster = rados.Rados(rados_id=name, conf=extraconf, conffile=conffile)
-        cluster.connect(timeout=10)
+        cluster.connect(timeout=15)
     except KeyboardInterrupt:
         print >> sys.stderr, "connection aborted"
         return 1
@@ -1365,6 +1360,8 @@ def main():
             else:
                 level = k.replace('watch_', '')
     if level:
+
+        # an awfully simple callback
         def watch_cb(arg, line, who, stamp_sec, stamp_nsec, seq, level, msg):
             print line
 
@@ -1431,7 +1428,8 @@ def main():
     if parsed_args.completion:
         return complete(sigdict, childargs, target)
 
-    ret, outbuf, outs = new_style_command(target, sigdict, inbuf, verbose)
+    ret, outbuf, outs = new_style_command(parsed_args, childargs, target,
+                                          sigdict, inbuf, verbose)
 
     if ret < 0:
         ret = -ret