]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: add function to parse rados psuedo-uri values
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 15 Jul 2024 19:22:43 +0000 (15:22 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 20 Aug 2024 13:53:56 +0000 (09:53 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/rados_store.py

index 1e739088e7eac18dfd7cdca3ce85f2572f65a535..8896350ee412c4670fe73acd7136b578467d7dc8 100644 (file)
@@ -273,3 +273,19 @@ def _init_pool(mgr: 'MgrModule', pool: str) -> None:
             'app': 'smb',
         }
     )
+
+
+def parse_uri(uri: str) -> Tuple[str, str, str]:
+    """Parse a rados-like uri into pool, namespace, and object values.
+    Namespace may be an empty string.
+    """
+    if uri.startswith('rados://'):
+        parts = uri.removeprefix('rados://').split('/')
+        if len(parts) == 3:
+            return tuple(parts)  # type: ignore
+        if len(parts) == 2:
+            return parts[0], '', parts[1]
+        raise ValueError('invalid rados uri: {uri!r}')
+    elif uri.startswith('rados:'):
+        raise ValueError('not a supported rados uri: {uri!r}')
+    raise ValueError('not a rados uri: {uri!r}')