Beispiel #1
0
@click.pass_context
def repository(ctx: click.Context, pulp_ctx: PulpContext, repo_type: str) -> None:
    if repo_type == "python":
        ctx.obj = PulpPythonRepositoryContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option, name_option]
nested_lookup_options = [repository_href_option, repository_option]
update_options = [
    click.option("--description"),
    remote_option,
    pulp_option(
        "--autopublish/--no-autopublish",
        needs_plugins=[PluginRequirement("python", "3.3.0.dev")],
        default=None,
    ),
    retained_versions_option,
]
create_options = update_options + [click.option("--name", required=True)]
package_option = click.option(
    "--filename",
    callback=_content_callback,
    expose_value=False,
    help=_("Filename of the python package"),
)
content_json_callback = create_content_json_callback(PulpPythonContentContext)
modify_options = [
    click.option(
        "--add-content",
Beispiel #2
0
    null_callback,
    pulp_option,
    show_command,
    update_command,
)
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.core.context import PulpUserContext, PulpUserRoleContext

translation = get_translation(__name__)
_ = translation.gettext

req_core_3_17 = PluginRequirement("core", min="3.17.dev")

username_option = pulp_option(
    "--username",
    help=_("Username of the {entity}"),
    expose_value=False,
    callback=lookup_callback("username", PulpUserContext),
)
lookup_options = [
    href_option,
    username_option,
]
update_options = [
    click.option(
        "--password",
        help=
        _("Password for the user. Provide an empty string to disable password authentication."
          ),
    ),
    click.option("--first-name"),
    click.option("--last-name"),
Beispiel #3
0
def repository(ctx: click.Context, pulp_ctx: PulpContext, repo_type: str) -> None:
    if repo_type == "file":
        ctx.obj = PulpFileRepositoryContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option, name_option]
nested_lookup_options = [repository_href_option, repository_option]
update_options = [
    click.option("--description"),
    click.option("--remote", callback=_remote_callback),
    click.option("--manifest"),
    pulp_option(
        "--autopublish/--no-autopublish",
        needs_plugins=[PluginRequirement("file", "1.7.0")],
        default=None,
    ),
    pulp_option("--retained-versions", needs_plugins=[PluginRequirement("core", "3.13.0.dev")]),
]
create_options = update_options + [
    click.option("--name", required=True),
]
file_options = [
    click.option("--sha256", cls=GroupOption, expose_value=False, group=["relative_path"]),
    click.option(
        "--relative-path",
        cls=GroupOption,
        expose_value=False,
        group=["sha256"],
        callback=_content_callback,
Beispiel #4
0
               repo_type: str) -> None:
    if repo_type == "file":
        ctx.obj = PulpFileRepositoryContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option, name_option]
nested_lookup_options = [repository_href_option, repository_option]
update_options = [
    click.option("--description"),
    remote_option,
    click.option("--manifest"),
    pulp_option(
        "--autopublish/--no-autopublish",
        needs_plugins=[PluginRequirement("file", "1.7.0")],
        default=None,
    ),
    retained_versions_option,
]
create_options = update_options + [click.option("--name", required=True)]
file_options = [
    click.option("--sha256",
                 cls=GroupOption,
                 expose_value=False,
                 group=["relative_path"]),
    click.option(
        "--relative-path",
        cls=GroupOption,
        expose_value=False,
        group=["sha256"],
Beispiel #5
0
filter_options = [
    label_select_option, base_path_option, base_path_contains_option
]
lookup_options = [href_option, name_option]
update_options = [
    click.option("--base-path"),
    click.option(
        "--publication",
        help=
        _("Publication to be served. This will unset the 'repository' and disable auto publish."
          ),
    ),
    repository_option,
    pulp_option(
        "--allow-uploads/--block-uploads",
        needs_plugins=[PluginRequirement("python", "3.4.0.dev")],
        default=None,
    ),
    remote_option,
]
create_options = update_options + [click.option("--name", required=True)]

distribution.add_command(list_command(decorators=filter_options))
distribution.add_command(show_command(decorators=lookup_options))
distribution.add_command(create_command(decorators=create_options))
distribution.add_command(
    update_command(decorators=lookup_options + update_options))
distribution.add_command(destroy_command(decorators=lookup_options))
distribution.add_command(label_command())
Beispiel #6
0

##############################################################################
# Generic reusable commands


task_filter = [
    click.option("--name", help=_("List only tasks with this name.")),
    click.option(
        "--name-contains",
        "name__contains",
        help=_("List only tasks whose name contains this."),
    ),
    pulp_option(
        "--cid",
        "logging_cid__contains",
        help=_("List only tasks with this correlation id."),
        needs_plugins=[PluginRequirement("core", "3.14.0.dev")],
    ),
    click.option(
        "--state",
        type=click.Choice(
            ["waiting", "skipped", "running", "completed", "failed", "canceled", "canceling"],
            case_sensitive=False,
        ),
        help=_("List only tasks in this state."),
    ),
]


def task_command(**kwargs: Any) -> click.Command:
    """A factory that creates a nested task command group."""
Beispiel #7
0
    ),
]
update_options = [
    click.option("--description"),
    click.option("--retain-package-versions", type=int),
    remote_option,
    click.option("--metadata-checksum-type",
                 type=click.Choice(CHECKSUM_CHOICES, case_sensitive=False)),
    click.option("--package-checksum-type",
                 type=click.Choice(CHECKSUM_CHOICES, case_sensitive=False)),
    click.option("--gpgcheck", type=click.Choice(("0", "1"))),
    click.option("--repo-gpgcheck", type=click.Choice(("0", "1"))),
    click.option("--sqlite-metadata/--no-sqlite-metadata", default=None),
    pulp_option(
        "--autopublish/--no-autopublish",
        needs_plugins=[PluginRequirement("rpm", "3.12.0")],
        default=None,
    ),
    retained_versions_option,
]
create_options = update_options + [click.option("--name", required=True)]

repository.add_command(list_command(decorators=[label_select_option]))
repository.add_command(show_command(decorators=lookup_options))
repository.add_command(create_command(decorators=create_options))
repository.add_command(
    update_command(decorators=lookup_options + update_options))
repository.add_command(destroy_command(decorators=lookup_options))
repository.add_command(task_command(decorators=nested_lookup_options))
repository.add_command(version_command(decorators=nested_lookup_options))
repository.add_command(label_command(decorators=nested_lookup_options))
Beispiel #8
0
@pass_pulp_context
@click.pass_context
def content(ctx: click.Context, pulp_ctx: PulpContext,
            content_type: str) -> None:
    if content_type == "collection-version":
        ctx.obj = PulpAnsibleCollectionVersionContext(pulp_ctx)
    elif content_type == "role":
        ctx.obj = PulpAnsibleRoleContext(pulp_ctx)
    else:
        raise NotImplementedError()


collection_context = (PulpAnsibleCollectionVersionContext, )
role_context = (PulpAnsibleRoleContext, )
list_options = [
    pulp_option("--name", help=_("Name of {entity}")),
    pulp_option("--namespace", help=_("Namespace of {entity}")),
    pulp_option("--version", help=_("Version of {entity}")),
    pulp_option(
        "--latest",
        "is_highest",
        is_flag=True,
        default=None,
        help=_("Only show highest version of collection version"),
        allowed_with_contexts=collection_context,
    ),
    pulp_option(
        "--tags",
        help=_("Comma separated list of tags that must all match"),
        allowed_with_contexts=collection_context,
    ),
Beispiel #9
0
def repository(ctx: click.Context, pulp_ctx: PulpContext,
               repo_type: str) -> None:
    if repo_type == "ansible":
        ctx.obj = PulpAnsibleRepositoryContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option, name_option]
create_options = [
    click.option("--name", required=True),
    click.option("--description"),
    click.option("--remote",
                 callback=_remote_callback,
                 help=_("an optional remote")),
    pulp_option("--retained-versions",
                needs_plugins=[PluginRequirement("core", "3.13.0.dev")]),
]
update_options = [
    click.option("--description"),
    click.option("--remote",
                 callback=_remote_callback,
                 help=_("new optional remote")),
    pulp_option("--retained-versions",
                needs_plugins=[PluginRequirement("core", "3.13.0.dev")]),
]

repository.add_command(show_command(decorators=lookup_options))
repository.add_command(list_command(decorators=[label_select_option]))
repository.add_command(destroy_command(decorators=lookup_options))
repository.add_command(version_command())
repository.add_command(create_command(decorators=create_options))
Beispiel #10
0

lookup_options = [href_option, name_option]
python_remote_options = [
    click.option("--policy",
                 type=click.Choice(["immediate", "on_demand", "streamed"],
                                   case_sensitive=False)),
    click.option("--includes",
                 callback=_package_list_callback,
                 help=_("Package allowlist")),
    click.option("--excludes",
                 callback=_package_list_callback,
                 help=_("Package blocklist")),
    click.option("--prereleases", type=click.BOOL, default=True),
    pulp_option("--keep-latest-packages",
                type=int,
                needs_plugins=[PluginRequirement("python", "3.2.0")]),
    pulp_option(
        "--package-types",
        callback=load_json_callback,
        needs_plugins=[PluginRequirement("python", "3.2.0")],
    ),
    pulp_option(
        "--exclude-platforms",
        callback=load_json_callback,
        needs_plugins=[PluginRequirement("python", "3.2.0")],
    ),
]

remote.add_command(list_command(decorators=[label_select_option]))
remote.add_command(show_command(decorators=lookup_options))
Beispiel #11
0
DATETIME_FORMATS = ["%Y-%m-%d", "%Y-%m-%dT%H:%M:%S"]


def _uuid_callback(ctx: click.Context, param: click.Parameter,
                   value: Optional[str]) -> Optional[str]:
    if value is not None:
        entity_ctx = ctx.find_object(PulpEntityContext)
        assert entity_ctx is not None
        entity_ctx.pulp_href = f"/pulp/api/v3/tasks/{value}/"
    return value


uuid_option = pulp_option(
    "--uuid",
    help=_("UUID of the {entity}"),
    callback=_uuid_callback,
    expose_value=False,
)


@click.group()
@pass_pulp_context
@click.pass_context
def task(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpTaskContext(pulp_ctx)


task.add_command(list_command(decorators=task_filter))
task.add_command(destroy_command(decorators=[href_option, uuid_option]))
task.add_command(
    role_command(decorators=[href_option, uuid_option],
Beispiel #12
0
    elif remote_type == "collection":
        ctx.obj = PulpAnsibleCollectionRemoteContext(pulp_ctx)
    else:
        raise NotImplementedError()


collection_context = (PulpAnsibleCollectionRemoteContext, )
lookup_options = [href_option, name_option]
remote_options = [
    click.option("--policy", help=_("policy to use when downloading")),
]
collection_options = [
    pulp_option(
        "--requirements-file",
        callback=_requirements_callback,
        type=click.File(),
        help=_("Collections only: a Collection requirements yaml"),
        allowed_with_contexts=collection_context,
    ),
    pulp_option(
        "--requirements",
        callback=_requirements_callback,
        help=_("Collections only: a string of a requirements yaml"),
        allowed_with_contexts=collection_context,
    ),
    pulp_option(
        "--auth-url",
        callback=_requirements_callback,
        help=_("Collections only: URL to receive a session token"),
        allowed_with_contexts=collection_context,
    ),