]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-12543] Add map_components() for sorting out split pkgs
authorTravis Rhoden <trhoden@redhat.com>
Mon, 3 Aug 2015 20:03:52 +0000 (13:03 -0700)
committerTravis Rhoden <trhoden@redhat.com>
Mon, 3 Aug 2015 20:16:28 +0000 (13:16 -0700)
Refs: #12543

Signed-off-by: Travis Rhoden <trhoden@redhat.com>
ceph_deploy/hosts/common.py
ceph_deploy/tests/unit/hosts/test_common.py [new file with mode: 0644]

index 593fbaec63b9dc500d1f84a611983f99b4472460..4fce095a35017014c984e8f5124923dc0429e042 100644 (file)
@@ -178,3 +178,23 @@ def mon_add(distro, args, monitor_keyring):
             args.address,
         ],
     )
+
+
+def map_components(notsplit_packages, components):
+    """
+    Returns a list of packages to install based on component names
+
+    This is done by checking if a component is in notsplit_packages,
+    if it is, we know we need to install 'ceph' instead of the
+    raw component name.  Essentially, this component hasn't been
+    'split' from the master 'ceph' package yet.
+    """
+    packages = set()
+
+    for c in components:
+        if c in notsplit_packages:
+            packages.add('ceph')
+        else:
+            packages.add(c)
+
+    return list(packages)
diff --git a/ceph_deploy/tests/unit/hosts/test_common.py b/ceph_deploy/tests/unit/hosts/test_common.py
new file mode 100644 (file)
index 0000000..278d09e
--- /dev/null
@@ -0,0 +1,24 @@
+from ceph_deploy.hosts.common import map_components
+
+
+class TestMapComponents(object):
+
+    def test_map_components_all_split(self):
+        components = ['ceph-mon', 'ceph-osd']
+        packages = map_components([], components)
+        assert set(packages) == set(components)
+
+    def test_map_components_mds_not_split(self):
+        components = ['ceph-mon', 'ceph-osd', 'ceph-mds']
+        packages = map_components(['ceph-mds'], components)
+        assert set(packages) == set(['ceph-mon', 'ceph-osd', 'ceph'])
+
+    def test_map_components_no_duplicates(self):
+        components = ['ceph-mon', 'ceph-osd', 'ceph-mds']
+        packages = map_components(['ceph-mds', 'ceph-osd'], components)
+        assert set(packages) == set(['ceph-mon', 'ceph'])
+        assert len(packages) == len(set(['ceph-mon', 'ceph']))
+
+    def test_map_components_no_components(self):
+        packages = map_components(['ceph-mon'], [])
+        assert len(packages) == 0