Beispiel #1
0
    create_command,
    destroy_command,
    href_option,
    label_command,
    label_select_option,
    list_command,
    name_option,
    resource_option,
    show_command,
)

_ = gettext.gettext

repository_option = resource_option(
    "--repository",
    default_plugin="ansible",
    default_type="ansible",
    context_table={"ansible:ansible": PulpAnsibleRepositoryContext},
)


@click.group()
@click.option(
    "-t",
    "--type",
    "distribution_type",
    type=click.Choice(["ansible"], case_sensitive=False),
    default="ansible",
)
@pass_pulp_context
@click.pass_context
def distribution(ctx: click.Context, pulp_ctx: PulpContext,
Beispiel #2
0
)
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.python.context import (
    PulpPythonDistributionContext,
    PulpPythonRemoteContext,
    PulpPythonRepositoryContext,
)

translation = get_translation(__name__)
_ = translation.gettext

repository_option = resource_option(
    "--repository",
    default_plugin="python",
    default_type="python",
    context_table={"python:python": PulpPythonRepositoryContext},
    help=_("Repository to be used for auto-publishing."
           " When set, this will unset the 'publication'."
           " Specified as '[[<plugin>:]<type>:]<name>' or as href."),
)

remote_option = resource_option(
    "--remote",
    default_plugin="python",
    default_type="python",
    context_table={"python:python": PulpPythonRemoteContext},
    needs_plugins=[PluginRequirement("python", "3.6.0.dev")],
)


@click.group()
Beispiel #3
0
    type_option,
    update_command,
    version_command,
)
from pulpcore.cli.common.i18n import get_translation

translation = get_translation(__name__)
_ = translation.gettext

remote_option = resource_option(
    "--remote",
    default_plugin="ansible",
    default_type="collection",
    context_table={
        "ansible:collection": PulpAnsibleCollectionRemoteContext,
        "ansible:role": PulpAnsibleRoleRemoteContext,
    },
    href_pattern=PulpRemoteContext.HREF_PATTERN,
    help=
    _("Remote used for synching in the form '[[<plugin>:]<resource_type>:]<name>' or by href."
      ),
)

CONTENT_LIST_SCHEMA = s.Schema([{
    "name": s.And(str, len),
    "namespace": s.And(str, len),
    "version": s.And(str, len)
}])


def _content_callback(ctx: click.Context, param: click.Parameter,
Beispiel #4
0
    repository_option,
    resource_option,
    retained_versions_option,
    show_command,
    update_command,
    version_command,
)
from pulpcore.cli.core.generic import task_command
from pulpcore.cli.rpm.common import CHECKSUM_CHOICES
from pulpcore.cli.rpm.context import PulpRpmRemoteContext, PulpRpmRepositoryContext

_ = gettext.gettext

remote_option = resource_option(
    "--remote",
    default_plugin="rpm",
    default_type="rpm",
    context_table={"rpm:rpm": PulpRpmRemoteContext},
)


@click.group()
@click.option(
    "-t",
    "--type",
    "repo_type",
    type=click.Choice(["rpm"], case_sensitive=False),
    default="rpm",
)
@pass_pulp_context
@click.pass_context
def repository(ctx: click.Context, pulp_ctx: PulpContext,
Beispiel #5
0
    show_command,
)
from pulpcore.cli.core.context import PulpSigningServiceContext

from pulpcore.cli.deb.context import (
    PulpAptPublicationContext,
    PulpAptRepositoryContext,
    PulpVerbatimPublicationContext,
)

_ = gettext.gettext


repository_option = resource_option(
    "--repository",
    default_plugin="deb",
    default_type="apt",
    context_table={"deb:apt": PulpAptRepositoryContext},
)


@click.group()
@click.option(
    "-t",
    "--type",
    "publication_type",
    type=click.Choice(["apt", "verbatim"], case_sensitive=False),
    default="apt",
)
@pass_pulp_context
@click.pass_context
def publication(ctx: click.Context, pulp_ctx: PulpContext, publication_type: str) -> None:
Beispiel #6
0
    resource_option,
    show_command,
)
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.core.context import PulpExporterContext

translation = get_translation(__name__)
_ = translation.gettext


multi_repository_option = resource_option(
    "--repository",
    context_table=registered_repository_contexts,
    capabilities=["pulpexport"],
    multiple=True,
    href_pattern=PulpRepositoryContext.HREF_PATTERN,
    help=_(
        "Repository to export from in the form '[[<plugin>:]<resource_type>:]<name>' or by href."
        " Can be called multiple times."
    ),
)


@click.group()
def exporter() -> None:
    pass


@exporter.group()
@pass_pulp_context
@click.pass_context
Beispiel #7
0
    list_command,
    name_option,
    resource_option,
    retained_versions_option,
    show_command,
    update_command,
    version_command,
)

_ = gettext.gettext

remote_option = resource_option(
    "--remote",
    default_plugin="ansible",
    default_type="collection",
    context_table={
        "ansible:collection": PulpAnsibleCollectionRemoteContext,
        "ansible:role": PulpAnsibleRoleRemoteContext,
    },
)


@click.group()
@click.option(
    "-t",
    "--type",
    "repo_type",
    type=click.Choice(["ansible"], case_sensitive=False),
    default="ansible",
)
@pass_pulp_context
Beispiel #8
0
from pulpcore.cli.core.generic import task_command
from pulpcore.cli.python.context import (
    PulpPythonContentContext,
    PulpPythonRemoteContext,
    PulpPythonRepositoryContext,
)

translation = get_translation(__name__)
_ = translation.gettext


remote_option = resource_option(
    "--remote",
    default_plugin="python",
    default_type="python",
    context_table={"python:python": PulpPythonRemoteContext},
    href_pattern=PulpRemoteContext.HREF_PATTERN,
    help=_(
        "Remote used for synching in the form '[[<plugin>:]<resource_type>:]<name>' or by href."
    ),
)


def _content_callback(
    ctx: click.Context, param: click.Parameter, value: Optional[str]
) -> Optional[str]:
    if value:
        pulp_ctx = ctx.find_object(PulpContext)
        assert pulp_ctx is not None
        ctx.obj = PulpPythonContentContext(pulp_ctx, entity={"filename": value})
    return value
Beispiel #9
0
    name_option,
    resource_option,
    show_command,
    update_command,
)
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.file.context import PulpFileDistributionContext, PulpFileRepositoryContext

translation = get_translation(__name__)
_ = translation.gettext

repository_option = resource_option(
    "--repository",
    default_plugin="file",
    default_type="file",
    context_table={"file:file": PulpFileRepositoryContext},
    help=_("Repository to be used for auto-publishing."
           " When set, this will unset the 'publication'."
           " Specified as '[[<plugin>:]<type>:]<name>' or as href."),
)


@click.group()
@click.option(
    "-t",
    "--type",
    "distribution_type",
    type=click.Choice(["file"], case_sensitive=False),
    default="file",
)
@pass_pulp_context
Beispiel #10
0
    label_select_option,
    list_command,
    name_option,
    resource_option,
    show_command,
    update_command,
)

from pulpcore.cli.deb.context import PulpAptDistributionContext, PulpAptRepositoryContext

_ = gettext.gettext

repository_option = resource_option(
    "--repository",
    default_plugin="deb",
    default_type="apt",
    context_table={"deb:apt": PulpAptRepositoryContext},
    help=_("Repository to be used for auto-distributing."
           " Specified as '[[<plugin>:]<type>:]<name>' or as href."),
)


@click.group()
@click.option(
    "-t",
    "--type",
    "distribution_type",
    type=click.Choice(["apt"], case_sensitive=False),
    default="apt",
)
@pass_pulp_context
@click.pass_context
Beispiel #11
0
    resource_option,
    retained_versions_option,
    show_command,
    update_command,
    version_command,
)
from pulpcore.cli.core.generic import task_command

from pulpcore.cli.deb.context import PulpAptRemoteContext, PulpAptRepositoryContext

_ = gettext.gettext

remote_option = resource_option(
    "--remote",
    default_plugin="deb",
    default_type="apt",
    context_table={"deb:apt": PulpAptRemoteContext},
    needs_plugins=[PluginRequirement("deb", "2.12.0")],
)


@click.group()
@click.option(
    "-t",
    "--type",
    "repo_type",
    type=click.Choice(["apt"], case_sensitive=False),
    default="apt",
)
@pass_pulp_context
@click.pass_context
Beispiel #12
0
    existing_paths = set(acs_ctx.show(href)["paths"])

    if paths - existing_paths:
        missing_paths = paths - existing_paths
        raise click.ClickException(
            _("ACS does not have path(s): {}.").format(missing_paths))

    paths = existing_paths - paths
    acs_ctx.update(href, body={"paths": list(paths)})


remote_option = resource_option(
    "--remote",
    default_plugin="rpm",
    default_type="rpm",
    context_table={"rpm:rpm": PulpRpmRemoteContext},
    href_pattern=PulpRemoteContext.HREF_PATTERN,
    help=
    _("Remote to attach to ACS in the form '[[<plugin>:]<resource_type>:]<name>' or by href."
      ),
)
lookup_options = [href_option, name_option]
update_options = [remote_option]
create_options = update_options + [
    click.option("--name", required=True), path_option
]

acs.add_command(list_command())
acs.add_command(show_command(decorators=lookup_options))
acs.add_command(create_command(decorators=create_options))
acs.add_command(update_command(decorators=lookup_options + update_options))
acs.add_command(destroy_command(decorators=lookup_options))
Beispiel #13
0
    show_command,
    update_command,
    version_command,
)
from pulpcore.cli.container.context import (
    PulpContainerPushRepositoryContext,
    PulpContainerRemoteContext,
    PulpContainerRepositoryContext,
)
from pulpcore.cli.core.generic import task_command

_ = gettext.gettext

remote_option = resource_option(
    "--remote",
    default_plugin="container",
    default_type="container",
    context_table={"container:container": PulpContainerRemoteContext},
)


@click.group()
@click.option(
    "-t",
    "--type",
    "repo_type",
    type=click.Choice(["container", "push"], case_sensitive=False),
    default="container",
)
@pass_pulp_context
@click.pass_context
def repository(ctx: click.Context, pulp_ctx: PulpContext,
Beispiel #14
0
    EntityFieldDefinition,
    PluginRequirement,
    PulpContext,
    PulpEntityContext,
    pass_pulp_context,
)
from pulpcore.cli.common.generic import resource_option
from pulpcore.cli.rpm.context import PulpRpmCompsXmlContext, PulpRpmRepositoryContext

_ = gettext.gettext

repository_option = resource_option(
    "--repository",
    default_plugin="rpm",
    default_type="rpm",
    context_table={"rpm:rpm": PulpRpmRepositoryContext},
    href_pattern=PulpRpmRepositoryContext.HREF_PATTERN,
    help=_(
        "Repository to associate the comps-units to, takes <name> or href."),
)


@click.command()
@click.option("--file", type=click.File("rb"), required=True)
@repository_option
@click.option("--replace", type=bool, default=False)
@pass_pulp_context
def comps_upload(
    pulp_ctx: PulpContext,
    file: IO[bytes],
    repository: Optional[EntityFieldDefinition],
Beispiel #15
0
    show_command,
    update_command,
    version_command,
)
from pulpcore.cli.core.generic import task_command
from pulpcore.cli.file.context import (
    PulpFileContentContext,
    PulpFileRemoteContext,
    PulpFileRepositoryContext,
)

_ = gettext.gettext

remote_option = resource_option(
    "--remote",
    default_plugin="file",
    default_type="file",
    context_table={"file:file": PulpFileRemoteContext},
)


def _content_callback(ctx: click.Context, param: click.Parameter,
                      value: Any) -> Any:
    if value:
        pulp_ctx = ctx.find_object(PulpContext)
        assert pulp_ctx is not None
        ctx.obj = PulpFileContentContext(pulp_ctx, entity=value)
    return value


@click.group()
@click.option(
Beispiel #16
0
    "publication_type",
    type=click.Choice(["rpm"], case_sensitive=False),
    default="rpm",
)
@pass_pulp_context
@click.pass_context
def publication(ctx: click.Context, pulp_ctx: PulpContext, publication_type: str) -> None:
    if publication_type == "rpm":
        ctx.obj = PulpRpmPublicationContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option]
create_options = [
    resource_option(
        "--repository",
        default_plugin="rpm",
        default_type="rpm",
        context_table={"rpm:rpm": PulpRpmRepositoryContext},
    ),
    click.option(
        "--version", type=int, help=_("a repository version number, leave blank for latest")
    ),
]

publication.add_command(list_command(decorators=publication_filter_options))
publication.add_command(show_command(decorators=lookup_options))
publication.add_command(create_command(decorators=create_options))
publication.add_command(destroy_command(decorators=lookup_options))
Beispiel #17
0
    create_command,
    destroy_command,
    href_option,
    list_command,
    publication_filter_options,
    resource_option,
    show_command,
)
from pulpcore.cli.python.context import PulpPythonPublicationContext, PulpPythonRepositoryContext

_ = gettext.gettext


repository_option = resource_option(
    "--repository",
    default_plugin="python",
    default_type="python",
    context_table={"python:python": PulpPythonRepositoryContext},
)


@click.group()
@click.option(
    "-t",
    "--type",
    "publication_type",
    type=click.Choice(["pypi"], case_sensitive=False),
    default="pypi",
)
@pass_pulp_context
@click.pass_context
def publication(ctx: click.Context, pulp_ctx: PulpContext, publication_type: str) -> None:
Beispiel #18
0
    resource_option,
    show_command,
)
from pulpcore.cli.container.context import (
    PulpContainerDistributionContext,
    PulpContainerPushRepositoryContext,
    PulpContainerRepositoryContext,
)

_ = gettext.gettext

repository_option = resource_option(
    "--repository",
    default_plugin="container",
    default_type="container",
    context_table={
        "container:container": PulpContainerRepositoryContext,
        "container:push": PulpContainerPushRepositoryContext,
    },
)


@click.group()
@click.option(
    "-t",
    "--type",
    "distribution_type",
    type=click.Choice(["container"], case_sensitive=False),
    default="container",
)
@pass_pulp_context
Beispiel #19
0
    update_command,
    version_command,
)
from pulpcore.cli.core.generic import task_command
from pulpcore.cli.python.context import (
    PulpPythonContentContext,
    PulpPythonRemoteContext,
    PulpPythonRepositoryContext,
)

_ = gettext.gettext


remote_option = resource_option(
    "--remote",
    default_plugin="python",
    default_type="python",
    context_table={"python:python": PulpPythonRemoteContext},
)


def _content_callback(
    ctx: click.Context, param: click.Parameter, value: Optional[str]
) -> Optional[str]:
    if value:
        pulp_ctx = ctx.find_object(PulpContext)
        assert pulp_ctx is not None
        ctx.obj = PulpPythonContentContext(pulp_ctx, entity={"filename": value})
    return value


@click.group()