--- /dev/null
+*~
+*.pyc
+*.pyo
+.coverage
+.tox
+*.egg-info
+*.egg
+dist
+build
+wheelhouse
+*.log
+*.trs
+
--- /dev/null
+- Owen Synge <osynge@suse.com>
+- Loic Dachary <loic@dachary.org>
--- /dev/null
+include AUTHORS.rst
--- /dev/null
+ceph-detect-init
+================
+
+ceph-detect-init is a command line tool that displays a normalized
+string describing the init system of the host on which it is running:
+
+Home page : https://pypi.python.org/pypi/ceph-detect-init
+
+Hacking
+=======
+
+* Get the code : git clone https://git.ceph.com/ceph.git
+* Run the unit tests : tox
+* Run the integration tests (requires docker) : tox -e integration
+* Check the documentation : rst2html < README.rst > /tmp/a.html
+* Prepare a new version
+
+ - version=1.0.0 ; perl -pi -e "s/^version.*/version='$version',/" setup.py ; do python setup.py sdist ; amend=$(git log -1 --oneline | grep --quiet "version $version" && echo --amend) ; git commit $amend -m "version $version" setup.py ; git tag -a -f -m "version $version" $version ; done
+
+* Publish a new version
+
+ - python setup.py sdist upload --sign
+ - git push ; git push --tags
+
+* pypi maintenance
+
+ - python setup.py register # if the project does not yet exist
+ - trim old versions at https://pypi.python.org/pypi/ceph-detect-init
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright (C) 2015 <contact@redhat.com>
+#
+# Author: Alfredo Deza <adeza@redhat.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library Public License for more details.
+#
+from ceph_detect_init import centos
+from ceph_detect_init import debian
+from ceph_detect_init import exc
+from ceph_detect_init import fedora
+from ceph_detect_init import rhel
+from ceph_detect_init import suse
+import logging
+import platform
+
+
+def get(use_rhceph=False):
+ distro_name, release, codename = platform_information()
+ if not codename or not _get_distro(distro_name):
+ raise exc.UnsupportedPlatform(
+ distro=distro_name,
+ codename=codename,
+ release=release)
+
+ module = _get_distro(distro_name, use_rhceph=use_rhceph)
+ module.name = distro_name
+ module.normalized_name = _normalized_distro_name(distro_name)
+ module.distro = module.normalized_name
+ module.is_el = module.normalized_name in ['redhat', 'centos',
+ 'fedora', 'scientific']
+ module.release = release
+ module.codename = codename
+ module.init = module.choose_init()
+ return module
+
+
+def _get_distro(distro, use_rhceph=False):
+ if not distro:
+ return
+
+ distro = _normalized_distro_name(distro)
+ distributions = {
+ 'debian': debian,
+ 'ubuntu': debian,
+ 'centos': centos,
+ 'scientific': centos,
+ 'redhat': centos,
+ 'fedora': fedora,
+ 'suse': suse,
+ }
+
+ if distro == 'redhat' and use_rhceph:
+ return rhel
+ else:
+ return distributions.get(distro)
+
+
+def _normalized_distro_name(distro):
+ distro = distro.lower()
+ if distro.startswith(('redhat', 'red hat')):
+ return 'redhat'
+ elif distro.startswith(('scientific', 'scientific linux')):
+ return 'scientific'
+ elif distro.startswith(('suse', 'opensuse')):
+ return 'suse'
+ elif distro.startswith('centos'):
+ return 'centos'
+ return distro
+
+
+def platform_information():
+ """detect platform information from remote host."""
+ logging.debug('platform_information: linux_distribution = ' +
+ str(platform.linux_distribution()))
+ distro, release, codename = platform.linux_distribution()
+ # this could be an empty string in Debian
+ if not codename and 'debian' in distro.lower():
+ debian_codenames = {
+ '8': 'jessie',
+ '7': 'wheezy',
+ '6': 'squeeze',
+ }
+ major_version = release.split('.')[0]
+ codename = debian_codenames.get(major_version, '')
+
+ # In order to support newer jessie/sid or wheezy/sid strings
+ # we test this if sid is buried in the minor, we should use
+ # sid anyway.
+ if not codename and '/' in release:
+ major, minor = release.split('/')
+ if minor == 'sid':
+ codename = minor
+ else:
+ codename = major
+
+ return (
+ str(distro).rstrip(),
+ str(release).rstrip(),
+ str(codename).rstrip()
+ )
--- /dev/null
+distro = None
+release = None
+codename = None
+
+
+def choose_init():
+ """Select a init system
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+ return 'sysvinit'
--- /dev/null
+distro = None
+release = None
+codename = None
+
+
+def choose_init():
+ """Select a init system
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+ if distro.lower() == 'ubuntu':
+ return 'upstart'
+ return 'sysvinit'
--- /dev/null
+#
+# Copyright (C) 2015 <contact@redhat.com>
+#
+# Author: Alfredo Deza <adeza@redhat.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see `<http://www.gnu.org/licenses/>`.
+#
+
+
+class UnsupportedPlatform(Exception):
+ """Platform is not supported."""
+ def __init__(self, distro, codename, release):
+ self.distro = distro
+ self.codename = codename
+ self.release = release
+
+ def __str__(self):
+ return '{doc}: {distro} {codename} {release}'.format(
+ doc=self.__doc__.strip(),
+ distro=self.distro,
+ codename=self.codename,
+ release=self.release,
+ )
--- /dev/null
+distro = None
+release = None
+codename = None
+
+
+def choose_init():
+ """Select a init system
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+ return 'sysvinit'
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright (C) 2015 <contact@redhat.com>
+# Copyright (C) 2015 SUSE LINUX GmbH
+#
+# Author: Alfredo Deza <alfredo.deza@inktank.com>
+# Author: Owen Synge <osynge@suse.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library Public License for more details.
+#
+import argparse
+import logging
+
+import ceph_detect_init
+from ceph_detect_init import exc
+
+
+def parser():
+ parser = argparse.ArgumentParser(
+ 'ceph-detect-init',
+ )
+ parser.add_argument(
+ "-v",
+ "--verbose",
+ action="store_true",
+ default=None,
+ )
+ parser.add_argument(
+ "--use-rhceph",
+ action="store_true",
+ default=False,
+ )
+ parser.add_argument(
+ "--default",
+ default=None,
+ )
+ return parser
+
+
+def run(argv=None, namespace=None):
+ args = parser().parse_args(argv, namespace)
+
+ if args.verbose:
+ logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
+ level=logging.DEBUG)
+ try:
+ print(ceph_detect_init.get(args.use_rhceph).init)
+ except exc.UnsupportedPlatform:
+ if args.default:
+ print(args.default)
+ else:
+ raise
+
+ return 0
--- /dev/null
+distro = None
+release = None
+codename = None
+
+
+def choose_init():
+ """Select a init system
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+ return 'sysvinit'
--- /dev/null
+distro = None
+release = None
+codename = None
+
+
+def choose_init():
+ """Select a init system
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+ init_mapping = {
+ '11': 'sysvinit', # SLE_11
+ '12': 'systemd', # SLE_12
+ '13.1': 'systemd', # openSUSE_13.1
+ '13.2': 'systemd', # openSUSE_13.2
+ }
+ return init_mapping.get(release, 'sysvinit')
--- /dev/null
+FROM centos:6
+
+RUN yum install -y yum-utils && yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/6/x86_64/ && yum install --nogpgcheck -y epel-release && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 && rm /etc/yum.repos.d/dl.fedoraproject.org*
+RUN yum install -y python-pip python-virtualenv git
--- /dev/null
+FROM centos:7
+
+RUN yum install -y yum-utils && yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/7/x86_64/ && yum install --nogpgcheck -y epel-release && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && rm /etc/yum.repos.d/dl.fedoraproject.org*
+RUN yum install -y python-pip python-virtualenv git
--- /dev/null
+FROM debian:jessie
+
+RUN apt-get update
+RUN apt-get install -y python-virtualenv python-pip git
+
+
--- /dev/null
+FROM debian:sid
+
+RUN apt-get update
+RUN apt-get install -y python-virtualenv python-pip git
--- /dev/null
+FROM debian:squeeze
+
+RUN apt-get update
+RUN apt-get install -y python-virtualenv python-pip git
--- /dev/null
+FROM debian:wheezy
+
+RUN apt-get update
+RUN apt-get install -y python-virtualenv python-pip git
--- /dev/null
+FROM fedora:21
+
+RUN yum install -y python-pip python-virtualenv git
--- /dev/null
+FROM opensuse:13.1
+
+RUN zypper --non-interactive --gpg-auto-import-keys install lsb python-pip python-virtualenv git
--- /dev/null
+FROM opensuse:13.2
+
+RUN zypper --non-interactive --gpg-auto-import-keys install python-pip python-virtualenv git
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright (C) 2015 SUSE LINUX GmbH
+# Copyright (C) 2015 <contact@redhat.com>
+#
+# Author: Owen Synge <osynge@suse.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library Public License for more details.
+#
+import logging
+import shutil
+import subprocess
+import testtools
+
+from ceph_detect_init import main
+
+logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
+ level=logging.DEBUG)
+
+
+def run(os):
+ name = 'ceph-detect-init-' + os
+ shutil.rmtree(name, ignore_errors=True)
+ script = """\
+docker build -t {name} --file integration/{os}.dockerfile .
+toplevel=$(git rev-parse --show-toplevel)
+mkdir {name}
+cat > {name}/try.sh <<EOF
+ virtualenv {name}
+ . {name}/bin/activate
+ pip install -r requirements.txt
+ python setup.py install
+ ceph-detect-init > {name}/init
+EOF
+
+docker run -v $toplevel:$toplevel -w $(pwd) --user $(id -u) {name} bash -x {name}/try.sh
+""".format(name=name,
+ os=os)
+ subprocess.check_call(script, shell=True)
+ init = open(name + '/init').read().strip()
+ shutil.rmtree(name)
+ return init
+
+
+class TestCephDetectInit(testtools.TestCase):
+
+ def test_centos_6(self):
+ self.assertEqual('sysvinit', run('centos-6'))
+
+ def test_centos_7(self):
+ self.assertEqual('sysvinit', run('centos-7'))
+
+ def test_ubuntu_12_04(self):
+ self.assertEqual('upstart', run('ubuntu-12.04'))
+
+ def test_ubuntu_14_04(self):
+ self.assertEqual('upstart', run('ubuntu-14.04'))
+
+ def test_ubuntu_15_04(self):
+ self.assertEqual('upstart', run('ubuntu-15.04'))
+
+ def test_debian_squeeze(self):
+ self.assertEqual('sysvinit', run('debian-squeeze'))
+
+ def test_debian_wheezy(self):
+ self.assertEqual('sysvinit', run('debian-wheezy'))
+
+ def test_debian_jessie(self):
+ self.assertEqual('sysvinit', run('debian-jessie'))
+
+ def test_debian_sid(self):
+ self.assertEqual('sysvinit', run('debian-sid'))
+
+ def test_fedora_21(self):
+ self.assertEqual('sysvinit', run('fedora-21'))
+
+ def test_opensuse_13_1(self):
+ self.assertEqual('systemd', run('opensuse-13.1'))
+
+ def test_opensuse_13_2(self):
+ self.assertEqual('systemd', run('opensuse-13.2'))
+
+# Local Variables:
+# compile-command: "cd .. ; .tox/py27/bin/py.test integration/test_main.py"
+# End:
--- /dev/null
+FROM ubuntu:12.04
+
+RUN apt-get update
+RUN apt-get install -y python-virtualenv python-pip git
--- /dev/null
+FROM ubuntu:14.04
+
+RUN apt-get update
+# http://stackoverflow.com/questions/27341064/how-do-i-fix-importerror-cannot-import-name-incompleteread
+RUN apt-get install -y python-setuptools && easy_install -U pip
+RUN apt-get install -y python-virtualenv git
--- /dev/null
+FROM ubuntu:15.04
+
+RUN apt-get update
+RUN apt-get install -y python-pip python-virtualenv git
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2015 SUSE LINUX GmbH
+# Copyright (C) 2015 <contact@redhat.com>
+#
+# Author: Owen Synge <osynge@suse.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library Public License for more details.
+#
+
+# run from the ceph-detect-init directory or from its parent
+test -d ceph-detect-init && cd ceph-detect-init
+trap "rm -fr make-check" EXIT
+virtualenv make-check
+. make-check/bin/activate
+# older versions of pip will not install wrap_console scripts
+# when using wheel packages
+pip install --upgrade 'pip >= 6.1'
+if test -d wheelhouse ; then
+ export NO_INDEX=--no-index
+fi
+pip install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse --upgrade distribute
+pip install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse 'tox >=1.9'
+tox 2>&1 | grep -v InterpreterNotFound
--- /dev/null
+#
+# Copyright (C) 2015 SUSE LINUX GmbH
+# Copyright (C) 2015 <contact@redhat.com>
+#
+# Author: Owen Synge <osynge@suse.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see `<http://www.gnu.org/licenses/>`.
+#
+import os
+from setuptools import setup
+from setuptools import find_packages
+
+def read(fname):
+ path = os.path.join(os.path.dirname(__file__), fname)
+ f = open(path)
+ return f.read()
+
+install_requires = read('requirements.txt').split()
+tests_require = read('test-requirements.txt').split()
+
+setup(
+ name='ceph-detect-init',
+ version='1.0.1',
+ packages=find_packages(),
+
+ author='Owen Synge, Loic Dachary',
+ author_email='osynge@suse.de, loic@dachary.org',
+ description='display the normalized name of the init system',
+ long_description=read('README.rst'),
+ license='LGPLv2+',
+ keywords='ceph',
+ url="https://git.ceph.com/?p=ceph.git;a=summary",
+
+ install_requires=[
+ 'setuptools',
+ ] + install_requires,
+
+ tests_require=tests_require,
+
+ classifiers=[
+ 'Environment :: Console',
+ 'Intended Audience :: Information Technology',
+ 'Intended Audience :: System Administrators',
+ 'Operating System :: POSIX :: Linux',
+ 'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 3',
+ 'Topic :: Utilities',
+ ],
+
+ entry_points={
+
+ 'console_scripts': [
+ 'ceph-detect-init = ceph_detect_init.main:run',
+ ],
+
+ },
+ )
--- /dev/null
+coverage>=3.6
+discover
+fixtures>=0.3.14
+python-subunit
+testrepository>=0.0.17
+testtools>=0.9.32
+mock
+pytest
+tox
+flake8
--- /dev/null
+#
+# Copyright (C) 2015 SUSE LINUX GmbH
+# Copyright (C) 2015 <contact@redhat.com>
+#
+# Author: Owen Synge <osynge@suse.com>
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see `<http://www.gnu.org/licenses/>`.
+#
+import logging
+import mock
+import testtools
+
+import ceph_detect_init
+from ceph_detect_init import centos
+from ceph_detect_init import debian
+from ceph_detect_init import exc
+from ceph_detect_init import fedora
+from ceph_detect_init import main
+from ceph_detect_init import rhel
+from ceph_detect_init import suse
+
+logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
+ level=logging.DEBUG)
+
+
+class TestCephDetectInit(testtools.TestCase):
+
+ def test_centos(self):
+ self.assertEqual('sysvinit', centos.choose_init())
+
+ def test_debian(self):
+ with mock.patch('ceph_detect_init.debian.distro',
+ 'debian'):
+ self.assertEqual('sysvinit', debian.choose_init())
+ with mock.patch('ceph_detect_init.debian.distro',
+ 'ubuntu'):
+ self.assertEqual('upstart', debian.choose_init())
+
+ def test_fedora(self):
+ self.assertEqual('sysvinit', fedora.choose_init())
+
+ def test_rhel(self):
+ self.assertEqual('sysvinit', rhel.choose_init())
+
+ def test_suse(self):
+ with mock.patch('ceph_detect_init.suse.release',
+ '11'):
+ self.assertEqual('sysvinit', suse.choose_init())
+ with mock.patch('ceph_detect_init.suse.release',
+ '12'):
+ self.assertEqual('systemd', suse.choose_init())
+ with mock.patch('ceph_detect_init.suse.release',
+ '13.1'):
+ self.assertEqual('systemd', suse.choose_init())
+ with mock.patch('ceph_detect_init.suse.release',
+ '13.2'):
+ self.assertEqual('systemd', suse.choose_init())
+
+ def test_get(self):
+ g = ceph_detect_init.get
+ with mock.patch('platform.linux_distribution',
+ lambda: (('unknown', '', ''))):
+ self.assertRaises(exc.UnsupportedPlatform, g)
+ try:
+ g()
+ except exc.UnsupportedPlatform as e:
+ self.assertIn('Platform is not supported', str(e))
+
+ with mock.patch('platform.linux_distribution',
+ lambda: (('debian', '6.0', ''))):
+ distro = ceph_detect_init.get()
+ self.assertEqual(debian, distro)
+ self.assertEqual('debian', distro.name)
+ self.assertEqual('debian', distro.normalized_name)
+ self.assertEqual('debian', distro.distro)
+ self.assertEqual(False, distro.is_el)
+ self.assertEqual('6.0', distro.release)
+ self.assertEqual('squeeze', distro.codename)
+ self.assertEqual('sysvinit', distro.init)
+
+ def test_get_distro(self):
+ g = ceph_detect_init._get_distro
+ self.assertEqual(None, g(None))
+ self.assertEqual(debian, g('debian'))
+ self.assertEqual(debian, g('ubuntu'))
+ self.assertEqual(centos, g('centos'))
+ self.assertEqual(centos, g('scientific'))
+ self.assertEqual(fedora, g('fedora'))
+ self.assertEqual(suse, g('suse'))
+ self.assertEqual(rhel, g('redhat', use_rhceph=True))
+
+ def test_normalized_distro_name(self):
+ n = ceph_detect_init._normalized_distro_name
+ self.assertEqual('redhat', n('RedHat'))
+ self.assertEqual('redhat', n('redhat'))
+ self.assertEqual('redhat', n('Red Hat'))
+ self.assertEqual('redhat', n('red hat'))
+ self.assertEqual('scientific', n('scientific'))
+ self.assertEqual('scientific', n('Scientific'))
+ self.assertEqual('scientific', n('Scientific Linux'))
+ self.assertEqual('scientific', n('scientific linux'))
+ self.assertEqual('suse', n('SUSE'))
+ self.assertEqual('suse', n('suse'))
+ self.assertEqual('suse', n('openSUSE'))
+ self.assertEqual('suse', n('opensuse'))
+ self.assertEqual('centos', n('CentOS'))
+ self.assertEqual('centos', n('centos'))
+ self.assertEqual('debian', n('Debian'))
+ self.assertEqual('debian', n('debian'))
+ self.assertEqual('ubuntu', n('Ubuntu'))
+ self.assertEqual('ubuntu', n('ubuntu'))
+
+ def test_platform_information(self):
+ with mock.patch('platform.linux_distribution',
+ lambda: (('debian', '6.0', ''))):
+ self.assertEqual(('debian', '6.0', 'squeeze'),
+ ceph_detect_init.platform_information())
+
+ with mock.patch('platform.linux_distribution',
+ lambda: (('debian', '7.0', ''))):
+ self.assertEqual(('debian', '7.0', 'wheezy'),
+ ceph_detect_init.platform_information())
+
+ with mock.patch('platform.linux_distribution',
+ lambda: (('debian', '8.0', ''))):
+ self.assertEqual(('debian', '8.0', 'jessie'),
+ ceph_detect_init.platform_information())
+
+ with mock.patch('platform.linux_distribution',
+ lambda: (('debian', 'jessie/sid', ''))):
+ self.assertEqual(('debian', 'jessie/sid', 'sid'),
+ ceph_detect_init.platform_information())
+
+ with mock.patch('platform.linux_distribution',
+ lambda: (('debian', 'sid/jessie', ''))):
+ self.assertEqual(('debian', 'sid/jessie', 'sid'),
+ ceph_detect_init.platform_information())
+
+ def test_run(self):
+ argv = ['--use-rhceph', '--verbose']
+ self.assertEqual(0, main.run(argv))
+
+ with mock.patch('platform.linux_distribution',
+ lambda: (('unknown', '', ''))):
+ self.assertRaises(exc.UnsupportedPlatform, main.run, argv)
+ self.assertEqual(0, main.run(argv + ['--default=sysvinit']))
+
+# Local Variables:
+# compile-command: "cd .. ; .tox/py27/bin/py.test tests/test_all.py"
+# End:
--- /dev/null
+[tox]
+envlist = pep8,py27,py3
+skip_missing_interpreters = True
+
+[testenv]
+basepython =
+ py27: python2.7
+ py3: python3
+setenv = VIRTUAL_ENV={envdir}
+usedevelop = true
+deps =
+ {env:NO_INDEX:}
+ --use-wheel
+ --find-links=file://{toxinidir}/wheelhouse
+ -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
+
+commands = coverage run --source=ceph_detect_init {envbindir}/py.test -v tests
+ coverage report --omit=*test*,*tox* --show-missing --fail-under=100
+
+[testenv:pep8]
+basepython = python2
+commands = flake8 ceph_detect_init tests
+
+[testenv:integration]
+basepython = python2
+setenv = VIRTUAL_ENV={envdir}
+deps = -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
+
+commands = {envbindir}/py.test -v integration/test_main.py