Fix SUSE detection on Tumbleweed and SLE15
It seems platform.dist and platform.linux_distribution are broken with newer operating systems. Specifically /etc/os-release seems to be the new hotness. EG: opensuse-tumbleweed and fedora-27. Vendor the distro (1.2.0) package, as not to have external dependencies installed. Change-Id: Ib9580aa7fe84a20e44d32248d7b4716456684dbc Depends-On: https://review.openstack.org/545183/ Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
091633b380
commit
2601b25a7c
0
glean/_vendor/__init__.py
Normal file
0
glean/_vendor/__init__.py
Normal file
1104
glean/_vendor/distro.py
Executable file
1104
glean/_vendor/distro.py
Executable file
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,6 @@ import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
@ -30,6 +29,7 @@ import time
|
||||
|
||||
from glean import systemlock
|
||||
from glean import utils
|
||||
from glean._vendor import distro
|
||||
|
||||
log = logging.getLogger("glean")
|
||||
|
||||
@ -1123,10 +1123,11 @@ def main():
|
||||
parser = argparse.ArgumentParser(description="Static network config")
|
||||
parser.add_argument(
|
||||
'-n', '--noop', action='store_true', help='Do not write files')
|
||||
_distro = distro.linux_distribution(
|
||||
full_distribution_name=False)[0].lower()
|
||||
parser.add_argument(
|
||||
'--distro', dest='distro',
|
||||
default=platform.dist()[0].lower(),
|
||||
help='Override distro (detected "%s")' % platform.dist()[0].lower())
|
||||
'--distro', dest='distro', default=_distro,
|
||||
help='Override distro (detected "%s")' % _distro)
|
||||
parser.add_argument(
|
||||
'--root', dest='root', default='/',
|
||||
help='Mounted root for config drive info, defaults to /')
|
||||
|
@ -138,10 +138,7 @@ class TestGlean(base.BaseTestCase):
|
||||
return False
|
||||
return real_path_exists(path)
|
||||
|
||||
@mock.patch('platform.dist', new_callable=mock.Mock)
|
||||
@mock.patch('subprocess.call', return_value=0, new_callable=mock.Mock)
|
||||
@mock.patch('subprocess.check_output', return_value=0,
|
||||
new_callable=mock.Mock)
|
||||
@mock.patch('os.unlink', return_value=0, new_callable=mock.Mock)
|
||||
@mock.patch('os.symlink', return_value=0, new_callable=mock.Mock)
|
||||
@mock.patch('os.path.exists', new_callable=mock.Mock)
|
||||
@ -156,21 +153,17 @@ class TestGlean(base.BaseTestCase):
|
||||
mock_os_path_exists,
|
||||
mock_os_symlink,
|
||||
mock_os_unlink,
|
||||
mock_check_output,
|
||||
mock_call,
|
||||
mock_platform_dist,
|
||||
skip_dns=False):
|
||||
"""Main test function
|
||||
|
||||
:param distro: distro to return from "platform.dist"
|
||||
:param distro: distro to return from "distro.linux_distribution()"
|
||||
:param provider: we will look in fixtures/provider for mocked
|
||||
out files
|
||||
:param interface: --interface argument; None for no argument
|
||||
:param skip_dns: --skip-dns argument; False for no argument
|
||||
"""
|
||||
|
||||
mock_platform_dist.return_value = (distro, '', '')
|
||||
|
||||
# These functions are watching the path and faking results
|
||||
# based on various things
|
||||
# XXX : There are several virtual file-systems available, we
|
||||
@ -184,6 +177,8 @@ class TestGlean(base.BaseTestCase):
|
||||
mock_open.side_effect = functools.partial(
|
||||
self.open_side_effect, provider)
|
||||
|
||||
sys.argv.append('--distro=%s' % distro.lower())
|
||||
|
||||
if interface:
|
||||
sys.argv.append('--interface=%s' % interface)
|
||||
if skip_dns:
|
||||
|
Loading…
x
Reference in New Issue
Block a user