mirror of
https://github.com/trailofbits/algo.git
synced 2026-08-17 21:25:50 +02:00
* feat: add destroy subcommand to tear down deployed servers Add `./algo destroy <server-ip>` to programmatically remove cloud resources and clean up local configs. Reads provider and server name from configs/<ip>/.config.yml, gathers credentials via existing prompts.yml, confirms with user, then dispatches to provider-specific destroy tasks. Supports all 11 cloud providers: - DigitalOcean, EC2, Lightsail (CloudFormation), Azure (resource group), GCE (instance + subsidiary resources), Hetzner, Vultr, Scaleway, OpenStack, CloudStack, Linode - Local provider: config cleanup only Also stores algo_region in .config.yml during deployment so destroy can auto-detect region. Fixes Scaleway module to allow state=absent without image/commercial_type/organization params. Adds Vultr to region-required providers and stores algo_region in Vultr prompts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add list-servers script and tests Add scripts/list_servers.py to scan configs/ for deployed server metadata and output JSON. Referenced by `./algo list-servers`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
832 B
Python
35 lines
832 B
Python
#!/usr/bin/env python3
|
|
"""List deployed Algo VPN servers as JSON."""
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
|
|
def list_servers(configs_dir: Path) -> list[dict]:
|
|
"""Scan configs directory for deployed server metadata."""
|
|
servers = []
|
|
for config_file in sorted(configs_dir.glob("*/.config.yml")):
|
|
with open(config_file) as f:
|
|
config = yaml.safe_load(f)
|
|
if config:
|
|
servers.append(config)
|
|
return servers
|
|
|
|
|
|
def main() -> None:
|
|
configs_dir = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("configs")
|
|
if not configs_dir.is_dir():
|
|
json.dump([], sys.stdout)
|
|
print()
|
|
sys.exit(0)
|
|
servers = list_servers(configs_dir)
|
|
json.dump(servers, sys.stdout, indent=2, default=str)
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|