forked from pulp/pulp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes pulp#133
- Loading branch information
David Davis
committed
Feb 15, 2021
1 parent
e701ec2
commit b060e36
Showing
10 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support for pulp-2to3-migration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pulpcore.cli.common import main | ||
from pulpcore.cli.common.context import PulpContext, pass_pulp_context | ||
from pulpcore.cli.migration.plan import plan | ||
from pulpcore.cli.migration.pulp2 import pulp2 | ||
|
||
|
||
@main.group() | ||
@pass_pulp_context | ||
def migration(pulp_ctx: PulpContext) -> None: | ||
pulp_ctx.needs_plugin("pulp_2to3_migration") | ||
|
||
|
||
migration.add_command(plan) | ||
migration.add_command(pulp2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import Any | ||
|
||
from pulpcore.cli.common.context import PulpEntityContext | ||
|
||
|
||
class PulpMigrationPlanContext(PulpEntityContext): | ||
ENTITY = "pulp_2to3_migration_migration_plan" | ||
HREF = "pulp_2to3_migration_migration_plan_href" | ||
LIST_ID = "migration_plans_list" | ||
READ_ID = "migration_plans_read" | ||
CREATE_ID = "migration_plans_create" | ||
UPDATE_ID = "migration_plans_partial_update" | ||
DELETE_ID = "migration_plans_delete" | ||
|
||
def run(self, href: str) -> Any: | ||
return self.pulp_ctx.call("migration_plans_run", parameters={self.HREF: href}) | ||
|
||
def reset(self, href: str) -> Any: | ||
return self.pulp_ctx.call("migration_plans_reset", parameters={self.HREF: href}) | ||
|
||
|
||
class PulpMigrationPulp2ContentContext(PulpEntityContext): | ||
ENTITY = "pulp_2to3_migration_pulp2_content" | ||
HREF = "pulp_2to3_migration_pulp2_content_href" | ||
LIST_ID = "pulp2content_list" | ||
READ_ID = "pulp2content_read" | ||
|
||
|
||
class PulpMigrationPulp2RepositoryContext(PulpEntityContext): | ||
ENTITY = "pulp_2to3_migration_pulp2_repository" | ||
HREF = "pulp_2to3_migration_pulp2_repository_href" | ||
LIST_ID = "pulp2repositories_list" | ||
READ_ID = "pulp2repositories_read" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import click | ||
|
||
from pulpcore.cli.common.context import PulpContext, pass_entity_context, pass_pulp_context | ||
from pulpcore.cli.common.generic import ( | ||
create_command, | ||
destroy_command, | ||
href_option, | ||
list_command, | ||
show_command, | ||
) | ||
from pulpcore.cli.migration.context import PulpMigrationPlanContext | ||
|
||
|
||
@click.group() | ||
@pass_pulp_context | ||
@click.pass_context | ||
def plan(ctx: click.Context, pulp_ctx: PulpContext) -> None: | ||
ctx.obj = PulpMigrationPlanContext(pulp_ctx) | ||
|
||
|
||
plan.add_command(list_command()) | ||
plan.add_command(show_command(decorators=[href_option])) | ||
plan.add_command(destroy_command(decorators=[href_option])) | ||
|
||
create_options = [click.option("--plan", required=True, help="Migration plan in JSON format")] | ||
plan.add_command(create_command(decorators=create_options)) | ||
|
||
|
||
@plan.command(help="Run migration plan") | ||
@click.option("--href", required=True, help="HREF of the plan") | ||
@pass_entity_context | ||
def run(plan_ctx: PulpMigrationPlanContext, href: str) -> None: | ||
plan_ctx.run(href) | ||
|
||
|
||
@plan.command(help="Reset Pulp 3 data for plugins specified in the migration plan") | ||
@click.option("--href", required=True, help="HREF of the plan") | ||
@pass_entity_context | ||
def reset(plan_ctx: PulpMigrationPlanContext, href: str) -> None: | ||
plan_ctx.reset(href) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import click | ||
|
||
from pulpcore.cli.common.context import PulpContext, pass_pulp_context | ||
from pulpcore.cli.common.generic import href_option, list_command, show_command | ||
from pulpcore.cli.migration.context import ( | ||
PulpMigrationPulp2ContentContext, | ||
PulpMigrationPulp2RepositoryContext, | ||
) | ||
|
||
|
||
@click.group() | ||
def pulp2() -> None: | ||
pass | ||
|
||
|
||
@pulp2.group() | ||
@pass_pulp_context | ||
@click.pass_context | ||
def content(ctx: click.Context, pulp_ctx: PulpContext) -> None: | ||
ctx.obj = PulpMigrationPulp2ContentContext(pulp_ctx) | ||
|
||
|
||
content.add_command(list_command()) | ||
content.add_command(show_command(decorators=[href_option])) | ||
|
||
|
||
@pulp2.group() | ||
@pass_pulp_context | ||
@click.pass_context | ||
def repository(ctx: click.Context, pulp_ctx: PulpContext) -> None: | ||
ctx.obj = PulpMigrationPulp2RepositoryContext(pulp_ctx) | ||
pass | ||
|
||
|
||
repository.add_command(list_command()) | ||
repository.add_command(show_command(decorators=[href_option])) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
# shellcheck source=tests/scripts/config.source | ||
. "$(dirname "$(dirname "$(realpath "$0")")")"/config.source | ||
|
||
pulp debug has-plugin --name "pulp_2to3_migration" || exit 3 | ||
|
||
plan_href="" | ||
plan_json='{"plugins": [{"type": "iso"}]}' | ||
|
||
cleanup() { | ||
pulp migration plan destroy --href "$plan_href" || true | ||
} | ||
trap cleanup EXIT | ||
|
||
expect_succ pulp migration plan create --plan "$plan_json" | ||
plan_href=$(echo "$OUTPUT" | jq -r ".pulp_href") | ||
expect_succ pulp migration plan show --href "$plan_href" | ||
|
||
expect_succ pulp migration plan list | ||
expect_succ pulp migration plan destroy --href "$plan_href" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
# shellcheck source=tests/scripts/config.source | ||
. "$(dirname "$(dirname "$(realpath "$0")")")"/config.source | ||
|
||
pulp debug has-plugin --name "pulp_2to3_migration" || exit 3 | ||
|
||
expect_succ pulp migration pulp2 repository list | ||
expect_succ pulp migration pulp2 content list |