Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAP-39220 : Run ccspv2 build_report outside awx #51

Merged
merged 4 commits into from
Feb 3, 2025

Conversation

himdel
Copy link
Collaborator

@himdel himdel commented Jan 27, 2025

Issue: AAP-39220
Follows #45

Make it possible to run the CCSPv2 build_report phase outside of the AWX environment.

Previously, when importing from awx failed, the util would try $AWX_PATH or /awx_devel, and fail when that failed.
Now, it will warn, but fall back to a mock_awx implementation.

Adds django-ansible-base as a dependency for the standalone mode,
imports advisory_lock from ansible-base when present (standalone or 2.5), or from awx otherwise (2.4).
(Either replaces #47, or replace this bit with #47.)

Mocks:

  • awx.prepare_env - sets up DJANGO_SETTINGS_MODULE to point at mock_awx/settings
  • awx.main.get_awx_version - hardcoded to 24.6.123 for now
  • awx.main.get_awx_http_client_headers - license info hardcoded to UNLICENSED
  • awx.main.datetime_hook - small wrapper around django parse_datetime, copied
  • (settings - empty module)

(The idea is to hardcode these for testing, and later replace with a param or an os.environ.get when we need to.)

This does not do anything about anything missing for the gather phase of ccspv2, or any other reports or backends - still unaddressed:

  • Job
  • Setting
  • access_registry
  • get_license
  • (and gather, renewal, s3, crc...)

Testing:

cd metrics-utility
gh pr checkout 51 # OR git fetch upstream pull/51/head ; git checkout FETCH_HEAD

./run-ccsp2-build
# check metrics_utility/test/test_data/reports/2024/04/CCSPv2-2024-04.xlsx

(The run-ccsp2-build script is just a convenience wrapper .. maybe we should move it to a tools dir or some such, ideas?)

(Possibly there should be an explicit param to allow running with the mocked env if we wanted to preserve 100% error compatibility too - but that means parsing the options before calling into ManagementUtility which deals with options and doesn't really align with the end goal?)

(Mocking awx is to help unblock testing, adding relative import dirs may not work so well for RPM installs.)

@himdel himdel changed the title Run build_report outside awx Run ccspv2 build_report outside awx Jan 27, 2025
pyproject.toml Show resolved Hide resolved
Copy link
Collaborator

@Ladas Ladas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 great step forward

@SherinV SherinV changed the title Run ccspv2 build_report outside awx AAP-39220 : Run ccspv2 build_report outside awx Jan 31, 2025
Copy link

sonarqubecloud bot commented Feb 3, 2025

Copy link
Contributor

@MilanPospisil MilanPospisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dhaustein dhaustein merged commit 33d428e into ansible:devel Feb 3, 2025
5 checks passed
@himdel himdel deleted the build-report branch February 17, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants