-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #133
- Loading branch information
David Davis
committed
Feb 13, 2021
1 parent
c1f1774
commit 09d51a0
Showing
6 changed files
with
96 additions
and
2 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,12 @@ | ||
from pulpcore.cli.common import main | ||
from pulpcore.cli.common.context import PulpContext, pass_pulp_context | ||
from pulpcore.cli.migration.plan import plan | ||
|
||
|
||
@main.group() | ||
@pass_pulp_context | ||
def migration(pulp_ctx: PulpContext) -> None: | ||
pulp_ctx.needs_plugin("pulp_2to3_migration") | ||
|
||
|
||
migration.add_command(plan) |
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,19 @@ | ||
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}) |
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, | ||
PulpEntityContext, | ||
pass_entity_context, | ||
pass_pulp_context, | ||
) | ||
from pulpcore.cli.common.generic import create_command, destroy_by_href, list_entities, show_by_href | ||
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) | ||
pass | ||
|
||
|
||
plan.add_command(list_entities) | ||
plan.add_command(show_by_href) | ||
plan.add_command(destroy_by_href) | ||
|
||
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
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" |