]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: avoid spurious "too many values to unpack"
authorJohn Spray <john.spray@redhat.com>
Wed, 3 Jun 2015 09:40:32 +0000 (10:40 +0100)
committerJohn Spray <john.spray@redhat.com>
Wed, 3 Jun 2015 09:40:32 +0000 (10:40 +0100)
When a user passes e.g. an IP address where
they should have passed a <service>.<id>,
the dots were causing us to raise "too many
values to unpack" exceptions instead of
proper complaints about it not being
a valid service name.

Fixes: #10950
Signed-off-by: John Spray <john.spray@redhat.com>
src/pybind/ceph_argparse.py

index 8698c4eb171a9ffa4d53c87d868403fde5597981..762ba604e88a7344223d30b4b9d5ae2ffb176b63 100644 (file)
@@ -338,12 +338,12 @@ class CephPgid(CephArgtype):
     def valid(self, s, partial=False):
         if s.find('.') == -1:
             raise ArgumentFormat('pgid has no .')
-        poolid, pgnum = s.split('.')
+        poolid, pgnum = s.split('.', 1)
         if poolid < 0:
             raise ArgumentFormat('pool {0} < 0'.format(poolid))
         try:
             pgnum = int(pgnum, 16)
-        except:
+        except ValueError:
             raise ArgumentFormat('pgnum {0} not hex integer'.format(pgnum))
         self.val = s
 
@@ -370,7 +370,7 @@ class CephName(CephArgtype):
         if s.find('.') == -1:
             raise ArgumentFormat('CephName: no . in {0}'.format(s))
         else:
-            t, i = s.split('.')
+            t, i = s.split('.', 1)
             if t not in ('osd', 'mon', 'client', 'mds'):
                 raise ArgumentValid('unknown type ' + t)
             if t == 'osd':
@@ -402,7 +402,7 @@ class CephOsdName(CephArgtype):
             self.val = s
             return
         if s.find('.') != -1:
-            t, i = s.split('.')
+            t, i = s.split('.', 1)
             if t != 'osd':
                 raise ArgumentValid('unknown type ' + t)
         else: