mirror of
https://github.com/ceph/ceph
synced 2024-12-17 00:46:05 +00:00
librados, ceph, rados.py: -EINVAL for create with null/invalid name
Means setting defaults should be more careful throughout as well Signed-off-by: Dan Mick <dan.mick@inktank.com>
This commit is contained in:
parent
3f7cac3280
commit
783b7ec847
9
src/ceph
9
src/ceph
@ -1309,7 +1309,7 @@ def main():
|
||||
verbose = parsed_args.verbose
|
||||
|
||||
# pass on --id, --name, --conf
|
||||
name = None
|
||||
name = 'client.admin'
|
||||
if parsed_args.client_id:
|
||||
name = 'client.' + parsed_args.client_id
|
||||
if parsed_args.client_name:
|
||||
@ -1359,7 +1359,12 @@ def main():
|
||||
'err_to_stderr':'true',
|
||||
'log_flush_on_exit':'true',
|
||||
}
|
||||
cluster_handle = rados.Rados(name=name, clustername=parsed_args.cluster,
|
||||
|
||||
clustername = 'ceph'
|
||||
if parsed_args.cluster:
|
||||
clustername = parsed_args.cluster
|
||||
|
||||
cluster_handle = rados.Rados(name=name, clustername=clustername,
|
||||
conf_defaults=conf_defaults, conffile='')
|
||||
|
||||
retargs = cluster_handle.conf_parse_argv(childargs)
|
||||
|
@ -1503,9 +1503,9 @@ extern "C" int rados_create2(rados_t *pcluster, const char *const clustername,
|
||||
{
|
||||
// client is assumed, but from_str will override
|
||||
CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
|
||||
if (name) {
|
||||
iparams.name.from_str(name);
|
||||
}
|
||||
if (!name || !iparams.name.from_str(name))
|
||||
return -EINVAL;
|
||||
|
||||
return rados_create_common(pcluster, clustername, &iparams);
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ class Rados(object):
|
||||
raise RadosStateError("You cannot perform that operation on a \
|
||||
Rados object in state %s." % (self.state))
|
||||
|
||||
def __init__(self, rados_id=None, name=None, clustername='ceph',
|
||||
def __init__(self, rados_id=None, name='client.admin', clustername='ceph',
|
||||
conf_defaults=None, conffile=None, conf=None, flags=0):
|
||||
self.librados = CDLL('librados.so.2')
|
||||
self.cluster = c_void_p()
|
||||
@ -193,9 +193,11 @@ Rados object in state %s." % (self.state))
|
||||
raise TypeError('conffile must be a string or None')
|
||||
if rados_id and name:
|
||||
raise Error("Rados(): can't supply both rados_id and name")
|
||||
if rados_id:
|
||||
name = 'client.' + rados_id
|
||||
ret = run_in_thread(self.librados.rados_create2,
|
||||
(byref(self.cluster), c_char_p(clustername),
|
||||
c_char_p(rados_id), c_uint64(flags)))
|
||||
c_char_p(name), c_uint64(flags)))
|
||||
|
||||
if ret != 0:
|
||||
raise Error("rados_initialize failed with error code: %d" % ret)
|
||||
|
Loading…
Reference in New Issue
Block a user