]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: configuration: allow splitting by other chars for getting a list
authorAlfredo Deza <adeza@redhat.com>
Tue, 11 Jul 2017 20:01:41 +0000 (16:01 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 4 Aug 2017 14:25:57 +0000 (10:25 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/configuration.py

index 69e893a8c0b38f9ab4b31bf450c8dd4c9cf151da..bd2cf4eb2f9477c695b7fd778c4bafd06826370c 100644 (file)
@@ -61,22 +61,27 @@ class Conf(configparser.SafeConfigParser):
         except (configparser.NoSectionError, configparser.NoOptionError):
             return default
 
-    def get_list(self, section, key):
+    def get_list(self, section, key, default=None, split=','):
         """
         Assumes that the value for a given key is going to be a list separated
         by commas. It gets rid of trailing comments.  If just one item is
         present it returns a list with a single item, if no key is found an
         empty list is returned.
+
+        Optionally split on other characters besides ',' and return a fallback
+        value if no items are found.
         """
         value = self.get_safe(section, key, [])
         if value == []:
+            if default is not None:
+                return default
             return value
 
         # strip comments
         value = re.split(r'\s+#', value)[0]
 
         # split on commas
-        value = value.split(',')
+        value = value.split(split)
 
         # strip spaces
         return [x.strip() for x in value]