diff --git a/.stestr.conf b/.stestr.conf index 0063aae..e84adce 100644 --- a/.stestr.conf +++ b/.stestr.conf @@ -1,3 +1,3 @@ [DEFAULT] -test_path=./tripleo_repos/tests +test_path=./tests/unit top_dir=./ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..d786bad --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +global-exclude *.py[cod] +global-exclude __pycache__ diff --git a/tripleo-get-hash/README.md b/docs/get_hash.md similarity index 85% rename from tripleo-get-hash/README.md rename to docs/get_hash.md index d55bd5d..681745f 100644 --- a/tripleo-get-hash/README.md +++ b/docs/get_hash.md @@ -10,12 +10,12 @@ information, including the commit, distro and full hashes where available. It includes a simple command line interface. If you clone the source you can try it out of the box without installation invoking it as a module: ``` - python -m tripleo_get_hash # by default centos8, master, current-tripleo. - python -m tripleo_get_hash --component tripleo --release victoria --os-version centos8 - python -m tripleo_get_hash --release master --os-version centos7 - python -m tripleo_get_hash --release train # by default centos8 - python -m tripleo_get_hash --os-version rhel8 --release osp16-2 --dlrn-url http://osp-trunk.hosted.upshift.rdu2.redhat.com - python -m tripleo_get_hash --help + tripleo-get-hash # by default centos8, master, current-tripleo. + tripleo-get-hash --component tripleo --release victoria --os-version centos8 + tripleo-get-hash --release master --os-version centos7 + tripleo-get-hash --release train # by default centos8 + tripleo-get-hash --os-version rhel8 --release osp16-2 --dlrn-url http://osp-trunk.hosted.upshift.rdu2.redhat.com + tripleo-get-hash --help ``` ## Quick start @@ -38,10 +38,10 @@ is placed in /usr/local/etc: #### Install using pip You can also install using python pip - you can see the -[tripleo-get-hash module here](https://pypi.org/project/tripleo-get-hash/) +[tripleo-get-hash module here](https://pypi.org/project/tripleo-repos/) ``` - pip install tripleo-get-hash --user + pip install tripleo-repos --user ``` After installation you can invoke tripleo-get-hash --help to see the various diff --git a/tripleo-yum-config/README.md b/docs/yum_config.md similarity index 88% rename from tripleo-yum-config/README.md rename to docs/yum_config.md index 6627d75..bb63306 100644 --- a/tripleo-yum-config/README.md +++ b/docs/yum_config.md @@ -1,4 +1,4 @@ -# tripleo-yum-config +# tripleo_repos.yum_config *tripleo-yum-config* utility was designed to simplify the way that TripleO deployments manage their yum configuration. This tool helps on updating @@ -32,10 +32,10 @@ its repository and invoking in command line: Examples: ``` - sudo python -m tripleo_yum_config module remove tomcat - sudo python -m tripleo_yum_config module disable tomcat - sudo python -m tripleo_yum_config module enable nginx --stream mainline - sudo python -m tripleo_yum_config module install nginx --profile common + sudo tripleo-yum-config module remove tomcat + sudo tripleo-yum-config module disable tomcat + sudo tripleo-yum-config module enable nginx --stream mainline + sudo tripleo-yum-config module install nginx --profile common ``` * **global** @@ -60,9 +60,9 @@ sudo python setup.py install #### Install using pip Alternatively you can install tripleo-yum-config with python pip: ``` -pip install tripleo-yum-config --user +pip install tripleo-repos --user ``` -See PyPI [tripleo-yum-config](https://pypi.org/project/tripleo-yum-config/) +See PyPI [tripleo-repos](https://pypi.org/project/tripleo-repos/) project for more details. ## Usage diff --git a/tripleo-get-hash/example_playbook.yaml b/playbooks/example_get_hash.yaml similarity index 100% rename from tripleo-get-hash/example_playbook.yaml rename to playbooks/example_get_hash.yaml diff --git a/tripleo-yum-config/example_playbook.yaml b/playbooks/example_yum_config.yaml similarity index 100% rename from tripleo-yum-config/example_playbook.yaml rename to playbooks/example_yum_config.yaml diff --git a/requirements.txt b/requirements.txt index 2623409..5ba9353 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 requests>=2.10.0 # Apache-2.0 +PyYAML>=3.12 # MIT diff --git a/setup.cfg b/setup.cfg index 6392b0d..400472d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,7 +24,14 @@ classifier = [files] packages = tripleo_repos +data_files = + etc/tripleo_get_hash/ = tripleo_repos/get_hash/config.yaml + # Temporary until we get a proper Ansible collection: + share/ansible/plugins/modules/ = tripleo_repos/yum_config/tripleo_yum_config.py + share/ansible/plugins/modules/ = tripleo_repos/get_hash/tripleo_get_hash.py [entry_points] console_scripts = tripleo-repos = tripleo_repos.main:main + tripleo-yum-config = tripleo_repos.yum_config.__main__:cli_entrypoint + tripleo-get-hash = tripleo_repos.get_hash.__main__:cli_entrypoint diff --git a/test-requirements.txt b/test-requirements.txt index 0f172a3..7cda47e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -13,3 +13,4 @@ testscenarios>=0.4 # Apache-2.0/BSD testtools>=1.4.0 # MIT stestr>=2.0.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD +requests_mock>=1.8.0 # Apache-2.0 diff --git a/tripleo-get-hash/test/__init__.py b/tests/unit/__init__.py similarity index 100% rename from tripleo-get-hash/test/__init__.py rename to tests/unit/__init__.py diff --git a/tripleo-get-hash/tripleo_get_hash/__init__.py b/tests/unit/get_hash/__init__.py similarity index 100% rename from tripleo-get-hash/tripleo_get_hash/__init__.py rename to tests/unit/get_hash/__init__.py diff --git a/tripleo-get-hash/test/fakes.py b/tests/unit/get_hash/fakes.py similarity index 100% rename from tripleo-get-hash/test/fakes.py rename to tests/unit/get_hash/fakes.py diff --git a/tripleo-get-hash/test/test_tripleo_get_hash.py b/tests/unit/get_hash/test_tripleo_get_hash.py similarity index 98% rename from tripleo-get-hash/test/test_tripleo_get_hash.py rename to tests/unit/get_hash/test_tripleo_get_hash.py index 301c27f..f0a82f2 100644 --- a/tripleo-get-hash/test/test_tripleo_get_hash.py +++ b/tests/unit/get_hash/test_tripleo_get_hash.py @@ -21,9 +21,9 @@ from unittest import mock from unittest.mock import mock_open import yaml -import tripleo_get_hash.exceptions as exc -import tripleo_get_hash.__main__ as tgh -import test.fakes as test_fakes +import tripleo_repos.get_hash.exceptions as exc +import tripleo_repos.get_hash.__main__ as tgh +from . import fakes as test_fakes @mock.patch( diff --git a/tripleo-get-hash/test/test_tripleo_get_hash_info.py b/tests/unit/get_hash/test_tripleo_get_hash_info.py similarity index 98% rename from tripleo-get-hash/test/test_tripleo_get_hash_info.py rename to tests/unit/get_hash/test_tripleo_get_hash_info.py index d263b0a..6e4a81e 100644 --- a/tripleo-get-hash/test/test_tripleo_get_hash_info.py +++ b/tests/unit/get_hash/test_tripleo_get_hash_info.py @@ -15,9 +15,9 @@ # import unittest -import tripleo_get_hash.tripleo_hash_info as thi -import tripleo_get_hash.exceptions as exc -import test.fakes as test_fakes +import tripleo_repos.get_hash.tripleo_hash_info as thi +import tripleo_repos.get_hash.exceptions as exc +from . import fakes as test_fakes import requests_mock from unittest import mock from unittest.mock import mock_open diff --git a/tripleo-yum-config/test/__init__.py b/tests/unit/tripleo_repos/__init__.py similarity index 100% rename from tripleo-yum-config/test/__init__.py rename to tests/unit/tripleo_repos/__init__.py diff --git a/tripleo_repos/tests/test_main.py b/tests/unit/tripleo_repos/test_main.py similarity index 100% rename from tripleo_repos/tests/test_main.py rename to tests/unit/tripleo_repos/test_main.py diff --git a/tripleo-yum-config/tripleo_yum_config/__init__.py b/tests/unit/yum_config/__init__.py similarity index 100% rename from tripleo-yum-config/tripleo_yum_config/__init__.py rename to tests/unit/yum_config/__init__.py diff --git a/tripleo-yum-config/test/fakes.py b/tests/unit/yum_config/fakes.py similarity index 100% rename from tripleo-yum-config/test/fakes.py rename to tests/unit/yum_config/fakes.py diff --git a/tripleo-yum-config/test/mock_modules.py b/tests/unit/yum_config/mock_modules.py similarity index 100% rename from tripleo-yum-config/test/mock_modules.py rename to tests/unit/yum_config/mock_modules.py diff --git a/tripleo-yum-config/test/test_dnf_manager.py b/tests/unit/yum_config/test_dnf_manager.py similarity index 96% rename from tripleo-yum-config/test/test_dnf_manager.py rename to tests/unit/yum_config/test_dnf_manager.py index 5ce7757..657aa6d 100644 --- a/tripleo-yum-config/test/test_dnf_manager.py +++ b/tests/unit/yum_config/test_dnf_manager.py @@ -14,8 +14,8 @@ import ddt from unittest import mock -import test.test_main as test_main -import tripleo_yum_config.dnf_manager as dnf_mgr +from . import test_main +import tripleo_repos.yum_config.dnf_manager as dnf_mgr @ddt.ddt diff --git a/tripleo-yum-config/test/test_main.py b/tests/unit/yum_config/test_main.py similarity index 94% rename from tripleo-yum-config/test/test_main.py rename to tests/unit/yum_config/test_main.py index 12aba2f..73c3dbc 100644 --- a/tripleo-yum-config/test/test_main.py +++ b/tests/unit/yum_config/test_main.py @@ -17,11 +17,11 @@ import sys import unittest from unittest import mock -import test.fakes as fakes -import test.mock_modules # noqa: F401 -import tripleo_yum_config.__main__ as main -import tripleo_yum_config.yum_config as yum_cfg -import tripleo_yum_config.dnf_manager as dnf_mgr +from . import fakes +from . import mock_modules # noqa: F401 +import tripleo_repos.yum_config.__main__ as main +import tripleo_repos.yum_config.yum_config as yum_cfg +import tripleo_repos.yum_config.dnf_manager as dnf_mgr class TestTripleoYumConfigBase(unittest.TestCase): diff --git a/tripleo-yum-config/test/test_yum_config.py b/tests/unit/yum_config/test_yum_config.py similarity index 98% rename from tripleo-yum-config/test/test_yum_config.py rename to tests/unit/yum_config/test_yum_config.py index d3d2ac4..47b0415 100644 --- a/tripleo-yum-config/test/test_yum_config.py +++ b/tests/unit/yum_config/test_yum_config.py @@ -18,11 +18,11 @@ import ddt import os from unittest import mock -import test.fakes as fakes -import test.test_main as test_main -import tripleo_yum_config.constants as const -import tripleo_yum_config.exceptions as exc -import tripleo_yum_config.yum_config as yum_cfg +from . import fakes +from . import test_main +import tripleo_repos.yum_config.constants as const +import tripleo_repos.yum_config.exceptions as exc +import tripleo_repos.yum_config.yum_config as yum_cfg @ddt.ddt diff --git a/tox.ini b/tox.ini index 979c660..46ea2b2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,17 @@ [tox] minversion = 3.1.1 skipsdist = True -envlist = py,pep8 +envlist = py,pep8,packaging [testenv] usedevelop = True -basepython = python3 setenv = VIRTUAL_ENV={envdir} deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt - -r{toxinidir}/tripleo-get-hash/requirements.txt - -r{toxinidir}/tripleo-get-hash/test-requirements.txt commands = stestr run --slowest {posargs} - stestr run --combine --slowest {posargs} --test-path ./tripleo-get-hash/test --top-dir ./tripleo-get-hash - stestr run --combine --slowest {posargs} --test-path ./tripleo-yum-config/test --top-dir ./tripleo-yum-config [testenv:venv] commands = {posargs} @@ -43,6 +38,37 @@ commands = coverage html -d cover coverage xml -o cover/coverage.xml +[testenv:packaging] +description = + Build package, verify metadata, install package and assert basic behavior +deps = + build + twine +skip_install = true +commands = + # build wheel and sdist using PEP-517 + {envpython} -c 'import os.path, shutil, sys; \ + dist_dir = os.path.join("{toxinidir}", "dist"); \ + os.path.isdir(dist_dir) or sys.exit(0); \ + print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \ + shutil.rmtree(dist_dir)' + {envpython} -m build \ + --sdist \ + --wheel \ + --outdir {toxinidir}/dist/ \ + {toxinidir} + # Validate metadata using twine + twine check {toxinidir}/dist/* + # Install the wheel + sh -c "python3 -m pip install {toxinidir}/dist/*.whl" + # Assure that CLIs were installed + tripleo-repos --help + tripleo-get-hash --help + tripleo-yum-config --help + +whitelist_externals = + sh + [flake8] ignore = H803 show-source = True diff --git a/tripleo-get-hash/LICENSE b/tripleo-get-hash/LICENSE deleted file mode 100644 index 692cf99..0000000 --- a/tripleo-get-hash/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021 Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. diff --git a/tripleo-get-hash/requirements.txt b/tripleo-get-hash/requirements.txt deleted file mode 100644 index 6c9fdba..0000000 --- a/tripleo-get-hash/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -PyYAML -requests diff --git a/tripleo-get-hash/setup.cfg b/tripleo-get-hash/setup.cfg deleted file mode 100644 index 0c05107..0000000 --- a/tripleo-get-hash/setup.cfg +++ /dev/null @@ -1,34 +0,0 @@ -[metadata] -name = tripleo-get-hash -author = Marios Andreou -author_email = openstack-discuss@lists.openstack.org -description = Get the tripleo build hash for a known RDO named tag. See https://opendev.org/openstack/tripleo-repos/src/branch/master/tripleo-get-hash/README.md#what-is-tripleo-get-hash for more information. -long_description = file: README.md LICENSE -long_description_content_type = text/markdown -url = https://opendev.org/openstack/tripleo-repos/src/branch/master/tripleo-get-hash -project_urls = - Bug Tracker = https://launchpad.net/tripleo -license_file = LICENSE -license = Apache-2.0 -classifiers = - Programming Language :: Python - -[options] -package_dir = - = . -packages = find: -python_requires = >=3.6 -install_requires = - pyyaml - requests -tests_require = - requests_mock - -[options.entry_points] -console_scripts = - tripleo-get-hash = tripleo_get_hash.__main__:cli_entrypoint - -[files] -data_files = - etc/tripleo_get_hash/ = config.yaml - share/ansible/plugins/modules/ = tripleo_get_hash.py diff --git a/tripleo-get-hash/setup.py b/tripleo-get-hash/setup.py deleted file mode 100644 index 171624f..0000000 --- a/tripleo-get-hash/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# - -import setuptools - -setuptools.setup(setup_requires=['pbr'], pbr=True) diff --git a/tripleo-get-hash/test-requirements.txt b/tripleo-get-hash/test-requirements.txt deleted file mode 100644 index 65a92dd..0000000 --- a/tripleo-get-hash/test-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests_mock diff --git a/tripleo-yum-config/LICENSE b/tripleo-yum-config/LICENSE deleted file mode 100644 index 692cf99..0000000 --- a/tripleo-yum-config/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021 Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. diff --git a/tripleo-yum-config/setup.cfg b/tripleo-yum-config/setup.cfg deleted file mode 100644 index 3c053ce..0000000 --- a/tripleo-yum-config/setup.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[metadata] -name = tripleo-yum-config -author = Douglas Viroel -author_email = openstack-discuss@lists.openstack.org -description = Updates yum configuration files (repo, modules, global configuration). -long_description = file: README.md LICENSE -long_description_content_type = text/markdown -url = https://opendev.org/openstack/tripleo-repos/src/branch/master/tripleo-yum-config -project_urls = - Bug Tracker = https://launchpad.net/tripleo -license_file = LICENSE -license = Apache-2.0 -classifiers = - Programming Language :: Python - -[options] -package_dir = - = . -packages = find: -python_requires = >=3.6 - -[options.entry_points] -console_scripts = - tripleo-yum-config = tripleo_yum_config.__main__:cli_entrypoint - -[files] -data_files = - share/ansible/plugins/modules/ = tripleo_yum_config.py diff --git a/tripleo-yum-config/setup.py b/tripleo-yum-config/setup.py deleted file mode 100644 index 171624f..0000000 --- a/tripleo-yum-config/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# - -import setuptools - -setuptools.setup(setup_requires=['pbr'], pbr=True) diff --git a/tripleo_repos/tests/__init__.py b/tripleo_repos/get_hash/__init__.py similarity index 100% rename from tripleo_repos/tests/__init__.py rename to tripleo_repos/get_hash/__init__.py diff --git a/tripleo-get-hash/tripleo_get_hash/__main__.py b/tripleo_repos/get_hash/__main__.py similarity index 96% rename from tripleo-get-hash/tripleo_get_hash/__main__.py rename to tripleo_repos/get_hash/__main__.py index 2fd4662..1542b25 100644 --- a/tripleo-get-hash/tripleo_get_hash/__main__.py +++ b/tripleo_repos/get_hash/__main__.py @@ -17,8 +17,8 @@ import argparse import logging import sys -from tripleo_get_hash.tripleo_hash_info import TripleOHashInfo -import tripleo_get_hash.exceptions as exc +from tripleo_repos.get_hash.tripleo_hash_info import TripleOHashInfo +import tripleo_repos.get_hash.exceptions as exc def _validate_args(parsed_args): diff --git a/tripleo-get-hash/config.yaml b/tripleo_repos/get_hash/config.yaml similarity index 100% rename from tripleo-get-hash/config.yaml rename to tripleo_repos/get_hash/config.yaml diff --git a/tripleo-get-hash/tripleo_get_hash/constants.py b/tripleo_repos/get_hash/constants.py similarity index 100% rename from tripleo-get-hash/tripleo_get_hash/constants.py rename to tripleo_repos/get_hash/constants.py diff --git a/tripleo-get-hash/tripleo_get_hash/exceptions.py b/tripleo_repos/get_hash/exceptions.py similarity index 100% rename from tripleo-get-hash/tripleo_get_hash/exceptions.py rename to tripleo_repos/get_hash/exceptions.py diff --git a/tripleo-get-hash/tripleo_get_hash.py b/tripleo_repos/get_hash/tripleo_get_hash.py similarity index 98% rename from tripleo-get-hash/tripleo_get_hash.py rename to tripleo_repos/get_hash/tripleo_get_hash.py index 5feec27..543da53 100644 --- a/tripleo-get-hash/tripleo_get_hash.py +++ b/tripleo_repos/get_hash/tripleo_get_hash.py @@ -14,7 +14,7 @@ # under the License. # -from tripleo_get_hash.tripleo_hash_info import TripleOHashInfo +from tripleo_repos.get_hash.tripleo_hash_info import TripleOHashInfo from ansible.module_utils.basic import AnsibleModule DOCUMENTATION = r''' diff --git a/tripleo-get-hash/tripleo_get_hash/tripleo_hash_info.py b/tripleo_repos/get_hash/tripleo_hash_info.py similarity index 93% rename from tripleo-get-hash/tripleo_get_hash/tripleo_hash_info.py rename to tripleo_repos/get_hash/tripleo_hash_info.py index cbe906d..21d39ea 100644 --- a/tripleo-get-hash/tripleo_get_hash/tripleo_hash_info.py +++ b/tripleo_repos/get_hash/tripleo_hash_info.py @@ -19,8 +19,8 @@ import sys import yaml import os import requests -import tripleo_get_hash.constants as const -import tripleo_get_hash.exceptions as exc +import tripleo_repos.get_hash.constants as const +import tripleo_repos.get_hash.exceptions as exc class TripleOHashInfo: @@ -91,16 +91,18 @@ class TripleOHashInfo: return False def _resolve_local_config_path(): - """ For running from source checkout, try ../config.yaml. For - pip install (--user) try ../local/etc/tripleo_get_hash/ - """ - for _path in ['config.yaml', - 'usr/local/etc/tripleo_get_hash/config.yaml']: - _local_config = os.path.join( - os.path.split(os.path.split( - os.path.abspath(__file__) - )[0])[0], "{}".format(_path) - ) + """ Load local config from disk from expected locations. """ + paths = [ + # pip install --user + os.path.expanduser( + "~/.local/etc/tripleo_get_hash/config.yaml"), + # root install + "/etc/tripleo_get_hash/config.yaml", + # embedded config.yaml as fallback + os.path.join( + os.path.dirname(os.path.abspath(__file__)), "config.yaml") + ] + for _local_config in paths: if _check_read_file(_local_config): return _local_config diff --git a/tripleo_repos/main.py b/tripleo_repos/main.py index 6f299b7..5dbd74d 100755 --- a/tripleo_repos/main.py +++ b/tripleo_repos/main.py @@ -17,6 +17,7 @@ from __future__ import print_function import argparse import os +import platform import re import subprocess import sys @@ -115,6 +116,11 @@ def _get_distro(): returns: distro_id, distro_major_version_id, distro_name """ + # Avoids a crash on unsupported platforms which would prevent even + # running with `--help`. + if not os.path.exists('/etc/os-release'): + return platform.system(), 'unknown', 'unknown' + output = subprocess.Popen( 'source /etc/os-release && echo -e -n "$ID\n$VERSION_ID\n$NAME"', shell=True, @@ -155,7 +161,7 @@ def _parse_args(distro_id, distro_major_version_id): distro = "{}{}".format(distro_id, distro_major_version_id) # Calculating arguments default from constants - default_mirror = DEFAULT_MIRROR_MAP[distro_id] + default_mirror = DEFAULT_MIRROR_MAP.get(distro_id, None) distro_choices = ["".join(distro_pair) for distro_pair in SUPPORTED_DISTROS] diff --git a/tripleo_repos/yum_config/__init__.py b/tripleo_repos/yum_config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tripleo-yum-config/tripleo_yum_config/__main__.py b/tripleo_repos/yum_config/__main__.py similarity index 97% rename from tripleo-yum-config/tripleo_yum_config/__main__.py rename to tripleo_repos/yum_config/__main__.py index 9c8d508..1e0d9cf 100644 --- a/tripleo-yum-config/tripleo_yum_config/__main__.py +++ b/tripleo_repos/yum_config/__main__.py @@ -17,8 +17,8 @@ import argparse import logging import sys -import tripleo_yum_config.yum_config as cfg -import tripleo_yum_config.dnf_manager as dnf_mgr +import tripleo_repos.yum_config.yum_config as cfg +import tripleo_repos.yum_config.dnf_manager as dnf_mgr def options_to_dict(options): diff --git a/tripleo-yum-config/tripleo_yum_config/constants.py b/tripleo_repos/yum_config/constants.py similarity index 100% rename from tripleo-yum-config/tripleo_yum_config/constants.py rename to tripleo_repos/yum_config/constants.py diff --git a/tripleo-yum-config/tripleo_yum_config/dnf_manager.py b/tripleo_repos/yum_config/dnf_manager.py similarity index 97% rename from tripleo-yum-config/tripleo_yum_config/dnf_manager.py rename to tripleo_repos/yum_config/dnf_manager.py index f4181e3..36bcf41 100644 --- a/tripleo-yum-config/tripleo_yum_config/dnf_manager.py +++ b/tripleo_repos/yum_config/dnf_manager.py @@ -13,13 +13,14 @@ # under the License. import logging -import dnf class DnfModuleManager: """Class that manages dnf modules.""" def __init__(self): + # lazy import to allow CLI to start without dnf + import dnf self.base = dnf.Base() self.base.conf.read() self.base.conf.best = True diff --git a/tripleo-yum-config/tripleo_yum_config/exceptions.py b/tripleo_repos/yum_config/exceptions.py similarity index 100% rename from tripleo-yum-config/tripleo_yum_config/exceptions.py rename to tripleo_repos/yum_config/exceptions.py diff --git a/tripleo-yum-config/tripleo_yum_config.py b/tripleo_repos/yum_config/tripleo_yum_config.py similarity index 98% rename from tripleo-yum-config/tripleo_yum_config.py rename to tripleo_repos/yum_config/tripleo_yum_config.py index ed55d0a..be2492c 100644 --- a/tripleo-yum-config/tripleo_yum_config.py +++ b/tripleo_repos/yum_config/tripleo_yum_config.py @@ -15,8 +15,8 @@ from ansible.module_utils.basic import AnsibleModule -import tripleo_yum_config.dnf_manager as dnf_mgr -import tripleo_yum_config.yum_config as cfg +import tripleo_repos.yum_config.dnf_manager as dnf_mgr +import tripleo_repos.yum_config.yum_config as cfg DOCUMENTATION = r''' --- diff --git a/tripleo-yum-config/tripleo_yum_config/yum_config.py b/tripleo_repos/yum_config/yum_config.py similarity index 98% rename from tripleo-yum-config/tripleo_yum_config/yum_config.py rename to tripleo_repos/yum_config/yum_config.py index facfe4c..4c2bf5f 100644 --- a/tripleo-yum-config/tripleo_yum_config/yum_config.py +++ b/tripleo_repos/yum_config/yum_config.py @@ -18,8 +18,8 @@ import logging import os import sys -import tripleo_yum_config.constants as const -import tripleo_yum_config.exceptions as exc +import tripleo_repos.yum_config.constants as const +import tripleo_repos.yum_config.exceptions as exc class TripleOYumConfig: diff --git a/zuul.d/layout.yaml b/zuul.d/layout.yaml index 7157b76..724f7eb 100644 --- a/zuul.d/layout.yaml +++ b/zuul.d/layout.yaml @@ -5,6 +5,9 @@ - openstack-python3-wallaby-jobs check: jobs: &cjobs + - openstack-tox-pep8: + vars: + tox_envlist: pep8,packaging - openstack-tox-py39 - tripleo-buildimage-overcloud-full-centos-8: dependencies: &deps_unit_lint_cprovider