pybind: ceph_argparse: validate incorrectly formed targets
Prior to this patch find_cmd_target() would perform the following
parsing for any given command:
- check if it's a "tell" to a parseable CephName
(i.e., ceph tell <type.id> ...)
- if so, return <type>, <id>
- check if it's a "tell" to a parseable PG id
(e.g., ceph tell 0.4a)
- if so, return 'pg', <pgid>
- check if it's a "pg" command to a parseable PG id
(e.g., ceph pg 0.4a)
- if so, return 'pg', <pgid>
- otherwise return 'mon', ''
However, parsing of CephName and CephPgid is performed in a relaxed
fashion, and tightening those checks requirements end up having
nefarious effects on properly formed commands, whereas keeping them
relaxed ends up having us returning 'mon','' in the end for a clearly
malformed target (e.g., 'ceph tell foo ...').
This patch fixes this behavior by adding a new check:
- if command is a "tell" and we were not able to parse either a CephName
nor a PG id, then explicitely validate the target as a CephName (given
we would be sending to a monitor anyway, we can just as well validate
a 'tell' as a CephName).
- if validation fails, we will propagate exceptions referring to the
cause of the validation failure.
Fixes: #10439 Signed-off-by: Joao Eduardo Luis <joao@redhat.com>