Combine new modules into a single package
- Make newly added get_hash and yum_config modules part of triple_repos package. - add simple packaging testing environment, which should validate installation of the command line - moves tests/docs/examples in official location required by ansible-test - includes required fix for looking up for local config.yaml Change-Id: I134ef8ac4c31b98dc25d17ab058af1ed34e27f32
This commit is contained in:
parent
06f41a630f
commit
0ecc6e0bbb
@ -1,3 +1,3 @@
|
||||
[DEFAULT]
|
||||
test_path=./tripleo_repos/tests
|
||||
test_path=./tests/unit
|
||||
top_dir=./
|
||||
|
2
MANIFEST.in
Normal file
2
MANIFEST.in
Normal file
@ -0,0 +1,2 @@
|
||||
global-exclude *.py[cod]
|
||||
global-exclude __pycache__
|
@ -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
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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(
|
@ -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
|
@ -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
|
@ -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):
|
@ -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
|
38
tox.ini
38
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
|
||||
|
@ -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.
|
@ -1,2 +0,0 @@
|
||||
PyYAML
|
||||
requests
|
@ -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
|
@ -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)
|
@ -1 +0,0 @@
|
||||
requests_mock
|
@ -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.
|
@ -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
|
@ -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)
|
@ -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):
|
@ -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'''
|
@ -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
|
||||
|
@ -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]
|
||||
|
||||
|
0
tripleo_repos/yum_config/__init__.py
Normal file
0
tripleo_repos/yum_config/__init__.py
Normal file
@ -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):
|
@ -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
|
@ -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'''
|
||||
---
|
@ -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:
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user