]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-12543] suse: use common map_components() 333/head
authorTravis Rhoden <trhoden@redhat.com>
Mon, 3 Aug 2015 20:25:47 +0000 (13:25 -0700)
committerTravis Rhoden <trhoden@redhat.com>
Mon, 3 Aug 2015 20:33:05 +0000 (13:33 -0700)
Update the SUSE tests to use the right pieces as well.

Removed the "invalid" test because the common map_components()
does not have a whitelist of packages (though it could).  It
doesn't police what package names go through it, it just modifies
specific ones that you ask it to.

Refs: #12543

Signed-off-by: Travis Rhoden <trhoden@redhat.com>
ceph_deploy/hosts/suse/install.py
ceph_deploy/tests/unit/hosts/test_suse.py

index a42eb6d0b8201089d19cc972e0f77820482e90bc..5a082955a60a3280d695efd93ba57790ae51c075 100644 (file)
@@ -1,29 +1,19 @@
+import logging
+
 from ceph_deploy.util import templates, pkg_managers
 from ceph_deploy.lib import remoto
-import logging
+from ceph_deploy.hosts.common import map_components
 
 LOG = logging.getLogger(__name__)
 
-
-def map_components(components):
-    # SUSE distributions don't offer the same granularity of packages as
-    # used by ceph-deploy, so we need to do some mapping.
-    packages = []
-
-    if (('ceph-osd' in components)
-     or ('ceph-mds' in components)
-     or ('ceph-mon' in components)):
-        packages.append('ceph')
-    if 'ceph-common' in components:
-        packages.append('ceph-common')
-    if 'ceph-radosgw' in components:
-        packages.append('ceph-radosgw')
-
-    return packages
+NON_SPLIT_PACKAGES = ['ceph-osd', 'ceph-mon', 'ceph-mds']
 
 
 def install(distro, version_kind, version, adjust_repos, **kw):
-    packages = map_components(kw.get('components', []))
+    packages = map_components(
+        NON_SPLIT_PACKAGES,
+        kw.get('components', [])
+    )
 
     pkg_managers.zypper_refresh(distro.conn)
     if len(packages):
@@ -31,7 +21,10 @@ def install(distro, version_kind, version, adjust_repos, **kw):
 
 
 def mirror_install(distro, repo_url, gpg_url, adjust_repos, **kw):
-    packages = map_components(kw.get('components', []))
+    packages = map_components(
+        NON_SPLIT_PACKAGES,
+        kw.get('components', [])
+    )
     repo_url = repo_url.strip('/')  # Remove trailing slashes
     gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present
 
@@ -59,9 +52,10 @@ def mirror_install(distro, repo_url, gpg_url, adjust_repos, **kw):
 
 
 def repo_install(distro, reponame, baseurl, gpgkey, **kw):
-    # do we have specific components to install?
-    # removed them from `kw` so that we don't mess with other defaults
-    packages = map_components(kw.pop('components', []))  # noqa
+    packages = map_components(
+        NON_SPLIT_PACKAGES,
+        kw.pop('components', [])
+    )
     # Get some defaults
     name = kw.get('name', '%s repo' % reponame)
     enabled = kw.get('enabled', 1)
index 841ec06cf5f5a37e9576fc03cd885f8b5a81b688..3998e2938d8c981cc80464dcfd5c780b11022fa6 100644 (file)
@@ -1,5 +1,5 @@
 from ceph_deploy.hosts import suse 
-from ceph_deploy.hosts.suse.install import map_components
+from ceph_deploy.hosts.suse.install import map_components, NON_SPLIT_PACKAGES
 
 class TestSuseInit(object):
     def setup(self):
@@ -27,13 +27,8 @@ class TestSuseInit(object):
 
 class TestSuseMapComponents(object):
     def test_valid(self):
-        pkgs = map_components(['ceph-osd', 'ceph-common', 'ceph-radosgw'])
+        pkgs = map_components(NON_SPLIT_PACKAGES, ['ceph-osd', 'ceph-common', 'ceph-radosgw'])
         assert 'ceph' in pkgs
         assert 'ceph-common' in pkgs
         assert 'ceph-radosgw' in pkgs
         assert 'ceph-osd' not in pkgs
-
-    def test_invalid(self):
-        pkgs = map_components(['not-provided', 'ceph-mon'])
-        assert 'not-provided' not in pkgs
-        assert 'ceph' in pkgs