From: Dan Mick Date: Fri, 31 May 2013 00:03:13 +0000 (-0700) Subject: ceph: use conf_parse_argv to deal with nonspecial Ceph args X-Git-Tag: v0.65~136^2^2~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df34cff7677f0877c01c14636bacee4754584fe3;p=ceph.git ceph: use conf_parse_argv to deal with nonspecial Ceph args 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 --- diff --git a/src/ceph b/src/ceph index 201b7d5a4c6..a85f01c3f33 100755 --- 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