Skip to content

Commit

Permalink
frontend: add script for changing storage for a project
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Aug 23, 2024
1 parent 69957fc commit ec203d9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
39 changes: 39 additions & 0 deletions frontend/coprs_frontend/commands/change_storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Change a storage for a project
"""

import sys
import click
from copr_common.enums import StorageEnum
from coprs import db
from coprs.logic.coprs_logic import CoprsLogic
from coprs.logic.actions_logic import ActionsLogic


@click.command()
@click.argument("fullname", required=True)
@click.argument(
"storage",
required=True,
type=click.Choice(["backend", "pulp"])
)
def change_storage(fullname, storage):
"""
Change a storage for a project
"""
if "/" not in fullname:
print("Must be a fullname, e.g. @copr/copr-dev")
sys.exit(1)

ownername, projectname = fullname.split("/", 1)
copr = CoprsLogic.get_by_ownername_coprname(ownername, projectname)
copr.storage = StorageEnum(storage)
db.session.add(copr)

action = ActionsLogic.send_createrepo(copr)
db.session.add(action)

db.session.commit()
print("Configured storage for {0} to {1}".format(copr.full_name, storage))
print("Submitted action to create repositories: {0}".format(action.id))
print("Existing builds not migrated (not implemented yet).")
2 changes: 1 addition & 1 deletion frontend/coprs_frontend/coprs/logic/actions_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def send_createrepo(cls, copr, dirnames=None, chroots=None, devel=None,
if priority is not None:
action.priority = priority
db.session.add(action)

return action

@classmethod
def send_delete_copr(cls, copr):
Expand Down
2 changes: 2 additions & 0 deletions frontend/coprs_frontend/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import commands.warning_banner
import commands.usage_treemap
import commands.failed_to_succeeded_stats
import commands.change_storage

from coprs import app

Expand Down Expand Up @@ -98,6 +99,7 @@
"warning_banner",
"usage_treemap",
"failed_to_succeeded_stats",
"change_storage",
]


Expand Down

0 comments on commit ec203d9

Please sign in to comment.