From 8aaffbdb2ea8db90dc8deb2b58f102cb3e1e3d27 Mon Sep 17 00:00:00 2001 From: Yasen Date: Thu, 7 Aug 2025 09:59:50 +0200 Subject: [PATCH] exposing the new create-domain --- pulpcore/cli/console/__init__.py | 2 ++ pulpcore/cli/console/populated_domain.py | 42 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 pulpcore/cli/console/populated_domain.py diff --git a/pulpcore/cli/console/__init__.py b/pulpcore/cli/console/__init__.py index 23e3e62..7337611 100644 --- a/pulpcore/cli/console/__init__.py +++ b/pulpcore/cli/console/__init__.py @@ -32,6 +32,7 @@ def custom_parse_response( # Continue with normal mounting from pulpcore.cli.console.task import attach_tasks_commands from pulpcore.cli.console.vulnerability import attach_vulnerability_commands + from pulpcore.cli.console.populated_domain import attach_domain_commands @main.group() def console() -> None: @@ -40,3 +41,4 @@ def console() -> None: attach_vulnerability_commands(console) # type: ignore attach_tasks_commands(console) # type: ignore + attach_domain_commands(console) # type: ignore diff --git a/pulpcore/cli/console/populated_domain.py b/pulpcore/cli/console/populated_domain.py new file mode 100644 index 0000000..1dda309 --- /dev/null +++ b/pulpcore/cli/console/populated_domain.py @@ -0,0 +1,42 @@ +import typing as t + +import click +from pulp_glue.common.context import PulpContext +from pulpcore.cli.common.generic import pass_pulp_context + + +@click.group() +def populated_domain() -> None: + """Populated domain management commands.""" + pass + + +@populated_domain.command() +@click.option("--name", required=True, help="Name of the domain to create") +@pass_pulp_context +def create( + pulp_ctx: PulpContext, + name: str, +) -> None: + """Create a new domain using the self-service endpoint.""" + + data = { + "name": name, + "storage_settings": {}, + "storage_class": "storages.backends.s3boto3.S3Boto3Storage", + } + + try: + response = pulp_ctx.call(operation_id="api_pulp_create_domain_post", body=data) + + click.echo(f"Domain '{name}' created successfully!") + click.echo(f"Domain ID: {response.get('pulp_id', 'N/A')}") + + except Exception as e: + click.echo(f"Error creating domain: {str(e)}", err=True) + raise click.ClickException(f"Failed to create domain '{name}': {str(e)}") + + +def attach_domain_commands(main_group: click.Group) -> None: + """Attach populated domain commands to the main console group.""" + main_group.add_command(populated_domain)