├── tests
├── __init__.py
├── container_package
│ ├── Containerfile.crhc-pkg
│ ├── README.md
│ ├── Containerfile.py_38
│ └── generate_binary.sh
├── test_report.py
├── test_help.py
├── end-to-end_crhc-cli_check.sh
└── data
│ └── inventory.json
├── crhc_cli
├── __init__.py
├── conf
│ ├── __init__.py
│ └── conf.py
├── help
│ ├── __init__.py
│ └── help_opt.py
├── parse
│ ├── __init__.py
│ └── parse.py
├── report
│ └── __init__.py
├── credential
│ ├── __init__.py
│ ├── credential.py
│ └── token.py
├── execution
│ └── __init__.py
├── troubleshoot
│ ├── __init__.py
│ └── ts.py
└── crhc.py
├── docs
├── crhc.rst
├── about.rst
├── modules.rst
├── conf.rst
├── parse.rst
├── help.rst
├── report.rst
├── execution.rst
├── troubleshoot.rst
├── index.rst
├── tests.rst
├── credential.rst
├── update.rst
├── Makefile
├── proxy.rst
├── features.rst
├── conf.py
├── quickstart.rst
├── contribution.rst
├── usage.rst
├── examples.rst
└── changelog.rst
├── bin
└── crhc-cli
├── .gitignore
├── .readthedocs.yaml
├── setup.py
├── .github
└── workflows
│ └── python-app.yml
├── requirements.txt
├── README.md
├── update_workflow.readme
└── LICENSE
/tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/conf/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/help/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/parse/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/report/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/credential/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/execution/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/crhc_cli/troubleshoot/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/crhc.rst:
--------------------------------------------------------------------------------
1 | crhc module
2 | ===========
3 |
4 | .. automodule:: crhc
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
--------------------------------------------------------------------------------
/docs/about.rst:
--------------------------------------------------------------------------------
1 | About CRHC-CLI
2 | ==============
3 |
4 | This project contains the ``crhc`` command line tool that simplifies the use of the C.RH.C API available at console.redhat.com.
5 |
--------------------------------------------------------------------------------
/bin/crhc-cli:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 |
4 | project_dir = os.path.dirname(os.path.dirname(__file__))
5 | os.sys.path.append(project_dir)
6 |
7 | from crhc_cli import crhc
8 | crhc.parse.main_menu()
--------------------------------------------------------------------------------
/docs/modules.rst:
--------------------------------------------------------------------------------
1 | crhc-cli
2 | ========
3 |
4 | .. toctree::
5 | :maxdepth: 4
6 |
7 | conf
8 | credential
9 | crhc
10 | execution
11 | help
12 | parse
13 | report
14 | tests
15 | troubleshoot
16 |
--------------------------------------------------------------------------------
/crhc_cli/crhc.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """
3 | .. code-block:: text
4 |
5 | App responsible for collect some information from
6 | console.redhat.com (Inventory, Subscription and much more)
7 | """
8 |
9 | from crhc_cli.parse import parse
10 |
11 | if __name__ == "__main__":
12 | parse.main_menu()
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *svn*
2 | *.ipynb
3 | *.pyc
4 | *.pyo
5 | .project
6 | .pydevproject
7 | *.swp
8 | *.swo
9 | build
10 | dist
11 | *.egg-info
12 | pip-wheel-metadata/
13 | .settings
14 | *.wpr
15 | *.wpu
16 | .idea
17 | .coverage
18 | cover
19 | .DS_Store
20 | *,cover
21 | tags
22 | .pytest_cache
23 | .venv
24 |
25 | #VScode
26 | .vscode/
27 |
--------------------------------------------------------------------------------
/docs/conf.rst:
--------------------------------------------------------------------------------
1 | conf package
2 | ============
3 |
4 | Submodules
5 | ----------
6 |
7 | conf.conf module
8 | ----------------
9 |
10 | .. automodule:: conf.conf
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | Module contents
16 | ---------------
17 |
18 | .. automodule:: conf
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
--------------------------------------------------------------------------------
/docs/parse.rst:
--------------------------------------------------------------------------------
1 | parse package
2 | =============
3 |
4 | Submodules
5 | ----------
6 |
7 | parse.parse module
8 | ------------------
9 |
10 | .. automodule:: parse.parse
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | Module contents
16 | ---------------
17 |
18 | .. automodule:: parse
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
--------------------------------------------------------------------------------
/docs/help.rst:
--------------------------------------------------------------------------------
1 | help package
2 | ============
3 |
4 | Submodules
5 | ----------
6 |
7 | help.help\_opt module
8 | ---------------------
9 |
10 | .. automodule:: help.help_opt
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | Module contents
16 | ---------------
17 |
18 | .. automodule:: help
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
--------------------------------------------------------------------------------
/docs/report.rst:
--------------------------------------------------------------------------------
1 | report package
2 | ==============
3 |
4 | Submodules
5 | ----------
6 |
7 | report.report module
8 | --------------------
9 |
10 | .. automodule:: report.report
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | Module contents
16 | ---------------
17 |
18 | .. automodule:: report
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
--------------------------------------------------------------------------------
/docs/execution.rst:
--------------------------------------------------------------------------------
1 | execution package
2 | =================
3 |
4 | Submodules
5 | ----------
6 |
7 | execution.execution module
8 | --------------------------
9 |
10 | .. automodule:: execution.execution
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | Module contents
16 | ---------------
17 |
18 | .. automodule:: execution
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
--------------------------------------------------------------------------------
/docs/troubleshoot.rst:
--------------------------------------------------------------------------------
1 | troubleshoot package
2 | ====================
3 |
4 | Submodules
5 | ----------
6 |
7 | troubleshoot.ts module
8 | ----------------------
9 |
10 | .. automodule:: troubleshoot.ts
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | Module contents
16 | ---------------
17 |
18 | .. automodule:: troubleshoot
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
--------------------------------------------------------------------------------
/tests/container_package/Containerfile.crhc-pkg:
--------------------------------------------------------------------------------
1 | FROM localhost/py_38
2 |
3 | WORKDIR /app
4 | CMD git clone https://github.com/C-RH-C/crhc-cli.git && \
5 | python3.8 -m venv ~/.venv/crhc-cli && \
6 | source ~/.venv/crhc-cli/bin/activate && \
7 | pip install --upgrade pip && \
8 | cd crhc-cli && \
9 | pip install -r requirements.txt && \
10 | chmod +x bin/crhc-cli && \
11 | bin/crhc-cli && \
12 | pyinstaller --paths=. --onefile bin/crhc-cli && \
13 | cp dist/crhc-cli /app/crhc-linux-x64
14 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | Welcome to crhc-cli's documentation!
2 | ====================================
3 |
4 | Welcome to this amazing project. Here you will find a solution for your
5 | ``console.redhat.com`` reporting.
6 |
7 | .. toctree::
8 | :maxdepth: 2
9 | :caption: Contents:
10 |
11 | about
12 | features
13 | quickstart
14 | usage
15 | examples
16 | proxy
17 | update
18 | contribution
19 | changelog
20 | modules
21 |
22 | Indices and tables
23 | ==================
24 |
25 | * :ref:`genindex`
26 | * :ref:`modindex`
27 | * :ref:`search`
28 |
--------------------------------------------------------------------------------
/docs/tests.rst:
--------------------------------------------------------------------------------
1 | tests package
2 | =============
3 |
4 | Submodules
5 | ----------
6 |
7 | tests.test\_help module
8 | -----------------------
9 |
10 | .. automodule:: tests.test_help
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | tests.test\_report module
16 | -------------------------
17 |
18 | .. automodule:: tests.test_report
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 | Module contents
24 | ---------------
25 |
26 | .. automodule:: tests
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
--------------------------------------------------------------------------------
/docs/credential.rst:
--------------------------------------------------------------------------------
1 | credential package
2 | ==================
3 |
4 | Submodules
5 | ----------
6 |
7 | credential.credential module
8 | ----------------------------
9 |
10 | .. automodule:: credential.credential
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | credential.token module
16 | -----------------------
17 |
18 | .. automodule:: credential.token
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 | Module contents
24 | ---------------
25 |
26 | .. automodule:: credential
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
--------------------------------------------------------------------------------
/tests/container_package/README.md:
--------------------------------------------------------------------------------
1 | # Generate the binary
2 |
3 | Feel free to execute this script on any rhel/linxu that you are testing crhc-cli, this will create 2 containers
4 |
5 | - The first one with the python version 3.8
6 | - The second one which will create a binary file based on the latest version of crhc-cli code, and this will be compatible with rhel7/8 or glibc of rhel7/8
7 |
8 |
9 | Just execute the script and it will be enough to prepare everything. Note that you will be notified about removing any image that you have, assuming this is not a big deal, the script will proceed and do all the necessary steps.
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yaml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | # Set the version of Python and other tools you might need
9 | build:
10 | os: ubuntu-22.04
11 | tools:
12 | python: "3.9"
13 |
14 | # Build documentation in the docs/ directory with Sphinx
15 | sphinx:
16 | configuration: docs/conf.py
17 |
18 | # We recommend specifying your dependencies to enable reproducible builds:
19 | # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
20 | python:
21 | install:
22 | - requirements: requirements.txt
23 |
--------------------------------------------------------------------------------
/docs/update.rst:
--------------------------------------------------------------------------------
1 | New Version
2 | ===========
3 |
4 | Once a new version get available, the crhc will let you know.
5 |
6 | .. code-block:: text
7 |
8 | ...
9 | Use "crhc [command] --help" for more information about a command.
10 |
11 | Please, download the latests version from https://github.com/C-RH-C/crhc-cli/releases/latest
12 | Current Version: 1.3.1
13 | New Version: 1.3.2
14 |
15 | You can safely download the latest version in the link and overwrite the current one. All the fix and new features will be already available.
16 |
17 | Note. The current ``token`` configuration will still valid. It's not necessary to rerun the token process when updating the ``crhc`` version.
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = .
9 | BUILDDIR = _build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
--------------------------------------------------------------------------------
/docs/proxy.rst:
--------------------------------------------------------------------------------
1 | Proxy Configuration
2 | ===================
3 |
4 | If you have proxy in your environment, it will be necessary to add this configuration in your terminal. In order to do that, you can proceed as below:
5 |
6 | To check the current configuration
7 |
8 | .. code-block::
9 |
10 | $ echo $http_proxy
11 |
12 | To setup your proxy
13 |
14 | .. code-block::
15 |
16 | $ export http_proxy=http://SERVER:PORT/
17 |
18 | or
19 |
20 | .. code-block::
21 |
22 | $ export http_proxy=http://USERNAME:PASSWORD@SERVER:PORT/
23 |
24 | And if you would like to keep it permanent
25 |
26 | .. code-block::
27 |
28 | # echo "export http_proxy=http://proxy.local.domain:3128/" > /etc/profile.d/http_proxy.sh
29 |
30 | Note. Please, change the values according to your environment. After that, you should be good to go and use the ``crhc`` with no problems.
--------------------------------------------------------------------------------
/tests/container_package/Containerfile.py_38:
--------------------------------------------------------------------------------
1 | FROM docker.io/dokken/centos-7
2 |
3 | WORKDIR /app
4 |
5 | RUN rm -rf /etc/yum.repos.d/* && \
6 | echo -e "[base]\nname=CentOS\nbaseurl=https://vault.centos.org/7.9.2009/os/x86_64/\ngpgcheck=1\ngpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7\n\n[updates]\nname=CentOS-$releasever-Updates\nbaseurl=https://vault.centos.org/7.9.2009/updates/x86_64/\ngpgcheck=1\ngpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7" >/etc/yum.repos.d/local.repo
7 |
8 | RUN yum install gcc zlib-devel openssl-devel libffi-devel git -y && \
9 | yum clean all && \
10 | wget https://www.python.org/ftp/python/3.8.18/Python-3.8.18.tgz && \
11 | tar xvf Python-3.8.18.tgz
12 |
13 | WORKDIR /app/Python-3.8.18
14 | RUN pwd && \
15 | ./configure --enable-shared && make && make install && \
16 | echo "/usr/local/lib/" >/etc/ld.so.conf.d/py.conf && \
17 | ldconfig -v && \
18 | python3.8 --version
19 |
20 | WORKDIR /app
21 | RUN rm -rf Python-3.8.18*
22 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import find_packages, setup
2 |
3 |
4 | with open("README.md", "r") as fh:
5 | long_description = fh.read()
6 |
7 | with open("requirements.txt", "r") as req:
8 | requirements = req.readlines()
9 |
10 |
11 | setup(
12 | name="crhc-cli",
13 | version="1.16.16",
14 | author="Waldirio",
15 | author_email="waldirio@gmail.com",
16 | description="This project contains the crhc command line tool that simplifies the use of the C.RH.C API available at console.redhat.com",
17 | long_description=long_description,
18 | long_description_content_type="text/markdown",
19 | install_requires=requirements,
20 | url="https://github.com/C-RH-C/crhc-cli/",
21 | packages=find_packages(),
22 | python_requires=">=3.9",
23 | scripts=['bin/crhc-cli'],
24 | include_package_data=True,
25 | classifiers=(
26 | "Programming Language :: Python :: 3",
27 | "License :: OSI Approved :: MIT License",
28 | "Operating System :: OS Independent",
29 | ),
30 | )
31 |
--------------------------------------------------------------------------------
/docs/features.rst:
--------------------------------------------------------------------------------
1 | Features
2 | ========
3 |
4 | In this section you can see all the available features in ``crhc-cli``
5 |
6 | * Export of Inventory data, in ``JSON`` and ``CSV`` format.
7 | * Export of Subscription data, in ``JSON`` and ``CSV`` format.
8 | * Creation of a Single Dataset including ``Inventory`` and ``Subscription`` data in ``CSV`` format.
9 | * Export of Advisor data, in ``JSON`` and ``CSV`` format.
10 | * Export of Vulnerability data, in ``JSON`` and ``CSV`` format.
11 | * Export of Patch data, in ``JSON`` and ``CSV`` format.
12 | * Subscription Socket summary (spliting the sockets from hypervisors and VM's with no host-guest mapping).
13 | * Easy way to present the available API endpoints.
14 | * Easy way to consume the API endpoints listed above.
15 | * Access Token generation to be used with 3rd party software, for example ``curl -H 'Authorization: Bearer $(./crhc token) ...'``
16 | * Currently supporting both platforms, ``Linux`` and ``MS Windows`` with python 3.6+
17 | * Export the whole information easily via ``./crhc ts dump`` to help the ``Red Hat Support team`` during the troubleshooting process.
18 |
19 | Are you looking for something new that is not listed above? Click `here`_ and let us know.
20 |
21 | .. _here: https://github.com/C-RH-C/crhc-cli/issues/new
--------------------------------------------------------------------------------
/tests/container_package/generate_binary.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/bash
2 |
3 | cleaning_all_images()
4 | {
5 | read -p "This operation will remove all the current container iamges. Proceed? (y/n): " answer
6 |
7 | if [ "$answer" == "y" ]; then
8 | echo "Ok, proceeding and removing all the local images"
9 | else
10 | echo "exiting ..."
11 | exit 1
12 | fi
13 | podman rmi -a --force
14 | }
15 |
16 | check_final_dir()
17 | {
18 | if [ -d /tmp/app ]; then
19 | echo "The directory '/tmp/app' is present, removing it"
20 | echo "running the command 'rm -rfv /tmp/app/'"
21 | rm -rfv /tmp/app/
22 | fi
23 |
24 | mkdir -pv /tmp/app
25 | }
26 |
27 | create_py38_container()
28 | {
29 | # Creating the container
30 | podman build . -t py_38 -f Containerfile.py_38 --layers=false --no-cache
31 | }
32 |
33 | create_crhc-cli_container()
34 | {
35 | # Creating the container
36 | podman build . -t crhc-pkg -f Containerfile.crhc-pkg --layers=false --no-cache
37 | }
38 |
39 | create_crhc_bin()
40 | {
41 | # Running the container and creating the binary at /tmp/app
42 | podman run --rm --name crhc-cli-build -v /tmp/app:/app:Z localhost/crhc-pkg
43 | }
44 |
45 | # Main
46 | cleaning_all_images
47 | check_final_dir
48 | create_py38_container
49 | create_crhc-cli_container
50 | create_crhc_bin
51 |
--------------------------------------------------------------------------------
/.github/workflows/python-app.yml:
--------------------------------------------------------------------------------
1 | # This workflow will install Python dependencies, run tests and lint with a single version of Python
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3 |
4 | name: Python application
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 | - name: Set up Python 3.10
20 | uses: actions/setup-python@v3
21 | with:
22 | python-version: "3.10"
23 | - name: Install dependencies
24 | run: |
25 | python -m pip install --upgrade pip
26 | pip install flake8 pytest pylint
27 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28 | - name: Lint with flake8
29 | run: |
30 | # stop the build if there are Python syntax errors or undefined names
31 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34 | - name: Lint with pylint
35 | run: |
36 | pylint * --exit-zero
37 | - name: Test with pytest
38 | run: |
39 | pytest -vv
40 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | alabaster==0.7.13
2 | altgraph==0.17.4
3 | astroid==2.11.7
4 | attrs==22.2.0
5 | Babel==2.11.0
6 | black==22.8.0
7 | certifi==2023.7.22
8 | cffi==1.15.1
9 | charset-normalizer==2.0.12
10 | click==8.0.4
11 | coverage==6.2
12 | cryptography==40.0.2
13 | dataclasses==0.6
14 | dill==0.3.4
15 | docutils==0.17.1
16 | flake8==5.0.4
17 | idna==3.4
18 | imagesize==1.4.1
19 | importlib-metadata==4.2.0
20 | iniconfig==1.1.1
21 | isort==5.10.1
22 | Jinja2==3.0.3
23 | lazy-object-proxy==1.7.1
24 | MarkupSafe==2.0.1
25 | mccabe==0.7.0
26 | mypy-extensions==1.0.0
27 | packaging
28 | pathspec==0.9.0
29 | platformdirs==2.4.0
30 | pluggy==1.0.0
31 | py==1.11.0
32 | pyasn1==0.5.0
33 | pycodestyle==2.9.1
34 | pycparser==2.21
35 | pyflakes==2.5.0
36 | Pygments==2.14.0
37 | pyinstaller
38 | pyinstaller-hooks-contrib==2022.0
39 | PyJWT==2.4.0
40 | pylint==2.13.9
41 | pyparsing==3.1.1
42 | pytest==7.0.1
43 | pytest-cov==4.0.0
44 | pytz==2023.3.post1
45 | regex==2023.8.8
46 | requests==2.27.1
47 | rsa==4.9
48 | rstcheck==3.5.0
49 | snowballstemmer==2.2.0
50 | Sphinx==4.3.2
51 | sphinx-rtd-theme==1.3.0
52 | sphinxcontrib-applehelp==1.0.2
53 | sphinxcontrib-devhelp==1.0.2
54 | sphinxcontrib-htmlhelp==2.0.0
55 | sphinxcontrib-jquery==4.1
56 | sphinxcontrib-jsmath==1.0.1
57 | sphinxcontrib-qthelp==1.0.3
58 | sphinxcontrib-serializinghtml==1.1.5
59 | toml==0.10.2
60 | tomli==1.2.3
61 | typed-ast==1.5.5
62 | typing_extensions==4.1.1
63 | urllib3==1.26.18
64 | wrapt==1.16.0
65 | zipp==3.6.0
66 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **Archived Project**
2 |
3 | For more information, please visit the issue [https://issues.redhat.com/browse/RHIN-2342](https://issues.redhat.com/browse/RHIN-2342)
4 |
5 | ---
6 |
7 | # C.RH.C API Command Line Tool
8 |
9 | This project contains the `crhc` command line tool that simplifies the use of the C.RH.C API available at `console.redhat.com`
10 |
11 | ---
12 |
13 | **Disclaimer**: This project or the binary files available in the `Releases` area are `NOT` delivered and/or released by Red Hat. This is an independent project to help customers and Red Hat Support team to export and/or collect the data from `console.redhat.com` for reporting or troubleshooting purposes.
14 |
15 |
16 | **crhc-cli** will work on those versions of python:
17 | - 3.6+
18 |
19 |
20 | **Supported Platforms**: At this moment supporting `Linux` and `MS Windows`.
21 |
22 |
23 |
24 | Documentation is on [Read the Docs](https://crhc-cli.readthedocs.io). Code repository and issue tracker are on [GitHub](https://github.com/C-RH-C/crhc-cli/).
25 |
26 | ---
27 | Getting Started
28 | ---------------
29 | See the [Quick Start](https://crhc-cli.readthedocs.io/en/latest/quickstart.html) section on Read The Docs.
30 |
31 | ---
32 | Change History
33 | --------------
34 | The complete changelog on the [changelog](https://crhc-cli.readthedocs.io/en/latest/changelog.html) page.
35 |
36 | ---
37 | Contributing
38 | ------------
39 | Click [here](https://crhc-cli.readthedocs.io/en/latest/contribution.html) and check how to contribute for this amazing project.
40 |
--------------------------------------------------------------------------------
/crhc_cli/conf/conf.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for keep all the configuration paths and also
5 | the app version
6 | """
7 |
8 | import tempfile
9 | from pathlib import Path
10 |
11 |
12 | # Current Version
13 | CURRENT_VERSION = "1.16.16"
14 |
15 | # Some file references
16 |
17 | p = Path(tempfile.gettempdir())
18 |
19 | # Report Info
20 | INVENTORY_FILE = (p / "inventory_report.csv").resolve()
21 | SWATCH_FILE = (p / "swatch_report.csv").resolve()
22 | MATCH_FILE = (p / "match_inv_sw.csv").resolve()
23 |
24 | ISSUE_SUMMARY = (p / "issue_summary.log").resolve()
25 | PATCH_SYSTEMS_FILE = (p / "patch_systems.csv").resolve()
26 | VULNERABILITY_SYSTEMS_FILE = (p / "vulnerability_systems.csv").resolve()
27 | ADVISOR_FILE = (p / "advisor_systems.csv").resolve()
28 |
29 | STALE_FILE = (p / "stale_systems_based_on_date.json").resolve()
30 |
31 | # TS Info
32 | INV_JSON_FILE = (p / "inventory.json").resolve()
33 | SW_JSON_FILE = (p / "swatch.json").resolve()
34 | MATCH_FILE = (p / "match_inv_sw.csv").resolve()
35 | PATCH_JSON_FILE = (p / "patch.json").resolve()
36 | VULNERABILITY_JSON_FILE = (p / "vulnerability.json").resolve()
37 | ADVISOR_JSON_FILE = (p / "advisor.json").resolve()
38 |
39 | # TGZ_FILE = (p / "crhc_data.tgz").resolve()
40 | ZIP_FILE = (p / "crhc_data.zip").resolve()
41 |
42 |
43 | # App conf file
44 |
45 | # 43200 sec == 12h
46 | # 21600 sec == 6h
47 | TIME_TO_CHECK_THE_NEW_VERSION = 21600
48 |
49 | # Items per page when doing the API call
50 | ITEMS_PER_PAGE = 50
51 |
52 | # Ansible has a max limit of 25 Items per page when doing the API call
53 | ANSIBLE_ITEMS_PER_PAGE = 25
54 |
--------------------------------------------------------------------------------
/tests/test_report.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Test to check the Inventory Report
5 | """
6 | import json
7 | import csv
8 | import tempfile
9 | from pathlib import Path
10 | from crhc_cli.report import report
11 |
12 |
13 | INPUT_JSON = "tests/data/inventory.json"
14 |
15 | p = Path(tempfile.gettempdir())
16 | OUTPUT_CSV = (p / "inventory_report.csv").resolve()
17 |
18 |
19 | def calling_csv_report_inventory():
20 | """
21 | Function responsible to read the template data and push against the
22 | function.
23 | """
24 |
25 | # Reading the Input data that will be used in this test
26 | with open(INPUT_JSON, "r") as file_obj:
27 | aux = json.load(file_obj)
28 | number_of_entries = len(aux['results'])
29 | report.csv_report_inventory(aux)
30 | return number_of_entries
31 |
32 |
33 | def test_csv_report_inventory_counting_number_of_columns():
34 | """
35 | Testing the csv_report_inventory feature.
36 | Here we are passing the input file, generating the output and
37 | counting the # of fields of each row
38 | """
39 |
40 | calling_csv_report_inventory()
41 |
42 | # Counting 41 fields from Inventory Report
43 | with open(OUTPUT_CSV, "r") as file_obj:
44 | aux = csv.reader(file_obj)
45 | for line in aux:
46 | print(line)
47 | assert len(line) == 41
48 |
49 |
50 | def test_csv_report_inventory_counting_number_of_rows():
51 | """
52 | Testing the # of rows, which should be the # of elements in the
53 | sample + 1 of header
54 | """
55 | number_of_entries = calling_csv_report_inventory()
56 |
57 | # Counting 3 rows, header + 2 lines from the input data
58 | with open(OUTPUT_CSV, "r") as file_obj:
59 | aux = file_obj.readlines()
60 | assert len(aux) == number_of_entries + 1
61 |
--------------------------------------------------------------------------------
/crhc_cli/credential/credential.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for set the app credential
5 | """
6 |
7 | import getpass
8 | import os
9 | import sys
10 | import requests
11 |
12 |
13 | def set_credential():
14 | """
15 | Responsible to set the credential, create the local file and also
16 | validade if the credential is working as expected
17 | """
18 | print(
19 | "setting the credential. At this moment, the credential will be \
20 | saved as clear text in ~/.crhc.conf"
21 | )
22 | user = input("Type your console.redhat.com username: ")
23 | password = getpass.getpass("Type your console.redhat.com password: ")
24 |
25 | url = "https://console.redhat.com/api/inventory/v1/hosts"
26 | response = requests.get(url, auth=(user, password))
27 |
28 | if response.status_code == 200:
29 | print("Authenticated and ready to go!")
30 | else:
31 | print("Please, type again, wrong username or password")
32 | sys.exit()
33 |
34 | home_dir = os.path.expanduser("~")
35 | with open(home_dir + "/.crhc.conf", "w") as file_obj:
36 | file_obj.writelines("username:" + user)
37 | file_obj.writelines("\n")
38 | file_obj.writelines("password:" + str(password))
39 |
40 |
41 | def read_credential():
42 | """
43 | Responsible to read the credential, and in case the credential
44 | is not present yet, a new file will be created with no valid
45 | username and/or password
46 | """
47 | home_dir = os.path.expanduser("~")
48 |
49 | try:
50 | with open(home_dir + "/.crhc.conf", "r") as file_obj:
51 | for line in file_obj:
52 | if "username" in line:
53 | username = line.split(":")[1]
54 | if "password" in line:
55 | password = line.split(":")[1]
56 | return username, password
57 | except FileNotFoundError:
58 | home_dir = os.path.expanduser("~")
59 | with open(home_dir + "/.crhc.conf", "w") as file_obj:
60 | file_obj.writelines("username:")
61 | file_obj.writelines("\n")
62 | file_obj.writelines("password:")
63 |
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | """
2 | Configuration file for the Sphinx documentation builder.
3 | """
4 | # Configuration file for the Sphinx documentation builder.
5 | #
6 | # This file only contains a selection of the most common options. For a full
7 | # list see the documentation:
8 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
9 |
10 | # -- Path setup --------------------------------------------------------------
11 |
12 | # If extensions (or modules to document with autodoc) are in another directory,
13 | # add these directories to sys.path here. If the directory is relative to the
14 | # documentation root, use os.path.abspath to make it absolute, like shown here.
15 | #
16 | import os
17 | import sys
18 | # from conf import conf
19 | sys.path.insert(0, os.path.abspath('..'))
20 |
21 |
22 | # -- Project information -----------------------------------------------------
23 |
24 | project = 'crhc-cli'
25 | copyright = '2021, Waldirio Pinheiro'
26 | author = 'Waldirio Pinheiro'
27 |
28 | # The full version, including alpha/beta/rc tags
29 |
30 | # Pointing to the current conf file with the app version
31 | release = '1.10.10'
32 | # release = conf.CURRENT_VERSION
33 |
34 |
35 | # -- General configuration ---------------------------------------------------
36 |
37 | # Add any Sphinx extension module names here, as strings. They can be
38 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
39 | # ones.
40 | extensions = ['sphinx.ext.autodoc']
41 |
42 | # Add any paths that contain templates here, relative to this directory.
43 | templates_path = ['_templates']
44 |
45 | # List of patterns, relative to source directory, that match files and
46 | # directories to ignore when looking for source files.
47 | # This pattern also affects html_static_path and html_extra_path.
48 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
49 |
50 |
51 | # -- Options for HTML output -------------------------------------------------
52 |
53 | # The theme to use for HTML and HTML Help pages. See the documentation for
54 | # a list of builtin themes.
55 | #
56 | html_theme = 'sphinx_rtd_theme'
57 | # html_theme = 'alabaster'
58 |
59 | # Add any paths that contain custom static files (such as style sheets) here,
60 | # relative to this directory. They are copied after the builtin static files,
61 | # so a file named "default.css" will overwrite the builtin "default.css".
62 | # html_static_path = ['_static']
63 |
--------------------------------------------------------------------------------
/docs/quickstart.rst:
--------------------------------------------------------------------------------
1 | Quick Start
2 | ===========
3 |
4 | Please, access the release page `here`_ and check the version that you would like to use.
5 |
6 | If for any reason the binary didn't run properly in your machine also with python3.6, as below example, probably you are using a bit old version of 3.6. In this case, you can create the virtual environment following the steps below, and generate a new binary file that will be 100% compatible with your current python version.
7 |
8 | .. _here: https://github.com/C-RH-C/crhc-cli/releases/latest
9 |
10 | If you see something as below, it seems that you have a python version older than 3.6.8
11 |
12 | .. code-block::
13 |
14 | $ ./crhc
15 | [9554] Error loading Python lib '/tmp/_MEIWS0hNs/libpython3.6m.so.1.0': dlopen: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/_MEIWS0hNs/libpython3.6m.so.1.0)
16 |
17 | After downloaded, you just need to download the offline token from `https://console.redhat.com/openshift/token`_ and proceed via ``cli`` as below.
18 |
19 | .. code-block:: sh
20 |
21 | $ ./crhc login --token eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiS...
22 |
23 | The output below is expected
24 |
25 | .. code-block:: sh
26 |
27 | Authenticated and ready to go!
28 |
29 |
30 | From now, you are good to go and proceed with your queries based on the options available in the tool.
31 |
32 | .. code-block::
33 |
34 | $ ./crhc
35 | Command line tool for console.redhat.com API
36 |
37 | Usage:
38 | crhc [command]
39 |
40 | Available Commands:
41 | inventory Retrieve Inventory information
42 | swatch Retrieve Subscriptions information
43 | advisor Retrieve Insights Information
44 | patch Retrieve Patch Information
45 | vulnerability Retrieve Vulnerability Information
46 | endpoint List all the available endpoints
47 | get Send a GET request
48 | ts Troubleshooting tasks
49 |
50 | login Log in
51 | logout Log out
52 | token Generates a token
53 | whoami Prints user information
54 |
55 | Flags:
56 | -h, --help help for crhc
57 | -v, --version crhc version
58 |
59 | Use "crhc [command] --help" for more information about a command.
60 |
61 |
62 | .. _https://console.redhat.com/openshift/token: https://console.redhat.com/openshift/token
--------------------------------------------------------------------------------
/update_workflow.readme:
--------------------------------------------------------------------------------
1 | In a different system, execute the steps below to check if the application is working. Please, request a new token and add it to the .token file.
2 | ---
3 | # > ~/.token
4 | # vi ~/.token
5 | << the file will be something like >>
6 | << TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCIg..." >>
7 | # cd /root
8 | # git clone https://github.com/C-RH-C/crhc-cli.git
9 | # cd crhc-cli/tests
10 | # ./end-to-end_crhc-cli_check.sh -p 9999
11 | ---
12 | Note. The steps above will do all the tests and will generate a log file "/tmp/crhc-system-test_$DATE.log" that you could review in the end. Assuming that everything is ok, we can move on.
13 | Don't forget to revoke the token once your tests are done.
14 |
15 |
16 |
17 | Execute the commnand below and collect all the changes above the last tag/version/release
18 | ---
19 | $ git log --oneline
20 | ---
21 |
22 |
23 |
24 | Create a new branch here for the "new_version"
25 |
26 |
27 |
28 | Edit the file "conf/conf.py" and change accordingly.
29 | ---
30 | CURRENT_VERSION = "1.11.12"
31 | ---
32 | Note. X.Y.Z, where:
33 | X is a Major change
34 | Y is Enhancement
35 | Z is BugFix
36 |
37 |
38 |
39 | Check the Commits and Issues related to the changes. If there is no Issue associated to them, please, create one and do the association. It will be used in the next step.
40 |
41 |
42 |
43 | Edit the file "docs/changelog.rst" and add the changelog for the new version. Below we can see an example
44 | ---
45 | **v1.11.12 - 01/26/2023**
46 |
47 | - [ENHANCEMENT] Adding the new feature to remove stale entries based on the # of days - [`issue 24`_]
48 | - [FIX] Fixing the syspurpose issue - [`issue 168`_]
49 |
50 | .. _issue 168: https://github.com/C-RH-C/crhc-cli/issues/168
51 | .. _issue 24: https://github.com/C-RH-C/crhc-cli/issues/24
52 |
53 | <...>
54 | ---
55 |
56 |
57 |
58 | Now, it's time to push.
59 | ---
60 | git status
61 | git add
62 | git commit -m "nice description about the new version here"
63 | git push --set-upstream origin new_version
64 | ---
65 |
66 |
67 |
68 | Ok. Once you have the latest version available in the master repo, let's create the binary version for Linux & Windows. In your local repo that you ran the test
69 | ---
70 | (crhc-cli) # git checkout master
71 | (crhc-cli) # git pull
72 | (crhc-cli) # pyinstaller --onefile crhc.py
73 | ---
74 | Note. The file will be available under "crhc-cli/dist" folder. Please, feel free to rename the file to "crhc-linux-x64" in case of Linux build or "crhc-win-x64.exe" in case of MS Windows build.
75 |
76 |
77 |
78 | Once it's done via CLI, just access the github page, proceed with the merge, in a sequence, create a new Release, it will also create a new tag. Keep in mind, th tag should match with the CURRENT_VESION set above.
79 |
--------------------------------------------------------------------------------
/docs/contribution.rst:
--------------------------------------------------------------------------------
1 | Contribution
2 | ============
3 |
4 | I really hope this helps you.
5 |
6 | If you need anything else of if you are facing issues trying to use it, please let me know via email or feel free to open a repository issue `here`_
7 |
8 | Also, if you believe this project is valuable for you, feel free to share your feedback via contacts below. This will help to push this project forward.
9 |
10 | waldirio@redhat.com / waldirio@gmail.com
11 |
12 |
13 | .. _here: https://github.com/C-RH-C/crhc-cli/issues/new
14 |
15 | If you would like to play around with the Code, let's proceed as below
16 |
17 | ------
18 |
19 | **Prerequisites**
20 | In order to build this project the following dependencies are needed:
21 |
22 | * git
23 | * gcc
24 | * python3-devel
25 | * libffi-devel
26 |
27 | **Source_Code**
28 |
29 | In your RHEL/CentOS/Fedora/etc with Python 3.x installed, let's execute the commands in a sequence
30 |
31 | .. code-block::
32 |
33 | $ git clone https://github.com/C-RH-C/crhc-cli.git
34 | $ cd crhc-cli
35 | $ python3 -m venv ~/.virtualenv/crhc-cli
36 | $ source ~/.virtualenv/crhc-cli/bin/activate
37 |
38 | Now, you should be in your virtual environment. You can realize your prompt will change
39 |
40 | .. code-block::
41 |
42 | (crhc-cli) [user@server crhc-cli]$
43 |
44 |
45 | We can continue
46 |
47 | .. code-block::
48 |
49 | (crhc-cli) [user@server crhc-cli]$ pip install --upgrade pip
50 | (crhc-cli) [user@server crhc-cli]$ pip install -r requirements.txt
51 |
52 |
53 | And finally, we are good to go.
54 |
55 | .. code-block::
56 |
57 | (crhc-cli) [user@server crhc-cli]$ ./crhc.py
58 |
59 |
60 | The menu will be as below
61 |
62 | .. code-block::
63 |
64 | (crhc-cli) [user@server crhc-cli]$ ./crhc.py
65 | Command line tool for console.redhat.com API
66 |
67 | Usage:
68 | crhc [command]
69 |
70 | Available Commands:
71 | inventory Retrieve Inventory information
72 | swatch Retrieve Subscriptions information
73 | advisor Retrieve Insights Information
74 | patch Retrieve Patch Information
75 | vulnerability Retrieve Vulnerability Information
76 | endpoint List all the available endpoints
77 | get Send a GET request
78 | ts Troubleshooting tasks
79 |
80 | login Log in
81 | logout Log out
82 | token Generates a token
83 | whoami Prints user information
84 |
85 | Flags:
86 | -h, --help help for crhc
87 | -v, --version crhc version
88 |
89 | Use "crhc [command] --help" for more information about a command.
90 |
91 |
92 | Great, now it's time to generate the binary file, please, execute the step below yet in your virtual environment
93 |
94 | .. code-block::
95 |
96 | (crhc-cli) [user@server crhc-cli]$ pyinstaller --onefile crhc.py
97 |
98 |
99 | At the end of this process, the binary file will be available under the `dist` dir, then you can redistribute or copy to any other machine running the same python version and everything will be running with no issues.
100 |
101 | .. code-block:: sh
102 |
103 | (crhc-cli) [user@server crhc-cli]$ file dist/crhc
104 | dist/crhc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=f6af5bc244c001328c174a6abf855d682aa7401b, for GNU/Linux 2.6.32, stripped
105 |
106 |
107 |
108 | Thank you in advance! :)
109 |
--------------------------------------------------------------------------------
/docs/usage.rst:
--------------------------------------------------------------------------------
1 | Usage
2 | =====
3 |
4 | The main idea of this script is to collect the information from console.redhat.com in order to generate some reports and/or proceed with some troubleshooting. That said, we can:
5 |
6 | .. list-table::
7 | :header-rows: 1
8 |
9 | * - Command
10 | - Description
11 | * - crhc inventory list
12 | - To list the first 50 entries of your Inventory
13 | * - crhc inventory list \-\-csv
14 | - To generate the output in csv file. A new file ``/tmp/inventory_report.csv`` will be created.
15 | * - crhc inventory list_all
16 | - To list the whole entries of your Inventory
17 | * - crhc inventory list_all \-\-csv
18 | - To generate the output in csv file. A new file ``/tmp/inventory_report.csv`` will be created.
19 | * - crhc inventory display_name
20 | - To search entries by ``display_name``
21 | * - crhc inventory display_name \-\-csv
22 | - To generate the output in csv file. A new file ``/tmp/inventory_report.csv`` will be created.
23 | * - crhc swatch list
24 | - To list the first 100 entries of your Subscription Watch Inventory
25 | * - crhc swatch list \-\-csv
26 | - To generate the output in csv file. A new file ``/tmp/swatch_report.csv`` will be created.
27 | * - crhc swatch list_all
28 | - To list all the entries of your Subscription Watch Inventory
29 | * - crhc swatch list_all \-\-csv
30 | - To generate the output in csv file. A new file ``/tmp/swatch_report.csv`` will be created.
31 | * - crhc swatch socket_summary
32 | - To list a summary of sockets based on your Subscription Watch Inventory
33 | * - crhc advisor systems
34 | - To list the Advisor systems information, for example, ``critical, important, moderate ...``
35 | * - crhc advisor systems \-\-csv
36 | - To generate the output in csv file. A new file ``/tmp/advisor_systems.csv`` will be created.
37 | * - crhc patch systems
38 | - To list the Patch systems information, for example, ``Security Advisory``, ``Bug Advisory`` and/or ``Enhancement Advisory``
39 | * - crhc patch systems \-\-csv
40 | - To generate the output in csv file. A new file ``/tmp/patch_systems.csv`` will be created.
41 | * - crhc vulnerability systems
42 | - To list the Vulnerabilities systems information, for example, ``CVE's``
43 | * - crhc vulnerability systems \-\-csv
44 | - To generate the output in csv file. A new file ``/tmp/vulnerability_systems.csv`` will be created.
45 | * - crhc endpoint list
46 | - To list all the available API endpoints on console.redhat.com
47 | * - crhc get ````
48 | - Here you should be able to query the API endpoint directly
49 | * - crhc login \-\-token ````
50 | - The way to inform the token that you can obtain from https://console.redhat.com/openshift/token
51 | * - crhc logout
52 | - Used to cleanup the local conf file, removing all the token information
53 | * - crhc token
54 | - This will print the access_token. This can be used with curl, for example.
55 | * - crhc whoami
56 | - This option will show some information regarding to the user who requested the token
57 | * - crhc ts dump
58 | - Export the whole Inventory and Subscription information in json format. Some files will be created.
59 | * - crhc ts dump_current
60 | - Export the current Inventory and Subscription information in json format. Some files will be created.
61 | * - crhc ts match
62 | - If the files mentioned above are not around, this feature will call the dump and after that will check both files and will create the 3rd one with the whole information correlated accordingly.
63 | * - crhc ts clean
64 | - This will cleanup all the temporary/cache files.
65 | * - crhc {\-\-version|\-v}
66 | - This option will present the app version
67 | * - crhc {\-\-help|\-h}
68 | - This option will present the help
69 |
70 | Note. All of them will generate the output in a JSON format, so you can use the output as input for any of your own script or also to ``jq`` command.
71 |
72 |
--------------------------------------------------------------------------------
/crhc_cli/credential/token.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for the token feature
5 | """
6 |
7 | import os
8 | import json
9 | import sys
10 | # import datetime
11 | from time import time as timetime
12 | import jwt
13 | import requests
14 |
15 |
16 | # Conf file used to store the access_key and some additional information
17 | CONF_FILE = "/.crhc.conf"
18 |
19 |
20 | def set_token(token):
21 | """
22 | Responsible for receive the customer token and
23 | create the access_key via API request
24 | """
25 |
26 | token_url = "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token"
27 |
28 | body = {}
29 | body["client_id"] = "cloud-services"
30 | body["grant_type"] = "refresh_token"
31 | body["refresh_token"] = token
32 |
33 | refresh = requests.post(token_url, data=body)
34 | full_response = refresh.json()
35 | try:
36 | access_token = refresh.json()["access_token"]
37 | except KeyError:
38 | access_token = None
39 |
40 | # Testing the access and credentials
41 | url = "https://console.redhat.com/api/inventory/v1/hosts"
42 | response = requests.get(
43 | url, headers={"Authorization": "Bearer {}".format(access_token)}
44 | )
45 |
46 | if response.status_code == 200:
47 | print("Authenticated and ready to go!")
48 | else:
49 | print("Please, type again, wrong token")
50 | sys.exit()
51 |
52 | home_dir = os.path.expanduser("~")
53 | with open(home_dir + CONF_FILE, "w") as file_obj:
54 | file_obj.write(json.dumps(full_response, indent=4))
55 |
56 |
57 | def get_token():
58 | """
59 | Used to return the access_token, also, this is the definition responsible
60 | to check the expiration time, once the current time is == or >, the
61 | refresh call will be made.
62 | """
63 |
64 | home_dir = os.path.expanduser("~")
65 |
66 | # temporary workaround for when the file is not present and the script
67 | # is called.
68 | token_info = {}
69 |
70 | try:
71 | file_obj = open(home_dir + CONF_FILE, "r")
72 | token_info = json.load(file_obj)
73 | except FileNotFoundError:
74 | delete_token()
75 | except json.decoder.JSONDecodeError:
76 | delete_token()
77 |
78 | try:
79 | access_token = token_info["access_token"]
80 | except KeyError:
81 | access_token = "Error: Failed to create C.RH.C connection: Not logged in, \
82 | credentials aren't set, run the 'crhc login' command"
83 |
84 | try:
85 | # Using jwt to collect some information from the local token file
86 | exp_date_from_token = jwt.decode(
87 | access_token, options={"verify_signature": False}
88 | )["exp"]
89 | # current_time = datetime.datetime.now()
90 |
91 | # Modified to support MS Windows & Linux.
92 | # current_time_epoch = int(current_time.strftime('%s'))
93 | current_time_epoch = int(timetime())
94 |
95 | # Conditional to check if the token is expired. In case of
96 | # affirmative, the same will be refreshed.
97 |
98 | # Setting the incremental to 500 in oder to avoid issues when
99 | # executing the `ts dump`. It's working with no issues.
100 | if (current_time_epoch + 800) >= exp_date_from_token:
101 | refresh_token()
102 |
103 | except jwt.exceptions.DecodeError:
104 | ...
105 |
106 | return access_token
107 |
108 |
109 | def refresh_token():
110 | """
111 | Responsible for refresh the token and update the local file with the fresh
112 | information
113 | """
114 |
115 | home_dir = os.path.expanduser("~")
116 | file_obj = open(home_dir + CONF_FILE, "r")
117 | token_info = json.load(file_obj)
118 | refresh_tk = token_info["refresh_token"]
119 |
120 | token_url = "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token"
121 |
122 | body = {}
123 | body["client_id"] = "cloud-services"
124 | body["grant_type"] = "refresh_token"
125 | body["refresh_token"] = refresh_tk
126 |
127 | refresh = requests.post(token_url, data=body)
128 | full_response = refresh.json()
129 | try:
130 | access_token = refresh.json()["access_token"]
131 | except KeyError:
132 | access_token = "Error: Failed to create C.RH.C connection: Not logged in, \
133 | credentials aren't set, run the 'crhc login' command"
134 |
135 | home_dir = os.path.expanduser("~")
136 | with open(home_dir + CONF_FILE, "w") as file_obj:
137 | file_obj.write(json.dumps(full_response, indent=4))
138 |
139 | return access_token
140 |
141 |
142 | def delete_token():
143 | """
144 | Responsible for delete the local information from CONF_FILE
145 | """
146 |
147 | home_dir = os.path.expanduser("~")
148 | with open(home_dir + CONF_FILE, "w") as file_obj:
149 | file_obj.write("{}")
150 |
--------------------------------------------------------------------------------
/crhc_cli/help/help_opt.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for all the helps on crhc-cli app
5 | """
6 |
7 |
8 | def help_main_menu():
9 | """
10 | Main help menu
11 | """
12 | content = "\
13 | CRHC Command Line Tool\n\
14 | \n\
15 | Usage: \n\
16 | crhc [command]\n\
17 | \n\
18 | Available Commands:\n\
19 | inventory To list the Inventory data.\n\
20 | swatch To list the Subscription data.\n\
21 | advisor Retrieve Insights Information\n\
22 | patch Retrieve Patch Information\n\
23 | vulnerability Retrieve Vulnerability Information\n\
24 | ansible Retrieve Ansible Managed Host Information\n\
25 | endpoint To list all the available API endpoints on `console.redhat.com`\n\
26 | get To consume the API endpoint directly.\n\
27 | login To authenticate using your offline token.\n\
28 | logout To cleanup the local conf file, removing all the token information.\n\
29 | token To print the access_token. This can be used with `curl`, for example.\n\
30 | whoami To show some information regarding to the user who requested the token.\n\
31 | ts To execute some advanced options / Troubleshooting.\n\
32 | \n\
33 | Flags: \n\
34 | --version, -v This option will present the app version.\n\
35 | --help, -h This option will present the help.\n\
36 | "
37 |
38 | print(content)
39 | return content
40 |
41 |
42 | def help_inventory_menu():
43 | """
44 | Main inventory menu
45 | """
46 | content = "\
47 | Usage: \n\
48 | crhc inventory [command]\n\
49 | \n\
50 | Available Commands:\n\
51 | list List the inventory entries, first 50\n\
52 | list_all List all the inventory entries\n\
53 | display_name Please, type the FQDN or Partial Hostname\n\
54 | list_stale List all the machines in stale and stale_warning status\n\
55 | remove_stale Remove all the stale entries based on the # of days\n\
56 | \n\
57 | Flags: \n\
58 | --csv This will generate the output in CSV format. By default, it will be JSON.\
59 | "
60 | print(content)
61 | return content
62 |
63 |
64 | def help_swatch_menu():
65 | """
66 | Main subscription menu
67 | """
68 | content = "\
69 | Usage: \n\
70 | crhc swatch [command]\n\
71 | \n\
72 | Available Commands:\n\
73 | list List the swatch entries, first 100\n\
74 | list_all List all the swatch entries\n\
75 | socket_summary Print the socket summary\n\
76 | \n\
77 | Flags: \n\
78 | --csv This will generate the output in CSV format. By default, it will be JSON.\
79 | "
80 | print(content)
81 | return content
82 |
83 |
84 | def help_endpoint_menu():
85 | """
86 | Main endpoint menu
87 | """
88 | content = "\
89 | Usage: \n\
90 | crhc endpoint [command]\n\
91 | \n\
92 | Available Commands:\n\
93 | list List all the available endpoints\
94 | "
95 | print(content)
96 | return content
97 |
98 |
99 | def help_get_menu():
100 | """
101 | Main get menu
102 | """
103 | content = "\
104 | Usage: \n\
105 | crhc get [command]\n\
106 | \n\
107 | Available Commands:\n\
108 | get It will retrieve all the available methods\
109 | "
110 | print(content)
111 | return content
112 |
113 |
114 | def help_login_menu():
115 | """
116 | Main login menu
117 | """
118 | content = "\
119 | Usage: \n\
120 | crhc login [flags]\n\
121 | \n\
122 | Flags:\n\
123 | --token Setting the offline token in order to get access to the content.\n\
124 | \n\
125 | Info:\n\
126 | You can obtain a token at: https://console.redhat.com/openshift/token\n\
127 | \n\
128 | The command will be something similar to 'crhc login --token eyJhbGciOiJIUzI1NiIsIn...'\
129 | "
130 | print(content)
131 | return content
132 |
133 |
134 | def help_logout_menu():
135 | """
136 | Main logout menu
137 | """
138 | content = ""
139 | print(content)
140 | return content
141 |
142 |
143 | def help_whoami_menu():
144 | """
145 | Main whoami menu
146 | """
147 | content = ""
148 | print(content)
149 | return content
150 |
151 |
152 | def help_ts_menu():
153 | """
154 | Main ts/troubleshooting menu
155 | """
156 | content = "\
157 | Usage: \n\
158 | crhc ts [command]\n\
159 | \n\
160 | Available Commands:\n\
161 | dump dump the json files, Inventory and Subscription\n\
162 | dump_current dump the json files with current systems only, Inventory and Subscription\n\
163 | match match the Inventory and Subscription information\n\
164 | clean cleanup the local 'cache/temporary/dump' files\
165 | "
166 | print(content)
167 | return content
168 |
169 |
170 | def help_patch_menu():
171 | """
172 | Main patch menu
173 | """
174 | content = "\
175 | Usage: \n\
176 | crhc patch [command]\n\
177 | \n\
178 | Available Commands:\n\
179 | systems It will provide some patch information\n\
180 | \n\
181 | Flags:\n\
182 | --csv This will generate the output in CSV format. By default, it will be JSON.\
183 | "
184 | print(content)
185 | return content
186 |
187 |
188 | def help_vulnerability_menu():
189 | """
190 | Main vulnerability menu
191 | """
192 | content = "\
193 | Usage: \n\
194 | crhc vulnerability [command]\n\
195 | \n\
196 | Available Commands:\n\
197 | systems It will provide some vulnerability information\n\
198 | \n\
199 | Flags:\n\
200 | --csv This will generate the output in CSV format. By default, it will be JSON.\
201 | "
202 | print(content)
203 | return content
204 |
205 |
206 | def help_advisor_menu():
207 | """
208 | Main advisor menu
209 | """
210 | content = "\
211 | Usage: \n\
212 | crhc advisor [command]\n\
213 | \n\
214 | Available Commands:\n\
215 | systems It will provide some insights information\n\
216 | \n\
217 | Flags:\n\
218 | --csv This will generate the output in CSV format. By default, it will be JSON.\
219 | "
220 | print(content)
221 | return content
222 |
223 |
224 | def help_ansible_menu():
225 | """
226 | Main ansible menu
227 | """
228 | content = "\
229 | Usage: \n\
230 | crhc ansible [command]\n\
231 | \n\
232 | Available Commands:\n\
233 | unique_hosts It will provide the list of unique hosts managed by ansible automation platform\n\
234 | \n\
235 | "
236 | print(content)
237 | return content
238 |
--------------------------------------------------------------------------------
/docs/examples.rst:
--------------------------------------------------------------------------------
1 | Some Examples
2 | =============
3 |
4 | **Subscriptions Socket Summary**
5 |
6 | .. code-block::
7 |
8 | $ ./crhc swatch socket_summary
9 | Public Cloud ........: 14
10 | Virtualized RHEL ....: 2968
11 | Physical RHEL .......: 1306
12 | Hypervisors .........: 154
13 | ----------------------
14 | Total # of Sockets ..: 4444
15 |
16 | **API Queries**
17 |
18 | Querying the API, we can first check the available API endpoints using the command below
19 |
20 | .. code-block::
21 |
22 | $ ./crhc endpoint list
23 | {
24 | "services": [
25 | "/api/aiops-clustering",
26 | "/api/aiops-idle-cost-savings",
27 | ...
28 | "/api/inventory",
29 | ...
30 | "/api/rhsm",
31 | "/api/rhsm-subscriptions",
32 | "/api/ros",
33 | "/api/sources",
34 | "/api/subscriptions",
35 | "/api/system-baseline",
36 | "/api/topological-inventory",
37 | "/api/tower-analytics",
38 | "/api/upload",
39 | ...
40 | ]
41 | }
42 |
43 | In a sequence, we can check the API endpoint using the ``get`` option
44 |
45 | .. code-block::
46 |
47 | $ ./crhc.py get /api/inventory
48 | /api/inventory/v1/hosts
49 | /api/inventory/v1/hosts/checkin
50 | /api/inventory/v1/hosts/{host_id_list}
51 | /api/inventory/v1/hosts/{host_id_list}/facts/{namespace}
52 | /api/inventory/v1/hosts/{host_id_list}/system_profile
53 | /api/inventory/v1/hosts/{host_id_list}/tags
54 | /api/inventory/v1/hosts/{host_id_list}/tags/count
55 | /api/inventory/v1/system_profile/sap_sids
56 | /api/inventory/v1/system_profile/sap_system
57 | /api/inventory/v1/system_profile/validate_schema
58 | /api/inventory/v1/tags
59 |
60 | And after that, we can see all the available methods. From now, we can call them directly, for example
61 |
62 | .. code-block::
63 |
64 | $ ./crhc.py get /api/inventory/v1/hosts
65 | {
66 | "total": 6221,
67 | "count": 50,
68 | "page": 1,
69 | "per_page": 50,
70 | "results": [
71 | {
72 | "insights_id": "1f959a58-9e13-4d60-8cef-33a452d2303b",
73 | "bios_uuid": null,
74 | ...
75 |
76 | **Using the token with the curl command**
77 |
78 | .. code-block::
79 |
80 | $ curl -s -H "Authorization: Bearer $(./crhc token)" https://api.openshift.com/api/accounts_mgmt/v1/current_account | json_reformat
81 |
82 | **Exporting Inventory data to CSV**
83 |
84 | .. code-block::
85 |
86 | $ ./crhc inventory list_all --csv
87 |
88 | This should be enough to export the data and create the file ``/tmp/inventory_report.csv`` with some Inventory information. In a sequence you can see the fields
89 |
90 |
91 | * id
92 | * created
93 | * updated
94 | * stale_timestamp
95 | * stale_warning_timestamp
96 | * culled_timestamp
97 | * fqdn
98 | * display_name
99 | * ansible_host
100 | * cpu_model
101 | * number_of_cpus
102 | * number_of_sockets
103 | * core_socket
104 | * system_memory_bytes
105 | * bios_vendor
106 | * bios_version
107 | * bios_release_date
108 | * os_release
109 | * os_kernel_version
110 | * arch
111 | * last_boot_time
112 | * infrastructure_type
113 | * infrastructure_vendor
114 | * insights_client_version
115 | * created
116 | * insights_id
117 | * reporter
118 | * bios_uuid
119 | * tuned_profile
120 | * sap_system
121 | * sap_version
122 | * system_purpose_sla
123 | * system_purpose_role
124 | * system_purpose_usage
125 | * is_simple_content_access
126 | * installed_product
127 | * has_satellite_package
128 | * has_openshift_package
129 | * hypervisor_fqdn
130 | * hypervisor_uuid
131 | * number_of_guests
132 |
133 |
134 | **Exporting Subscription Watch data to CSV**
135 |
136 | .. code-block::
137 |
138 | $ ./crhc swatch list_all --csv
139 |
140 |
141 | This should be enough to export the data and create the file ``/tmp/swatch_report.csv`` with the whole Subscription Watch information. In a sequence you can see the fields
142 |
143 |
144 | * display_name
145 | * hardware_type
146 | * inventory_id
147 | * insights_id
148 | * is_hypervisor
149 | * number_of_guests
150 | * is_unmapped_guest
151 | * last_seen
152 | * measurement_type
153 | * sockets
154 | * cores
155 | * subscription_manager_id
156 | * cloud_provider
157 |
158 |
159 | **Analysing the Customer Data**
160 |
161 | Please, copy the files sent by the customer according to below. Let's assume the customer sent two files ``inventory.json`` and ``swatch.json``, once you received them, let's execute the commands below
162 |
163 | .. code-block::
164 |
165 | $ cp full_inventory.json /tmp/inventory.json
166 | $ cp full_swatch.json /tmp/swatch.json
167 |
168 |
169 | After that, you can execute the command ``crhc ts match`` and the output will be as below
170 |
171 | .. code-block::
172 |
173 | $ ./crhc ts match
174 | File /tmp/inventory.json already in place, using it.
175 | File /tmp/swatch.json already in place, using it.
176 | File /tmp/match_inv_sw.csv created
177 |
178 |
179 | Note. Once the files ``/tmp/inventory.json`` and ``/tmp/swatch.json`` are in place, they will be used for this analysis and as result, the file /tmp/match_inv_sw.csv will be created. This is the file that will be used for troubleshooting process.
180 |
181 |
182 | **ATTENTION**
183 |
184 | This is an awesome report because will combine both information from Inventory and Subscriptions in a single dataset. The final result will be the file ``/tmp/match_inv_sw.csv`` with the respective fields.
185 |
186 | * id
187 | * created
188 | * updated
189 | * stale_timestamp
190 | * stale_warning_timestamp
191 | * culled_timestamp
192 | * fqdn
193 | * display_name
194 | * ansible_host
195 | * cpu_model
196 | * number_of_cpus
197 | * number_of_sockets
198 | * core_socket
199 | * system_memory_bytes
200 | * bios_vendor
201 | * bios_version
202 | * bios_release_date
203 | * os_release
204 | * os_kernel_version
205 | * arch
206 | * last_boot_time
207 | * infrastructure_type
208 | * infrastructure_vendor
209 | * insights_client_version
210 | * created
211 | * insights_id
212 | * reporter
213 | * bios_uuid
214 | * tuned_profile
215 | * sap_system
216 | * sap_version
217 | * system_purpose_sla
218 | * system_purpose_role
219 | * system_purpose_usage
220 | * is_simple_content_access
221 | * installed_product
222 | * has_satellite_package
223 | * has_openshift_package
224 | * hypervisor_fqdn
225 | * hypervisor_uuid
226 | * number_of_guests
227 | * display_name
228 | * hardware_type
229 | * inventory_id
230 | * insights_id
231 | * is_hypervisor
232 | * number_of_guests
233 | * is_unmapped_guest
234 | * last_seen
235 | * measurement_type
236 | * sockets
237 | * cores
238 | * subscription_manager_id
239 | * cloud_provider
240 |
241 |
--------------------------------------------------------------------------------
/tests/test_help.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for test the help menu content
5 | """
6 |
7 | from crhc_cli.help import help_opt
8 |
9 |
10 | def test_check_main_help_menu():
11 | """
12 | Responsible for test the main help menu
13 | """
14 | response = help_opt.help_main_menu()
15 | content = "\
16 | CRHC Command Line Tool\n\
17 | \n\
18 | Usage: \n\
19 | crhc [command]\n\
20 | \n\
21 | Available Commands:\n\
22 | inventory To list the Inventory data.\n\
23 | swatch To list the Subscription data.\n\
24 | advisor Retrieve Insights Information\n\
25 | patch Retrieve Patch Information\n\
26 | vulnerability Retrieve Vulnerability Information\n\
27 | ansible Retrieve Ansible Managed Host Information\n\
28 | endpoint To list all the available API endpoints on `console.redhat.com`\n\
29 | get To consume the API endpoint directly.\n\
30 | login To authenticate using your offline token.\n\
31 | logout To cleanup the local conf file, removing all the token information.\n\
32 | token To print the access_token. This can be used with `curl`, for example.\n\
33 | whoami To show some information regarding to the user who requested the token.\n\
34 | ts To execute some advanced options / Troubleshooting.\n\
35 | \n\
36 | Flags: \n\
37 | --version, -v This option will present the app version.\n\
38 | --help, -h This option will present the help.\n\
39 | "
40 | assert response == content
41 |
42 |
43 | def test_check_inventory_help_menu():
44 | """
45 | Responsible for test the inventory help menu
46 | """
47 | response = help_opt.help_inventory_menu()
48 | content = "\
49 | Usage: \n\
50 | crhc inventory [command]\n\
51 | \n\
52 | Available Commands:\n\
53 | list List the inventory entries, first 50\n\
54 | list_all List all the inventory entries\n\
55 | display_name Please, type the FQDN or Partial Hostname\n\
56 | list_stale List all the machines in stale and stale_warning status\n\
57 | remove_stale Remove all the stale entries based on the # of days\n\
58 | \n\
59 | Flags: \n\
60 | --csv This will generate the output in CSV format. By default, it will be JSON.\
61 | "
62 | assert response == content
63 |
64 |
65 | def test_check_swatch_help_menu():
66 | """
67 | Responsible for test the subscription help menu
68 | """
69 | response = help_opt.help_swatch_menu()
70 | content = "\
71 | Usage: \n\
72 | crhc swatch [command]\n\
73 | \n\
74 | Available Commands:\n\
75 | list List the swatch entries, first 100\n\
76 | list_all List all the swatch entries\n\
77 | socket_summary Print the socket summary\n\
78 | \n\
79 | Flags: \n\
80 | --csv This will generate the output in CSV format. By default, it will be JSON.\
81 | "
82 | assert response == content
83 |
84 |
85 | def test_check_endpoint_help_menu():
86 | """
87 | Responsible for test the endpoint help menu
88 | """
89 | response = help_opt.help_endpoint_menu()
90 | content = "\
91 | Usage: \n\
92 | crhc endpoint [command]\n\
93 | \n\
94 | Available Commands:\n\
95 | list List all the available endpoints\
96 | "
97 | assert response == content
98 |
99 |
100 | def test_check_get_help_menu():
101 | """
102 | Responsible for test the get help menu
103 | """
104 | response = help_opt.help_get_menu()
105 | content = "\
106 | Usage: \n\
107 | crhc get [command]\n\
108 | \n\
109 | Available Commands:\n\
110 | get It will retrieve all the available methods\
111 | "
112 | assert response == content
113 |
114 |
115 | def test_check_login_help_menu():
116 | """
117 | Responsible for test the login help menu
118 | """
119 | response = help_opt.help_login_menu()
120 | content = "\
121 | Usage: \n\
122 | crhc login [flags]\n\
123 | \n\
124 | Flags:\n\
125 | --token Setting the offline token in order to get access to the content.\n\
126 | \n\
127 | Info:\n\
128 | You can obtain a token at: https://console.redhat.com/openshift/token\n\
129 | \n\
130 | The command will be something similar to 'crhc login --token eyJhbGciOiJIUzI1NiIsIn...'\
131 | "
132 | assert response == content
133 |
134 |
135 | def test_check_ts_help_menu():
136 | """
137 | Responsible for test the ts help menu
138 | """
139 | response = help_opt.help_ts_menu()
140 | content = "\
141 | Usage: \n\
142 | crhc ts [command]\n\
143 | \n\
144 | Available Commands:\n\
145 | dump dump the json files, Inventory and Subscription\n\
146 | dump_current dump the json files with current systems only, Inventory and Subscription\n\
147 | match match the Inventory and Subscription information\n\
148 | clean cleanup the local 'cache/temporary/dump' files\
149 | "
150 | assert response == content
151 |
152 |
153 | def test_check_patch_help_menu():
154 | """
155 | Responsible for test the patch help menu
156 | """
157 | response = help_opt.help_patch_menu()
158 | content = "\
159 | Usage: \n\
160 | crhc patch [command]\n\
161 | \n\
162 | Available Commands:\n\
163 | systems It will provide some patch information\n\
164 | \n\
165 | Flags:\n\
166 | --csv This will generate the output in CSV format. By default, it will be JSON.\
167 | "
168 | assert response == content
169 |
170 |
171 | def test_check_vulnerability_help_menu():
172 | """
173 | Responsible for test the patch help menu
174 | """
175 | response = help_opt.help_vulnerability_menu()
176 | content = "\
177 | Usage: \n\
178 | crhc vulnerability [command]\n\
179 | \n\
180 | Available Commands:\n\
181 | systems It will provide some vulnerability information\n\
182 | \n\
183 | Flags:\n\
184 | --csv This will generate the output in CSV format. By default, it will be JSON.\
185 | "
186 | assert response == content
187 |
188 |
189 | def test_check_advisor_help_menu():
190 | """
191 | Responsible for test the advisor help menu
192 | """
193 | response = help_opt.help_advisor_menu()
194 | content = "\
195 | Usage: \n\
196 | crhc advisor [command]\n\
197 | \n\
198 | Available Commands:\n\
199 | systems It will provide some insights information\n\
200 | \n\
201 | Flags:\n\
202 | --csv This will generate the output in CSV format. By default, it will be JSON.\
203 | "
204 | assert response == content
205 |
206 |
207 | def test_check_ansible_help_menu():
208 | """
209 | Responsible for test the advisor help menu
210 | """
211 | response = help_opt.help_ansible_menu()
212 | content = "\
213 | Usage: \n\
214 | crhc ansible [command]\n\
215 | \n\
216 | Available Commands:\n\
217 | unique_hosts It will provide the list of unique hosts managed by ansible automation platform\n\
218 | \n\
219 | "
220 | assert response == content
221 |
--------------------------------------------------------------------------------
/docs/changelog.rst:
--------------------------------------------------------------------------------
1 | Changelog
2 | ---------
3 |
4 | **v1.16.16 - 03/25/2024**
5 |
6 | - [FIX] Fixed ansible issue with max items in request - [`issue 228`_]
7 | - [ENHANCEMENT] New structure to be able to install it via pip - [`issue 229`_]
8 | - [FIX] Fixing the bios_uuid information - [`issue 233`_]
9 | - [ENHANCEMENT] added the feature to list all the stale and stale_warning - [`issue 232`_]
10 | - [ENHANCEMENT] remove stale feature updated - [`issue 236`_]
11 | - [FIX] Added the missing files - [`issue 238`_]
12 | - [FIX] Container file updated - [`issue 240`_]
13 |
14 | .. _issue 228: https://github.com/C-RH-C/crhc-cli/issues/228
15 | .. _issue 229: https://github.com/C-RH-C/crhc-cli/issues/229
16 | .. _issue 233: https://github.com/C-RH-C/crhc-cli/issues/233
17 | .. _issue 232: https://github.com/C-RH-C/crhc-cli/issues/232
18 | .. _issue 236: https://github.com/C-RH-C/crhc-cli/issues/236
19 | .. _issue 238: https://github.com/C-RH-C/crhc-cli/issues/238
20 | .. _issue 240: https://github.com/C-RH-C/crhc-cli/issues/240
21 |
22 |
23 |
24 | **v1.15.15 - 02/09/2024**
25 |
26 | - [FIX] items per page normalized across the items - [`issue 217`_]
27 | - [ENHANCEMENT] Fixed patch api to use v3, instead of v1 - [`issue 222`_]
28 | - [ENHANCEMENT] automated way to create the binary - [`issue 221`_]
29 | - [ENHANCEMENT] Updated the data in a way that the count will be possible - [`issue 215`_]
30 | - [FIX] requirement updated - [`issue 213`_]
31 |
32 | .. _issue 217: https://github.com/C-RH-C/crhc-cli/issues/217
33 | .. _issue 222: https://github.com/C-RH-C/crhc-cli/issues/222
34 | .. _issue 221: https://github.com/C-RH-C/crhc-cli/issues/221
35 | .. _issue 215: https://github.com/C-RH-C/crhc-cli/issues/215
36 | .. _issue 213: https://github.com/C-RH-C/crhc-cli/issues/213
37 |
38 |
39 | **v1.14.14 - 01/21/2024**
40 |
41 | - [FIX] Updating pyinstaller - [`issue 210`_]
42 | - [FIX] Fixing the socket_summary - [`issue 204`_]
43 | - [FIX] Report updated to fix the csv information and fields - [`issue 203`_]
44 | - [FIX] swatch error when pulling the information - [`issue 200`_]
45 | - [ENHANCEMENT] Fixed some issues presented by flake8. - [`issue 206`_]
46 | - [ENHANCEMENT] Update dependencies file - [`issue 191`_]
47 |
48 | .. _issue 210: https://github.com/C-RH-C/crhc-cli/issues/210
49 | .. _issue 204: https://github.com/C-RH-C/crhc-cli/issues/204
50 | .. _issue 203: https://github.com/C-RH-C/crhc-cli/issues/203
51 | .. _issue 200: https://github.com/C-RH-C/crhc-cli/issues/200
52 | .. _issue 206: https://github.com/C-RH-C/crhc-cli/issues/206
53 | .. _issue 191: https://github.com/C-RH-C/crhc-cli/issues/191
54 |
55 |
56 | **v1.13.13 - 09/06/2023**
57 |
58 | - [ENHANCEMENT] Ansible report feature added - [`issue 179`_]
59 | - [ENHANCEMENT] adding dump_current feature under ts menu - [`issue 184`_]
60 | - [FIX] Fixing the endpoint that was changed on console.redhat.com side - [`issue 188`_]
61 |
62 |
63 | .. _issue 179: https://github.com/C-RH-C/crhc-cli/issues/179
64 | .. _issue 184: https://github.com/C-RH-C/crhc-cli/issues/184
65 | .. _issue 188: https://github.com/C-RH-C/crhc-cli/issues/188
66 |
67 |
68 |
69 | **v1.12.12 - 06/23/2023**
70 |
71 | - [ENHANCEMENT] changed inventory_list_all to collect details in batches of 50 - [`issue 180`_]
72 |
73 | .. _issue 180: https://github.com/C-RH-C/crhc-cli/issues/180
74 |
75 |
76 |
77 | **v1.11.12 - 01/26/2023**
78 |
79 | - [ENHANCEMENT] Adding the new feature to remove stale entries based on the # of days - [`issue 24`_]
80 | - [FIX] Fixing the syspurpose issue - [`issue 168`_]
81 |
82 | .. _issue 168: https://github.com/C-RH-C/crhc-cli/issues/168
83 | .. _issue 24: https://github.com/C-RH-C/crhc-cli/issues/24
84 |
85 |
86 |
87 | **v1.10.11 - 08/16/2022**
88 |
89 | - [FIX] Ordering the inventory output, avoiding wrong information - [`issue 163`_]
90 | .. _issue 163: https://github.com/C-RH-C/crhc-cli/issues/163
91 |
92 |
93 |
94 | **v1.10.10 - 03/25/2022**
95 |
96 | - [ENHANCEMENT] Fixing linters warnings - [`issue 97`_]
97 | - [ENHANCEMENT] Updating end to end test - [`issue 156`_]
98 | - [FIX] #118 - Fixing the api endpoint list - [`issue 118`_]
99 | - [ENHANCEMENT] Removing the square brackets and single quotations marks from installed product - [`issue 152`_]
100 | - [FIX] fixing the kvm dup entries - [`issue 40`_]
101 |
102 | .. _issue 97: https://github.com/C-RH-C/crhc-cli/issues/97
103 | .. _issue 156: https://github.com/C-RH-C/crhc-cli/issues/156
104 | .. _issue 118: https://github.com/C-RH-C/crhc-cli/issues/118
105 | .. _issue 152: https://github.com/C-RH-C/crhc-cli/issues/152
106 | .. _issue 40: https://github.com/C-RH-C/crhc-cli/issues/40
107 |
108 |
109 |
110 | **v1.9.9 - 03/01/2022**
111 |
112 | - [FIX] Issue when exporting the advisory data - [`issue 149`_]
113 | - [FIX] test updated - [`issue 147`_]
114 | - [ENHANCEMENT] MS version added
115 | - [ENHANCEMENT] Total # of entries added to swatch list_all - [`issue 135`_]
116 | - [ENHANCEMENT] Fixed the time to check for a new version - [`issue 127`_]
117 | - [FIX] Fixing some issues when generating the ts dump - [`issue 136`_]
118 | - [ENHANCEMENT] Adding the GPL 3 license - [`issue 134`_]
119 | - [ENHANCEMENT] fix readme links
120 | - [ENHANCEMENT] some update in the documentation
121 | - [ENHANCEMENT] end to end test added
122 |
123 | .. _issue 149: https://github.com/C-RH-C/crhc-cli/issues/149
124 | .. _issue 147: https://github.com/C-RH-C/crhc-cli/issues/147
125 | .. _issue 135: https://github.com/C-RH-C/crhc-cli/issues/135
126 | .. _issue 127: https://github.com/C-RH-C/crhc-cli/issues/127
127 | .. _issue 136: https://github.com/C-RH-C/crhc-cli/issues/136
128 | .. _issue 134: https://github.com/C-RH-C/crhc-cli/pull/134
129 |
130 |
131 |
132 | **v1.8.8 - 11/06/2021**
133 |
134 | - [ENHANCEMENT] Docs updated and Feature page created - [`issue 125`_]
135 | - [FIX] fixed the messages even when with no token - [`issue 116`_] | [`issue 117`_]
136 | - [ENHANCEMENT] Advisor feature added - [`issue 121`_]
137 | - [ENHANCEMENT] Adding total in the json, dumping the patch and vuln in JSON and also doing some additional stuff - [`issue 108`_]
138 | - [ENHANCEMENT] Conf file added to the project - [`issue 114`_]
139 | - [ENHANCEMENT] Added vulnerability feature - [`issue 108`_]
140 | - [ENHANCEMENT] Adding the patch feature - [`issue 110`_]
141 | - [ENHANCEMENT] Fixed the api endpoint information when using get /api/patch - [`issue 109`_]
142 | - [FIX] requirements updated - [`issue 103`_]
143 | - [ENHANCEMENT] Sphinx configuration + readthedocs ready - [`issue 102`_]
144 |
145 | .. _issue 125: https://github.com/C-RH-C/crhc-cli/pull/125
146 | .. _issue 116: https://github.com/C-RH-C/crhc-cli/issues/116
147 | .. _issue 117: https://github.com/C-RH-C/crhc-cli/issues/117
148 | .. _issue 121: https://github.com/C-RH-C/crhc-cli/issues/121
149 | .. _issue 108: https://github.com/C-RH-C/crhc-cli/issues/108
150 | .. _issue 114: https://github.com/C-RH-C/crhc-cli/issues/114
151 | .. _issue 110: https://github.com/C-RH-C/crhc-cli/issues/110
152 | .. _issue 109: https://github.com/C-RH-C/crhc-cli/issues/109
153 | .. _issue 103: https://github.com/C-RH-C/crhc-cli/issues/103
154 | .. _issue 102: https://github.com/C-RH-C/crhc-cli/issues/102
155 |
156 |
157 |
158 | **v1.7.7 - 10/16/2021**
159 |
160 | - [ENHANCEMENT] issue_summary_created - [`issue 76`_]
161 | - [ENHANCEMENT] installed_product updated and some refactory - [`issue 81`_]
162 | - [ENHANCEMENT] Added the compress feature - [`issue 83`_]
163 | - [FIX] Fixing the message in inventory list_all - [`issue 87`_]
164 | - [ENHANCEMENT] Adding proxy information on readme.md - [`issue 88`_]
165 |
166 | .. _issue 76: https://github.com/C-RH-C/crhc-cli/issues/76
167 | .. _issue 81: https://github.com/C-RH-C/crhc-cli/issues/81
168 | .. _issue 83: https://github.com/C-RH-C/crhc-cli/issues/83
169 | .. _issue 87: https://github.com/C-RH-C/crhc-cli/issues/87
170 | .. _issue 88: https://github.com/C-RH-C/crhc-cli/issues/88
171 |
172 |
173 |
174 | **v1.6.6 - 10/12/2021**
175 |
176 | - [ENHANCEMENT] help redesigned and some tests added - [`issue 82`_]
177 | - [ENHANCEMENT] unit test - inventory_report - [`issue 82`_]
178 |
179 | .. _issue 82: https://github.com/C-RH-C/crhc-cli/issues/82
180 |
181 |
182 |
183 | **v1.5.6 - 10/03/2021**
184 |
185 | - [FIX] Fixed the correct # of pages and servers - [`issue 78`_]
186 |
187 | .. _issue 78: https://github.com/C-RH-C/crhc-cli/issues/78
188 |
189 |
190 |
191 | **v1.5.5 - 10/02/2021**
192 |
193 | - [ENHANCEMENT] Stale fields added - [`issue 68`_]
194 | - [ENHANCEMENT] Adding the # of guests on top of it - [`issue 65`_]
195 | - [ENHANCEMENT] Added the new 3 fields, 2 of system_purpose and one of sca - [`issue 69`_]
196 | - [FIX] Fixed issue with sw report - [`issue 64`_]
197 | - [FIX] Fixing some issues related to columns/positioning - [`issue 63`_]
198 | - [ENHANCEMENT] Checking the rhsm namespace for host-guest mapping - [`issue 61`_]
199 | - [FIX] fixing the issue for customers with less then 50 entries on crhc - [`issue 59`_]
200 |
201 | .. _issue 68: https://github.com/C-RH-C/crhc-cli/issues/68
202 | .. _issue 65: https://github.com/C-RH-C/crhc-cli/issues/65
203 | .. _issue 69: https://github.com/C-RH-C/crhc-cli/issues/69
204 | .. _issue 64: https://github.com/C-RH-C/crhc-cli/issues/64
205 | .. _issue 63: https://github.com/C-RH-C/crhc-cli/issues/63
206 | .. _issue 61: https://github.com/C-RH-C/crhc-cli/issues/61
207 | .. _issue 59: https://github.com/C-RH-C/crhc-cli/issues/59
208 |
209 |
210 |
211 | **v1.4.4 - 09/23/2021**
212 |
213 | - [FIX] Fixing the error caused by an empty conf file
214 | - [FIX] fixing a minor typo that is causing keyerror issue for the inventory list - short version
215 |
216 |
217 |
218 | **v1.4.3 - 09/11/2021**
219 |
220 | - [ENHANCEMENT] Adding the troubleshooting feature - dump json files for inventory
221 | - [ENHANCEMENT] Adding the troubleshooting feature - dump json files for subscriptions
222 | - [ENHANCEMENT] Adding the troubleshooting feature - cleaning the temporary/cache files
223 | - [ENHANCEMENT] Adding the version option
224 | - [FIX] Improving and fixing the Inventory report with some additional fields
225 | - [ENHANCEMENT] Adding the feature to load the 3rd party data and generate the match information to be used during the analysis/troubleshooting
226 | - [FIX] Improving the exception when the token gets revoked
227 |
228 |
229 |
230 | **v1.3.2 - 09/06/2021**
231 |
232 | - [FEATURE] --csv option added to the current inventory and swatch reports
233 | - [FEATURE] Checking for new releases based on the app version
234 | - [FIX] Fixing some KeyErrors when running the app
235 | - [FIX] Adding the cast for the field "sap_system" (when using the jq command)
236 | - [ENHANCEMENT] Disclaimer added
237 |
238 |
239 |
240 | **v1.2.1 - 08/31/2021**
241 |
242 | - [ENHANCEMENT] Inventory with some new information
243 | - [FEATURE] Authentication using Token
244 |
245 |
246 |
247 | **v1.1.0 08/25/2021**
248 |
249 | - [RFE] remove the sort keys in the JSON output
250 | - [FEATURE] Supporting all the minor versions of python 3 (3.6.8+) when creating the binary file
251 | - [FEATURE] # of sockets based on the swatch info - Summary
252 | - [FEATURE] List all the available API endpoints in console.redhat.com
253 | - [FEATURE] Way to query the API endpoint directly
254 |
255 |
256 |
257 | **v1.0.0 - 08/07/2021**
258 |
259 | - Initial idea and first piece of code! :)
260 |
--------------------------------------------------------------------------------
/crhc_cli/troubleshoot/ts.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for troublheshooting
5 | """
6 |
7 | # import csv
8 | import json
9 | import os
10 | from zipfile import ZipFile
11 | from crhc_cli.execution import execution
12 | from crhc_cli.report import report
13 | from crhc_cli.conf import conf
14 |
15 |
16 | def dump_inv_json(current_only):
17 | """
18 | Function to dump only Inventory information
19 | """
20 | # Checking if the connection still alive before printing sometihng
21 | if execution.check_authentication():
22 | print(
23 | "dumping the inventory information to '{}', this can take \
24 | some time to finish".format(
25 | conf.INV_JSON_FILE
26 | )
27 | )
28 | inventory = execution.inventory_list_all(current_only)
29 |
30 | file_obj = open(conf.INV_JSON_FILE, "w")
31 | file_obj.write(json.dumps(inventory, indent=4))
32 |
33 |
34 | def dump_sw_json(current_only):
35 | """
36 | Function to dump only Swatch information
37 | """
38 |
39 | print(
40 | "dumping the subscription information to '{}'".format(
41 | conf.SW_JSON_FILE
42 | )
43 | )
44 | swatch = execution.swatch_list_all(current_only)
45 |
46 | file_obj = open(conf.SW_JSON_FILE, "w")
47 | file_obj.write(json.dumps(swatch, indent=4))
48 |
49 |
50 | def dump_patch_json():
51 | """
52 | Function to dump only the Patch information
53 | """
54 |
55 | print(
56 | "dumping the patch information to '{}'".format(conf.PATCH_JSON_FILE)
57 | )
58 | patch = execution.patch_systems()
59 |
60 | file_obj = open(conf.PATCH_JSON_FILE, "w")
61 | file_obj.write(json.dumps(patch, indent=4))
62 |
63 |
64 | def dump_vulnerability_json():
65 | """
66 | Function to dump only the Vulnerability information
67 | """
68 |
69 | print(
70 | "dumping the vulnerability information to '{}'".format(
71 | conf.VULNERABILITY_JSON_FILE
72 | )
73 | )
74 | vulnerability = execution.vulnerability_systems()
75 |
76 | file_obj = open(conf.VULNERABILITY_JSON_FILE, "w")
77 | file_obj.write(json.dumps(vulnerability, indent=4))
78 |
79 |
80 | def dump_advisor_json():
81 | """
82 | Function to dump only the Advisor/Insights information
83 | """
84 |
85 | print(
86 | "dumping the advisor information to '{}'".format(
87 | conf.ADVISOR_JSON_FILE
88 | )
89 | )
90 | advisor = execution.advisor_systems()
91 |
92 | file_obj = open(conf.ADVISOR_JSON_FILE, "w")
93 | file_obj.write(json.dumps(advisor, indent=4))
94 |
95 |
96 | def compress_json_files():
97 | """
98 | Function to compress the JSON files in a zip format.
99 | At this moment working in Linux and MS Windows.
100 | """
101 |
102 | if os.path.isfile(conf.INV_JSON_FILE) and os.path.isfile(
103 | conf.SW_JSON_FILE
104 | ):
105 | with ZipFile(conf.ZIP_FILE, "w") as zip_obj:
106 | zip_obj.write(conf.INV_JSON_FILE)
107 | zip_obj.write(conf.SW_JSON_FILE)
108 | zip_obj.write(conf.PATCH_JSON_FILE)
109 | zip_obj.write(conf.VULNERABILITY_JSON_FILE)
110 | zip_obj.write(conf.ADVISOR_JSON_FILE)
111 |
112 | if os.path.isfile(conf.ZIP_FILE):
113 | print("File {} created.".format(conf.ZIP_FILE))
114 | else:
115 | print(
116 | "The file {} or {} is missing.".format(
117 | conf.INV_JSON_FILE, conf.SW_JSON_FILE
118 | )
119 | )
120 |
121 |
122 | def match_hbi_sw():
123 | """
124 | Function to cross both HBI and Swatch files and generate a single
125 | dataset that will be used for troubleshooting purposes.
126 | """
127 |
128 | final_lst = []
129 | stage_lst = []
130 |
131 | try:
132 | file_obj = open(conf.INV_JSON_FILE, "r")
133 | inventory = json.load(file_obj)
134 | print(
135 | "File {} already in place, using it.".format(conf.INV_JSON_FILE)
136 | )
137 | except FileNotFoundError:
138 | dump_inv_json(False)
139 | file_obj = open(conf.INV_JSON_FILE, "r")
140 | inventory = json.load(file_obj)
141 |
142 | try:
143 | file_obj = open(conf.SW_JSON_FILE, "r")
144 | swatch = json.load(file_obj)
145 | print("File {} already in place, using it.".format(conf.SW_JSON_FILE))
146 | except FileNotFoundError:
147 | dump_sw_json(False)
148 | file_obj = open(conf.SW_JSON_FILE, "r")
149 | swatch = json.load(file_obj)
150 |
151 | for inv_element in inventory["results"]:
152 | count = 0
153 | for sw_element in swatch["data"]:
154 | if inv_element["server"]["id"] == sw_element["instance_id"]:
155 | # Debug
156 | # if inv_element['server']['display_name'] == "FQDN.HERE":
157 | # print("HERE")
158 |
159 | # print("found it")
160 | # print("{},{}".format(inv_element,sw_element))
161 | stage_lst.append(inv_element)
162 | stage_lst.append(sw_element)
163 | final_lst.append(stage_lst)
164 | stage_lst = []
165 | count = count + 1
166 | if count == 0:
167 | stage_lst.append(inv_element)
168 | stage_lst.append("not in swatch")
169 | final_lst.append(stage_lst)
170 | stage_lst = []
171 |
172 | report.csv_match_report(final_lst)
173 | issue_summary_report(final_lst)
174 |
175 |
176 | def clean():
177 | """
178 | Function to cleanup all the local cache/temporary files
179 | """
180 |
181 | if os.path.exists(conf.INV_JSON_FILE):
182 | print("removing the file {}".format(conf.INV_JSON_FILE))
183 | os.remove(conf.INV_JSON_FILE)
184 |
185 | if os.path.exists(conf.SW_JSON_FILE):
186 | print("removing the file {}".format(conf.SW_JSON_FILE))
187 | os.remove(conf.SW_JSON_FILE)
188 |
189 | if os.path.exists(conf.MATCH_FILE):
190 | print("removing the file {}".format(conf.MATCH_FILE))
191 | os.remove(conf.MATCH_FILE)
192 |
193 | if os.path.exists(conf.PATCH_JSON_FILE):
194 | print("removing the file {}".format(conf.PATCH_JSON_FILE))
195 | os.remove(conf.PATCH_JSON_FILE)
196 |
197 | if os.path.exists(conf.VULNERABILITY_JSON_FILE):
198 | print("removing the file {}".format(conf.VULNERABILITY_JSON_FILE))
199 | os.remove(conf.VULNERABILITY_JSON_FILE)
200 |
201 | if os.path.exists(conf.ADVISOR_JSON_FILE):
202 | print("removing the file {}".format(conf.ADVISOR_JSON_FILE))
203 | os.remove(conf.ADVISOR_JSON_FILE)
204 |
205 |
206 | def organize_list_by_column(list_obj, col):
207 | """
208 | Responsible for organize the list according to the column.
209 | """
210 | return sorted(list_obj, key=lambda x: x[col])
211 |
212 |
213 | def issue_summary_report(final_lst):
214 | """
215 | Function to check everything that is wrong or not expected in
216 | Inventory and Subscriptions.
217 | """
218 |
219 | wrong_socket_inventory = []
220 | wrong_socket_subscription = []
221 | duplicate_fqdn = []
222 | duplicate_display_name = []
223 | different_fqdn_display_name = []
224 | server_with_no_socket_key = []
225 | installed_product_with_no_package_sat = []
226 | installed_product_with_no_package_cap = []
227 | installed_product_with_no_package_ocp = []
228 |
229 | for obj in final_lst:
230 | # Checking for 0 sockets in Inventory
231 | stage_lst = []
232 | try:
233 | if obj[0]["system_profile"]["number_of_sockets"] == 0:
234 | wrong_socket_inventory.append(obj)
235 | except KeyError:
236 | stage_lst.append(obj[0]["server"]["id"])
237 | stage_lst.append(obj[0]["server"]["fqdn"])
238 | stage_lst.append(obj[0]["server"]["display_name"])
239 | stage_lst.append(obj[0]["server"]["created"])
240 | stage_lst.append(obj[0]["server"]["updated"])
241 |
242 | server_with_no_socket_key.append(stage_lst)
243 | # Checking for 0 sockets in Subscription
244 | try:
245 | if obj[1]["sockets"] == 0:
246 | wrong_socket_subscription.append(obj)
247 | except TypeError as e:
248 | # print(e)
249 | ...
250 | except KeyError as e:
251 | # print(e)
252 | ...
253 |
254 | # Checking for duplicate FQDN
255 | fqdn = obj[0]["server"]["fqdn"]
256 | count = 0
257 | stage_lst = []
258 | for item in final_lst:
259 | if item[0]["server"]["fqdn"] == fqdn:
260 | stage_lst.append(obj[0]["server"]["id"])
261 | if obj[0]["server"]["fqdn"] is None:
262 | stage_lst.append("None")
263 | else:
264 | stage_lst.append(obj[0]["server"]["fqdn"])
265 | stage_lst.append(obj[0]["server"]["display_name"])
266 | stage_lst.append(obj[0]["server"]["created"])
267 | stage_lst.append(obj[0]["server"]["updated"])
268 | count = count + 1
269 |
270 | if count > 1:
271 | duplicate_fqdn.append(stage_lst)
272 |
273 | # Checking for duplicate display_name
274 | display_name = obj[0]["server"]["display_name"]
275 | count = 0
276 | stage_lst = []
277 | for item in final_lst:
278 | if item[0]["server"]["display_name"] == display_name:
279 | stage_lst.append(obj[0]["server"]["id"])
280 | stage_lst.append(obj[0]["server"]["fqdn"])
281 | if obj[0]["server"]["display_name"] is None:
282 | stage_lst.append("None")
283 | else:
284 | stage_lst.append(obj[0]["server"]["display_name"])
285 | stage_lst.append(obj[0]["server"]["created"])
286 | stage_lst.append(obj[0]["server"]["updated"])
287 | count = count + 1
288 |
289 | if count > 1:
290 | duplicate_display_name.append(stage_lst)
291 |
292 | # Checking for same server with different display_name and FQDN
293 | stage_lst = []
294 |
295 | fqdn = obj[0]["server"]["fqdn"]
296 | display_name = obj[0]["server"]["display_name"]
297 | if fqdn != display_name:
298 | stage_lst.append(obj[0]["server"]["id"])
299 | stage_lst.append(fqdn)
300 | stage_lst.append(display_name)
301 | stage_lst.append(obj[0]["server"]["created"])
302 | stage_lst.append(obj[0]["server"]["updated"])
303 |
304 | different_fqdn_display_name.append(stage_lst)
305 |
306 | # Checking if the 250, 269 or 209 pem file is present
307 | stage_lst = []
308 |
309 | # Checking for the installed_products
310 | installed_products_response = report.check_for_installed_products(
311 | obj[0]
312 | )
313 |
314 | # Checking for satellite packages
315 | installed_package_satellite_response = (
316 | report.check_for_satellite_package(obj[0])
317 | )
318 |
319 | # Checking for openshift packages
320 | installed_package_openshift_response = (
321 | report.check_for_openshift_package(obj[0])
322 | )
323 |
324 | if (
325 | "250" in installed_products_response
326 | and installed_package_satellite_response != "TRUE"
327 | ):
328 | stage_lst.append(obj[0]["server"]["id"])
329 | stage_lst.append(obj[0]["server"]["fqdn"])
330 | stage_lst.append(obj[0]["server"]["display_name"])
331 | stage_lst.append(installed_products_response)
332 | stage_lst.append(installed_package_satellite_response)
333 |
334 | installed_product_with_no_package_sat.append(stage_lst)
335 |
336 | if (
337 | "269" in installed_products_response
338 | and installed_package_satellite_response != "TRUE"
339 | ):
340 | stage_lst.append(obj[0]["server"]["id"])
341 | stage_lst.append(obj[0]["server"]["fqdn"])
342 | stage_lst.append(obj[0]["server"]["display_name"])
343 | stage_lst.append(installed_products_response)
344 | stage_lst.append(installed_package_satellite_response)
345 |
346 | installed_product_with_no_package_cap.append(stage_lst)
347 |
348 | if ("290" in installed_products_response) and (
349 | installed_package_openshift_response != "TRUE"
350 | ):
351 | stage_lst.append(obj[0]["server"]["id"])
352 | stage_lst.append(obj[0]["server"]["fqdn"])
353 | stage_lst.append(obj[0]["server"]["display_name"])
354 | stage_lst.append(installed_products_response)
355 | stage_lst.append(installed_package_openshift_response)
356 |
357 | installed_product_with_no_package_ocp.append(stage_lst)
358 |
359 | # Passing the list and also the column that will be
360 | # used to order (column #1 is the FQDN one)
361 | organized_duplicate_fqdn = organize_list_by_column(duplicate_fqdn, 1)
362 |
363 | # Passing the list and also the column that will
364 | # be used to order (column #2 is the Display Name one)
365 | organized_duplicate_display_name = organize_list_by_column(
366 | duplicate_display_name, 2
367 | )
368 |
369 | report.txt_issue_report(
370 | wrong_socket_inventory,
371 | wrong_socket_subscription,
372 | organized_duplicate_fqdn,
373 | organized_duplicate_display_name,
374 | different_fqdn_display_name,
375 | server_with_no_socket_key,
376 | installed_product_with_no_package_sat,
377 | installed_product_with_no_package_cap,
378 | installed_product_with_no_package_ocp,
379 | )
380 |
--------------------------------------------------------------------------------
/tests/end-to-end_crhc-cli_check.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Developer .: Waldirio M Pinheiro /
5 | # Date ......: 11/07/2021
6 | # Purpose ...: End to End test to check the crhc-cli app
7 | #
8 |
9 |
10 | CRHC="/tmp/crhc-cli/crhc.py"
11 |
12 | #
13 | # Please, create the file in your home directory called ".token" and with the content as below. Please,
14 | # update the token properly.
15 | #
16 | # TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCIg..."
17 | #
18 |
19 | source ~/.token
20 | DATE=$(date +%m-%d-%Y_%H:%M:%S)
21 | LOG="/tmp/crhc-system-test_$DATE.log"
22 | > $LOG
23 |
24 | check_packages()
25 | {
26 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Checking for python3 package" | tee -a $LOG
27 | check_python3=$(rpm -qa | grep ^python3 | wc -l)
28 | if [ $check_python3 == 0 ]; then
29 | echo "exiting ... please, install python3 package" | tee -a $LOG
30 | exit
31 | fi
32 |
33 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Checking for git package" | tee -a $LOG
34 | check_python3=$(rpm -qa | grep ^git | wc -l)
35 | if [ $check_python3 == 0 ]; then
36 | echo "exiting ... please, install git package" | tee -a $LOG
37 | exit
38 | fi
39 | }
40 |
41 | virtualenv()
42 | {
43 | if [ "$2" == "" ]; then
44 | url="https://github.com/C-RH-C/crhc-cli.git"
45 | else
46 | url=$2
47 | fi
48 |
49 | if [ -d /tmp/crhc-cli ]; then
50 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Removing current /tmp/crhc-cli dir ..." | tee -a $LOG
51 | rm -rf /tmp/crhc-cli | tee -a $LOG
52 | fi
53 |
54 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Cloning the crhc-cli repository: $url" | tee -a $LOG
55 | cd /tmp
56 | if [ "$1" <> " " ]; then
57 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Cloning the crhc-cli repository from branch '$1'" | tee -a $LOG
58 | git clone -b $1 $url
59 | if [ $? -ne 0 ]; then
60 | echo "something is wrong, probably the branch '$1' doesn't exist"
61 | echo "exiting ..."
62 | exit
63 | fi
64 | else
65 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Cloning the crhc-cli repository from origin" | tee -a $LOG
66 | git clone $url | tee -a $LOG
67 | fi
68 | cd crhc-cli
69 |
70 |
71 | if [ -d ~/.venv/crhc-cli ]; then
72 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Removing current venv dir ..." | tee -a $LOG
73 | rm -rf ~/.venv/crhc-cli | tee -a $LOG
74 | fi
75 |
76 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Creating the virtual env" | tee -a $LOG
77 | python3 -m venv ~/.venv/crhc-cli | tee -a $LOG
78 |
79 | if [ -d ~/.venv/crhc-cli ]; then
80 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Virtual environment created successfully" | tee -a $LOG
81 | fi
82 |
83 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Loading the Virtual Environment" | tee -a $LOG
84 | source ~/.venv/crhc-cli/bin/activate
85 |
86 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Installing the requirements" | tee -a $LOG
87 | ~/.venv/crhc-cli/bin/pip install --upgrade pip | tee -a $LOG
88 | ~/.venv/crhc-cli/bin/pip install -r requirements.txt | tee -a $LOG
89 | }
90 |
91 |
92 | inventory_def()
93 | {
94 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Inventory Pipeline" | tee -a $LOG
95 |
96 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory menu" | tee -a $LOG
97 | $CRHC inventory | tee -a $LOG
98 |
99 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory list" | tee -a $LOG
100 | $CRHC inventory list | tee -a $LOG
101 |
102 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory list_all" | tee -a $LOG
103 | $CRHC inventory list_all | tee -a $LOG
104 |
105 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory display_name" | tee -a $LOG
106 | $CRHC inventory display_name | tee -a $LOG
107 |
108 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory list --csv" | tee -a $LOG
109 | $CRHC inventory list --csv | tee -a $LOG
110 |
111 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory list_all --csv" | tee -a $LOG
112 | $CRHC inventory list_all --csv | tee -a $LOG
113 |
114 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory display_name esxi1" | tee -a $LOG
115 | $CRHC inventory display_name esxi1 | tee -a $LOG
116 |
117 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - inventory display_name esxi1 --csv" | tee -a $LOG
118 | $CRHC inventory display_name esxi1 --csv | tee -a $LOG
119 | }
120 |
121 | swatch_def()
122 | {
123 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Swatch Pipeline" | tee -a $LOG
124 |
125 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - swatch menu" | tee -a $LOG
126 | $CRHC swatch | tee -a $LOG
127 |
128 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - swatch list" | tee -a $LOG
129 | $CRHC swatch list | tee -a $LOG
130 |
131 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - swatch list_all" | tee -a $LOG
132 | $CRHC swatch list_all | tee -a $LOG
133 |
134 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - swatch list --csv" | tee -a $LOG
135 | $CRHC swatch list --csv | tee -a $LOG
136 |
137 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - swatch list_all --csv" | tee -a $LOG
138 | $CRHC swatch list_all --csv | tee -a $LOG
139 |
140 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - swatch socket_summary" | tee -a $LOG
141 | $CRHC swatch socket_summary | tee -a $LOG
142 | }
143 |
144 | patch_def()
145 | {
146 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Patch Pipeline" | tee -a $LOG
147 |
148 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - patch" | tee -a $LOG
149 | $CRHC patch | tee -a $LOG
150 |
151 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - patch systems" | tee -a $LOG
152 | $CRHC patch systems | tee -a $LOG
153 |
154 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - patch systems --csv" | tee -a $LOG
155 | $CRHC patch systems --csv | tee -a $LOG
156 | }
157 |
158 | vulnerability_def()
159 | {
160 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Vulnerability Pipeline" | tee -a $LOG
161 |
162 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - vulnerability" | tee -a $LOG
163 | $CRHC vulnerability | tee -a $LOG
164 |
165 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - vulnerability systems" | tee -a $LOG
166 | $CRHC vulnerability systems | tee -a $LOG
167 |
168 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - vulnerability systems --csv" | tee -a $LOG
169 | $CRHC vulnerability systems --csv | tee -a $LOG
170 | }
171 |
172 | advisor_def()
173 | {
174 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Advisor Pipeline" | tee -a $LOG
175 |
176 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - advisor" | tee -a $LOG
177 | $CRHC advisor | tee -a $LOG
178 |
179 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - advisor systems" | tee -a $LOG
180 | $CRHC advisor systems | tee -a $LOG
181 |
182 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - advisor systems --csv" | tee -a $LOG
183 | $CRHC advisor systems --csv | tee -a $LOG
184 | }
185 |
186 | ts_def()
187 | {
188 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Ts Pipeline" | tee -a $LOG
189 |
190 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ts menu" | tee -a $LOG
191 | $CRHC ts | tee -a $LOG
192 |
193 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ts dump" | tee -a $LOG
194 | $CRHC ts dump | tee -a $LOG
195 |
196 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ts match" | tee -a $LOG
197 | $CRHC ts match | tee -a $LOG
198 |
199 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ts match (files already in place)" | tee -a $LOG
200 | $CRHC ts match | tee -a $LOG
201 |
202 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ts clean" | tee -a $LOG
203 | $CRHC ts clean | tee -a $LOG
204 | }
205 |
206 |
207 | endpoint_def()
208 | {
209 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Endpoint Pipeline" | tee -a $LOG
210 |
211 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - endpoint list" | tee -a $LOG
212 | $CRHC endpoint list | tee -a $LOG
213 |
214 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - checking all the endpoint" | tee -a $LOG
215 | for b in $($CRHC endpoint list | grep \" | cut -d\" -f2 | sed '1d'); do echo - $b; $CRHC get $b; echo; done | tee -a $LOG
216 |
217 | #$CRHC get
218 | #$CRHC get
219 | #$CRHC login --token
220 | #$CRHC logout
221 | }
222 |
223 | binary_def()
224 | {
225 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Bynary Pipeline" | tee -a $LOG
226 |
227 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - generating the bynary version" | tee -a $LOG
228 | ~/.venv/crhc-cli/bin/pyinstaller --onefile $CRHC | tee -a $LOG
229 |
230 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ldd binary file" | tee -a $LOG
231 | ldd /tmp/crhc-cli/dist/crhc | tee -a $LOG
232 |
233 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - executing the binary file" | tee -a $LOG
234 | /tmp/crhc-cli/dist/crhc | tee -a $LOG
235 | }
236 |
237 | general_def()
238 | {
239 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - General Pipeline" | tee -a $LOG
240 |
241 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - token" | tee -a $LOG
242 | $CRHC token | tee -a $LOG
243 |
244 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - whoami" | tee -a $LOG
245 | $CRHC whoami | tee -a $LOG
246 |
247 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - '--version'" | tee -a $LOG
248 | $CRHC --version | tee -a $LOG
249 |
250 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - '-v'" | tee -a $LOG
251 | $CRHC -v | tee -a $LOG
252 |
253 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - '--help'" | tee -a $LOG
254 | $CRHC --help | tee -a $LOG
255 |
256 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - '-h'" | tee -a $LOG
257 | $CRHC -h | tee -a $LOG
258 | }
259 |
260 | logout_def()
261 | {
262 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Logout Pipeline" | tee -a $LOG
263 |
264 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Logout" | tee -a $LOG
265 | $CRHC logout | tee -a $LOG
266 | }
267 |
268 | login_def()
269 | {
270 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Login Pipeline" | tee -a $LOG
271 |
272 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - login with token" | tee -a $LOG
273 | $CRHC login --token $TOKEN | tee -a $LOG
274 | }
275 |
276 | pytest_def()
277 | {
278 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Pytest Pipeline" | tee -a $LOG
279 |
280 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - pytest -v" | tee -a $LOG
281 | pytest -v | tee -a $LOG
282 | }
283 |
284 |
285 |
286 |
287 | ## Main
288 | #
289 | # It starts from here
290 | #
291 |
292 |
293 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - STARTING" | tee -a $LOG
294 | if [ ! -f ~/.token ]; then
295 | echo "Please, create the file '~/.token' with the content as below. Update the token information properly, based on your own token"
296 | echo "TOKEN=\"eyJhbGciOiJIUzI1NiIsInR5cCIg...\""
297 | echo "exiting ..."
298 | exit
299 | fi
300 |
301 | check_packages
302 |
303 | if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "" ] ; then
304 | echo "##########################"
305 | echo "# crhc-cli End to End Test"
306 | echo "#-------------------------"
307 | echo "#"
308 | echo "# Flags:"
309 | echo "# -b "
310 | echo "#"
311 | echo "# -p "
312 | echo "#"
313 | echo "# -g "
314 | echo "#"
315 | echo "#"
316 | echo "# Pipeline Options:"
317 | echo "# 0 - inventory"
318 | echo "# 1 - swatch"
319 | echo "# 2 - patch"
320 | echo "# 3 - vulnerability"
321 | echo "# 4 - advisor"
322 | echo "# 5 - ts"
323 | echo "# 6 - endpoint"
324 | echo "# 7 - binary version"
325 | echo "# 8 - general"
326 | echo "# 9 - pytest"
327 | echo "#"
328 | echo "# 9999 - all together"
329 | echo "##########################"
330 | echo ""
331 | echo "e.g."
332 | echo ""
333 | echo " $ $0 -b fix_report -p 9 -g git@github.com:waldirio/crhc-cli.git"
334 | echo " or"
335 | echo " $ $0 -b fix_report -p 9 -g https://github.com/waldirio/crhc-cli.git"
336 | echo " or"
337 | echo " $ $0 -p 9"
338 | fi
339 |
340 |
341 |
342 |
343 | # Passing the branch and also the pipeline
344 | if [ "$1" == "-b" ] && [ "$3" == "-p" ] && [ "$5" == "-g" ]; then
345 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Passing the branch: $2,the pipeline: $4 and the repo: $6" | tee -a $LOG
346 | branch=$2
347 | pipeline=$4
348 | gitrepo=$6
349 | fi
350 |
351 | if [ "$1" == "-p" ]; then
352 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - Using the origin branch and the pipeline: $2" | tee -a $LOG
353 | pipeline=$2
354 | fi
355 |
356 | # It only will run once the tester pass the pipeline
357 | if [ $pipeline ]; then
358 | virtualenv $branch $gitrepo
359 | fi
360 |
361 | case $pipeline in
362 | '0') #echo "inventory"
363 | logout_def
364 | inventory_def
365 |
366 | login_def
367 | inventory_def
368 | ;;
369 | '1') #echo "swatch"
370 | logout_def
371 | swatch_def
372 |
373 | login_def
374 | swatch_def
375 | ;;
376 | '2') #echo "patch"
377 | logout_def
378 | patch_def
379 |
380 | login_def
381 | patch_def
382 | ;;
383 | '3') #echo "vulnerability"
384 | logout_def
385 | vulnerability_def
386 |
387 | login_def
388 | vulnerability_def
389 | ;;
390 | '4') #echo "advisor"
391 | logout_def
392 | advisor_def
393 |
394 | login_def
395 | advisor_def
396 | ;;
397 | '5') #echo "ts"
398 | logout_def
399 | ts_def
400 |
401 | login_def
402 | ts_def
403 | ;;
404 | '6') #echo "ts"
405 | logout_def
406 | endpoint_def
407 |
408 | login_def
409 | endpoint_def
410 | ;;
411 | '7') #echo "ts"
412 | logout_def
413 | binary_def
414 |
415 | login_def
416 | binary_def
417 | ;;
418 | '8') #echo "ts"
419 | logout_def
420 | general_def
421 |
422 | login_def
423 | general_def
424 | ;;
425 | '9') #echo "ts"
426 | logout_def
427 | pytest_def
428 |
429 | login_def
430 | pytest_def
431 | ;;
432 | '9999') #echo "all"
433 | logout_def
434 | inventory_def
435 | swatch_def
436 | patch_def
437 | vulnerability_def
438 | advisor_def
439 | ts_def
440 | pytest_def
441 |
442 | login_def
443 | inventory_def
444 | swatch_def
445 | patch_def
446 | vulnerability_def
447 | advisor_def
448 | ts_def
449 | pytest_def
450 | ;;
451 | '*') echo "Please, inform a valid pipeline, exiting ...."
452 | ;;
453 | esac
454 |
455 | echo "## $(date +%m-%d-%Y_%H:%M:%S) - ENDING" | tee -a $LOG
456 |
--------------------------------------------------------------------------------
/crhc_cli/parse/parse.py:
--------------------------------------------------------------------------------
1 | """
2 | .. code-block:: text
3 |
4 | Module responsible for the main menu
5 | """
6 |
7 | import sys
8 | import json
9 | from crhc_cli.conf import conf
10 | from crhc_cli.execution import execution
11 | from crhc_cli.report import report
12 | from crhc_cli.credential import token
13 | from crhc_cli.troubleshoot import ts
14 | from crhc_cli.help import help_opt
15 |
16 | access_token = token.get_token()
17 |
18 |
19 | def inventory_sub_menu():
20 | """
21 | The inventory sub menu
22 | """
23 |
24 | # To present the available options
25 | if len(sys.argv) == 2:
26 | # Passing only inventory, the help menu will be presented.
27 | help_opt.help_inventory_menu()
28 |
29 | if len(sys.argv) == 3:
30 |
31 | # To print in JSON format
32 | try:
33 | if (sys.argv[1] == "inventory") and (sys.argv[2] == "list"):
34 | # execution.inventory_list()
35 | response = execution.inventory_list()
36 | # print(response)
37 | print(json.dumps(response, indent=4))
38 | sys.exit()
39 | except IndexError as e:
40 | # print("Error: {}".format(e))
41 | ...
42 |
43 | # To print in JSON format
44 | try:
45 | if (sys.argv[1] == "inventory") and (sys.argv[2] == "list_all"):
46 | # print("This process can spend some minutes according to the
47 | # number of servers in your account.")
48 | response = execution.inventory_list_all()
49 | print(json.dumps(response, indent=4))
50 | sys.exit()
51 | except IndexError as e:
52 | # print("Error: {}".format(e))
53 | ...
54 |
55 | # To print in JSON format
56 | try:
57 | if (sys.argv[1] == "inventory") and (
58 | sys.argv[2] == "display_name"
59 | ):
60 |
61 | if len(sys.argv) == 3:
62 | print(
63 | "Please, pass the FQDN or Partial FQDN to display_name, \
64 | for example 'crhc inventory display_name virt-who-esxi'"
65 | )
66 | sys.exit()
67 | fqdn = sys.argv[3]
68 | response = execution.inventory_list_search_by_name(fqdn)
69 | print(json.dumps(response, indent=4))
70 | sys.exit()
71 | except IndexError as e:
72 | # print("Error: {}".format(e))
73 | ...
74 |
75 | # To print in JSON format
76 | try:
77 | if (sys.argv[1] == "inventory") and (sys.argv[2] == "list_stale"):
78 | response = execution.inventory_list_stale()
79 | print(json.dumps(response, indent=4))
80 | sys.exit()
81 | except IndexError as e:
82 | # print("Error: {}".format(e))
83 | ...
84 |
85 |
86 | # To print in JSON format
87 | try:
88 | if (sys.argv[1] == "inventory") and (sys.argv[2] == "remove_stale"):
89 | response = execution.inventory_remove_stale()
90 | sys.exit()
91 | except IndexError as e:
92 | # print("Error: {}".format(e))
93 | ...
94 |
95 | # To print in JSON format
96 | if len(sys.argv) == 4 and (sys.argv[2]) == "display_name":
97 | try:
98 | if (sys.argv[1] == "inventory") and (
99 | sys.argv[2] == "display_name"
100 | ):
101 |
102 | if len(sys.argv) == 3:
103 | print(
104 | "Please, pass the FQDN or Partial FQDN to display_name, \
105 | for example 'crhc inventory display_name virt-who-esxi'"
106 | )
107 | sys.exit()
108 | fqdn = sys.argv[3]
109 | response = execution.inventory_list_search_by_name(fqdn)
110 | print(json.dumps(response, indent=4))
111 | sys.exit()
112 | except IndexError as e:
113 | # print("Error: {}".format(e))
114 | ...
115 |
116 | # To print in CSV format
117 | if (
118 | len(sys.argv) == 5
119 | and (sys.argv[2]) == "display_name"
120 | and (sys.argv[4]) == "--csv"
121 | ):
122 | try:
123 | if (sys.argv[1] == "inventory") and (
124 | sys.argv[2] == "display_name"
125 | ):
126 |
127 | if len(sys.argv) == 3:
128 | print(
129 | "Please, pass the FQDN or Partial FQDN to display_name, \
130 | for example 'crhc inventory display_name virt-who-esxi'"
131 | )
132 | sys.exit()
133 | fqdn = sys.argv[3]
134 | response = execution.inventory_list_search_by_name(fqdn)
135 | report.csv_report_inventory(response)
136 | sys.exit()
137 | except IndexError as e:
138 | # print("Error: {}".format(e))
139 | ...
140 |
141 | if len(sys.argv) == 4 and (sys.argv[3]) == "--help":
142 | print(" --csv - List the inventory entries in CSV format")
143 |
144 | if len(sys.argv) == 4:
145 |
146 | # To print in CSV format
147 | try:
148 | if (
149 | (sys.argv[1] == "inventory")
150 | and (sys.argv[2] == "list")
151 | and (sys.argv[3] == "--csv")
152 | ):
153 | # execution.inventory_list()
154 | response = execution.inventory_list()
155 | report.csv_report_inventory(response)
156 | sys.exit()
157 | except IndexError as e:
158 | # print("Error: {}".format(e))
159 | ...
160 |
161 | # To print in CSV format
162 | try:
163 | if (
164 | (sys.argv[1] == "inventory")
165 | and (sys.argv[2] == "list_all")
166 | and (sys.argv[3] == "--csv")
167 | ):
168 | # Checking if the connection still alive before
169 | # printing sometihng
170 | if execution.check_authentication():
171 | print(
172 | "This process can spend some minutes according to \
173 | the number of servers in your account."
174 | )
175 | response = execution.inventory_list_all()
176 | report.csv_report_inventory(response)
177 | sys.exit()
178 | except IndexError as e:
179 | # print("Error: {}".format(e))
180 | ...
181 |
182 | # To print in CSV format
183 | try:
184 | if (
185 | (sys.argv[1] == "inventory")
186 | and (sys.argv[2] == "display_name")
187 | and (sys.argv[4] == "--csv")
188 | ):
189 | # execution.inventory_list()
190 | response = execution.inventory_list_search_by_name()
191 | report.csv_report_inventory(response)
192 | sys.exit()
193 | except IndexError as e:
194 | # print("Error: {}".format(e))
195 | ...
196 |
197 | # To print in CSV format
198 | try:
199 | if (
200 | (sys.argv[1] == "inventory")
201 | and (sys.argv[2] == "list_stale")
202 | and (sys.argv[3] == "--csv")
203 | ):
204 | # Checking if the connection still alive before
205 | # printing sometihng
206 | if execution.check_authentication():
207 | print(
208 | "This process can spend some minutes according to \
209 | the number of servers in your account."
210 | )
211 | response = execution.inventory_list_stale()
212 | report.csv_report_inventory(response)
213 | sys.exit()
214 | except IndexError as e:
215 | # print("Error: {}".format(e))
216 | ...
217 |
218 |
219 | def swatch_sub_menu():
220 | """
221 | The Subscription Watch sub menu
222 | """
223 |
224 | # To present the available options
225 | if len(sys.argv) == 2:
226 | # Passing only swatch, the help menu will be presented.
227 | help_opt.help_swatch_menu()
228 |
229 | if len(sys.argv) == 3:
230 |
231 | # To print in JSON format
232 | try:
233 | if (sys.argv[1] == "swatch") and (sys.argv[2] == "list"):
234 | response = execution.swatch_list()
235 | print(json.dumps(response, indent=4))
236 |
237 | sys.exit()
238 | except IndexError as e:
239 | # print("Error: {}".format(e))
240 | ...
241 |
242 | # To print in JSON format
243 | try:
244 | if (sys.argv[1] == "swatch") and (sys.argv[2] == "list_all"):
245 | response = execution.swatch_list_all()
246 | print(json.dumps(response, indent=4))
247 | sys.exit()
248 | except IndexError as e:
249 | # print("Error: {}".format(e))
250 | ...
251 |
252 | # To print in JSON format
253 | try:
254 | if (sys.argv[1] == "swatch") and (sys.argv[2] == "socket_summary"):
255 | execution.swatch_socket_summary()
256 | sys.exit()
257 | except IndexError as e:
258 | # print("Error: {}".format(e))
259 | ...
260 |
261 | if len(sys.argv) == 4 and (sys.argv[3]) == "--help":
262 | print(" --csv - List the swatch entries in CSV format")
263 |
264 | if len(sys.argv) == 4:
265 |
266 | # To print in CSV format
267 | try:
268 | if (
269 | (sys.argv[1] == "swatch")
270 | and (sys.argv[2] == "list")
271 | and (sys.argv[3] == "--csv")
272 | ):
273 | response = execution.swatch_list()
274 | report.csv_report_swatch(response)
275 |
276 | sys.exit()
277 | except IndexError as e:
278 | # print("Error: {}".format(e))
279 | ...
280 |
281 | # To print in CSV format
282 | try:
283 | if (
284 | (sys.argv[1] == "swatch")
285 | and (sys.argv[2] == "list_all")
286 | and (sys.argv[3] == "--csv")
287 | ):
288 | response = execution.swatch_list_all()
289 | report.csv_report_swatch(response)
290 | sys.exit()
291 | except IndexError as e:
292 | # print("Error: {}".format(e))
293 | ...
294 |
295 |
296 | def endpoint_sub_menu():
297 | """
298 | The endpoint sub menu
299 | """
300 |
301 | # To present the available options
302 | if len(sys.argv) == 2:
303 | # Passing only endpoint, the help menu will be presented.
304 | help_opt.help_endpoint_menu()
305 |
306 | try:
307 | if (sys.argv[1] == "endpoint") and (sys.argv[2] == "list"):
308 | response = execution.endpoint_list()
309 | print(json.dumps(response, indent=4))
310 | sys.exit()
311 | except IndexError as e:
312 | # print("Error: {}".format(e))
313 | ...
314 |
315 |
316 | def patch_sub_menu():
317 | """
318 | The patch sub menu
319 | """
320 |
321 | # To present the available options
322 | if len(sys.argv) == 2:
323 | # Passing only swatch, the help menu will be presented.
324 | help_opt.help_patch_menu()
325 |
326 | if len(sys.argv) == 3:
327 |
328 | # To print in JSON format
329 | try:
330 | if (sys.argv[1] == "patch") and (sys.argv[2] == "systems"):
331 | response = execution.patch_systems()
332 | print(json.dumps(response, indent=4))
333 | sys.exit()
334 | except IndexError as e:
335 | # print("Error: {}".format(e))
336 | ...
337 |
338 | if len(sys.argv) == 4 and (
339 | (sys.argv[3]) == "--help" or (sys.argv[3]) == "-h"
340 | ):
341 | help_opt.help_patch_menu()
342 |
343 | if len(sys.argv) == 4:
344 |
345 | # To print in CSV format
346 | try:
347 | if (
348 | (sys.argv[1] == "patch")
349 | and (sys.argv[2] == "systems")
350 | and (sys.argv[3] == "--csv")
351 | ):
352 | response = execution.patch_systems()
353 | report.csv_report_patch(response)
354 |
355 | sys.exit()
356 | except IndexError as e:
357 | # print("Error: {}".format(e))
358 | ...
359 |
360 |
361 | def vulnerability_sub_menu():
362 | """
363 | The vulnerability sub menu
364 | """
365 |
366 | # To present the available options
367 | if len(sys.argv) == 2:
368 | # Passing only swatch, the help menu will be presented.
369 | help_opt.help_vulnerability_menu()
370 |
371 | if len(sys.argv) == 3:
372 |
373 | # To print in JSON format
374 | try:
375 | if (sys.argv[1] == "vulnerability") and (sys.argv[2] == "systems"):
376 | response = execution.vulnerability_systems()
377 | print(json.dumps(response, indent=4))
378 | sys.exit()
379 | except IndexError as e:
380 | # print("Error: {}".format(e))
381 | ...
382 |
383 | if len(sys.argv) == 4 and (
384 | (sys.argv[3]) == "--help" or (sys.argv[3]) == "-h"
385 | ):
386 | help_opt.help_vulnerability_menu()
387 |
388 | if len(sys.argv) == 4:
389 |
390 | # To print in CSV format
391 | try:
392 | if (
393 | (sys.argv[1] == "vulnerability")
394 | and (sys.argv[2] == "systems")
395 | and (sys.argv[3] == "--csv")
396 | ):
397 | response = execution.vulnerability_systems()
398 | report.csv_report_vulnerability(response)
399 |
400 | sys.exit()
401 | except IndexError as e:
402 | # print("Error: {}".format(e))
403 | ...
404 |
405 |
406 | def advisor_sub_menu():
407 | """
408 | The advisor/insights sub menu
409 | """
410 |
411 | # To present the available options
412 | if len(sys.argv) == 2:
413 | # Passing only swatch, the help menu will be presented.
414 | help_opt.help_advisor_menu()
415 |
416 | if len(sys.argv) == 3:
417 |
418 | # To print in JSON format
419 | try:
420 | if (sys.argv[1] == "advisor") and (sys.argv[2] == "systems"):
421 | response = execution.advisor_systems()
422 | print(json.dumps(response, indent=4))
423 | sys.exit()
424 | except IndexError as e:
425 | # print("Error: {}".format(e))
426 | ...
427 |
428 | if len(sys.argv) == 4 and (
429 | (sys.argv[3]) == "--help" or (sys.argv[3]) == "-h"
430 | ):
431 | help_opt.help_advisor_menu()
432 |
433 | if len(sys.argv) == 4:
434 |
435 | # To print in CSV format
436 | try:
437 | if (
438 | (sys.argv[1] == "advisor")
439 | and (sys.argv[2] == "systems")
440 | and (sys.argv[3] == "--csv")
441 | ):
442 | response = execution.advisor_systems()
443 | report.csv_report_advisor(response)
444 |
445 | sys.exit()
446 | except IndexError as e:
447 | # print("Error: {}".format(e))
448 | ...
449 |
450 |
451 | def get_sub_menu():
452 | """
453 | The get sub menu
454 | """
455 |
456 | # To present the available options
457 | if len(sys.argv) == 2:
458 | # Passing only the get, the help menu will be presented.
459 | help_opt.help_get_menu()
460 |
461 | try:
462 | if (sys.argv[1] == "get") and (sys.argv[2]):
463 | response = execution.get_command(sys.argv[2])
464 | if response:
465 | print(json.dumps(response, indent=4))
466 | sys.exit()
467 | except IndexError as e:
468 | # print("Error: {}".format(e))
469 | ...
470 |
471 |
472 | def login_sub_menu():
473 | """
474 | Function responsible for pass the token and create the
475 | necessary configuration file that will be used from this point.
476 | """
477 |
478 | # To present the available options
479 | if len(sys.argv) == 2:
480 | # Passing only login, the help menu will be presented.
481 | help_opt.help_login_menu()
482 |
483 | try:
484 | if (sys.argv[1] == "login") and (sys.argv[2] == "--token"):
485 | secret = sys.argv[3]
486 | token.set_token(secret)
487 | sys.exit()
488 | except IndexError as e:
489 | # print("Error: {}".format(e))
490 | ...
491 |
492 |
493 | def logout_sub_menu():
494 | """
495 | Function responsile for remove all the content from the .conf file.
496 | This will remove all the current information available in the local
497 | machine.
498 | """
499 | try:
500 | if sys.argv[1] == "logout":
501 | token.delete_token()
502 | sys.exit()
503 | except IndexError as e:
504 | # print("Error: {}".format(e))
505 | ...
506 |
507 |
508 | def token_sub_menu():
509 | """
510 | Here you can see the full access_key and use it in order to access
511 | the API endpoint, for example
512 | """
513 | try:
514 | if sys.argv[1] == "token":
515 | print(token.get_token())
516 | sys.exit()
517 | except IndexError as e:
518 | # print("Error: {}".format(e))
519 | ...
520 |
521 |
522 | def whoami_sub_menu():
523 | """
524 | Retrieving the user information from c.rh.c API endpoint
525 | """
526 | try:
527 | if sys.argv[1] == "whoami":
528 | response = execution.whoami()
529 | if response:
530 | print(json.dumps(response, indent=4))
531 |
532 | sys.exit()
533 | except IndexError as e:
534 | # print("Error: {}".format(e))
535 | ...
536 |
537 |
538 | def ansible_sub_menu():
539 |
540 | if len(sys.argv) == 2:
541 | # Passing only ansible, the help menu will be presented.
542 | help_opt.help_ansible_menu()
543 |
544 | """
545 | Retrieving the ansible managed host information from c.rh.c API endpoint
546 | """
547 | try:
548 | if (sys.argv[1] == "ansible") and (sys.argv[2] == "unique_hosts"):
549 | response = execution.get_ansible_unique_hosts()
550 | print(json.dumps(response, indent=4))
551 | sys.exit()
552 | except IndexError as e:
553 | # print("Error: {}".format(e))
554 | ...
555 |
556 |
557 | def troubleshoot_sub_menu():
558 | """
559 | The troubleshooting sub menu
560 | """
561 |
562 | # To present the available options
563 | if len(sys.argv) == 2:
564 | # Passing only ts, the help menu will be presented.
565 | help_opt.help_ts_menu()
566 |
567 | try:
568 | if (sys.argv[1] == "ts") and (sys.argv[2] == "dump"):
569 | ts.dump_inv_json(False)
570 | ts.dump_sw_json(False)
571 | ts.dump_patch_json()
572 | ts.dump_vulnerability_json()
573 | ts.dump_advisor_json()
574 | ts.compress_json_files()
575 | sys.exit()
576 | except IndexError as e:
577 | # print("Error1: {}".format(e))
578 | ...
579 |
580 | try:
581 | if (sys.argv[1] == "ts") and (sys.argv[2] == "dump_current"):
582 | ts.dump_inv_json(True)
583 | ts.dump_sw_json(True)
584 | ts.dump_patch_json()
585 | ts.dump_vulnerability_json()
586 | ts.dump_advisor_json()
587 | ts.compress_json_files()
588 | sys.exit()
589 | except IndexError as e:
590 | # print("Error1: {}".format(e))
591 | ...
592 |
593 | try:
594 | if (sys.argv[1] == "ts") and (sys.argv[2] == "match"):
595 | ts.match_hbi_sw()
596 | sys.exit()
597 | except IndexError as e:
598 | # print("Error: {}".format(e))
599 | ...
600 |
601 | try:
602 | if (sys.argv[1] == "ts") and (sys.argv[2] == "clean"):
603 | ts.clean()
604 | sys.exit()
605 | except IndexError as e:
606 | # print("Error: {}".format(e))
607 | ...
608 |
609 |
610 | def update_check():
611 | """
612 | Function to check the app version according to the latest available version
613 | in GitHub
614 | """
615 | return execution.update_check()
616 |
617 |
618 | def troubleshoot():
619 | """
620 | Function to call the troubleshoot submenu
621 | """
622 | troubleshoot_sub_menu()
623 |
624 |
625 | def main_menu():
626 | """
627 | The Main menu
628 | """
629 |
630 | if len(sys.argv) > 1:
631 | if sys.argv[1] == "inventory":
632 | try:
633 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
634 | help_opt.help_inventory_menu()
635 | sys.exit()
636 | except IndexError:
637 | ...
638 |
639 | # print("inventory")
640 | inventory_sub_menu()
641 |
642 | elif sys.argv[1] == "swatch":
643 | try:
644 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
645 | help_opt.help_swatch_menu()
646 | sys.exit()
647 | except IndexError as e:
648 | # print("Error: {}".format(e))
649 | ...
650 |
651 | # print("swatch")
652 | swatch_sub_menu()
653 |
654 | elif sys.argv[1] == "endpoint":
655 | try:
656 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
657 | help_opt.help_endpoint_menu()
658 | sys.exit()
659 | except IndexError as e:
660 | # print("Error: {}".format(e))
661 | ...
662 |
663 | # print("swatch")
664 | endpoint_sub_menu()
665 |
666 | elif sys.argv[1] == "patch":
667 | try:
668 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
669 | help_opt.help_patch_menu()
670 | sys.exit()
671 | except IndexError as e:
672 | # print("Error: {}".format(e))
673 | ...
674 |
675 | # print("swatch")
676 | patch_sub_menu()
677 |
678 | elif sys.argv[1] == "vulnerability":
679 | try:
680 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
681 | help_opt.help_vulnerability_menu()
682 | sys.exit()
683 | except IndexError as e:
684 | # print("Error: {}".format(e))
685 | ...
686 |
687 | # print("swatch")
688 | vulnerability_sub_menu()
689 |
690 | elif sys.argv[1] == "advisor":
691 | try:
692 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
693 | help_opt.help_advisor_menu()
694 | sys.exit()
695 | except IndexError as e:
696 | # print("Error: {}".format(e))
697 | ...
698 |
699 | # print("swatch")
700 | advisor_sub_menu()
701 |
702 | elif sys.argv[1] == "get":
703 | try:
704 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
705 | help_opt.help_get_menu()
706 | sys.exit()
707 | except IndexError as e:
708 | # print("Error: {}".format(e))
709 | ...
710 |
711 | # print("swatch")
712 | get_sub_menu()
713 |
714 | elif sys.argv[1] == "login":
715 | try:
716 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
717 | help_opt.help_login_menu()
718 | sys.exit()
719 | except IndexError as e:
720 | # print("Error: {}".format(e))
721 | ...
722 |
723 | # print("swatch")
724 | login_sub_menu()
725 |
726 | elif sys.argv[1] == "logout":
727 | try:
728 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
729 | help_opt.help_logout_menu()
730 | sys.exit()
731 | except IndexError as e:
732 | # print("Error: {}".format(e))
733 | ...
734 |
735 | # print("swatch")
736 | logout_sub_menu()
737 |
738 | elif sys.argv[1] == "token":
739 | token_sub_menu()
740 |
741 | elif sys.argv[1] == "whoami":
742 | try:
743 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
744 | help_opt.help_whoami_menu()
745 | sys.exit()
746 | except IndexError as e:
747 | # print("Error: {}".format(e))
748 | ...
749 |
750 | # print("swatch")
751 | whoami_sub_menu()
752 |
753 | elif sys.argv[1] == "ansible":
754 | try:
755 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
756 | help_opt.help_ansible_menu()
757 | sys.exit()
758 | except IndexError as e:
759 | # print("Error: {}".format(e))
760 | ...
761 |
762 | # print("swatch")
763 | ansible_sub_menu()
764 |
765 | elif (sys.argv[1] == "--help") or (sys.argv[1] == "-h"):
766 | help_opt.help_main_menu()
767 |
768 | elif (sys.argv[1] == "--version") or (sys.argv[1] == "-v"):
769 | print(conf.CURRENT_VERSION)
770 |
771 | elif sys.argv[1] == "ts":
772 | try:
773 | if (sys.argv[2] == "--help") or (sys.argv[2] == "-h"):
774 | help_opt.help_ts_menu()
775 | sys.exit()
776 | except IndexError as e:
777 | # print("Error: {}".format(e))
778 | ...
779 | troubleshoot()
780 |
781 | else:
782 | print("invalid option")
783 | else:
784 | print("Command line tool for console.redhat.com API")
785 | print("")
786 | print("Usage:")
787 | print(" crhc [command]")
788 | print("")
789 | print("Available Commands:")
790 | print(" inventory Retrieve Inventory information")
791 | print(" swatch Retrieve Subscriptions information")
792 | print(" advisor Retrieve Insights Information")
793 | print(" patch Retrieve Patch Information")
794 | print(" vulnerability Retrieve Vulnerability Information")
795 | print(" ansible Retrieve Ansible Managed Host Information")
796 | print(" endpoint List all the available endpoints")
797 | print(" get Send a GET request")
798 | print(" ts Troubleshooting tasks")
799 | print("")
800 | print(" login Log in")
801 | print(" logout Log out")
802 | print(" token Generates a token")
803 | print(" whoami Prints user information")
804 | print("")
805 | print("Flags:")
806 | print(" -h, --help help for crhc")
807 | print(" -v, --version crhc version")
808 | print("")
809 | print(
810 | 'Use "crhc [command] --help" for more information about a command.'
811 | )
812 | print("")
813 | print("{}".format(update_check()))
814 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/tests/data/inventory.json:
--------------------------------------------------------------------------------
1 | {
2 | "results": [
3 | {
4 | "server": {
5 | "insights_id": null,
6 | "subscription_manager_id": "91a96b56-fb42-4c21-8945-eceb4baef98d",
7 | "satellite_id": "91a96b56-fb42-4c21-8945-eceb4baef98d",
8 | "bios_uuid": "a4cf5f59-f11c-e111-2000-000000000001",
9 | "ip_addresses": null,
10 | "fqdn": "virt-who-server01.local.net-1",
11 | "mac_addresses": null,
12 | "provider_id": null,
13 | "provider_type": null,
14 | "id": "316ebd0f-8a1a-4c97-b829-6b03fa46db91",
15 | "account": "999999",
16 | "display_name": "virt-who-server01.local.net-1",
17 | "ansible_host": null,
18 | "facts": [
19 | {
20 | "namespace": "satellite",
21 | "facts": {
22 | "satellite_instance_id": "70ddb6c2-acd2-459d-aa4b-6701e67024c5",
23 | "system_purpose_sla": "",
24 | "is_simple_content_access": false,
25 | "satellite_version": "6.7.5",
26 | "organization_id": 1,
27 | "system_purpose_role": "",
28 | "system_purpose_usage": "",
29 | "is_hostname_obfuscated": false
30 | }
31 | },
32 | {
33 | "namespace": "yupana",
34 | "facts": {
35 | "report_platform_id": "ec01065b-72d3-4278-b333-cc677e255606",
36 | "report_slice_id": "2cf4293b-c05d-4a0b-9d16-183310aa5985",
37 | "source": "Satellite",
38 | "yupana_host_id": "ccbe8c31-29f3-4428-8cf8-a7e8355acaf6",
39 | "account": "999999"
40 | }
41 | }
42 | ],
43 | "reporter": "yupana",
44 | "per_reporter_staleness": {
45 | "yupana": {
46 | "stale_timestamp": "2021-10-05T10:21:11.474000+00:00",
47 | "last_check_in": "2021-10-04T04:26:11.590083+00:00",
48 | "check_in_succeeded": true
49 | }
50 | },
51 | "stale_timestamp": "2021-10-05T10:21:11.474000+00:00",
52 | "stale_warning_timestamp": "2021-10-12T10:21:11.474000+00:00",
53 | "culled_timestamp": "2021-10-19T10:21:11.474000+00:00",
54 | "created": "2021-03-15T18:57:58.726808+00:00",
55 | "updated": "2021-10-04T04:22:53.426826+00:00"
56 | },
57 | "system_profile": {
58 | "owner_id": "2f592bbc-e570-42cc-a180-2557db71d58e",
59 | "number_of_cpus": 0,
60 | "cores_per_socket": 0,
61 | "number_of_sockets": 2,
62 | "satellite_managed": true,
63 | "installed_packages": [],
64 | "network_interfaces": [],
65 | "infrastructure_type": "physical",
66 | "subscription_status": "Fully entitled",
67 | "system_memory_bytes": 0
68 | }
69 | },
70 | {
71 | "server": {
72 | "insights_id": null,
73 | "subscription_manager_id": "ace99f9c-c38f-461d-af31-ce0591943594",
74 | "satellite_id": "ace99f9c-c38f-461d-af31-ce0591943594",
75 | "bios_uuid": "c574a5da-1134-4338-8d0a-278946f0bef7",
76 | "ip_addresses": [
77 | "10.10.182.124"
78 | ],
79 | "fqdn": "node01.local.net",
80 | "mac_addresses": [
81 | "00:ca:fe:16:01:6a",
82 | "00:ca:fe:16:01:6d"
83 | ],
84 | "provider_id": null,
85 | "provider_type": null,
86 | "id": "b490fb29-dd14-43fb-bd48-a98069a67952",
87 | "account": "999999",
88 | "display_name": "node01.local.net",
89 | "ansible_host": null,
90 | "facts": [
91 | {
92 | "namespace": "satellite",
93 | "facts": {
94 | "satellite_instance_id": "70ddb6c2-acd2-459d-aa4b-6701e67024c5",
95 | "system_purpose_sla": "",
96 | "is_simple_content_access": false,
97 | "distribution_version": "8.3",
98 | "satellite_version": "6.7.5",
99 | "organization_id": 1,
100 | "system_purpose_role": "",
101 | "system_purpose_usage": "",
102 | "is_hostname_obfuscated": false
103 | }
104 | },
105 | {
106 | "namespace": "yupana",
107 | "facts": {
108 | "report_platform_id": "ec01065b-72d3-4278-b333-cc677e255606",
109 | "report_slice_id": "2cf4293b-c05d-4a0b-9d16-183310aa5985",
110 | "source": "Satellite",
111 | "yupana_host_id": "1de6a98f-3060-4fd2-a5b9-306e0ea4e17d",
112 | "account": "999999"
113 | }
114 | }
115 | ],
116 | "reporter": "yupana",
117 | "per_reporter_staleness": {
118 | "yupana": {
119 | "stale_timestamp": "2021-10-05T10:21:11.474000+00:00",
120 | "last_check_in": "2021-10-04T04:26:11.590436+00:00",
121 | "check_in_succeeded": true
122 | }
123 | },
124 | "stale_timestamp": "2021-10-05T10:21:11.474000+00:00",
125 | "stale_warning_timestamp": "2021-10-12T10:21:11.474000+00:00",
126 | "culled_timestamp": "2021-10-19T10:21:11.474000+00:00",
127 | "created": "2021-04-02T19:01:17.714520+00:00",
128 | "updated": "2021-10-04T04:22:45.742229+00:00"
129 | },
130 | "system_profile": {
131 | "arch": "x86_64",
132 | "owner_id": "2f592bbc-e570-42cc-a180-2557db71d58e",
133 | "cpu_flags": [
134 | "fpu",
135 | "vme",
136 | "de",
137 | "pse",
138 | "tsc",
139 | "msr",
140 | "pae",
141 | "mce",
142 | "cx8",
143 | "apic",
144 | "sep",
145 | "mtrr",
146 | "pge",
147 | "mca",
148 | "cmov",
149 | "pat",
150 | "pse36",
151 | "clflush",
152 | "mmx",
153 | "fxsr",
154 | "sse",
155 | "sse2",
156 | "syscall",
157 | "nx",
158 | "pdpe1gb",
159 | "rdtscp",
160 | "lm",
161 | "constant_tsc",
162 | "rep_good",
163 | "nopl",
164 | "xtopology",
165 | "cpuid",
166 | "tsc_known_freq",
167 | "pni",
168 | "pclmulqdq",
169 | "ssse3",
170 | "fma",
171 | "cx16",
172 | "pcid",
173 | "sse4_1",
174 | "sse4_2",
175 | "x2apic",
176 | "movbe",
177 | "popcnt",
178 | "tsc_deadline_timer",
179 | "aes",
180 | "xsave",
181 | "avx",
182 | "f16c",
183 | "rdrand",
184 | "hypervisor",
185 | "lahf_lm",
186 | "abm",
187 | "3dnowprefetch",
188 | "invpcid_single",
189 | "pti",
190 | "ssbd",
191 | "ibrs",
192 | "ibpb",
193 | "fsgsbase",
194 | "bmi1",
195 | "hle",
196 | "avx2",
197 | "smep",
198 | "bmi2",
199 | "erms",
200 | "invpcid",
201 | "rtm",
202 | "mpx",
203 | "avx512f",
204 | "avx512dq",
205 | "rdseed",
206 | "adx",
207 | "smap",
208 | "clflushopt",
209 | "clwb",
210 | "avx512cd",
211 | "avx512bw",
212 | "avx512vl",
213 | "xsaveopt",
214 | "xsavec",
215 | "xgetbv1",
216 | "arat",
217 | "md_clear"
218 | ],
219 | "os_release": "8.3",
220 | "bios_vendor": "SeaBIOS",
221 | "bios_version": "1.11.0-2.el7",
222 | "number_of_cpus": 2,
223 | "cores_per_socket": 1,
224 | "operating_system": {
225 | "name": "RHEL",
226 | "major": 8,
227 | "minor": 3
228 | },
229 | "number_of_sockets": 2,
230 | "os_kernel_version": "4.18.0",
231 | "satellite_managed": true,
232 | "installed_packages": [
233 | "acl-2.2.53-1.el8.x86_64",
234 | "at-3.1.20-11.el8.x86_64",
235 | "audit-3.0-0.17.20191104git1c2f876.el8.x86_64",
236 | "audit-libs-3.0-0.17.20191104git1c2f876.el8.x86_64",
237 | "avahi-libs-0.7-19.el8.x86_64",
238 | "basesystem-11-5.el8.noarch",
239 | "bc-1.07.1-5.el8.x86_64",
240 | "biosdevname-0.7.3-2.el8.x86_64",
241 | "bzip2-libs-1.0.6-26.el8.x86_64",
242 | "c-ares-1.13.0-5.el8.x86_64",
243 | "chrony-3.5-1.el8.x86_64",
244 | "cpio-2.12-8.el8.x86_64",
245 | "cracklib-2.9.6-15.el8.x86_64",
246 | "cracklib-dicts-2.9.6-15.el8.x86_64",
247 | "cronie-1.5.2-4.el8.x86_64",
248 | "cronie-anacron-1.5.2-4.el8.x86_64",
249 | "crontabs-1.11-16.20150630git.el8.noarch",
250 | "dbus-glib-0.110-2.el8.x86_64",
251 | "diffutils-3.6-6.el8.x86_64",
252 | "ed-1.14.2-4.el8.x86_64",
253 | "ethtool-5.0-2.el8.x86_64",
254 | "findutils-4.6.0-20.el8.x86_64",
255 | "fipscheck-1.5.0-4.el8.x86_64",
256 | "fipscheck-lib-1.5.0-4.el8.x86_64",
257 | "fuse-libs-2.9.7-12.el8.x86_64",
258 | "gawk-4.2.1-1.el8.x86_64",
259 | "gdbm-1.18-1.el8.x86_64",
260 | "gdbm-libs-1.18-1.el8.x86_64",
261 | "geolite2-city-20180605-1.el8.noarch",
262 | "geolite2-country-20180605-1.el8.noarch",
263 | "gettext-0.19.8.1-17.el8.x86_64",
264 | "gettext-libs-0.19.8.1-17.el8.x86_64",
265 | "glib2-2.56.4-8.el8.x86_64",
266 | "gmp-6.1.2-10.el8.x86_64",
267 | "gobject-introspection-1.56.1-1.el8.x86_64",
268 | "grep-3.1-6.el8.x86_64",
269 | "groff-base-1.22.3-18.el8.x86_64",
270 | "gzip-1.9-9.el8.x86_64",
271 | "hardlink-1.3-6.el8.x86_64",
272 | "hdparm-9.54-2.el8.x86_64",
273 | "hostname-3.20-6.el8.x86_64",
274 | "ima-evm-utils-1.1-5.el8.x86_64",
275 | "info-6.5-6.el8.x86_64",
276 | "ipcalc-0.2.4-4.el8.x86_64",
277 | "ipset-7.1-1.el8.x86_64",
278 | "ipset-libs-7.1-1.el8.x86_64",
279 | "iputils-20180629-2.el8.x86_64",
280 | "irqbalance-1.4.0-4.el8.x86_64",
281 | "jansson-2.11-3.el8.x86_64",
282 | "json-c-0.13.1-0.2.el8.x86_64",
283 | "json-glib-1.4.4-1.el8.x86_64",
284 | "katello-ca-consumer-wallsat67.usersys.redhat.com-1.0-1.noarch",
285 | "keyutils-libs-1.5.10-6.el8.x86_64",
286 | "langpacks-en-1.0-12.el8.noarch",
287 | "less-530-1.el8.x86_64",
288 | "libacl-2.2.53-1.el8.x86_64",
289 | "libaio-0.3.112-1.el8.x86_64",
290 | "libassuan-2.5.1-3.el8.x86_64",
291 | "libattr-2.4.48-3.el8.x86_64",
292 | "libbasicobjects-0.1.1-39.el8.x86_64",
293 | "libcap-ng-0.7.9-5.el8.x86_64",
294 | "libcollection-0.7.0-39.el8.x86_64",
295 | "libcomps-0.1.11-4.el8.x86_64",
296 | "libdaemon-0.14-15.el8.x86_64",
297 | "libdhash-0.5.0-39.el8.x86_64",
298 | "libedit-3.1-23.20170329cvs.el8.x86_64",
299 | "libestr-0.1.10-1.el8.x86_64",
300 | "libevent-2.1.8-5.el8.x86_64",
301 | "libfastjson-0.99.8-2.el8.x86_64",
302 | "libgpg-error-1.31-1.el8.x86_64",
303 | "libgudev-232-4.el8.x86_64",
304 | "libicu-60.3-2.el8_1.x86_64",
305 | "libidn2-2.2.0-1.el8.x86_64",
306 | "libini_config-1.3.1-39.el8.x86_64",
307 | "libksba-1.3.5-7.el8.x86_64",
308 | "libmetalink-0.1.3-7.el8.x86_64",
309 | "libmnl-1.0.4-6.el8.x86_64",
310 | "libndp-1.7-3.el8.x86_64",
311 | "libnetfilter_conntrack-1.0.6-5.el8.x86_64",
312 | "libnfnetlink-1.0.1-13.el8.x86_64",
313 | "libnftnl-1.1.5-4.el8.x86_64",
314 | "libnl3-3.5.0-1.el8.x86_64",
315 | "libnl3-cli-3.5.0-1.el8.x86_64",
316 | "libnsl2-1.2.0-2.20180605git4a062cf.el8.x86_64",
317 | "libpath_utils-0.2.1-39.el8.x86_64",
318 | "libpipeline-1.5.0-2.el8.x86_64",
319 | "libpng-1.6.34-5.el8.x86_64",
320 | "libpwquality-1.4.0-9.el8.x86_64",
321 | "libref_array-0.1.5-39.el8.x86_64",
322 | "librhsm-0.0.3-3.el8.x86_64",
323 | "libsecret-0.18.6-1.el8.x86_64",
324 | "libsepol-2.9-1.el8.x86_64",
325 | "libsigsegv-2.11-5.el8.x86_64",
326 | "libsysfs-2.1.0-24.el8.x86_64",
327 | "libtasn1-4.13-3.el8.x86_64",
328 | "libtirpc-1.1.4-4.el8.x86_64",
329 | "libunistring-0.9.9-3.el8.x86_64",
330 | "libuser-0.62-23.el8.x86_64",
331 | "libutempter-1.1.6-14.el8.x86_64",
332 | "libverto-0.3.0-5.el8.x86_64",
333 | "libxcrypt-4.1.1-4.el8.x86_64",
334 | "libxkbcommon-0.9.1-1.el8.x86_64",
335 | "libyaml-0.1.7-5.el8.x86_64",
336 | "lsscsi-0.30-1.el8.x86_64",
337 | "lua-libs-5.3.4-11.el8.x86_64",
338 | "lzo-2.08-14.el8.x86_64",
339 | "make-4.2.1-10.el8.x86_64",
340 | "man-db-2.7.6.1-17.el8.x86_64",
341 | "mozjs60-60.9.0-4.el8.x86_64",
342 | "mpfr-3.1.6-1.el8.x86_64",
343 | "ncurses-6.1-7.20180224.el8.x86_64",
344 | "ncurses-base-6.1-7.20180224.el8.noarch",
345 | "ncurses-libs-6.1-7.20180224.el8.x86_64",
346 | "newt-0.52.20-11.el8.x86_64",
347 | "npth-1.5-4.el8.x86_64",
348 | "openssl-pkcs11-0.4.10-2.el8.x86_64",
349 | "os-prober-1.74-6.el8.x86_64",
350 | "p11-kit-0.23.14-5.el8_0.x86_64",
351 | "p11-kit-trust-0.23.14-5.el8_0.x86_64",
352 | "parted-3.2-38.el8.x86_64",
353 | "passwd-0.80-3.el8.x86_64",
354 | "pcre-8.42-4.el8.x86_64",
355 | "pigz-2.4-4.el8.x86_64",
356 | "pinentry-1.1.0-2.el8.x86_64",
357 | "policycoreutils-2.9-9.el8.x86_64",
358 | "polkit-0.115-11.el8.x86_64",
359 | "polkit-libs-0.115-11.el8.x86_64",
360 | "polkit-pkla-compat-0.1-12.el8.x86_64",
361 | "popt-1.16-14.el8.x86_64",
362 | "prefixdevname-0.1.0-6.el8.x86_64",
363 | "publicsuffix-list-dafsa-20180723-1.el8.noarch",
364 | "python3-asn1crypto-0.24.0-3.el8.noarch",
365 | "python3-cffi-1.11.5-5.el8.x86_64",
366 | "python3-configobj-5.0.6-11.el8.noarch",
367 | "python3-cryptography-2.3-3.el8.x86_64",
368 | "python3-dateutil-2.6.1-6.el8.noarch",
369 | "python3-dbus-1.2.4-15.el8.x86_64",
370 | "python3-decorator-4.2.1-2.el8.noarch",
371 | "python3-dmidecode-3.12.2-15.el8.x86_64",
372 | "python3-ethtool-0.14-3.el8.x86_64",
373 | "python3-hwdata-2.3.6-3.el8.noarch",
374 | "python3-idna-2.5-5.el8.noarch",
375 | "python3-iniparse-0.4-31.el8.noarch",
376 | "python3-inotify-0.9.6-13.el8.noarch",
377 | "python3-libcomps-0.1.11-4.el8.x86_64",
378 | "python3-netifaces-0.10.6-4.el8.x86_64",
379 | "python3-newt-0.52.20-11.el8.x86_64",
380 | "python3-ply-3.9-8.el8.noarch",
381 | "python3-pycparser-2.14-14.el8.noarch",
382 | "python3-pyOpenSSL-18.0.0-1.el8.noarch",
383 | "python3-pyudev-0.21.0-7.el8.noarch",
384 | "python3-schedutils-0.6-6.el8.x86_64",
385 | "python3-six-1.11.0-8.el8.noarch",
386 | "python3-slip-0.6.4-11.el8.noarch",
387 | "python3-slip-dbus-0.6.4-11.el8.noarch",
388 | "readline-7.0-10.el8.x86_64",
389 | "rng-tools-6.8-3.el8.x86_64",
390 | "rootfiles-8.1-22.el8.noarch",
391 | "sg3_utils-1.44-5.el8.x86_64",
392 | "sg3_utils-libs-1.44-5.el8.x86_64",
393 | "shared-mime-info-1.9-3.el8.x86_64",
394 | "slang-2.3.2-3.el8.x86_64",
395 | "squashfs-tools-4.3-19.el8.x86_64",
396 | "time-1.9-3.el8.x86_64",
397 | "timedatex-0.5-3.el8.x86_64",
398 | "trousers-0.3.14-4.el8.x86_64",
399 | "trousers-lib-0.3.14-4.el8.x86_64",
400 | "usermode-1.113-1.el8.x86_64",
401 | "virt-what-1.18-6.el8.x86_64",
402 | "which-2.21-12.el8.x86_64",
403 | "xkeyboard-config-2.28-1.el8.noarch",
404 | "xz-5.2.4-3.el8.x86_64",
405 | "xz-libs-5.2.4-3.el8.x86_64",
406 | "dnf-plugin-spacewalk-2.8.5-11.module+el8.1.0+3455+3ddf2832.noarch",
407 | "kernel-core-4.18.0-193.el8.x86_64",
408 | "spax-1.5.3-13.el8.x86_64",
409 | "kernel-4.18.0-193.el8.x86_64",
410 | "redhat-lsb-submod-security-4.1-47.el8.x86_64",
411 | "mailx-12.5-29.el8.x86_64",
412 | "python3-rhnlib-2.8.6-8.module+el8.1.0+3455+3ddf2832.noarch",
413 | "rhn-client-tools-2.8.16-13.module+el8.1.0+3455+3ddf2832.x86_64",
414 | "python3-dnf-plugin-spacewalk-2.8.5-11.module+el8.1.0+3455+3ddf2832.noarch",
415 | "rhn-check-2.8.16-13.module+el8.1.0+3455+3ddf2832.x86_64",
416 | "python3-rhn-setup-2.8.16-13.module+el8.1.0+3455+3ddf2832.x86_64",
417 | "kernel-modules-4.18.0-193.el8.x86_64",
418 | "patch-2.7.6-11.el8.x86_64",
419 | "ncurses-compat-libs-6.1-7.20180224.el8.x86_64",
420 | "m4-1.4.18-7.el8.x86_64",
421 | "rhnlib-2.8.6-8.module+el8.1.0+3455+3ddf2832.noarch",
422 | "redhat-lsb-core-4.1-47.el8.x86_64",
423 | "python3-rhn-client-tools-2.8.16-13.module+el8.1.0+3455+3ddf2832.x86_64",
424 | "python3-rhn-check-2.8.16-13.module+el8.1.0+3455+3ddf2832.x86_64",
425 | "rhn-setup-2.8.16-13.module+el8.1.0+3455+3ddf2832.x86_64",
426 | "authselect-1.2.1-2.el8.x86_64",
427 | "authselect-libs-1.2.1-2.el8.x86_64",
428 | "bash-4.4.19-12.el8.x86_64",
429 | "bind-export-libs-9.11.20-5.el8.x86_64",
430 | "brotli-1.0.6-2.el8.x86_64",
431 | "ca-certificates-2020.2.41-80.0.el8_2.noarch",
432 | "chkconfig-1.13-2.el8.x86_64",
433 | "coreutils-8.30-8.el8.x86_64",
434 | "coreutils-common-8.30-8.el8.x86_64",
435 | "crypto-policies-20200713-1.git51d1222.el8.noarch",
436 | "crypto-policies-scripts-20200713-1.git51d1222.el8.noarch",
437 | "cryptsetup-libs-2.3.3-2.el8.x86_64",
438 | "cups-libs-2.2.6-38.el8.x86_64",
439 | "cyrus-sasl-lib-2.1.27-5.el8.x86_64",
440 | "device-mapper-persistent-data-0.8.5-4.el8.x86_64",
441 | "dhcp-client-4.3.6-41.el8.x86_64",
442 | "dhcp-common-4.3.6-41.el8.noarch",
443 | "dhcp-libs-4.3.6-41.el8.x86_64",
444 | "dmidecode-3.2-6.el8.x86_64",
445 | "dnf-4.2.23-4.el8.noarch",
446 | "dnf-data-4.2.23-4.el8.noarch",
447 | "dnf-plugins-core-4.0.17-5.el8.noarch",
448 | "e2fsprogs-1.45.6-1.el8.x86_64",
449 | "e2fsprogs-libs-1.45.6-1.el8.x86_64",
450 | "elfutils-debuginfod-client-0.180-1.el8.x86_64",
451 | "elfutils-default-yama-scope-0.180-1.el8.noarch",
452 | "elfutils-libelf-0.180-1.el8.x86_64",
453 | "elfutils-libs-0.180-1.el8.x86_64",
454 | "expat-2.2.5-4.el8.x86_64",
455 | "file-5.33-16.el8.x86_64",
456 | "file-libs-5.33-16.el8.x86_64",
457 | "filesystem-3.8-3.el8.x86_64",
458 | "firewalld-0.8.2-2.el8.noarch",
459 | "firewalld-filesystem-0.8.2-2.el8.noarch",
460 | "gnupg2-2.2.20-2.el8.x86_64",
461 | "gnupg2-smime-2.2.20-2.el8.x86_64",
462 | "gpgme-1.13.1-3.el8.x86_64",
463 | "grub2-common-2.02-90.el8.noarch",
464 | "grub2-pc-2.02-90.el8.x86_64",
465 | "grub2-pc-modules-2.02-90.el8.noarch",
466 | "grub2-tools-2.02-90.el8.x86_64",
467 | "grub2-tools-extra-2.02-90.el8.x86_64",
468 | "grub2-tools-minimal-2.02-90.el8.x86_64",
469 | "grubby-8.40-41.el8.x86_64",
470 | "hwdata-0.314-8.6.el8.noarch",
471 | "initscripts-10.00.9-1.el8.x86_64",
472 | "iproute-5.3.0-5.el8.x86_64",
473 | "iprutils-2.4.19-1.el8.x86_64",
474 | "kbd-2.0.4-10.el8.x86_64",
475 | "kbd-legacy-2.0.4-10.el8.noarch",
476 | "kbd-misc-2.0.4-10.el8.noarch",
477 | "kpartx-0.8.4-5.el8.x86_64",
478 | "krb5-libs-1.18.2-5.el8.x86_64",
479 | "libarchive-3.3.2-9.el8.x86_64",
480 | "libblkid-2.32.1-24.el8.x86_64",
481 | "libcap-2.26-4.el8.x86_64",
482 | "libcom_err-1.45.6-1.el8.x86_64",
483 | "libcroco-0.6.12-4.el8_2.1.x86_64",
484 | "libdb-5.3.28-39.el8.x86_64",
485 | "libdb-utils-5.3.28-39.el8.x86_64",
486 | "libdnf-0.48.0-5.el8.x86_64",
487 | "libfdisk-2.32.1-24.el8.x86_64",
488 | "libffi-3.1-22.el8.x86_64",
489 | "libgcc-8.3.1-5.1.el8.x86_64",
490 | "libgcrypt-1.8.5-4.el8.x86_64",
491 | "libgomp-8.3.1-5.1.el8.x86_64",
492 | "libkcapi-1.2.0-2.el8.x86_64",
493 | "libkcapi-hmaccalc-1.2.0-2.el8.x86_64",
494 | "libldb-2.1.3-2.el8.x86_64",
495 | "libmaxminddb-1.2.0-10.el8.x86_64",
496 | "libmodulemd-2.9.4-2.el8.x86_64",
497 | "libmount-2.32.1-24.el8.x86_64",
498 | "libnfsidmap-2.3.3-35.el8.x86_64",
499 | "libnghttp2-1.33.0-3.el8_2.1.x86_64",
500 | "libpcap-1.9.1-4.el8.x86_64",
501 | "libpsl-0.20.2-6.el8.x86_64",
502 | "librepo-1.12.0-2.el8.x86_64",
503 | "libreport-filesystem-2.9.5-15.el8.x86_64",
504 | "libseccomp-2.4.3-1.el8.x86_64",
505 | "libsemanage-2.9-3.el8.x86_64",
506 | "libsmartcols-2.32.1-24.el8.x86_64",
507 | "libsolv-0.7.11-1.el8.x86_64",
508 | "libss-1.45.6-1.el8.x86_64",
509 | "libssh-0.9.4-2.el8.x86_64",
510 | "libssh-config-0.9.4-2.el8.noarch",
511 | "libsss_autofs-2.3.0-9.el8.x86_64",
512 | "libsss_certmap-2.3.0-9.el8.x86_64",
513 | "libsss_idmap-2.3.0-9.el8.x86_64",
514 | "libsss_nss_idmap-2.3.0-9.el8.x86_64",
515 | "libsss_sudo-2.3.0-9.el8.x86_64",
516 | "libstdc++-8.3.1-5.1.el8.x86_64",
517 | "libtalloc-2.3.1-2.el8.x86_64",
518 | "libtdb-1.4.3-1.el8.x86_64",
519 | "libteam-1.31-2.el8.x86_64",
520 | "libtevent-0.10.2-2.el8.x86_64",
521 | "libusbx-1.0.23-4.el8.x86_64",
522 | "libuuid-2.32.1-24.el8.x86_64",
523 | "libxml2-2.9.7-8.el8.x86_64",
524 | "libzstd-1.4.4-1.el8.x86_64",
525 | "logrotate-3.14.0-4.el8.x86_64",
526 | "lshw-B.02.19.2-2.el8.x86_64",
527 | "lz4-libs-1.8.3-2.el8.x86_64",
528 | "memstrack-0.1.11-1.el8.x86_64",
529 | "nettle-3.4.1-2.el8.x86_64",
530 | "nftables-0.9.3-16.el8.x86_64",
531 | "nspr-4.25.0-2.el8_2.x86_64",
532 | "nss-3.53.1-11.el8_2.x86_64",
533 | "nss-softokn-3.53.1-11.el8_2.x86_64",
534 | "nss-softokn-freebl-3.53.1-11.el8_2.x86_64",
535 | "nss-sysinit-3.53.1-11.el8_2.x86_64",
536 | "nss-util-3.53.1-11.el8_2.x86_64",
537 | "numactl-libs-2.0.12-11.el8.x86_64",
538 | "openldap-2.4.46-15.el8.x86_64",
539 | "openssh-8.0p1-5.el8.x86_64",
540 | "openssh-clients-8.0p1-5.el8.x86_64",
541 | "openssh-server-8.0p1-5.el8.x86_64",
542 | "openssl-1.1.1g-12.el8_3.x86_64",
543 | "openssl-libs-1.1.1g-12.el8_3.x86_64",
544 | "pam-1.3.1-11.el8.x86_64",
545 | "pciutils-libs-3.6.4-2.el8.x86_64",
546 | "pcre2-10.32-2.el8.x86_64",
547 | "platform-python-3.6.8-31.el8.x86_64",
548 | "platform-python-pip-9.0.3-18.el8.noarch",
549 | "platform-python-setuptools-39.2.0-6.el8.noarch",
550 | "plymouth-0.9.4-7.20200615git1e36e30.el8.x86_64",
551 | "plymouth-core-libs-0.9.4-7.20200615git1e36e30.el8.x86_64",
552 | "plymouth-scripts-0.9.4-7.20200615git1e36e30.el8.x86_64",
553 | "procps-ng-3.3.15-3.el8.x86_64",
554 | "psmisc-23.1-5.el8.x86_64",
555 | "python3-chardet-3.0.4-7.el8.noarch",
556 | "python3-dnf-4.2.23-4.el8.noarch",
557 | "python3-dnf-plugins-core-4.0.17-5.el8.noarch",
558 | "python3-firewall-0.8.2-2.el8.noarch",
559 | "python3-gobject-base-3.28.3-2.el8.x86_64",
560 | "python3-gpg-1.13.1-3.el8.x86_64",
561 | "python3-hawkey-0.48.0-5.el8.x86_64",
562 | "python3-libdnf-0.48.0-5.el8.x86_64",
563 | "python3-librepo-1.12.0-2.el8.x86_64",
564 | "python3-libs-3.6.8-31.el8.x86_64",
565 | "python3-libxml2-2.9.7-8.el8.x86_64",
566 | "python3-linux-procfs-0.6.2-2.el8.noarch",
567 | "python3-nftables-0.9.3-16.el8.x86_64",
568 | "python3-pip-wheel-9.0.3-18.el8.noarch",
569 | "python3-pysocks-1.6.8-3.el8.noarch",
570 | "python3-requests-2.20.0-2.1.el8_1.noarch",
571 | "python3-rpm-4.14.3-4.el8.x86_64",
572 | "python3-setuptools-wheel-39.2.0-6.el8.noarch",
573 | "python3-unbound-1.7.3-14.el8.x86_64",
574 | "python3-urllib3-1.24.2-4.el8.noarch",
575 | "redhat-release-8.3-1.0.el8.x86_64",
576 | "redhat-release-eula-8.3-1.0.el8.x86_64",
577 | "rhnsd-5.0.35-3.module+el8+2754+6a08e8f4.x86_64",
578 | "rpm-4.14.3-4.el8.x86_64",
579 | "rpm-build-libs-4.14.3-4.el8.x86_64",
580 | "rpm-libs-4.14.3-4.el8.x86_64",
581 | "rpm-plugin-selinux-4.14.3-4.el8.x86_64",
582 | "rpm-plugin-systemd-inhibit-4.14.3-4.el8.x86_64",
583 | "rsyslog-8.1911.0-6.el8.x86_64",
584 | "sed-4.5-2.el8.x86_64",
585 | "setup-2.12.2-6.el8.noarch",
586 | "shadow-utils-4.6-11.el8.x86_64",
587 | "snappy-1.1.8-3.el8.x86_64",
588 | "sqlite-libs-3.26.0-11.el8.x86_64",
589 | "sssd-client-2.3.0-9.el8.x86_64",
590 | "sssd-common-2.3.0-9.el8.x86_64",
591 | "sssd-kcm-2.3.0-9.el8.x86_64",
592 | "sssd-nfs-idmap-2.3.0-9.el8.x86_64",
593 | "teamd-1.31-2.el8.x86_64",
594 | "unbound-libs-1.7.3-14.el8.x86_64",
595 | "util-linux-2.32.1-24.el8.x86_64",
596 | "vim-minimal-8.0.1763-15.el8.x86_64",
597 | "xfsprogs-5.0.0-4.el8.x86_64",
598 | "yum-4.2.23-4.el8.noarch",
599 | "zlib-1.2.11-16.el8_2.x86_64",
600 | "gnutls-3.6.14-7.el8_3.x86_64",
601 | "systemd-libs-239-41.el8_3.1.x86_64",
602 | "kmod-25-16.el8_3.1.x86_64",
603 | "dbus-daemon-1.12.8-12.el8_3.x86_64",
604 | "systemd-pam-239-41.el8_3.1.x86_64",
605 | "systemd-239-41.el8_3.1.x86_64",
606 | "NetworkManager-libnm-1.26.0-13.el8_3.x86_64",
607 | "device-mapper-event-1.02.171-5.el8_3.2.x86_64",
608 | "dnf-plugin-subscription-manager-1.27.18-1.el8_3.x86_64",
609 | "selinux-policy-3.14.3-54.el8_3.2.noarch",
610 | "python3-perf-4.18.0-240.15.1.el8_3.x86_64",
611 | "NetworkManager-team-1.26.0-13.el8_3.x86_64",
612 | "dracut-config-rescue-049-95.git20200804.el8_3.4.x86_64",
613 | "sudo-1.8.29-6.el8_3.1.x86_64",
614 | "python3-libselinux-2.9-4.el8_3.x86_64",
615 | "tar-1.30-5.el8.x86_64",
616 | "libmodulemd1-1.8.16-0.2.9.4.2.x86_64",
617 | "iwl6050-firmware-41.28.5.1-101.el8_3.1.noarch",
618 | "iwl3160-firmware-25.30.13.0-101.el8_3.1.noarch",
619 | "iwl135-firmware-18.168.6.1-101.el8_3.1.noarch",
620 | "iwl6000g2a-firmware-18.168.6.1-101.el8_3.1.noarch",
621 | "linux-firmware-20200619-101.git3890db36.el8_3.noarch",
622 | "glibc-2.28-127.el8_3.2.x86_64",
623 | "iptables-libs-1.8.4-15.el8_3.3.x86_64",
624 | "freetype-2.9.1-4.el8_3.1.x86_64",
625 | "curl-7.61.1-14.el8_3.1.x86_64",
626 | "device-mapper-1.02.171-5.el8_3.2.x86_64",
627 | "device-mapper-libs-1.02.171-5.el8_3.2.x86_64",
628 | "kmod-libs-25-16.el8_3.1.x86_64",
629 | "dbus-tools-1.12.8-12.el8_3.x86_64",
630 | "dracut-049-95.git20200804.el8_3.4.x86_64",
631 | "dbus-1.12.8-12.el8_3.x86_64",
632 | "systemd-udev-239-41.el8_3.1.x86_64",
633 | "device-mapper-event-libs-1.02.171-5.el8_3.2.x86_64",
634 | "NetworkManager-1.26.0-13.el8_3.x86_64",
635 | "kernel-modules-4.18.0-240.15.1.el8_3.x86_64",
636 | "lvm2-libs-2.03.09-5.el8_3.2.x86_64",
637 | "dracut-squash-049-95.git20200804.el8_3.4.x86_64",
638 | "python3-subscription-manager-rhsm-1.27.18-1.el8_3.x86_64",
639 | "selinux-policy-targeted-3.14.3-54.el8_3.2.noarch",
640 | "dracut-network-049-95.git20200804.el8_3.4.x86_64",
641 | "kernel-tools-4.18.0-240.15.1.el8_3.x86_64",
642 | "tuned-2.14.0-3.el8_3.2.noarch",
643 | "subscription-manager-1.27.18-1.el8_3.x86_64",
644 | "cups-client-2.2.6-38.el8.x86_64",
645 | "postfix-3.3.1-12.el8_3.1.x86_64",
646 | "kernel-4.18.0-240.15.1.el8_3.x86_64",
647 | "NetworkManager-tui-1.26.0-13.el8_3.x86_64",
648 | "microcode_ctl-20200609-2.20210216.1.el8_3.x86_64",
649 | "qemu-guest-agent-4.2.0-34.module+el8.3.0+8829+e7a0a3ea.1.x86_64",
650 | "util-linux-user-2.32.1-24.el8.x86_64",
651 | "libselinux-utils-2.9-4.el8_3.x86_64",
652 | "iwl5150-firmware-8.24.2.2-101.el8_3.1.noarch",
653 | "iwl100-firmware-39.31.5.1-101.el8_3.1.noarch",
654 | "iwl7260-firmware-25.30.13.0-101.el8_3.1.noarch",
655 | "iwl2030-firmware-18.168.6.1-101.el8_3.1.noarch",
656 | "iwl1000-firmware-39.31.5.1-101.el8_3.1.noarch",
657 | "iwl2000-firmware-18.168.6.1-101.el8_3.1.noarch",
658 | "iwl6000-firmware-9.221.4.1-101.el8_3.1.noarch",
659 | "iwl105-firmware-18.168.6.1-101.el8_3.1.noarch",
660 | "dbus-common-1.12.8-12.el8_3.noarch",
661 | "tzdata-2021a-1.el8.noarch",
662 | "libselinux-2.9-4.el8_3.x86_64",
663 | "glibc-langpack-en-2.28-127.el8_3.2.x86_64",
664 | "iptables-1.8.4-15.el8_3.3.x86_64",
665 | "iptables-ebtables-1.8.4-15.el8_3.3.x86_64",
666 | "libcurl-7.61.1-14.el8_3.1.x86_64",
667 | "dbus-libs-1.12.8-12.el8_3.x86_64",
668 | "kernel-core-4.18.0-240.15.1.el8_3.x86_64",
669 | "python3-syspurpose-1.27.18-1.el8_3.x86_64",
670 | "kexec-tools-2.0.20-34.el8_3.2.x86_64",
671 | "wget-1.19.5-10.el8.x86_64",
672 | "lvm2-2.03.09-5.el8_3.2.x86_64",
673 | "grub2-tools-efi-2.02-90.el8.x86_64",
674 | "binutils-2.30-79.el8.x86_64",
675 | "iwl3945-firmware-15.32.2.9-101.el8_3.1.noarch",
676 | "iwl4965-firmware-228.61.2.24-101.el8_3.1.noarch",
677 | "iwl5000-firmware-8.83.5.1_1-101.el8_3.1.noarch",
678 | "subscription-manager-rhsm-certificates-1.27.18-1.el8_3.x86_64",
679 | "glibc-common-2.28-127.el8_3.2.x86_64",
680 | "kernel-tools-libs-4.18.0-240.15.1.el8_3.x86_64",
681 | "libxslt-1.1.32-5.el8.x86_64",
682 | "nginx-filesystem-1.14.1-9.module+el8.0.0+4108+af250afe.noarch",
683 | "php-cli-7.3.20-1.module+el8.2.0+7373+b272fdef.x86_64",
684 | "httpd-filesystem-2.4.37-30.module+el8.3.0+7001+0766b9e7.noarch",
685 | "php-fpm-7.3.20-1.module+el8.2.0+7373+b272fdef.x86_64",
686 | "php-json-7.3.20-1.module+el8.2.0+7373+b272fdef.x86_64",
687 | "php-common-7.3.20-1.module+el8.2.0+7373+b272fdef.x86_64",
688 | "php-xml-7.3.20-1.module+el8.2.0+7373+b272fdef.x86_64",
689 | "php-mbstring-7.3.20-1.module+el8.2.0+7373+b272fdef.x86_64"
690 | ],
691 | "installed_products": [
692 | {
693 | "id": "479",
694 | "name": "Red Hat Enterprise Linux for x86_64"
695 | }
696 | ],
697 | "network_interfaces": [
698 | {
699 | "name": "ens3",
700 | "mac_address": "00:ca:fe:16:01:6a",
701 | "ipv4_addresses": [
702 | "10.10.182.124"
703 | ],
704 | "ipv6_addresses": []
705 | },
706 | {
707 | "name": "ens4",
708 | "mac_address": "00:ca:fe:16:01:6d",
709 | "ipv4_addresses": [],
710 | "ipv6_addresses": []
711 | }
712 | ],
713 | "infrastructure_type": "virtual",
714 | "subscription_status": "Fully entitled",
715 | "system_memory_bytes": 1836392448,
716 | "katello_agent_running": false
717 | }
718 | }
719 | ],
720 | "total": 5824
721 | }
722 |
--------------------------------------------------------------------------------