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

ceph-detect-init: Adds Oracle Linux Server and Oracle VM Server detect #13917

Merged
1 commit merged into from Mar 18, 2017
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
2 changes: 1 addition & 1 deletion install-deps.sh
Expand Up @@ -88,7 +88,7 @@ else
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
if [ -n "$backports" ] ; then rm $control; fi
;;
centos|fedora|rhel)
centos|fedora|rhel|ol)
yumdnf="yum"
builddepcmd="yum-builddep -y"
if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
Expand Down
18 changes: 16 additions & 2 deletions src/ceph-detect-init/ceph_detect_init/__init__.py
Expand Up @@ -24,6 +24,7 @@
from ceph_detect_init import gentoo
from ceph_detect_init import freebsd
from ceph_detect_init import docker
from ceph_detect_init import oraclevms
import os
import logging
import platform
Expand All @@ -44,7 +45,8 @@ def get(use_rhceph=False):
module.normalized_name = _normalized_distro_name(distro_name)
module.distro = module.normalized_name
module.is_el = module.normalized_name in ['redhat', 'centos',
'fedora', 'scientific']
'fedora', 'scientific',
'oraclel']
module.release = release
module.codename = codename
module.init = module.choose_init()
Expand All @@ -64,6 +66,8 @@ def _get_distro(distro, use_rhceph=False):
'linuxmint': debian,
'centos': centos,
'scientific': centos,
'oraclel': centos,
'oraclevms': oraclevms,
'redhat': centos,
'fedora': fedora,
'suse': suse,
Expand All @@ -90,6 +94,10 @@ def _normalized_distro_name(distro):
return 'suse'
elif distro.startswith('centos'):
return 'centos'
elif distro.startswith('oracle linux'):
return 'oraclel'
elif distro.startswith('oracle vm'):
return 'oraclevms'
elif distro.startswith(('gentoo', 'funtoo', 'exherbo')):
return 'gentoo'
return distro
Expand Down Expand Up @@ -127,8 +135,9 @@ def platform_information():
else:
raise exc.UnsupportedPlatform(platform.system(), '', '')

distro_lower = distro.lower()
# this could be an empty string in Debian
if not codename and 'debian' in distro.lower():
if not codename and 'debian' in distro_lower:
debian_codenames = {
'8': 'jessie',
'7': 'wheezy',
Expand All @@ -146,6 +155,11 @@ def platform_information():
codename = minor
else:
codename = major
# this is an empty string in Oracle
elif distro_lower.startswith('oracle linux'):
codename = 'OL' + release
elif distro_lower.startswith('oracle vm'):
codename = 'OVS' + release

return (
str(distro).rstrip(),
Expand Down
11 changes: 11 additions & 0 deletions src/ceph-detect-init/ceph_detect_init/oraclevms/__init__.py
@@ -0,0 +1,11 @@
distro = None
release = None
codename = None


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

Returns the name of a init system (upstart, sysvinit ...).
"""
return 'sysvinit'
18 changes: 18 additions & 0 deletions src/ceph-detect-init/tests/test_all.py
Expand Up @@ -35,6 +35,7 @@
from ceph_detect_init import gentoo
from ceph_detect_init import freebsd
from ceph_detect_init import docker
from ceph_detect_init import oraclevms

logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
level=logging.DEBUG)
Expand All @@ -54,6 +55,9 @@ def test_freebsd(self):
def test_docker(self):
self.assertEqual('none', docker.choose_init())

def test_oraclevms(self):
self.assertEqual('sysvinit', oraclevms.choose_init())

def test_centos(self):
with mock.patch('ceph_detect_init.centos.release',
'7.0'):
Expand Down Expand Up @@ -207,6 +211,8 @@ def test_get_distro(self):
self.assertEqual(debian, g('ubuntu'))
self.assertEqual(centos, g('centos'))
self.assertEqual(centos, g('scientific'))
self.assertEqual(centos, g('Oracle Linux Server'))
self.assertEqual(oraclevms, g('Oracle VM server'))
self.assertEqual(fedora, g('fedora'))
self.assertEqual(suse, g('suse'))
self.assertEqual(rhel, g('redhat', use_rhceph=True))
Expand All @@ -222,6 +228,8 @@ def test_normalized_distro_name(self):
self.assertEqual('scientific', n('Scientific'))
self.assertEqual('scientific', n('Scientific Linux'))
self.assertEqual('scientific', n('scientific linux'))
self.assertEqual('oraclel', n('Oracle Linux Server'))
self.assertEqual('oraclevms', n('Oracle VM server'))
self.assertEqual('suse', n('SUSE'))
self.assertEqual('suse', n('suse'))
self.assertEqual('suse', n('openSUSE'))
Expand Down Expand Up @@ -266,6 +274,16 @@ def test_platform_information_linux(self):
self.assertEqual(('debian', 'sid/jessie', 'sid'),
ceph_detect_init.platform_information())

with mock.patch('platform.linux_distribution',
lambda **kwargs: (('Oracle Linux Server', '7.3', ''))):
self.assertEqual(('Oracle Linux Server', '7.3', 'OL7.3'),
ceph_detect_init.platform_information())

with mock.patch('platform.linux_distribution',
lambda **kwargs: (('Oracle VM server', '3.4.2', ''))):
self.assertEqual(('Oracle VM server', '3.4.2', 'OVS3.4.2'),
ceph_detect_init.platform_information())

@mock.patch('platform.linux_distribution')
def test_platform_information_container(self, mock_linux_dist):
import sys
Expand Down