summaryrefslogtreecommitdiff
path: root/src/pybind/ceph_argparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/ceph_argparse.py')
-rw-r--r--src/pybind/ceph_argparse.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py
index f115d3791af..7ec7b8b2f0c 100644
--- a/src/pybind/ceph_argparse.py
+++ b/src/pybind/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):