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

Add support for rpm_distribution repository attribute #143

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions plugins/modules/rpm_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
- Href of the publication to be served
type: str
required: false
repository:
description:
- Name of the repository to be served
type: str
required: false
version_added: "0.0.15"
content_guard:
description:
- Name of the content guard for the served content
Expand Down Expand Up @@ -91,26 +97,44 @@
PulpContentGuard,
PulpEntityAnsibleModule,
PulpRpmDistribution,
PulpRpmRepository,
)


def main():
with PulpEntityAnsibleModule(
argument_spec=dict(name=dict(), base_path=dict(), publication=dict(), content_guard=dict()),
argument_spec=dict(
name=dict(),
base_path=dict(),
publication=dict(),
repository=dict(),
content_guard=dict(),
),
required_if=[
("state", "present", ["name", "base_path"]),
("state", "absent", ["name"]),
],
mutually_exclusive=[("publication", "repository")],
) as module:
content_guard_name = module.params["content_guard"]
repository_name = module.params["repository"]

natural_key = {"name": module.params["name"]}
desired_attributes = {
key: module.params[key]
for key in ["base_path", "publication"]
for key in ["base_path", "publication", "repository"]
if module.params[key] is not None
}

# support switching between using publication and repository
if module.params["publication"] is not None:
desired_attributes["repository"] = None
elif repository_name is not None:
desired_attributes["publication"] = None
repository = PulpRpmRepository(module, {"name": repository_name})
repository.find(failsafe=False)
desired_attributes["repository"] = repository.href

if content_guard_name is not None:
if content_guard_name:
content_guard = PulpContentGuard(module, {"name": content_guard_name})
Expand Down
57,937 changes: 38,717 additions & 19,220 deletions tests/fixtures/rpm_distribution-0.yml

Large diffs are not rendered by default.

226 changes: 21 additions & 205 deletions tests/fixtures/rpm_distribution-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,14 @@ interactions:
Content-Type:
- application/json
Host:
- localhost:80
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/contentguards/?limit=1&name=test_content_guard
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/?limit=1&name=test_rpm_repository
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/contentguards/certguard/x509/0ac1d333-9391-4eb0-b55a-489ace40b9db/","pulp_created":"2022-11-21T13:12:59.589357Z","name":"test_content_guard","description":null}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Allow:
- GET, HEAD, OPTIONS
Connection:
- close
Content-Length:
- '239'
Content-Type:
- application/json
Correlation-ID:
- 17353e772b194aae986a45cd777c7001
Date:
- Mon, 21 Nov 2022 13:13:04 GMT
Referrer-Policy:
- same-origin
Server:
- nginx/1.14.1
Vary:
- Accept, Cookie
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Connection:
- close
Content-Type:
- application/json
Host:
- localhost:80
User-Agent:
- Python-urllib/3.9
method: GET
uri: http://pulp.example.org/pulp/api/v3/distributions/rpm/rpm/?limit=1&name=test_rpm_distribution
response:
body:
string: '{"count":0,"next":null,"previous":null,"results":[]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/018d88ee-7aa1-77c3-b702-2dfdca32de34/","pulp_created":"2024-02-08T13:35:46.850237Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/018d88ee-7aa1-77c3-b702-2dfdca32de34/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/018d88ee-7aa1-77c3-b702-2dfdca32de34/versions/1/","name":"test_rpm_repository","description":null,"retain_repo_versions":null,"remote":null,"autopublish":false,"metadata_signing_service":null,"retain_package_versions":0,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -71,115 +25,21 @@ interactions:
Connection:
- close
Content-Length:
- '52'
- '759'
Content-Type:
- application/json
Correlation-ID:
- f660d0c5edac4215ac2d8cd69dd3c8ac
Date:
- Mon, 21 Nov 2022 13:13:05 GMT
Referrer-Policy:
- 3507f98328004ef39841e7fc5a310899
Cross-Origin-Opener-Policy:
- same-origin
Server:
- nginx/1.14.1
Vary:
- Accept, Cookie
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
- request:
body: '{"name": "test_rpm_distribution", "base_path": "test_rpm_base_path", "publication":
"/pulp/api/v3/publications/rpm/rpm/ec325bbb-3384-478e-a796-7f37468431d5/", "content_guard":
"/pulp/api/v3/contentguards/certguard/x509/0ac1d333-9391-4eb0-b55a-489ace40b9db/"}'
headers:
Accept:
- application/json
Connection:
- close
Content-Length:
- 258
Content-Type:
- application/json
Host:
- localhost:80
User-Agent:
- Python-urllib/3.9
method: POST
uri: http://pulp.example.org/pulp/api/v3/distributions/rpm/rpm/
response:
body:
string: '{"task":"/pulp/api/v3/tasks/6707e244-4390-4bc7-b3a0-e37418bf267f/"}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Allow:
- GET, POST, HEAD, OPTIONS
Connection:
- close
Content-Length:
- '67'
Content-Type:
- application/json
Correlation-ID:
- 488fb6b4978d4ae68a2c9939dc8a7f6f
Date:
- Mon, 21 Nov 2022 13:13:05 GMT
- Thu, 08 Feb 2024 13:36:00 GMT
Referrer-Policy:
- same-origin
Server:
- nginx/1.14.1
- nginx/1.22.1
Vary:
- Accept, Cookie
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 202
message: Accepted
- request:
body: null
headers:
Accept:
- application/json
Connection:
- close
Content-Type:
- application/json
Host:
- localhost:80
User-Agent:
- Python-urllib/3.9
method: GET
uri: http://pulp.example.org/pulp/api/v3/tasks/6707e244-4390-4bc7-b3a0-e37418bf267f/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/tasks/6707e244-4390-4bc7-b3a0-e37418bf267f/","pulp_created":"2022-11-21T13:13:05.646670Z","state":"running","name":"pulpcore.app.tasks.base.general_create","logging_cid":"488fb6b4978d4ae68a2c9939dc8a7f6f","started_at":"2022-11-21T13:13:05.713240Z","finished_at":null,"error":null,"worker":"/pulp/api/v3/workers/518aed5f-e7e1-4a03-9338-9d9da378164e/","parent_task":null,"child_tasks":[],"task_group":null,"progress_reports":[],"created_resources":[],"reserved_resources_record":["/api/v3/distributions/"]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Allow:
- GET, PATCH, DELETE, HEAD, OPTIONS
Connection:
- close
Content-Length:
- '531'
Content-Type:
- application/json
Correlation-ID:
- 8e88895220a14580a36c1b03713fab3d
Date:
- Mon, 21 Nov 2022 13:13:06 GMT
Referrer-Policy:
- same-origin
Server:
- nginx/1.14.1
Vary:
- Accept, Cookie
- Accept
X-Content-Type-Options:
- nosniff
X-Frame-Options:
Expand All @@ -197,81 +57,37 @@ interactions:
Content-Type:
- application/json
Host:
- localhost:80
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/tasks/6707e244-4390-4bc7-b3a0-e37418bf267f/
uri: http://pulp.example.org/pulp/api/v3/publications/rpm/rpm/?limit=1&repository_version=%2Fpulp%2Fapi%2Fv3%2Frepositories%2Frpm%2Frpm%2F018d88ee-7aa1-77c3-b702-2dfdca32de34%2Fversions%2F1%2F
response:
body:
string: '{"pulp_href":"/pulp/api/v3/tasks/6707e244-4390-4bc7-b3a0-e37418bf267f/","pulp_created":"2022-11-21T13:13:05.646670Z","state":"completed","name":"pulpcore.app.tasks.base.general_create","logging_cid":"488fb6b4978d4ae68a2c9939dc8a7f6f","started_at":"2022-11-21T13:13:05.713240Z","finished_at":"2022-11-21T13:13:06.295990Z","error":null,"worker":"/pulp/api/v3/workers/518aed5f-e7e1-4a03-9338-9d9da378164e/","parent_task":null,"child_tasks":[],"task_group":null,"progress_reports":[],"created_resources":["/pulp/api/v3/distributions/rpm/rpm/8e287d91-be22-4638-819e-446eb8b12bb4/"],"reserved_resources_record":["/api/v3/distributions/"]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/publications/rpm/rpm/018d88ee-9499-7bc2-b326-ed28df2bbef8/","pulp_created":"2024-02-08T13:35:53.498423Z","repository_version":"/pulp/api/v3/repositories/rpm/rpm/018d88ee-7aa1-77c3-b702-2dfdca32de34/versions/1/","repository":"/pulp/api/v3/repositories/rpm/rpm/018d88ee-7aa1-77c3-b702-2dfdca32de34/","checksum_type":"sha256","metadata_checksum_type":"sha256","package_checksum_type":"sha256","gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Allow:
- GET, PATCH, DELETE, HEAD, OPTIONS
- GET, POST, HEAD, OPTIONS
Connection:
- close
Content-Length:
- '632'
- '571'
Content-Type:
- application/json
Correlation-ID:
- 47e4df0b62b34edeb03fc89a465ce769
Date:
- Mon, 21 Nov 2022 13:13:08 GMT
Referrer-Policy:
- b3a9f20014e040bc923e9e879ab38db5
Cross-Origin-Opener-Policy:
- same-origin
Server:
- nginx/1.14.1
Vary:
- Accept, Cookie
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Connection:
- close
Content-Type:
- application/json
Host:
- localhost:80
User-Agent:
- Python-urllib/3.9
method: GET
uri: http://pulp.example.org/pulp/api/v3/distributions/rpm/rpm/8e287d91-be22-4638-819e-446eb8b12bb4/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/distributions/rpm/rpm/8e287d91-be22-4638-819e-446eb8b12bb4/","pulp_created":"2022-11-21T13:13:06.282273Z","base_path":"test_rpm_base_path","base_url":"http://alex-rocky-pulp.novalocal:8080/pulp/content/test_rpm_base_path/","content_guard":"/pulp/api/v3/contentguards/certguard/x509/0ac1d333-9391-4eb0-b55a-489ace40b9db/","pulp_labels":{},"name":"test_rpm_distribution","repository":null,"publication":"/pulp/api/v3/publications/rpm/rpm/ec325bbb-3384-478e-a796-7f37468431d5/"}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Allow:
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Connection:
- close
Content-Length:
- '502'
Content-Type:
- application/json
Correlation-ID:
- a2e672347cbc4690b3580b2437274c41
Date:
- Mon, 21 Nov 2022 13:13:08 GMT
- Thu, 08 Feb 2024 13:36:01 GMT
Referrer-Policy:
- same-origin
Server:
- nginx/1.14.1
- nginx/1.22.1
Vary:
- Accept, Cookie
- Accept
X-Content-Type-Options:
- nosniff
X-Frame-Options:
Expand Down
Loading