WIP
This commit is contained in:
parent
e70a0584c9
commit
a7a5b5c8ea
43 changed files with 5531 additions and 9 deletions
1
control_plane/management/commands/__init__.py
Normal file
1
control_plane/management/commands/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Management commands for local control-plane operations."""
|
||||
57
control_plane/management/commands/create_test_deployment.py
Normal file
57
control_plane/management/commands/create_test_deployment.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
from control_plane.local_test_deployment import create_test_deployment
|
||||
from control_plane.local_test_deployment import provision_test_deployment
|
||||
from control_plane.local_test_deployment import queue_test_deployment_provisioning
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import ArgumentParser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Create a randomized local test deployment and optionally wait for readiness."""
|
||||
|
||||
help = "Create a randomized tenant and provision a local test deployment inline by default."
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
"""Register CLI flags for local test deployment orchestration."""
|
||||
parser.add_argument(
|
||||
"--no-wait",
|
||||
action="store_true",
|
||||
help="Queue provisioning asynchronously and return immediately without running it inline.",
|
||||
)
|
||||
|
||||
def handle(self, *_args: str, **options: bool | float) -> None:
|
||||
"""Create a randomized local test deployment and optionally wait for readiness.
|
||||
|
||||
Raises:
|
||||
CommandError: If the deployment fails or never becomes ready.
|
||||
"""
|
||||
created = create_test_deployment()
|
||||
self.stdout.write(f"tenant_slug={created.tenant.slug}")
|
||||
self.stdout.write(f"site_slug={created.hosted_site.slug}")
|
||||
self.stdout.write(f"deployment_id={created.deployment.id}")
|
||||
self.stdout.write(f"sentinel_url={created.sentinel_url}")
|
||||
|
||||
if options["no_wait"]:
|
||||
try:
|
||||
task_id = queue_test_deployment_provisioning(str(created.deployment.id))
|
||||
except RuntimeError as error:
|
||||
raise CommandError(str(error)) from error
|
||||
|
||||
self.stdout.write(f"celery_task_id={task_id}")
|
||||
self.stdout.write("status=queued")
|
||||
return
|
||||
|
||||
self.stdout.write("execution_mode=inline")
|
||||
try:
|
||||
deployment = provision_test_deployment(str(created.deployment.id))
|
||||
except (RuntimeError, TimeoutError, ValueError) as error:
|
||||
raise CommandError(str(error)) from error
|
||||
|
||||
self.stdout.write(f"status={deployment.status}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue