Project

General

Profile

Revision 38e7d29d

ID38e7d29ddd673d1d7467ce4efd6ee118e627d490
Parent 93fb1312
Child 9aca50d4

Added by Travis Rhoden over 8 years ago

[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 <>

View differences:

ceph_deploy/hosts/suse/install.py
1
import logging
2

  
1 3
from ceph_deploy.util import templates, pkg_managers
2 4
from ceph_deploy.lib import remoto
3
import logging
5
from ceph_deploy.hosts.common import map_components
4 6

  
5 7
LOG = logging.getLogger(__name__)
6 8

  
7

  
8
def map_components(components):
9
    # SUSE distributions don't offer the same granularity of packages as
10
    # used by ceph-deploy, so we need to do some mapping.
11
    packages = []
12

  
13
    if (('ceph-osd' in components)
14
     or ('ceph-mds' in components)
15
     or ('ceph-mon' in components)):
16
        packages.append('ceph')
17
    if 'ceph-common' in components:
18
        packages.append('ceph-common')
19
    if 'ceph-radosgw' in components:
20
        packages.append('ceph-radosgw')
21

  
22
    return packages
9
NON_SPLIT_PACKAGES = ['ceph-osd', 'ceph-mon', 'ceph-mds']
23 10

  
24 11

  
25 12
def install(distro, version_kind, version, adjust_repos, **kw):
26
    packages = map_components(kw.get('components', []))
13
    packages = map_components(
14
        NON_SPLIT_PACKAGES,
15
        kw.get('components', [])
16
    )
27 17

  
28 18
    pkg_managers.zypper_refresh(distro.conn)
29 19
    if len(packages):
......
31 21

  
32 22

  
33 23
def mirror_install(distro, repo_url, gpg_url, adjust_repos, **kw):
34
    packages = map_components(kw.get('components', []))
24
    packages = map_components(
25
        NON_SPLIT_PACKAGES,
26
        kw.get('components', [])
27
    )
35 28
    repo_url = repo_url.strip('/')  # Remove trailing slashes
36 29
    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present
37 30

  
......
59 52

  
60 53

  
61 54
def repo_install(distro, reponame, baseurl, gpgkey, **kw):
62
    # do we have specific components to install?
63
    # removed them from `kw` so that we don't mess with other defaults
64
    packages = map_components(kw.pop('components', []))  # noqa
55
    packages = map_components(
56
        NON_SPLIT_PACKAGES,
57
        kw.pop('components', [])
58
    )
65 59
    # Get some defaults
66 60
    name = kw.get('name', '%s repo' % reponame)
67 61
    enabled = kw.get('enabled', 1)
ceph_deploy/tests/unit/hosts/test_suse.py
1 1
from ceph_deploy.hosts import suse 
2
from ceph_deploy.hosts.suse.install import map_components
2
from ceph_deploy.hosts.suse.install import map_components, NON_SPLIT_PACKAGES
3 3

  
4 4
class TestSuseInit(object):
5 5
    def setup(self):
......
27 27

  
28 28
class TestSuseMapComponents(object):
29 29
    def test_valid(self):
30
        pkgs = map_components(['ceph-osd', 'ceph-common', 'ceph-radosgw'])
30
        pkgs = map_components(NON_SPLIT_PACKAGES, ['ceph-osd', 'ceph-common', 'ceph-radosgw'])
31 31
        assert 'ceph' in pkgs
32 32
        assert 'ceph-common' in pkgs
33 33
        assert 'ceph-radosgw' in pkgs
34 34
        assert 'ceph-osd' not in pkgs
35

  
36
    def test_invalid(self):
37
        pkgs = map_components(['not-provided', 'ceph-mon'])
38
        assert 'not-provided' not in pkgs
39
        assert 'ceph' in pkgs

Also available in: Unified diff