hexaqueue-cli 0.5.0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/PKG-INFO +6 -6
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/pyproject.toml +7 -7
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/pyproject.toml.orig +7 -7
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/adapters/local.py +23 -4
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/adapters/presenter.py +69 -10
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/commands/__init__.py +4 -0
- hexaqueue_cli-0.7.0/src/hexaqueue_cli/commands/admin.py +172 -0
- hexaqueue_cli-0.7.0/src/hexaqueue_cli/commands/cluster.py +983 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/commands/collateral.py +3 -0
- hexaqueue_cli-0.7.0/src/hexaqueue_cli/commands/mcp.py +117 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/commands/run.py +16 -1
- hexaqueue_cli-0.7.0/src/hexaqueue_cli/commands/scanner.py +198 -0
- hexaqueue_cli-0.7.0/src/hexaqueue_cli/commands/server.py +181 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/commands/workflow.py +5 -1
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/domain/session.py +23 -16
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/main.py +21 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/ports/client.py +20 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/README.md +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/__init__.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/adapters/__init__.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/commands/node.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/commands/suite.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/domain/__init__.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/domain/models.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/domain/options.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/domain/parser.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/infra/__init__.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/infra/bootstrap.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/infra/options.py +0 -0
- {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.7.0}/src/hexaqueue_cli/ports/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hexaqueue-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Hexaqueue CLI - Modern developer and operator terminal interface
|
|
5
5
|
Author: Richard West
|
|
6
6
|
Author-email: Richard West <dopplereffect.us@gmail.com>
|
|
@@ -9,14 +9,14 @@ Requires-Dist: hexaqueue-core
|
|
|
9
9
|
Requires-Dist: hexaqueue-server
|
|
10
10
|
Requires-Dist: hexaqueue-worker
|
|
11
11
|
Requires-Dist: hexaqueue-workflow
|
|
12
|
-
Requires-Dist: hexastack-cli>=0.
|
|
13
|
-
Requires-Dist: hexastack-core>=0.
|
|
14
|
-
Requires-Dist: hexastack-cqrs>=0.
|
|
15
|
-
Requires-Dist: hexastack-grpc>=0.
|
|
12
|
+
Requires-Dist: hexastack-cli>=0.11.0
|
|
13
|
+
Requires-Dist: hexastack-core>=0.11.0
|
|
14
|
+
Requires-Dist: hexastack-cqrs>=0.11.0
|
|
15
|
+
Requires-Dist: hexastack-grpc>=0.11.0
|
|
16
16
|
Requires-Dist: pyyaml>=6.0.2
|
|
17
17
|
Requires-Dist: rich>=13.8.0
|
|
18
18
|
Requires-Dist: typer>=0.15.0
|
|
19
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
|
|
22
22
|
# 💻 `hexaqueue-cli`
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "hexaqueue-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.7.0"
|
|
4
4
|
description = "Hexaqueue CLI - Modern developer and operator terminal interface"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
|
-
requires-python = ">=3.
|
|
7
|
+
requires-python = ">=3.12"
|
|
8
8
|
dependencies = [
|
|
9
9
|
"hexaqueue-core",
|
|
10
10
|
"hexaqueue-server",
|
|
11
11
|
"hexaqueue-worker",
|
|
12
12
|
"hexaqueue-workflow",
|
|
13
|
-
"hexastack-cli>=0.
|
|
14
|
-
"hexastack-core>=0.
|
|
15
|
-
"hexastack-cqrs>=0.
|
|
16
|
-
"hexastack-grpc>=0.
|
|
13
|
+
"hexastack-cli>=0.11.0",
|
|
14
|
+
"hexastack-core>=0.11.0",
|
|
15
|
+
"hexastack-cqrs>=0.11.0",
|
|
16
|
+
"hexastack-grpc>=0.11.0",
|
|
17
17
|
"pyyaml>=6.0.2",
|
|
18
18
|
"rich>=13.8.0",
|
|
19
19
|
"typer>=0.15.0",
|
|
@@ -27,7 +27,7 @@ email = "dopplereffect.us@gmail.com"
|
|
|
27
27
|
hq = "hexaqueue_cli.main:app"
|
|
28
28
|
|
|
29
29
|
[build-system]
|
|
30
|
-
requires = ["uv_build>=0.12.3,<0.
|
|
30
|
+
requires = ["uv_build>=0.12.3,<0.14.0"]
|
|
31
31
|
build-backend = "uv_build"
|
|
32
32
|
|
|
33
33
|
[tool.uv.sources.hexaqueue-core]
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "hexaqueue-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.7.0"
|
|
4
4
|
description = "Hexaqueue CLI - Modern developer and operator terminal interface"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
authors = [
|
|
8
8
|
{ name = "Richard West", email = "dopplereffect.us@gmail.com" }
|
|
9
9
|
]
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
11
|
dependencies = [
|
|
12
12
|
"hexaqueue-core",
|
|
13
13
|
"hexaqueue-server",
|
|
14
14
|
"hexaqueue-worker",
|
|
15
15
|
"hexaqueue-workflow",
|
|
16
|
-
"hexastack-cli>=0.
|
|
17
|
-
"hexastack-core>=0.
|
|
18
|
-
"hexastack-cqrs>=0.
|
|
19
|
-
"hexastack-grpc>=0.
|
|
16
|
+
"hexastack-cli>=0.11.0",
|
|
17
|
+
"hexastack-core>=0.11.0",
|
|
18
|
+
"hexastack-cqrs>=0.11.0",
|
|
19
|
+
"hexastack-grpc>=0.11.0",
|
|
20
20
|
"pyyaml>=6.0.2",
|
|
21
21
|
"rich>=13.8.0",
|
|
22
22
|
"typer>=0.15.0",
|
|
@@ -26,7 +26,7 @@ dependencies = [
|
|
|
26
26
|
hq = "hexaqueue_cli.main:app"
|
|
27
27
|
|
|
28
28
|
[build-system]
|
|
29
|
-
requires = ["uv_build>=0.12.3,<0.
|
|
29
|
+
requires = ["uv_build>=0.12.3,<0.14.0"]
|
|
30
30
|
build-backend = "uv_build"
|
|
31
31
|
|
|
32
32
|
[tool.uv.sources]
|
|
@@ -8,6 +8,7 @@ Notes/Architectural Intent:
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
10
|
from collections.abc import AsyncIterator
|
|
11
|
+
from datetime import UTC, datetime
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from uuid import uuid4
|
|
13
14
|
|
|
@@ -143,6 +144,28 @@ class LocalClientAdapter(ClientPort):
|
|
|
143
144
|
c async for c in self._session.log_stream.stream_logs(job_id, follow=False)
|
|
144
145
|
]
|
|
145
146
|
|
|
147
|
+
async def get_log_download_url(
|
|
148
|
+
self,
|
|
149
|
+
job_id: str,
|
|
150
|
+
expires_in_seconds: int = 900,
|
|
151
|
+
user_id: str = "default",
|
|
152
|
+
elevate: bool = False,
|
|
153
|
+
) -> str:
|
|
154
|
+
"""Retrieve presigned direct download URL for job execution logs."""
|
|
155
|
+
from hexaqueue_core.domain.cqrs import (
|
|
156
|
+
GetJobLogDownloadUrlQuery,
|
|
157
|
+
PresignedDownloadUrl,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
qry = GetJobLogDownloadUrlQuery(
|
|
161
|
+
job_id=job_id,
|
|
162
|
+
expires_in_seconds=expires_in_seconds,
|
|
163
|
+
user_id=user_id,
|
|
164
|
+
elevate=elevate,
|
|
165
|
+
)
|
|
166
|
+
res: PresignedDownloadUrl = self._session.pipeline.execute(qry)
|
|
167
|
+
return res.download_url
|
|
168
|
+
|
|
146
169
|
async def stream_logs(
|
|
147
170
|
self, job_id: str, follow: bool = False, tail: int | None = None
|
|
148
171
|
) -> AsyncIterator[LogChunk]:
|
|
@@ -208,8 +231,6 @@ class LocalClientAdapter(ClientPort):
|
|
|
208
231
|
is_admin: bool = False,
|
|
209
232
|
) -> SchedulingDecisionReport:
|
|
210
233
|
"""Generate explainability report for a job in the local session."""
|
|
211
|
-
from datetime import UTC, datetime
|
|
212
|
-
|
|
213
234
|
from hexaqueue_core.domain.explainability import SchedulerExplainabilityEngine
|
|
214
235
|
from hexaqueue_core.domain.redaction import MultiTenantRedactionFilter
|
|
215
236
|
from hexaqueue_core.domain.scheduling import ResourceSlotPool
|
|
@@ -234,8 +255,6 @@ class LocalClientAdapter(ClientPort):
|
|
|
234
255
|
is_admin: bool = False,
|
|
235
256
|
) -> FairShareTreeReport:
|
|
236
257
|
"""Generate fair-share tree report for the local session."""
|
|
237
|
-
from datetime import UTC, datetime
|
|
238
|
-
|
|
239
258
|
from hexaqueue_core.domain.explainability import (
|
|
240
259
|
SchedulerExplainabilityEngine,
|
|
241
260
|
)
|
|
@@ -21,6 +21,7 @@ from rich.tree import Tree
|
|
|
21
21
|
|
|
22
22
|
from hexaqueue_cli.domain.models import ClusterStatsReport
|
|
23
23
|
from hexaqueue_cli.domain.options import OutputFormat
|
|
24
|
+
from hexaqueue_core.domain.bastion import BastionSession
|
|
24
25
|
from hexaqueue_core.domain.explainability import (
|
|
25
26
|
FairShareNodeReport,
|
|
26
27
|
FairShareTreeReport,
|
|
@@ -86,11 +87,7 @@ class CliPresenter:
|
|
|
86
87
|
if hasattr(report.state, "value")
|
|
87
88
|
else str(report.state)
|
|
88
89
|
),
|
|
89
|
-
"outcome": (
|
|
90
|
-
report.outcome.value
|
|
91
|
-
if hasattr(report.outcome, "value")
|
|
92
|
-
else (str(report.outcome) if report.outcome else None)
|
|
93
|
-
),
|
|
90
|
+
"outcome": (report.outcome.value if report.outcome is not None else None),
|
|
94
91
|
"total_jobs": report.total_jobs,
|
|
95
92
|
"completed_jobs": report.completed_jobs,
|
|
96
93
|
"failed_jobs": report.failed_jobs,
|
|
@@ -236,11 +233,7 @@ class CliPresenter:
|
|
|
236
233
|
)
|
|
237
234
|
|
|
238
235
|
state_val = job.state.value if hasattr(job.state, "value") else str(job.state)
|
|
239
|
-
outcome_val =
|
|
240
|
-
job.outcome.value
|
|
241
|
-
if hasattr(job.outcome, "value")
|
|
242
|
-
else (str(job.outcome) if job.outcome else None)
|
|
243
|
-
)
|
|
236
|
+
outcome_val = job.outcome.value if job.outcome is not None else None
|
|
244
237
|
|
|
245
238
|
data = {
|
|
246
239
|
"id": job.id,
|
|
@@ -724,6 +717,72 @@ class CliPresenter:
|
|
|
724
717
|
)
|
|
725
718
|
self._console.print(table)
|
|
726
719
|
|
|
720
|
+
def render_bastion_sessions_table(
|
|
721
|
+
self,
|
|
722
|
+
sessions: list[BastionSession],
|
|
723
|
+
format_type: str | OutputFormat = OutputFormat.TABLE,
|
|
724
|
+
) -> None:
|
|
725
|
+
"""Render active administrative bastion sessions in requested format.
|
|
726
|
+
|
|
727
|
+
Args:
|
|
728
|
+
sessions: List of BastionSession records.
|
|
729
|
+
format_type: Output format (table, json, markdown, plain).
|
|
730
|
+
"""
|
|
731
|
+
fmt = (
|
|
732
|
+
format_type.value
|
|
733
|
+
if isinstance(format_type, OutputFormat)
|
|
734
|
+
else str(format_type).lower().strip()
|
|
735
|
+
)
|
|
736
|
+
if fmt == OutputFormat.JSON.value:
|
|
737
|
+
dumped = [s.model_dump(mode="json") for s in sessions]
|
|
738
|
+
self._console.print(json.dumps(dumped, indent=2))
|
|
739
|
+
return
|
|
740
|
+
|
|
741
|
+
if fmt == OutputFormat.MARKDOWN.value:
|
|
742
|
+
lines = [
|
|
743
|
+
"| Session ID | Node ID | Operator | Protocol | Created (UTC) | Expires (UTC) | Active |",
|
|
744
|
+
"|---|---|---|---|---|---|---|",
|
|
745
|
+
]
|
|
746
|
+
for s in sessions:
|
|
747
|
+
created_str = s.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
748
|
+
expires_str = s.expires_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
749
|
+
lines.append(
|
|
750
|
+
f"| {s.session_id} | {s.node_id} | {s.operator_id} | {s.protocol.value} | {created_str} | {expires_str} | {s.is_active} |"
|
|
751
|
+
)
|
|
752
|
+
self._console.print("\n".join(lines))
|
|
753
|
+
return
|
|
754
|
+
|
|
755
|
+
if fmt == OutputFormat.PLAIN.value:
|
|
756
|
+
for s in sessions:
|
|
757
|
+
self._console.print(
|
|
758
|
+
f"SESSION={s.session_id} NODE={s.node_id} OPERATOR={s.operator_id} PROTOCOL={s.protocol.value} ACTIVE={s.is_active}"
|
|
759
|
+
)
|
|
760
|
+
return
|
|
761
|
+
|
|
762
|
+
table = Table(title="Active Bastion Sessions", border_style="cyan")
|
|
763
|
+
table.add_column("Session ID", style="bold cyan")
|
|
764
|
+
table.add_column("Node ID", style="green")
|
|
765
|
+
table.add_column("Operator", style="yellow")
|
|
766
|
+
table.add_column("Protocol", style="magenta")
|
|
767
|
+
table.add_column("Created (UTC)", justify="center")
|
|
768
|
+
table.add_column("Expires (UTC)", justify="center")
|
|
769
|
+
table.add_column("Active", justify="center")
|
|
770
|
+
|
|
771
|
+
for s in sessions:
|
|
772
|
+
created_str = s.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
773
|
+
expires_str = s.expires_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
774
|
+
active_str = "[bold green]YES[/]" if s.is_active else "[bold red]NO[/]"
|
|
775
|
+
table.add_row(
|
|
776
|
+
s.session_id,
|
|
777
|
+
s.node_id,
|
|
778
|
+
s.operator_id,
|
|
779
|
+
s.protocol.value,
|
|
780
|
+
created_str,
|
|
781
|
+
expires_str,
|
|
782
|
+
active_str,
|
|
783
|
+
)
|
|
784
|
+
self._console.print(table)
|
|
785
|
+
|
|
727
786
|
def build_top_dashboard(
|
|
728
787
|
self,
|
|
729
788
|
stats: ClusterStatsReport,
|
|
@@ -4,6 +4,8 @@ Notes/Architectural Intent:
|
|
|
4
4
|
Exposes Typer subcommand modules for batch run pipelines and distributed workflow execution.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from hexaqueue_cli.commands.admin import app as admin_app
|
|
8
|
+
from hexaqueue_cli.commands.cluster import app as cluster_app
|
|
7
9
|
from hexaqueue_cli.commands.collateral import app as collateral_app
|
|
8
10
|
from hexaqueue_cli.commands.node import app as node_app
|
|
9
11
|
from hexaqueue_cli.commands.run import app as run_app
|
|
@@ -11,6 +13,8 @@ from hexaqueue_cli.commands.suite import app as suite_app
|
|
|
11
13
|
from hexaqueue_cli.commands.workflow import app as workflow_app
|
|
12
14
|
|
|
13
15
|
__all__ = [
|
|
16
|
+
"admin_app",
|
|
17
|
+
"cluster_app",
|
|
14
18
|
"collateral_app",
|
|
15
19
|
"node_app",
|
|
16
20
|
"run_app",
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""CLI subcommand group for administrative operations and bastion session governance.
|
|
2
|
+
|
|
3
|
+
Notes/Architectural Intent:
|
|
4
|
+
Provides `hq admin session` commands to mint zero-trust bastion sessions,
|
|
5
|
+
generate cloud-specific tunnel connection commands, audit active sessions,
|
|
6
|
+
and terminate maintenance leases across AWS SSM, GCP IAP, Azure Bastion,
|
|
7
|
+
Tailscale/Teleport, and Native Break-Glass setups.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import asyncio
|
|
13
|
+
|
|
14
|
+
import typer
|
|
15
|
+
from rich.console import Console
|
|
16
|
+
from rich.panel import Panel
|
|
17
|
+
|
|
18
|
+
from hexaqueue_cli.adapters.presenter import CliPresenter
|
|
19
|
+
from hexaqueue_cli.infra.options import format_option, resolve_format
|
|
20
|
+
from hexaqueue_core.adapters.bastion import (
|
|
21
|
+
AWSSSMAdapter,
|
|
22
|
+
AzureBastionAdapter,
|
|
23
|
+
GCPIAPAdapter,
|
|
24
|
+
NativeBreakGlassAdapter,
|
|
25
|
+
TailscaleTeleportAdapter,
|
|
26
|
+
)
|
|
27
|
+
from hexaqueue_core.domain.bastion import BastionProtocolType
|
|
28
|
+
from hexaqueue_core.ports.bastion import BastionAccessPort
|
|
29
|
+
|
|
30
|
+
app = typer.Typer(
|
|
31
|
+
name="admin",
|
|
32
|
+
help="Administrative operations and zero-trust session governance",
|
|
33
|
+
no_args_is_help=True,
|
|
34
|
+
)
|
|
35
|
+
session_app = typer.Typer(
|
|
36
|
+
name="session",
|
|
37
|
+
help="Manage and audit zero-trust bastion operator access sessions",
|
|
38
|
+
no_args_is_help=True,
|
|
39
|
+
)
|
|
40
|
+
app.add_typer(session_app, name="session")
|
|
41
|
+
console = Console()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_bastion_adapter(protocol: BastionProtocolType) -> BastionAccessPort:
|
|
45
|
+
"""Resolve the appropriate bastion adapter for a given protocol."""
|
|
46
|
+
if protocol == BastionProtocolType.AWS_SSM:
|
|
47
|
+
return AWSSSMAdapter()
|
|
48
|
+
if protocol == BastionProtocolType.GCP_IAP:
|
|
49
|
+
return GCPIAPAdapter()
|
|
50
|
+
if protocol == BastionProtocolType.AZURE_BASTION:
|
|
51
|
+
return AzureBastionAdapter()
|
|
52
|
+
if protocol == BastionProtocolType.TAILSCALE_TELEPORT:
|
|
53
|
+
return TailscaleTeleportAdapter()
|
|
54
|
+
return NativeBreakGlassAdapter()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@session_app.command("create")
|
|
58
|
+
def create_session_cmd(
|
|
59
|
+
node_id: str = typer.Argument(..., help="Target compute node ID"),
|
|
60
|
+
operator: str = typer.Option(
|
|
61
|
+
"default", "--operator", "-o", help="Requesting operator identity"
|
|
62
|
+
),
|
|
63
|
+
protocol: BastionProtocolType = typer.Option(
|
|
64
|
+
BastionProtocolType.NATIVE_BREAK_GLASS,
|
|
65
|
+
"--protocol",
|
|
66
|
+
"-p",
|
|
67
|
+
help="Bastion access protocol",
|
|
68
|
+
),
|
|
69
|
+
duration: int = typer.Option(
|
|
70
|
+
3600, "--duration", "-d", help="Lease duration in seconds"
|
|
71
|
+
),
|
|
72
|
+
admin: bool = typer.Option(
|
|
73
|
+
False,
|
|
74
|
+
"--admin",
|
|
75
|
+
help="Assert explicit administrative elevation for bastion shell access",
|
|
76
|
+
),
|
|
77
|
+
) -> None:
|
|
78
|
+
"""Mint an ephemeral zero-trust bastion session and generate connection command."""
|
|
79
|
+
if not admin:
|
|
80
|
+
console.print(
|
|
81
|
+
f"[bold red]Permission denied:[/] Minting bastion session on node '{node_id}' "
|
|
82
|
+
"requires explicit administrative elevation (--admin)."
|
|
83
|
+
)
|
|
84
|
+
raise typer.Exit(code=1)
|
|
85
|
+
|
|
86
|
+
adapter = get_bastion_adapter(protocol)
|
|
87
|
+
|
|
88
|
+
async def _create() -> None:
|
|
89
|
+
try:
|
|
90
|
+
session = await adapter.generate_session_token(
|
|
91
|
+
node_id=node_id,
|
|
92
|
+
operator_id=operator,
|
|
93
|
+
duration_seconds=duration,
|
|
94
|
+
)
|
|
95
|
+
cmd = await adapter.get_connection_command(node_id, session)
|
|
96
|
+
|
|
97
|
+
console.print(
|
|
98
|
+
f"[bold green]✓[/] Bastion session '[bold cyan]{session.session_id}[/]' "
|
|
99
|
+
f"minted for operator '[bold yellow]{operator}[/]'.\n"
|
|
100
|
+
f" Protocol: [magenta]{session.protocol.value}[/]\n"
|
|
101
|
+
f" Expires: [dim]{session.expires_at.strftime('%Y-%m-%d %H:%M:%S UTC')}[/]"
|
|
102
|
+
)
|
|
103
|
+
console.print(
|
|
104
|
+
Panel(
|
|
105
|
+
cmd.as_shell_string(),
|
|
106
|
+
title="[bold green]Connection Command[/]",
|
|
107
|
+
border_style="green",
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
except Exception as exc:
|
|
111
|
+
console.print(f"[bold red]Error creating bastion session:[/] {exc}")
|
|
112
|
+
raise typer.Exit(code=1) from exc
|
|
113
|
+
|
|
114
|
+
asyncio.run(_create())
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@session_app.command("list")
|
|
118
|
+
def list_sessions_cmd(
|
|
119
|
+
protocol: BastionProtocolType = typer.Option(
|
|
120
|
+
BastionProtocolType.NATIVE_BREAK_GLASS,
|
|
121
|
+
"--protocol",
|
|
122
|
+
"-p",
|
|
123
|
+
help="Target bastion access protocol to audit",
|
|
124
|
+
),
|
|
125
|
+
format_type: str = format_option(),
|
|
126
|
+
) -> None:
|
|
127
|
+
"""Audit and list active unexpired bastion sessions."""
|
|
128
|
+
resolved_fmt = resolve_format(format_type)
|
|
129
|
+
presenter = CliPresenter(console=console)
|
|
130
|
+
adapter = get_bastion_adapter(protocol)
|
|
131
|
+
|
|
132
|
+
async def _list() -> None:
|
|
133
|
+
try:
|
|
134
|
+
sessions = await adapter.audit_active_sessions()
|
|
135
|
+
presenter.render_bastion_sessions_table(sessions, resolved_fmt)
|
|
136
|
+
except Exception as exc:
|
|
137
|
+
console.print(f"[bold red]Error auditing bastion sessions:[/] {exc}")
|
|
138
|
+
raise typer.Exit(code=1) from exc
|
|
139
|
+
|
|
140
|
+
asyncio.run(_list())
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@session_app.command("terminate")
|
|
144
|
+
def terminate_session_cmd(
|
|
145
|
+
session_id: str = typer.Argument(..., help="Target session ID to terminate"),
|
|
146
|
+
protocol: BastionProtocolType = typer.Option(
|
|
147
|
+
BastionProtocolType.NATIVE_BREAK_GLASS,
|
|
148
|
+
"--protocol",
|
|
149
|
+
"-p",
|
|
150
|
+
help="Bastion access protocol governing the session",
|
|
151
|
+
),
|
|
152
|
+
) -> None:
|
|
153
|
+
"""Revoke an active bastion session immediately."""
|
|
154
|
+
adapter = get_bastion_adapter(protocol)
|
|
155
|
+
|
|
156
|
+
async def _terminate() -> None:
|
|
157
|
+
try:
|
|
158
|
+
await adapter.terminate_session(session_id)
|
|
159
|
+
console.print(
|
|
160
|
+
f"[bold green]✓[/] Bastion session '[bold cyan]{session_id}[/]' successfully terminated."
|
|
161
|
+
)
|
|
162
|
+
except Exception as exc:
|
|
163
|
+
console.print(f"[bold red]Error terminating bastion session:[/] {exc}")
|
|
164
|
+
raise typer.Exit(code=1) from exc
|
|
165
|
+
|
|
166
|
+
asyncio.run(_terminate())
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
__all__ = [
|
|
170
|
+
"app",
|
|
171
|
+
"get_bastion_adapter",
|
|
172
|
+
]
|