From: Travis Rhoden Date: Thu, 30 Jul 2015 16:54:52 +0000 (-0700) Subject: [RM-12439] centos: use Yum Class package manager X-Git-Tag: v1.5.27~6^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d7beb434b2fdea21b9ecf2a06c3a9571a8904635;p=ceph-deploy.git [RM-12439] centos: use Yum Class package manager Refs: #12439 --- diff --git a/ceph_deploy/hosts/__init__.py b/ceph_deploy/hosts/__init__.py index b9971d2..bc73c25 100644 --- a/ceph_deploy/hosts/__init__.py +++ b/ceph_deploy/hosts/__init__.py @@ -69,7 +69,7 @@ def get(hostname, module.conn = conn module.machine_type = machine_type module.init = module.choose_init() - if module.normalized_name in ['fedora']: + if module.normalized_name in ['fedora', 'centos']: module.packager = module.get_packager(module) return module diff --git a/ceph_deploy/hosts/centos/__init__.py b/ceph_deploy/hosts/centos/__init__.py index 9ac4683..b36d87d 100644 --- a/ceph_deploy/hosts/centos/__init__.py +++ b/ceph_deploy/hosts/centos/__init__.py @@ -2,6 +2,7 @@ import mon # noqa import pkg # noqa from install import install, mirror_install, repo_install, repository_url_part, rpm_dist # noqa from uninstall import uninstall # noqa +from ceph_deploy.util import pkg_managers # Allow to set some information about this distro # @@ -10,6 +11,7 @@ distro = None release = None codename = None + def choose_init(): """ Select a init system @@ -17,3 +19,7 @@ def choose_init(): Returns the name of a init system (upstart, sysvinit ...). """ return 'sysvinit' + + +def get_packager(module): + return pkg_managers.Yum(module) diff --git a/ceph_deploy/hosts/centos/install.py b/ceph_deploy/hosts/centos/install.py index 3d0d473..8dab18a 100644 --- a/ceph_deploy/hosts/centos/install.py +++ b/ceph_deploy/hosts/centos/install.py @@ -1,6 +1,5 @@ -from ceph_deploy.util import pkg_managers, templates +from ceph_deploy.util import templates from ceph_deploy.lib import remoto -from ceph_deploy.hosts.util import install_yum_priorities from ceph_deploy.hosts.common import map_components from ceph_deploy.util.paths import gpg @@ -50,12 +49,12 @@ def install(distro, version_kind, version, adjust_repos, **kw): repo_part = repository_url_part(distro) dist = rpm_dist(distro) - pkg_managers.yum_clean(distro.conn) + distro.packager.clean() # Get EPEL installed before we continue: if adjust_repos: - install_epel(distro) - install_yum_priorities(distro) + distro.packager.install('epel-release') + distro.packager.install_priorities_plugin() distro.conn.remote_module.enable_yum_priority_obsoletes() logger.warning('check_obsoletes has been enabled for Yum priorities plugin') if version_kind in ['stable', 'testing']: @@ -111,27 +110,8 @@ def install(distro, version_kind, version, adjust_repos, **kw): distro.conn.remote_module.set_repo_priority(['Ceph', 'Ceph-noarch', 'ceph-source']) logger.warning('altered ceph.repo priorities to contain: priority=1') - if len(packages): - cmd = [ - 'yum', - '-y', - 'install', - ] - cmd.extend(packages) - remoto.process.run( - distro.conn, - cmd, - ) - - -def install_epel(distro): - """ - CentOS and Scientific need the EPEL repo, otherwise Ceph cannot be - installed. - """ - if distro.normalized_name in ['centos', 'scientific']: - distro.conn.logger.info('adding EPEL repository') - pkg_managers.yum(distro.conn, 'epel-release') + if packages: + distro.packager.install(packages) def mirror_install(distro, repo_url, gpg_url, adjust_repos, extra_installs=True, **kw): @@ -142,7 +122,7 @@ def mirror_install(distro, repo_url, gpg_url, adjust_repos, extra_installs=True, repo_url = repo_url.strip('/') # Remove trailing slashes gpg_url_path = gpg_url.split('file://')[-1] # Remove file if present - pkg_managers.yum_clean(distro.conn) + distro.packager.clean() if adjust_repos: remoto.process.run( @@ -161,13 +141,13 @@ def mirror_install(distro, repo_url, gpg_url, adjust_repos, extra_installs=True, distro.conn.remote_module.write_yum_repo(ceph_repo_content) # set the right priority - install_yum_priorities(distro) + distro.packager.install_priorities_plugin() distro.conn.remote_module.set_repo_priority(['Ceph', 'Ceph-noarch', 'ceph-source']) distro.conn.logger.warning('alter.d ceph.repo priorities to contain: priority=1') - if extra_installs: - pkg_managers.yum(distro.conn, packages) + if extra_installs and packages: + distro.packager.install(packages) def repo_install(distro, reponame, baseurl, gpgkey, **kw): @@ -185,7 +165,7 @@ def repo_install(distro, reponame, baseurl, gpgkey, **kw): _type = 'repo-md' baseurl = baseurl.strip('/') # Remove trailing slashes - pkg_managers.yum_clean(distro.conn) + distro.packager.clean() if gpgkey: remoto.process.run( @@ -218,7 +198,7 @@ def repo_install(distro, reponame, baseurl, gpgkey, **kw): # set the right priority if kw.get('priority'): - install_yum_priorities(distro) + distro.packager.install_priorities_plugin() logger.warning( 'ensuring that {repo_path} contains a high priority'.format( repo_path=repo_path) @@ -230,5 +210,5 @@ def repo_install(distro, reponame, baseurl, gpgkey, **kw): ) # Some custom repos do not need to install ceph - if install_ceph: - pkg_managers.yum(distro.conn, packages) + if install_ceph and packages: + distro.packager.install(packages) diff --git a/ceph_deploy/hosts/centos/uninstall.py b/ceph_deploy/hosts/centos/uninstall.py index 6fdd9c6..758c34c 100644 --- a/ceph_deploy/hosts/centos/uninstall.py +++ b/ceph_deploy/hosts/centos/uninstall.py @@ -1,6 +1,3 @@ -from ceph_deploy.util import pkg_managers - - def uninstall(distro, purge=False): packages = [ 'ceph', @@ -9,9 +6,5 @@ def uninstall(distro, purge=False): 'ceph-radosgw', ] - pkg_managers.yum_remove( - distro.conn, - packages, - ) - - pkg_managers.yum_clean(distro.conn) + distro.packager.remove(packages) + distro.packager.clean()