From bb851bfecd21defc730ee788d7d29be5af28a221 Mon Sep 17 00:00:00 2001 From: Travis Rhoden Date: Fri, 31 Jul 2015 16:58:53 -0700 Subject: [PATCH] [RM-12439] debian: use Apt Class pkg manager Refs: #12439 Signed-off-by: Travis Rhoden --- ceph_deploy/hosts/__init__.py | 3 +- ceph_deploy/hosts/debian/__init__.py | 5 +++ ceph_deploy/hosts/debian/install.py | 51 ++++++--------------------- ceph_deploy/hosts/debian/uninstall.py | 6 +--- 4 files changed, 18 insertions(+), 47 deletions(-) diff --git a/ceph_deploy/hosts/__init__.py b/ceph_deploy/hosts/__init__.py index e725882..297f342 100644 --- a/ceph_deploy/hosts/__init__.py +++ b/ceph_deploy/hosts/__init__.py @@ -69,7 +69,8 @@ def get(hostname, module.conn = conn module.machine_type = machine_type module.init = module.choose_init() - if module.normalized_name in ['fedora', 'centos', 'redhat']: + if module.normalized_name in ['fedora', 'centos', 'redhat', + 'ubuntu', 'debian']: module.packager = module.get_packager(module) return module diff --git a/ceph_deploy/hosts/debian/__init__.py b/ceph_deploy/hosts/debian/__init__.py index 654d838..7453b6b 100644 --- a/ceph_deploy/hosts/debian/__init__.py +++ b/ceph_deploy/hosts/debian/__init__.py @@ -2,6 +2,7 @@ import mon # noqa import pkg # noqa from install import install, mirror_install, repo_install # noqa from uninstall import uninstall # noqa +from ceph_deploy.util import pkg_managers # Allow to set some information about this distro # @@ -19,3 +20,7 @@ def choose_init(): if distro.lower() == 'ubuntu': return 'upstart' return 'sysvinit' + + +def get_packager(module): + return pkg_managers.Apt(module) diff --git a/ceph_deploy/hosts/debian/install.py b/ceph_deploy/hosts/debian/install.py index 6944758..58d755f 100644 --- a/ceph_deploy/hosts/debian/install.py +++ b/ceph_deploy/hosts/debian/install.py @@ -1,7 +1,6 @@ from urlparse import urlparse from ceph_deploy.lib import remoto -from ceph_deploy.util import pkg_managers from ceph_deploy.util.paths import gpg from ceph_deploy.hosts.common import map_components @@ -22,19 +21,7 @@ def install(distro, version_kind, version, adjust_repos, **kw): else: key = 'autobuild' - # Make sure ca-certificates is installed - remoto.process.run( - distro.conn, - [ - 'env', - 'DEBIAN_FRONTEND=noninteractive', - 'apt-get', - '-q', - 'install', - '--assume-yes', - 'ca-certificates', - ] - ) + distro.packager.install('ca-certificates') if adjust_repos: # Wheezy does not like the git.ceph.com SSL cert @@ -81,30 +68,11 @@ def install(distro, version_kind, version, adjust_repos, **kw): distro.conn.remote_module.set_apt_priority(fqdn) distro.conn.remote_module.write_sources_list(url, codename) - remoto.process.run( - distro.conn, - ['apt-get', '-q', 'update'], - ) + distro.packager.clean() # TODO this does not downgrade -- should it? - if len(packages): - cmd = [ - 'env', - 'DEBIAN_FRONTEND=noninteractive', - 'DEBIAN_PRIORITY=critical', - 'apt-get', - '-q', - '-o', 'Dpkg::Options::=--force-confnew', - '--no-install-recommends', - '--assume-yes', - 'install', - '--', - ] - cmd.extend(packages) - remoto.process.run( - distro.conn, - cmd - ) + if packages: + distro.packager.install(packages, force_confnew=True) def mirror_install(distro, repo_url, gpg_url, adjust_repos, **kw): @@ -144,8 +112,9 @@ def mirror_install(distro, repo_url, gpg_url, adjust_repos, **kw): distro.conn.remote_module.write_sources_list(repo_url, distro.codename) - pkg_managers.apt_update(distro.conn) - pkg_managers.apt(distro.conn, packages) + if packages: + distro.packager.clean() + distro.packager.install(packages) def repo_install(distro, repo_name, baseurl, gpgkey, **kw): @@ -190,7 +159,7 @@ def repo_install(distro, repo_name, baseurl, gpgkey, **kw): distro.conn.remote_module.set_apt_priority(fqdn) # repo is not operable until an update - pkg_managers.apt_update(distro.conn) + distro.packager.clean() - if install_ceph: - pkg_managers.apt(distro.conn, packages) + if install_ceph and packages: + distro.packager.install(packages) diff --git a/ceph_deploy/hosts/debian/uninstall.py b/ceph_deploy/hosts/debian/uninstall.py index 6e55586..42d0ce4 100644 --- a/ceph_deploy/hosts/debian/uninstall.py +++ b/ceph_deploy/hosts/debian/uninstall.py @@ -1,6 +1,3 @@ -from ceph_deploy.util import pkg_managers - - def uninstall(distro, purge=False): packages = [ 'ceph', @@ -9,8 +6,7 @@ def uninstall(distro, purge=False): 'ceph-fs-common', 'radosgw', ] - pkg_managers.apt_remove( - distro.conn, + distro.packager.remove( packages, purge=purge, ) -- 2.47.3