Commit Graph

185 Commits

Author SHA1 Message Date
Sage Weil
15de2c48a1 ceph: add --connect-timeout option
Signed-off-by: Sage Weil <sage@inktank.com>
2013-10-22 12:34:53 -07:00
Sage Weil
e9224755e2 ceph: print basic options before connecting
This will let you control-c if the mon is unresponsive.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-10-22 12:34:41 -07:00
Greg Farnum
445e8c9860 ceph: fixup do_help() function connection check
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>
2013-10-22 12:33:03 -07:00
Sage Weil
32a23c5bba ceph.in: add emacs modeline
Signed-off-by: Sage Weil <sage@inktank.com>
2013-10-22 12:33:03 -07:00
Dan Mick
b6f278c886 ceph.in: fix missing exception variable in failure to open -o file
Fixes: #6424
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-09-27 17:07:26 -07:00
Sage Weil
97f462be48 Revert "ceph: parse CEPH_ARGS environment variable"
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.
2013-09-26 16:06:29 -07:00
Benoît Knecht
30abe3244c Add CEPH_ARGS at the end of sys.argv
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>
2013-09-26 16:06:29 -07:00
Dan Mick
37850e1be6 ceph.in: add to $PATH if needed regardless of LD_LIBRARY_PATH state
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-08-27 13:40:23 -07:00
Sage Weil
67a95b9880 ceph: parse CEPH_ARGS environment variable
Fixes: #6052
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-08-19 12:48:58 -07:00
Dan Mick
266460e97e ceph.in: --admin-daemon was not returning EINVAL on bad command
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>
2013-08-15 17:10:56 -07:00
Sage Weil
d3d56ee502 Merge remote-tracking branch 'gh/next' 2013-08-09 16:03:27 -07:00
Sage Weil
44b093c808 ceph: retry new-style mon command if we get EINVAL from the old-style command
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>
2013-08-09 15:38:39 -07:00
Sage Weil
7e285149fb Merge remote-tracking branch 'gh/next' 2013-08-08 22:18:16 -07:00
Sage Weil
f4aa05a44f Merge pull request #487 from ceph/wip-5746
ceph.in: Re-enable ceph interactive mode (missing its output).

Reviewed-by: Sage Weil <sage@inktank.com>
2013-08-08 18:29:57 -07:00
Dan Mick
fd1923589c ceph.in: return EINVAL on daemon command error
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-08-08 10:23:34 -07:00
Dan Mick
0be14757e2 ceph.in: Re-enable ceph interactive mode (missing its output).
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>
2013-08-08 09:38:04 -07:00
Dan Mick
28d58ebae5 ceph.in, ceph_rest_api.py: import only used syms from ceph_argparse.py
This makes pyflakes/pylint happier and is better practice in general

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-08-05 11:21:19 -07:00
Sage Weil
9797986697 Merge remote-tracking branch 'gh/next' 2013-08-02 11:54:53 -07:00
Sage Weil
00dc634451 ceph: developer mode: set PATH, too
Otherwise the call to ceph-conf may fail if it is not installed on the
local machine.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-30 23:08:58 -07:00
Sage Weil
ee18322e5b Merge remote-tracking branch 'gh/next' 2013-07-28 16:17:55 -07:00
Dan Mick
3f93691bf3 ceph.in: make osdids() (and mon, mds) work on old mons
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-07-26 17:24:22 -07:00
Dan Mick
cd16d73fda ceph.in: clean up help, fix partial matching on all help
Remove --help-all; too much effort for low benefit

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-26 13:51:09 -07:00
Dan Mick
cb38762bca ceph.in: admin_socket() now validates command and passes format
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-26 13:51:09 -07:00
Dan Mick
67eb7de42f ceph_argparse.py, ceph.in: validate_command: stop handling format
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>
2013-07-26 13:51:09 -07:00
Sage Weil
ddaf6d5a93 Merge remote-tracking branch 'gh/next'
Conflicts:
	configure.ac
	src/ceph.in
	src/pybind/ceph_argparse.py
2013-07-25 10:48:57 -07:00
Dan Mick
085f129a6f ceph.in: remove dead code
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-24 11:56:21 -07:00
Dan Mick
92855064b8 ceph.in/ceph_argparse.py: move find_cmd_target() to ceph_argparse.py
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-24 11:56:03 -07:00
Sage Weil
2c5b68c383 Merge remote-tracking branch 'gh/next'
Conflicts:
	PendingReleaseNotes
2013-07-22 18:46:23 -07:00
Dan Mick
e60d14d97d ceph.in: reject --admin-daemon so it can't do harm
Fixes: #3944
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-22 13:12:33 -07:00
Samuel Just
e71808f696 Merge remote-tracking branch 'upstream/next' 2013-07-22 10:32:47 -07:00
Dan Mick
ce46961e32 ceph.in: better error message when daemon command returns nothing
Fixes: #5683
signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-07-19 15:01:18 -07:00
Sage Weil
23cde453c1 Merge remote-tracking branch 'gh/next' 2013-07-19 09:17:48 -07:00
Dan Mick
39654aa0f8 Merge pull request #423 from dalgaaf/wip-da-SCA-pylint
ceph.in, ceph_argparse.py: Fix some pylint issues

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-07-16 23:07:11 -07:00
Sage Weil
f2fa01e22d ceph: send successful commands twice with CEPH_CLI_TEST_DUP_COMMAND
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>
2013-07-16 16:58:13 -07:00
Sage Weil
daf7672309 ceph: drop --threshold hack for 'pg dump_stuck'
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>
2013-07-15 14:05:21 -07:00
Sage Weil
8e83a3bea2 Merge remote-tracking branch 'gh/next' 2013-07-12 10:16:27 -07:00
Dan Mick
cb0f831834 ceph.in: output even a blank status line in compat mode
Fixes: #5594
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-07-11 16:30:38 -07:00
Danny Al-Gaaf
707c39ddd7 ceph.in: add missing spaces around operator
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-07-11 14:02:46 +02:00
Danny Al-Gaaf
f714c01b55 ceph.in: add missing spaces after comma
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-07-11 14:01:21 +02:00
Danny Al-Gaaf
b82473adb3 ceph.in: remove unnecessary semicolons
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-07-11 13:59:10 +02:00
Dan Mick
a5621625e1 ceph CLI: valid() no longer returns bool, but just exception
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>
2013-07-10 19:02:30 -07:00
Dan Mick
0f2ebc6ee3 ceph.in, ceph_argparse.py: move descsort() to ceph_argparse
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-10 19:02:30 -07:00
Dan Mick
bfa2284d21 MonCommands: add new fields: modulename, perms, availability
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>
2013-07-10 19:02:30 -07:00
Dan Mick
b89d7420e3 Merge branch 'next'
Conflicts:
	src/ceph.in
2013-06-21 18:46:08 -07:00
Dan Mick
94eada4046 Add header comments and Inktank copyrights to ceph.in/ceph_argparse.py
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-21 18:39:59 -07:00
Dan Mick
67a3c1e48d ceph.in: rip out reusable code to pybind/ceph_argparse.py
Signed-off-by: Dan Mick <dan.mick@inktank.com>

Conflicts:
	src/ceph.in
2013-06-21 18:39:43 -07:00
Sage Weil
c4272a1758 ceph: even shinier
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-06-21 15:52:32 -07:00
Sage Weil
34ef2f2484 ceph: do not busy-loop on ceph -w
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-06-21 15:50:59 -07:00
Dan Mick
31d221c3a4 ceph.in: remove some TAB chars
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-20 15:14:36 -07:00
Dan Mick
69e1a9121d ceph.in: fix ^C handling in watch (trap exception in while, too)
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-20 15:14:36 -07:00
Sage Weil
29f6f27729 ceph: --version as well as -v
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-20 15:04:51 -07:00
Sage Weil
88f73c5a63 ceph: fix ceph-conf call to get admin socket path for 'daemon <name> ...'
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-19 19:44:45 -07:00
Sage Weil
1a3f0b3c5b Merge branch 'next' 2013-06-19 09:58:54 -07:00
Dan Mick
81e73c7a63 ceph.in: pass parsed conffile to Rados constructor
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-06-18 14:22:40 -07:00
Dan Mick
2fc8d86445 ceph.in: global var dontsplit should be capitalized
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-06-18 14:22:07 -07:00
Sage Weil
e3fb095d8a Merge branch 'next' 2013-06-16 16:49:47 -07:00
Sage Weil
2fe4d29f4d ceph: remove space when prefix is blank
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-16 16:49:05 -07:00
Sage Weil
8d9eef2394 ceph: fix return code for multi-target commands
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-16 16:48:41 -07:00
Sage Weil
84d1847f50 ceph: error out properly when failing to get commands
If we make ret positive here we miss the failure check below.  Instead,
just set outs appropriately.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-16 16:48:27 -07:00
Sage Weil
efebdba011 ceph: do not print status to output file when talking to old mons
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>
2013-06-16 13:36:19 -07:00
Sage Weil
08c915c87c Merge remote-tracking branch 'gh/next' 2013-06-14 21:05:18 -07:00
Sage Weil
9253cd8174 ceph: pass --format=foo to old monitors
And --threshold too, although.. really.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviwed-by: Dan Mick <dan.mick@inktank.com>
2013-06-14 17:30:57 -07:00
Sage Weil
c35c98d16d ceph: add newline when using old monitors
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>
2013-06-14 17:30:44 -07:00
Dan Mick
bb5fae4a5c ceph.in: zero-arg invocation was broken (check array length)
Also remove stray comment char

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-14 16:52:33 -07:00
Sage Weil
b1293ee834 ceph: flush stderr, stdout for sane output; add prefix
Aie.

e.g., ceph tell mon.* injectargs '--debug-ms 1'

 mon.a: injectargs:debug_ms=1/1
 mon.b: injectargs:debug_ms=1/1
 mon.c: injectargs:debug_ms=1/1

or

 osd.0: debug_ms=1/1
 osd.1: debug_ms=1/1
 osd.2: Problem getting command descriptions from ('osd', '2'), ENXIO
 osd.3: Problem getting command descriptions from ('osd', '3'), ENXIO
 osd.4: Problem getting command descriptions from ('osd', '4'), ENXIO
 osd.5: Problem getting command descriptions from ('osd', '5'), ENXIO

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-06-14 12:35:46 -07:00
Sage Weil
7503db9a17 ceph: fix mon.*
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-14 11:02:06 -07:00
Sage Weil
9b66f1aa81 Merge remote-tracking branch 'gh/next' 2013-06-13 21:33:25 -07:00
Dan Mick
06f0b72485 ceph.in: allow args with -h to limit help to cmds that match partially
Enables "ceph -h pg" to see just the pg commands

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-13 17:40:02 -07:00
Dan Mick
6ebfd3c923 ceph.in: better global description of tool
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-13 17:38:50 -07:00
Dan Mick
821b203c4e ceph.in: less verbosity on error
Only show 'did you mean?' when in verbose mode
Only show first ten closest matches on error

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-13 17:38:26 -07:00
Dan Mick
e4f9dce7a5 ceph.in: refuse 'ceph <type> tell' commands; suggest 'ceph tell <type>'
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-06-13 15:56:52 -07:00
Dan Mick
a6876ad7d9 ceph.in: argparsing cleanup: suppress --completion, add help
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>
2013-06-13 15:30:38 -07:00
Sage Weil
3abd2d8bc9 Merge branch 'wip-tell' into next
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-06-13 09:27:15 -07:00
Sage Weil
8adf88a2d5 ceph: add support for 'tell mon.X ...'
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-13 09:26:52 -07:00
Dan Mick
a3767010a8 ceph, mon/OSDMonitor: fix up osd crush commands for <osd.N> or <N>
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>
2013-06-12 21:56:16 -07:00
Sage Weil
d0e6575919 ceph: implement 'ceph tell osd.* ...'
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>
2013-06-12 21:44:29 -07:00
Sage Weil
11d5c7a23b ceph: only use readline when in interactive mode
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>
2013-06-12 17:13:39 -07:00
Sage Weil
b3b0f035b0 ceph: filter out empty lines from osdids()
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-12 14:54:10 -07:00
Sage Weil
edba986314 ceph: accept osd.* as a valid name
This will be used for 'ceph tell osd.* ...'

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-12 14:53:56 -07:00
Dan Mick
e5184ea950 ceph: make life easier on developers by handling in-tree runs
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>
2013-06-12 14:05:34 -07:00
Sage Weil
b70f5658c4 ceph: flush stdout on watch print
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-12 14:00:04 -07:00
Dan Mick
0e0e896e8c ceph: --keyring must be passed to parse_argv, which means not argparse
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>
2013-06-10 18:09:05 -07:00
Dan Mick
359f456a70 ceph: old daemons output to outs and outbuf, combine
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>
2013-06-07 17:29:03 -07:00
Dan Mick
b3f38f3ed8 ceph: handle old OSDs as command destinations, fix status part of -w
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>
2013-06-07 17:28:30 -07:00
Dan Mick
11e1afd84c ceph: add -v for version. Makefile processes ceph_ver.h
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-07 17:20:27 -07:00