summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2013-09-26 18:00:31 -0700
committerGary Lowell <gary.lowell@inktank.com>2013-10-09 10:04:51 -0700
commit68d59156894a12ce77aa90b6cd287469cd14533e (patch)
tree67047a2934d36ba06162bf4b77426fbe362ae0ee
parent49d9e1522eb06261f799ec484eefa6f05f4b8337 (diff)
downloadceph-68d59156894a12ce77aa90b6cd287469cd14533e.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.py21
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):