Skip to content

Commit

Permalink
ceph_detect_init/__init__.py: Define alpine as a supported distro whe…
Browse files Browse the repository at this point in the history
…n using platform.linux_distribution().

Python does not define alpine as a supported dist.

https://hg.python.org/cpython/file/default/Lib/platform.py#l268

Signed-off-by: John Coyle <[email protected]>
  • Loading branch information
dx9 committed Sep 7, 2016
1 parent f8abb62 commit 5fb666c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/ceph-detect-init/ceph_detect_init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def _normalized_distro_name(distro):

def platform_information():
"""detect platform information from remote host."""
linux_distro = platform.linux_distribution(
supported_dists=platform._supported_dists + ('alpine',))
logging.debug('platform_information: linux_distribution = ' +
str(platform.linux_distribution()))
distro, release, codename = platform.linux_distribution()
str(linux_distro))
distro, release, codename = linux_distro
# this could be an empty string in Debian
if not codename and 'debian' in distro.lower():
debian_codenames = {
Expand Down
16 changes: 8 additions & 8 deletions src/ceph-detect-init/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ def test_gentoo(self):
def test_get(self):
g = ceph_detect_init.get
with mock.patch('platform.linux_distribution',
lambda: (('unknown', '', ''))):
lambda **kwargs: (('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', ''))):
lambda **kwargs: (('debian', '6.0', ''))):
distro = ceph_detect_init.get()
self.assertEqual(debian, distro)
self.assertEqual('debian', distro.name)
Expand Down Expand Up @@ -203,27 +203,27 @@ def test_normalized_distro_name(self):

def test_platform_information(self):
with mock.patch('platform.linux_distribution',
lambda: (('debian', '6.0', ''))):
lambda **kwargs: (('debian', '6.0', ''))):
self.assertEqual(('debian', '6.0', 'squeeze'),
ceph_detect_init.platform_information())

with mock.patch('platform.linux_distribution',
lambda: (('debian', '7.0', ''))):
lambda **kwargs: (('debian', '7.0', ''))):
self.assertEqual(('debian', '7.0', 'wheezy'),
ceph_detect_init.platform_information())

with mock.patch('platform.linux_distribution',
lambda: (('debian', '8.0', ''))):
lambda **kwargs: (('debian', '8.0', ''))):
self.assertEqual(('debian', '8.0', 'jessie'),
ceph_detect_init.platform_information())

with mock.patch('platform.linux_distribution',
lambda: (('debian', 'jessie/sid', ''))):
lambda **kwargs: (('debian', 'jessie/sid', ''))):
self.assertEqual(('debian', 'jessie/sid', 'sid'),
ceph_detect_init.platform_information())

with mock.patch('platform.linux_distribution',
lambda: (('debian', 'sid/jessie', ''))):
lambda **kwargs: (('debian', 'sid/jessie', ''))):
self.assertEqual(('debian', 'sid/jessie', 'sid'),
ceph_detect_init.platform_information())

Expand All @@ -232,7 +232,7 @@ def test_run(self):
self.assertEqual(0, main.run(argv))

with mock.patch('platform.linux_distribution',
lambda: (('unknown', '', ''))):
lambda **kwargs: (('unknown', '', ''))):
self.assertRaises(exc.UnsupportedPlatform, main.run, argv)
self.assertEqual(0, main.run(argv + ['--default=sysvinit']))

Expand Down

0 comments on commit 5fb666c

Please sign in to comment.