From: Travis Rhoden Date: Mon, 3 Aug 2015 20:25:47 +0000 (-0700) Subject: [RM-12543] suse: use common map_components() X-Git-Tag: v1.5.27~7^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=38e7d29ddd673d1d7467ce4efd6ee118e627d490;p=ceph-deploy.git [RM-12543] suse: use common map_components() 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 --- diff --git a/ceph_deploy/hosts/suse/install.py b/ceph_deploy/hosts/suse/install.py index a42eb6d..5a08295 100644 --- a/ceph_deploy/hosts/suse/install.py +++ b/ceph_deploy/hosts/suse/install.py @@ -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) diff --git a/ceph_deploy/tests/unit/hosts/test_suse.py b/ceph_deploy/tests/unit/hosts/test_suse.py index 841ec06..3998e29 100644 --- a/ceph_deploy/tests/unit/hosts/test_suse.py +++ b/ceph_deploy/tests/unit/hosts/test_suse.py @@ -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