From: Dan Mick Date: Fri, 31 May 2013 04:58:46 +0000 (-0700) Subject: ceph: various cleanups X-Git-Tag: v0.65~136^2^2~32 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8c674800d25c40da20812f86b64f3b482ebe7565;p=ceph.git ceph: various cleanups - make base class valid() do useful work - remove valid from CephPoolname; pool need not exist for create - add --user as alias for --id - remove vestige of special --keyring handing - be sure childargs is an empty list rather than None - remove -- from childargs if present (to stop interpreting -- args) - handle connection timeout cleanly Signed-off-by: Dan Mick --- diff --git a/src/ceph b/src/ceph index 5c03e3c7645..99477135c30 100755 --- a/src/ceph +++ b/src/ceph @@ -83,7 +83,8 @@ class CephArgtype(object): thereof, for example), and return True if not, throw ArgumentError(msg-as-to-why) """ - pass + self.val = s + return True def __repr__(self): """ @@ -277,14 +278,8 @@ class CephEntityAddr(CephIPAddr): class CephPoolname(CephArgtype): """ - Pool name; checked for presence in cluster + Pool name; very little utility """ - def valid(self, s, partial=False): - if cluster.pool.exists(s): - raise ArgumentValid("pool {0} does not exist".format(s)) - self.val = s - return True - def __str__(self): return '' @@ -800,7 +795,7 @@ def parse_cmdargs(args=None, target='', first=False): parser.add_argument('-k', '--keyring', dest='keyring_file', help='keyring file') - parser.add_argument('--id', dest='client_id', + parser.add_argument('--id', '--user', dest='client_id', help='client id for authentication') parser.add_argument('--name', '-n', dest='client_name', help='client name for authentication') @@ -1147,7 +1142,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(parsed_args, childargs, target, sigdict, inbuf, verbose): +def new_style_command(parsed_args, cmdargs, target, sigdict, inbuf, verbose): """ Do new-style command dance. target: daemon to receive command: mon (any) or osd.N @@ -1300,18 +1295,16 @@ def main(): parsed_args, childargs = parse_cmdargs(first=False) + global verbose verbose = parsed_args.verbose - # pass on --id, --name, -k, -c + # pass on --id, --name, --conf name = None if parsed_args.client_id: name = 'client.' + parsed_args.client_id if parsed_args.client_name: name = parsed_args.client_name - if parsed_args.keyring_file: - extraconf.update({'keyring':parsed_args.keyring_file}) - # default '' means default conf search conffile = '' if parsed_args.cephconf: @@ -1340,13 +1333,23 @@ def main(): global cluster cluster = rados.Rados(rados_id=name, conffile='') retargs = cluster.conf_parse_argv(childargs) - childargs = retargs[:] + #tmp = childargs + childargs = retargs + if not childargs: + childargs = [] + + # -- means "stop parsing args", but we don't want to see it either + if '--' in childargs: + childargs.remove('--') try: cluster.connect(timeout=15) except KeyboardInterrupt: print >> sys.stderr, "connection aborted" return 1 + except: + print >> sys.stderr, "connection to cluster timed out" + return 1 # implement -w/--watch_* # This is ugly, but Namespace() isn't quite rich enough.