diff options
-rwxr-xr-x | qa/workunits/cephtool/test.sh | 11 | ||||
-rw-r--r-- | src/mon/MonCommands.h | 2 | ||||
-rw-r--r-- | src/pybind/ceph_argparse.py | 20 |
3 files changed, 28 insertions, 5 deletions
diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 51420a2f134..09e55b9a842 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -169,7 +169,16 @@ bl=192.168.0.1:0/1000 ceph osd blacklist add $bl ceph osd blacklist ls | grep $bl ceph osd blacklist rm $bl -expect_false "(ceph osd blacklist ls | grep $bl)" +expect_false "ceph osd blacklist ls | grep $bl" + +bl=192.168.0.1 +# test without nonce, invalid nonce +ceph osd blacklist add $bl +ceph osd blacklist ls | grep $bl +ceph osd blacklist rm $bl +expect_false "ceph osd blacklist ls | grep $bl" +expect_false "ceph osd blacklist $bl/-1" +expect_false "ceph osd blacklist $bl/foo" ceph osd crush tunables legacy ceph osd crush tunables bobtail diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index baef4ea50a5..b28a84943d4 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -59,7 +59,7 @@ * CephString: optional badchars * CephSocketpath: validation involves "is it S_ISSOCK" * CephIPAddr: v4 or v6 addr with optional port, syntax validated - * CephEntityAddr: CephIPAddr + '/nonce' + * CephEntityAddr: CephIPAddr + optional '/nonce' * CephPoolname: Plainold string * CephObjectname: Another plainold string * CephPgid: n.xxx where n is an int > 0, xxx is a hex number > 0 diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 427a4621216..7ec7b8b2f0c 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -275,12 +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): - ip, nonce = s.split('/') + nonce = None + if '/' in s: + ip, nonce = s.split('/') + 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): |