We might have cluster_handle defined, but not have
successfully connected. Instead, check if it's in
the connected state.
Signed-off-by: Greg Farnum <greg@inktank.com>
This reverts commit 67a95b9880.
We now put CEPH_ARGS in the actual args we parse in python, which are passed
to rados piecemeal later. This lets you put things like --id ... in there
that need to be parsed before librados is initialized.
This allows, for instance, to pass a different client name to ceph by
exporting CEPH_ARGS="--id client_id".
Signed-off-by: Benoît Knecht <benoit.knecht@fsfe.org>
Signed-off-by: Sage Weil <sage@inktank.com>
Fix by restructuring code to hoist common code and have only one
place where admin_socket is actually called.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
We can race with a mon upgrade:
- get command descriptions, get EINVAL
- mons upgrade, new quorum
- send old-style command
- get EINVAL
In this case, we should try one last time to get the command descriptions.
Fixes: #5788
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Signed-off-by: Sage Weil <sage@inktank.com>
Also, loop on error. There's no reason to exit the interpreter loop on
an error, and it's probably less annoying if we don't. Print the error,
and any output, and continue.
Fixes: #5746
Signed-off-by: Dan Mick <dan.mick@inktank.com>
We were passing the entire parsed_args Namespace just to look at
and tack on 'format', and that's kinda silly; do it in the callers
instead.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Monitor commands need to be idempotent. This helps us test this by
simply issuing any successful command a second time so that we notice
when a dup submission fails.
Signed-off-by: Sage Weil <sage@inktank.com>
We can live with the incompatibility here; the hack is currently
not working anyway (see #5623).
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
The type validation's valid() method was using a combination of
return code and exception to really indicate the same thing;
simplify by only raising on validation error, and change callers
to cope. validate_one() follows suit.
Also, allow validate() to be called with args that are dicts
(for REST support) rather than bare words. Rules: 'name':'value'
must both match descriptor's name and validate (through valid() for
the value. If value is '', it's assumed to be the same as name,
(one can pass, for example, "detail" as one parameter to
REST, but it will still show up as {'detail':''} here).
Tweak validate()'s algorithm a bit in the process, and make
validate_command() exit the bestcmds loop immediately on first
full validation.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
To help optimize the REST API, we need to know whether the commands
are read (GET) or write (PUT/POST). However, we also could use that
same info for permission/caps checking. Add modulename/perms as
the required caps for each command to drive both needs.
The availability field is to control whether a command is displayed/
advertised through the CLI or REST interfaces; some commands aren't
really useful for REST, and we may want to invent REST-only commands;
also, this gives us a way to deprecate commands quickly and leave the
code, should that be desirable. Make the CLI display only commands
marked with the 'CLI' marker.
Also stop renaming 'help' to 'helptext' in the client.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
The old cli would send the status message to stdout instead of stderr;
we try to emulate that behavior when talking to old monitors because
they send some useful data to outs instead of the data payload.
However, when outputting to a *file*, the outs would still go to
stdout. Maintain that so that, e.g.,
ceph mon getmap -o /tmp/foo
doesn't prefix the monmap with 'got latest monmap\n'.
Signed-off-by: Sage Weil <sage@inktank.com>
The old tool would print a newline after outs, e.g. from 'ceph osd create'.
Do the same when we are talking to old monitors. Also, put outs at the
top, not the bottom!
Tweak the json code to not add the newline again if we already did so
above.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Options -v, --verbose, --concise didn't have helpstrings
Option --completion doesn't quite work yet, and should be hidden anyway
Signed-off-by: Dan Mick <dan.mick@inktank.com>
The new parsing code had been trying to allow flexibility for the
'old form' commands (where id could be different from N in osd.N),
but also accept 'new form' commands. The new rule is that where
there's an OSD specified in the osd crush command, it is of type
CephOsdName, which can be an id *or* 'osd.<id>', but not both.
Pass CephOsdName as int64_t 'id' for convenience in mon code
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Send the command to each target. Do this in series, for now. Error out if
any one fails.
Later, we should do them in parallel.
Signed-off-by: Sage Weil <sage@inktank.com>
A mere
import readline
line is dumping this to stdout on CentOS 6.3:
00000000 1b 5b 3f 31 30 33 34 68 .[?1034h
That confuses non-terminals that read from stdout, so only import when we
are in the interactive mode.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
If <path-to-ceph> contains pybind and .libs:
- prepend <path-to-ceph>/pybind to PYTHONPATH
- append <path-to-ceph>/.libs to LD_LIBRARY_PATH if not already there
and exec self so it takes effect
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
If argparse gets its hands on it, it's not available for parse_argv()
and is therefore ignored.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
When talking to old daemons, if a command succeeds, there may be
output on outs, outbuf, or both; combine them if there's no error,
and clear outs so it's not treated as stderr fodder.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
For osd tell or pg <pgid> commands, the CLI sends the command directly
to the OSD; if the OSDs are still old, the command needs to be sent
in 'plain' (non-JSON) form. Also, the 'ceph status' from -w needs to
handle failure/fallback-to-old-command.
Refactor the guts of json_command() into send_command(), and call it
from json_command() and where needed for old-style commands.
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>