Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RM-7505 Add support for Arch Linux #461

Merged
merged 4 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ if ! [ -d virtualenv ]; then
exit 1
fi
;;

Arch)
for package in "$python_package" python-virtualenv; do
if ! pacman -Qs -- "$package" >/dev/null 2>&1; then
# add a space after old values
missing="${missing:+$missing }$package"
fi
done
if [ -n "$missing" ]; then
echo "$0: missing required packages, please install them:" 1>&2
echo " pacman -Sy $missing"
exit 1
fi
;;
esac

case "$(lsb_release --id --short | awk '{print $1}')" in
Expand All @@ -42,6 +56,7 @@ if ! [ -d virtualenv ]; then
fi
;;
esac

fi

if [ -f /etc/redhat-release ]; then
Expand Down
12 changes: 8 additions & 4 deletions ceph_deploy/hosts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from ceph_deploy import exc
from ceph_deploy.util import versions
from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel
from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel, arch
from ceph_deploy.connection import get_connection

logger = logging.getLogger()
Expand Down Expand Up @@ -69,7 +69,8 @@ def get(hostname,
module.is_el = module.normalized_name in ['redhat', 'centos', 'fedora', 'scientific', 'oracle', 'virtuozzo']
module.is_rpm = module.normalized_name in ['redhat', 'centos',
'fedora', 'scientific', 'suse', 'oracle', 'virtuozzo']
module.is_deb = not module.is_rpm
module.is_deb = module.normalized_name in ['debian', 'ubuntu']
module.is_pkgtarxz = module.normalized_name in ['arch']
module.release = release
module.codename = codename
module.conn = conn
Expand All @@ -93,11 +94,12 @@ def _get_distro(distro, fallback=None, use_rhceph=False):
'ubuntu': debian,
'centos': centos,
'scientific': centos,
'oracle' : centos,
'oracle': centos,
'redhat': centos,
'fedora': fedora,
'suse': suse,
'virtuozzo' : centos
'virtuozzo': centos,
'arch': arch
}

if distro == 'redhat' and use_rhceph:
Expand All @@ -122,6 +124,8 @@ def _normalized_distro_name(distro):
return 'ubuntu'
elif distro.startswith('virtuozzo'):
return 'virtuozzo'
elif distro.startswith('arch'):
return 'arch'
return distro


Expand Down
26 changes: 26 additions & 0 deletions ceph_deploy/hosts/arch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from . import mon # noqa
from ceph_deploy.hosts.centos.install import repo_install # noqa
from .install import install, mirror_install # noqa
from .uninstall import uninstall # noqa
from ceph_deploy.util import pkg_managers

# Allow to set some information about this distro
#

distro = None
release = None
codename = None


def choose_init(module):
"""
Select a init system

Returns the name of a init system (upstart, sysvinit ...).
"""

return 'systemd'


def get_packager(module):
return pkg_managers.Pacman(module)
49 changes: 49 additions & 0 deletions ceph_deploy/hosts/arch/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from ceph_deploy.hosts.centos.install import repo_install, mirror_install # noqa
from ceph_deploy.hosts.common import map_components
from ceph_deploy.util.system import enable_service, start_service


NON_SPLIT_PACKAGES = [
'ceph-osd',
'ceph-radosgw',
'ceph-mds',
'ceph-mon',
'ceph-mgr',
'ceph-common',
'ceph-test'
]

SYSTEMD_UNITS = [
'ceph.target',
'ceph-radosgw.target',
'ceph-rbd-mirror.target',
'ceph-fuse.target',
'ceph-mds.target',
'ceph-mon.target',
'ceph-mgr.target',
'ceph-osd.target',
]
SYSTEMD_UNITS_SKIP_START = [
'ceph-mgr.target',
'ceph-mon.target',
]
SYSTEMD_UNITS_SKIP_ENABLE = [
]


def install(distro, version_kind, version, adjust_repos, **kw):
packages = map_components(
NON_SPLIT_PACKAGES,
kw.pop('components', [])
)

distro.packager.install(
packages
)

# Start and enable services
for unit in SYSTEMD_UNITS:
if unit not in SYSTEMD_UNITS_SKIP_START:
start_service(distro.conn, unit)
if unit not in SYSTEMD_UNITS_SKIP_ENABLE:
enable_service(distro.conn, unit)
2 changes: 2 additions & 0 deletions ceph_deploy/hosts/arch/mon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ceph_deploy.hosts.common import mon_add as add # noqa
from ceph_deploy.hosts.common import mon_create as create # noqa
50 changes: 50 additions & 0 deletions ceph_deploy/hosts/arch/uninstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import logging

from ceph_deploy.util.system import disable_service, stop_service
from ceph_deploy.lib import remoto


SYSTEMD_UNITS = [
'ceph-mds.target',
'ceph-mon.target',
'ceph-osd.target',
'ceph-radosgw.target',
'ceph-fuse.target',
'ceph-mgr.target',
'ceph-rbd-mirror.target',
'ceph.target',
]


def uninstall(distro, purge=False):
packages = [
'ceph',
]

hostname = distro.conn.hostname
LOG = logging.getLogger(hostname)

# I need to stop and disable services prior package removal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reads like a packaging problem on Arch's side. It is the package itself that should have rules that take care of this. I guess this doesn't happen here because you have encountered this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, Arch packages don't start nor stop services, neither handle enabling/disabling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer to notify the user, instead of starting and enabling services?

LOG.info('stopping and disabling services on {}'.format(hostname))
for unit in SYSTEMD_UNITS:
stop_service(distro.conn, unit)
disable_service(distro.conn, unit)

# remoto.process.run(
# distro.conn,
# [
# 'systemctl',
# 'daemon-reload',
# ]
# )

LOG.info('uninstalling packages on {}'.format(hostname))
distro.packager.remove(packages)

remoto.process.run(
distro.conn,
[
'systemctl',
'reset-failed',
]
)
12 changes: 12 additions & 0 deletions ceph_deploy/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def detect_components(args, distro):

if distro.is_rpm:
defaults = default_components.rpm
elif distro.is_pkgtarxz:
# archlinux doesn't have components!
flags = {
'install_osd': 'ceph',
'install_rgw': 'ceph',
'install_mds': 'ceph',
'install_mon': 'ceph',
'install_mgr': 'ceph',
'install_common': 'ceph',
'install_tests': 'ceph',
}
defaults = default_components.pkgtarxz
else:
defaults = default_components.deb
# different naming convention for deb than rpm for radosgw
Expand Down
26 changes: 26 additions & 0 deletions ceph_deploy/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_install_all_returns_all_packages_deb(self):
self.args.install_all = True
self.distro.is_rpm = False
self.distro.is_deb = True
self.distro.is_pkgtarxz = False
result = sorted(install.detect_components(self.args, self.distro))
assert result == sorted([
'ceph-osd', 'ceph-mds', 'ceph', 'ceph-mon', 'radosgw'
Expand All @@ -71,6 +72,7 @@ def test_install_all_returns_all_packages_deb(self):
def test_install_all_with_other_options_returns_all_packages_deb(self):
self.distro.is_rpm = False
self.distro.is_deb = True
self.distro.is_pkgtarxz = False
self.args.install_all = True
self.args.install_mds = True
self.args.install_mgr = True
Expand Down Expand Up @@ -99,6 +101,30 @@ def test_install_all_with_other_options_returns_all_packages_rpm(self):
'ceph-osd', 'ceph-mds', 'ceph', 'ceph-mon', 'ceph-radosgw'
])

def test_install_all_returns_all_packages_pkgtarxz(self):
self.args.install_all = True
self.distro.is_rpm = False
self.distro.is_deb = False
self.distro.is_pkgtarxz = True
result = sorted(install.detect_components(self.args, self.distro))
assert result == sorted([
'ceph',
])

def test_install_all_with_other_options_returns_all_packages_pkgtarxz(self):
self.distro.is_rpm = False
self.distro.is_deb = False
self.distro.is_pkgtarxz = True
self.args.install_all = True
self.args.install_mds = True
self.args.install_mgr = True
self.args.install_mon = True
self.args.install_osd = True
result = sorted(install.detect_components(self.args, self.distro))
assert result == sorted([
'ceph',
])

def test_install_only_one_component(self):
self.args.install_osd = True
result = install.detect_components(self.args, self.distro)
Expand Down
8 changes: 8 additions & 0 deletions ceph_deploy/tests/unit/hosts/test_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def test_get_virtuozzo(self):
result = hosts._normalized_distro_name('Virtuozzo Linux')
assert result == 'virtuozzo'

def test_get_arch(self):
result = hosts._normalized_distro_name('Arch Linux')
assert result == 'arch'


class TestNormalizeRelease(object):

Expand Down Expand Up @@ -419,3 +423,7 @@ def test_get_mint(self):
def test_get_virtuozzo(self):
result = hosts._get_distro('Virtuozzo Linux')
assert result.__name__.endswith('centos')

def test_get_arch(self):
result = hosts._get_distro('Arch Linux')
assert result.__name__.endswith('arch')
3 changes: 2 additions & 1 deletion ceph_deploy/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
'ceph-mon',
]

default_components = namedtuple('DefaultComponents', ['rpm', 'deb'])
default_components = namedtuple('DefaultComponents', ['rpm', 'deb', 'pkgtarxz'])

# the difference here is because RPMs currently name the radosgw differently than DEBs.
# TODO: This needs to get unified once the packaging naming gets consistent
default_components.rpm = tuple(_base_components + ['ceph-radosgw'])
default_components.deb = tuple(_base_components + ['radosgw'])
default_components.pkgtarxz = tuple(['ceph'])

gpg_key_base_url = "download.ceph.com/keys/"
52 changes: 52 additions & 0 deletions ceph_deploy/util/pkg_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,55 @@ def remove(self, packages, **kw):
def clean(self):
cmd = self.executable + ['refresh']
return self._run(cmd)


class Pacman(PackageManager):
"""
Pacman package management
"""

executable = [
'pacman',
'--noconfirm',
]
name = 'pacman'

def install(self, packages, **kw):
if isinstance(packages, str):
packages = [packages]

extra_flags = kw.pop('extra_install_flags', None)
cmd = self.executable + [
'-Sy',
]

if extra_flags:
if isinstance(extra_flags, str):
extra_flags = [extra_flags]
cmd.extend(extra_flags)
cmd.extend(packages)
return self._run(cmd)

def remove(self, packages, **kw):
if isinstance(packages, str):
packages = [packages]

extra_flags = kw.pop('extra_remove_flags', None)
cmd = self.executable + [
'-R'
]
if extra_flags:
if isinstance(extra_flags, str):
extra_flags = [extra_flags]
cmd.extend(extra_flags)

cmd.extend(packages)
return self._run(cmd)

def clean(self):
cmd = self.executable + ['-Syy']
return self._run(cmd)

def add_repo_gpg_key(self, url):
cmd = ['pacman-key', '-a', url]
self._run(cmd)