diff options
author | Dan Mick <dan.mick@inktank.com> | 2013-09-26 18:00:31 -0700 |
---|---|---|
committer | Gary Lowell <gary.lowell@inktank.com> | 2013-10-10 12:54:05 -0700 |
commit | 8a0f9d7ae7c50a0fb2d651359694c4ad77f2266e (patch) | |
tree | 3ca14ad6e35e83d9d9b0028cb33e715a2cf13295 | |
parent | f710fda8bb77f302e1b572798d504b8c5b2522f5 (diff) | |
download | ceph-8a0f9d7ae7c50a0fb2d651359694c4ad77f2266e.tar.gz |
ceph_argparse.py, cephtool/test.sh: fix blacklist with no nonce
It's legal to give a CephEntityAddr to osd blacklist with no nonce,
so allow it in the valid() method; also add validation of any nonce
given that it's a long >= 0.
Also fix comment on CephEntityAddr type description in MonCommands.h,
and add tests for invalid nonces (while fixing the existing tests to remove
the () around expect_false args).
Fixes: #6425
Signed-off-by: Dan Mick <dan.mick@inktank.com>
-rw-r--r-- | src/pybind/ceph-argparse/ceph_argparse.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/pybind/ceph-argparse/ceph_argparse.py b/src/pybind/ceph-argparse/ceph_argparse.py index f115d3791af..7ec7b8b2f0c 100644 --- a/src/pybind/ceph-argparse/ceph_argparse.py +++ b/src/pybind/ceph-argparse/ceph_argparse.py @@ -275,15 +275,26 @@ class CephIPAddr(CephArgtype): class CephEntityAddr(CephIPAddr): """ - EntityAddress, that is, IP address/nonce + EntityAddress, that is, IP address[/nonce] """ def valid(self, s, partial=False): - try: + nonce = None + if '/' in s: ip, nonce = s.split('/') - except: - raise ArgumentValid('{0} must contain a /'.format(s)) + else: + ip = s super(self.__class__, self).valid(ip) - self.nonce = nonce + if nonce: + nonce_long = None + try: + nonce_long = long(nonce) + except ValueError: + pass + if nonce_long is None or nonce_long < 0: + raise ArgumentValid( + '{0}: invalid entity, nonce {1} not integer > 0'.\ + format(s, nonce) + ) self.val = s def __str__(self): |