voltagegpu-cli 1.2.1__py3-none-any.whl → 1.3.1__py3-none-any.whl

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.
volt/__init__.py CHANGED
@@ -1,6 +1,5 @@
1
- """VoltageGPU — Confidential AI Infrastructure CLI and SDK."""
1
+ """VoltageGPU command-line interface and Python SDK."""
2
2
 
3
- from volt.sdk import Config, Machine, Pod, SSHKey, Template, VoltageGPUClient
3
+ __version__ = "1.3.1"
4
4
 
5
- __all__ = ["VoltageGPUClient", "Config", "Pod", "SSHKey", "Template", "Machine"]
6
- __version__ = "1.2.1"
5
+ __all__ = ["__version__"]
volt/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ """`python -m volt` runs the CLI."""
2
+
3
+ from .cli.main import main
4
+
5
+ main()
volt/cli/__init__.py CHANGED
@@ -1,3 +1,5 @@
1
- """VoltageGPU CLI - Command line interface for VoltageGPU."""
2
-
3
- __all__ = []
1
+ """The `voltagegpu` command line."""
2
+
3
+ from .main import cli, main
4
+
5
+ __all__ = ["cli", "main"]
@@ -0,0 +1,176 @@
1
+ """`login`, `logout`, `config`, `balance` and `ssh-keys`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+ import click
9
+
10
+ from ..sdk.config import (
11
+ API_KEYS_PAGE,
12
+ Config,
13
+ default_config_path,
14
+ is_valid_api_key,
15
+ permissions_warning,
16
+ remove_api_key,
17
+ save_api_key,
18
+ )
19
+ from ..sdk.errors import ApiError, ConfigError
20
+ from .output import console, echo_json, esc, fail, hint, info, is_interactive, money, table, warn
21
+ from .state import AppState, pass_state
22
+
23
+ _PUBLIC_KEY_PREFIXES = ("ssh-ed25519 ", "ssh-rsa ", "ecdsa-sha2-", "sk-ssh-ed25519@openssh.com ", "sk-ecdsa-sha2-")
24
+ _DEFAULT_PUBLIC_KEYS = ("id_ed25519.pub", "id_ecdsa.pub", "id_rsa.pub")
25
+
26
+
27
+ def read_public_key(text: str) -> str:
28
+ """Validate an OpenSSH public key; refuse private keys loudly."""
29
+ key = (text or "").strip()
30
+ if "PRIVATE KEY" in key:
31
+ raise click.BadParameter("this is a PRIVATE key. Never upload it: pass the matching .pub file instead.")
32
+ lines = [line for line in key.splitlines() if line.strip()]
33
+ if len(lines) != 1 or not lines[0].startswith(_PUBLIC_KEY_PREFIXES) or len(lines[0]) > 16384:
34
+ raise click.BadParameter("expected one OpenSSH public key line, e.g. 'ssh-ed25519 AAAA... you@laptop'.")
35
+ return lines[0].strip()
36
+
37
+
38
+ def default_public_key_file() -> Optional[Path]:
39
+ ssh_dir = Path.home() / ".ssh"
40
+ for name in _DEFAULT_PUBLIC_KEYS:
41
+ candidate = ssh_dir / name
42
+ if candidate.is_file():
43
+ return candidate
44
+ return None
45
+
46
+
47
+ @click.command("login")
48
+ @click.option("--api-key", envvar=None, help="Key to store (prompted, hidden, if omitted). Prefer the prompt: "
49
+ "a key on the command line lands in your shell history.")
50
+ @pass_state
51
+ def login_cmd(state: AppState, api_key: Optional[str]) -> None:
52
+ """Store your API key in ~/.volt/config.ini (readable by you only)."""
53
+ if not api_key:
54
+ if not is_interactive():
55
+ fail("No terminal to prompt on. Export VOLT_API_KEY instead, or pass --api-key.", code=2)
56
+ info(f"Create a key at {API_KEYS_PAGE} (it is shown once).")
57
+ api_key = click.prompt("API key", hide_input=True).strip()
58
+ if not is_valid_api_key(api_key):
59
+ fail(f"That does not look like a VoltageGPU API key (volt_...). Create one at {API_KEYS_PAGE}.")
60
+ try:
61
+ with state.client_with_key(api_key) as client:
62
+ client.list_ssh_keys() # cheapest authenticated call: proves the key works
63
+ except ApiError as exc:
64
+ if exc.is_auth_error:
65
+ fail("The API refused this key. Check it on " + API_KEYS_PAGE)
66
+ raise
67
+ path = save_api_key(api_key)
68
+ console.print(f"[green]Logged in.[/green] Key saved to {esc(path)}")
69
+ hint("Environment variables (VOLT_API_KEY) take precedence over this file.")
70
+
71
+
72
+ @click.command("logout")
73
+ def logout_cmd() -> None:
74
+ """Remove the stored API key from ~/.volt/config.ini."""
75
+ if remove_api_key():
76
+ info(f"Removed the key from {esc(default_config_path())}. Revoke it too on {API_KEYS_PAGE} if it may have leaked.")
77
+ else:
78
+ info("No stored key.")
79
+
80
+
81
+ @click.command("config")
82
+ @pass_state
83
+ def config_cmd(state: AppState) -> None:
84
+ """Show where the API key comes from (masked) and the API base URL."""
85
+ try:
86
+ cfg = Config.load(base_url=state.base_url)
87
+ except ConfigError as exc:
88
+ fail(str(exc))
89
+ info(f"API base URL {esc(cfg.base_url)}")
90
+ info(f"API key {esc(cfg.masked_key)} from {esc(cfg.source)}")
91
+ warning = permissions_warning(default_config_path())
92
+ if warning:
93
+ warn(warning)
94
+
95
+
96
+ @click.command("balance")
97
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
98
+ @pass_state
99
+ def balance_cmd(state: AppState, as_json: bool) -> None:
100
+ """Your balance and number of running pods."""
101
+ try:
102
+ bal = state.client().get_balance()
103
+ except ApiError as exc:
104
+ if exc.is_not_found:
105
+ fail("This API server does not expose the balance yet. See it on https://voltagegpu.com/billing")
106
+ raise
107
+ if as_json:
108
+ echo_json(bal.to_dict())
109
+ return
110
+ console.print(f"Balance [bold green]{money(bal.balance)}[/bold green] {esc(bal.currency)}")
111
+ if bal.active_pods is not None:
112
+ info(f"Running {bal.active_pods} pod{'s' if bal.active_pods != 1 else ''}")
113
+ hint(f"Top up: {esc(bal.top_up_url)}")
114
+
115
+
116
+ @click.group("ssh-keys")
117
+ def ssh_keys_group() -> None:
118
+ """Manage the SSH public keys injected into your pods."""
119
+
120
+
121
+ @ssh_keys_group.command("list")
122
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
123
+ @pass_state
124
+ def ssh_keys_list(state: AppState, as_json: bool) -> None:
125
+ """List your SSH keys."""
126
+ keys = state.client().list_ssh_keys()
127
+ if as_json:
128
+ echo_json([k.to_dict() for k in keys])
129
+ return
130
+ if not keys:
131
+ info("No SSH key yet. Add one: voltagegpu ssh-keys add")
132
+ return
133
+ table("SSH keys", [("KEY ID", {"style": "cyan", "no_wrap": True}), ("NAME",), ("KEY",), ("ADDED",)],
134
+ [(k.id, k.name, k.summary, (k.created_at or "")[:10]) for k in keys])
135
+
136
+
137
+ @ssh_keys_group.command("add")
138
+ @click.option("--name", help="Label for the key (default: the file name).")
139
+ @click.option("--file", "key_file", type=click.Path(exists=True, dir_okay=False, path_type=Path),
140
+ help="Public key file (default: ~/.ssh/id_ed25519.pub, id_ecdsa.pub or id_rsa.pub).")
141
+ @click.option("--key", "key_text", help="Public key string instead of a file.")
142
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
143
+ @pass_state
144
+ def ssh_keys_add(state: AppState, name: Optional[str], key_file: Optional[Path], key_text: Optional[str], as_json: bool) -> None:
145
+ """Register an SSH public key."""
146
+ if key_file and key_text:
147
+ fail("Give --file or --key, not both.", code=2)
148
+ if not key_text:
149
+ path = key_file or default_public_key_file()
150
+ if path is None:
151
+ fail("No public key found in ~/.ssh. Create one with: ssh-keygen -t ed25519", code=2)
152
+ if path.suffix != ".pub" and path.with_suffix(path.suffix + ".pub").exists():
153
+ fail(f"{path} looks like a private key. Use {path}.pub", code=2)
154
+ key_text = path.read_text(encoding="utf-8", errors="replace")
155
+ name = name or path.name
156
+ public_key = read_public_key(key_text)
157
+ key = state.client().add_ssh_key(name or "cli-key", public_key)
158
+ if as_json:
159
+ echo_json(key.to_dict())
160
+ else:
161
+ console.print(f"[green]Added.[/green] {esc(key.name)} ({esc(key.id)})")
162
+
163
+
164
+ @ssh_keys_group.command("delete")
165
+ @click.argument("key_id")
166
+ @click.option("-y", "--yes", is_flag=True, help="Do not ask for confirmation.")
167
+ @pass_state
168
+ def ssh_keys_delete(state: AppState, key_id: str, yes: bool) -> None:
169
+ """Delete an SSH key (running pods keep the keys they were created with)."""
170
+ if not yes:
171
+ if not is_interactive():
172
+ fail("Re-run with --yes to confirm in a script.", code=2)
173
+ if not click.confirm(f"Delete SSH key {key_id}?", default=False):
174
+ raise click.exceptions.Exit(1)
175
+ state.client().delete_ssh_key(key_id)
176
+ console.print(f"[green]Deleted.[/green] {esc(key_id)}")
volt/cli/cmd_deploy.py ADDED
@@ -0,0 +1,218 @@
1
+ """`voltagegpu deploy standard` and `voltagegpu deploy confidential`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ import secrets
7
+ from typing import Any, Dict, List, Optional, Tuple
8
+
9
+ import click
10
+
11
+ from ..sdk.errors import ApiError
12
+ from ..sdk.models import CONFIDENTIAL, STANDARD, DeployResult, Machine, Pod, strip_controls
13
+ from .cmd_machines import filter_machines
14
+ from .output import console, echo_json, esc, fail, hint, info, is_interactive, money, plain, status_style, warn
15
+ from .state import AppState, pass_state
16
+
17
+ NAME_RE = re.compile(r"[a-z0-9][a-z0-9-]{0,39}")
18
+ UNCERTAIN = ("The deploy request got no answer, so it may have gone through and been charged. "
19
+ "Check `voltagegpu pods list` before deploying again.")
20
+ _PORT_RE = re.compile(r"^(\d{1,5})(?:/(tcp|udp))?$", re.IGNORECASE)
21
+
22
+
23
+ def default_name() -> str:
24
+ return f"pod-{secrets.token_hex(3)}"
25
+
26
+
27
+ def check_name(name: str) -> str:
28
+ if not NAME_RE.fullmatch(name):
29
+ raise click.BadParameter("use 1-40 lowercase letters, digits and hyphens, starting with a letter or digit", param_hint="--name")
30
+ return name
31
+
32
+
33
+ def parse_port_spec(spec: str) -> Dict[str, Any]:
34
+ """'8000' / '8000/tcp' / '53/udp' -> {"port": 8000, "protocol": "tcp"}."""
35
+ match = _PORT_RE.fullmatch(spec.strip())
36
+ if not match:
37
+ raise click.BadParameter(f"{spec!r}: expected PORT or PORT/tcp or PORT/udp", param_hint="--port")
38
+ port = int(match.group(1))
39
+ if not 1 <= port <= 65535:
40
+ raise click.BadParameter(f"{port} is not between 1 and 65535", param_hint="--port")
41
+ if port == 22:
42
+ raise click.BadParameter("port 22 (SSH) is already mapped for you", param_hint="--port")
43
+ return {"port": port, "protocol": (match.group(2) or "tcp").lower()}
44
+
45
+
46
+ def pick_machine(machines: List[Machine], machine_id: Optional[str], cheapest: bool, gpu: Optional[str],
47
+ max_price: Optional[float]) -> Machine:
48
+ """The machine to deploy: an explicit id, or the cheapest one matching the filters."""
49
+ if machine_id:
50
+ for m in machines:
51
+ if m.id == machine_id:
52
+ return m
53
+ raise LookupError(f"Machine {machine_id} is not in the deployable list right now. "
54
+ "List machines with: voltagegpu machines --standard")
55
+ candidates = filter_machines(machines, gpu=gpu, max_price=max_price)
56
+ priced = [m for m in candidates if m.price_per_hour is not None]
57
+ if not priced:
58
+ raise LookupError("No standard machine matches these filters right now.")
59
+ return min(priced, key=lambda m: m.price_per_hour or 0.0)
60
+
61
+
62
+ def _confirm_charge(amount: Optional[float], yes: bool) -> None:
63
+ if yes:
64
+ return
65
+ if not is_interactive():
66
+ fail("This deploy charges your balance. Re-run with --yes to confirm in a script.", code=2)
67
+ if not click.confirm(f"Charge {money(amount)} now (first hour, prepaid) and deploy?", default=False):
68
+ raise click.exceptions.Exit(1)
69
+
70
+
71
+ def _deploy(call: Any) -> DeployResult:
72
+ """Run a deploy call; a lost answer is reported as 'maybe charged', never as 'try again'."""
73
+ try:
74
+ return call()
75
+ except ApiError as exc:
76
+ if exc.status_code == 0:
77
+ fail(UNCERTAIN)
78
+ raise
79
+
80
+
81
+ def _check_price(confirmed: Optional[float], result: DeployResult, pod_id: str) -> None:
82
+ """The price is re-read by the server at deploy time; say so if it moved up."""
83
+ if confirmed is not None and result.hourly_price is not None and result.hourly_price > confirmed + 1e-9:
84
+ warn(f"The hourly price changed from {money(confirmed)} to {money(result.hourly_price)} between the list and the deploy. "
85
+ f"Stop it with `voltagegpu pods stop {pod_id}` if that does not suit you.")
86
+
87
+
88
+ def _wait(state: AppState, pod_id: str, timeout: int) -> Pod:
89
+ seen: Dict[str, str] = {}
90
+
91
+ def on_poll(pod: Pod) -> None:
92
+ label = pod.provider_status or pod.status
93
+ if seen.get("s") != label:
94
+ seen["s"] = label
95
+ console.print(f" status: [{status_style(pod.status)}]{esc(label)}[/]")
96
+
97
+ info(f"Waiting for SSH on {esc(pod_id)} (up to {timeout} s)...")
98
+ return state.client().wait_until_reachable(pod_id, timeout=timeout, interval=10.0, on_poll=on_poll)
99
+
100
+
101
+ def _after_deploy(state: AppState, result: DeployResult, wait: bool, timeout: int, as_json: bool) -> None:
102
+ pod: Optional[Pod] = None
103
+ if wait:
104
+ try:
105
+ pod = _wait(state, result.pod_id, timeout) if not as_json else state.client().wait_until_reachable(result.pod_id, timeout=timeout)
106
+ except (TimeoutError, ApiError) as exc:
107
+ warn(f"{exc} The pod is still billing: stop it with `voltagegpu pods stop {result.pod_id}` if needed.")
108
+ if as_json:
109
+ echo_json({"deploy": result.to_dict(), "pod": pod.to_dict() if pod else None})
110
+ return
111
+ if pod and pod.ssh_command:
112
+ console.print(f"[green]Ready.[/green] SSH: {esc(pod.ssh_command)}")
113
+ pid = esc(result.pod_id)
114
+ info("")
115
+ info("Next:")
116
+ info(f" voltagegpu pods wait {pid} # until SSH is ready" if not pod else f" voltagegpu ssh {pid}")
117
+ info(f" voltagegpu pods stop {pid} # release it (billing stops)")
118
+
119
+
120
+ @click.group("deploy")
121
+ def deploy_group() -> None:
122
+ """Deploy a standard pod or a Confidential VM (charges the first hour)."""
123
+
124
+
125
+ @deploy_group.command("standard")
126
+ @click.option("--machine", "machine_id", help="machine_id from `voltagegpu machines --standard`.")
127
+ @click.option("--cheapest", is_flag=True, help="Pick the cheapest available machine (combine with --gpu/--max-price).")
128
+ @click.option("--gpu", help="With --cheapest: GPU model filter, e.g. A6000.")
129
+ @click.option("--max-price", type=float, help="With --cheapest: maximum price per hour (USD).")
130
+ @click.option("--name", help="Pod name: lowercase letters, digits, hyphens (default: pod-xxxxxx).")
131
+ @click.option("--template", "template_id", help="Template id from `voltagegpu templates` (default: PyTorch).")
132
+ @click.option("--ssh-key", "ssh_key_id", help="SSH key id (required if your account has several keys).")
133
+ @click.option("--jupyter", is_flag=True, default=None, help="Start Jupyter on the pod.")
134
+ @click.option("--ports", "port_count", type=click.IntRange(1, 31), help="Number of extra public ports to map.")
135
+ @click.option("--auto-terminate", "auto_terminate_hours", type=click.IntRange(1, 720), help="Release automatically after N hours.")
136
+ @click.option("--wait", is_flag=True, help="Wait until SSH is ready and print the command.")
137
+ @click.option("--timeout", type=click.IntRange(30, 3600), default=900, show_default=True, help="Seconds to wait with --wait.")
138
+ @click.option("-y", "--yes", is_flag=True, help="Do not ask for confirmation before charging.")
139
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
140
+ @pass_state
141
+ def deploy_standard(state: AppState, machine_id: Optional[str], cheapest: bool, gpu: Optional[str], max_price: Optional[float],
142
+ name: Optional[str], template_id: Optional[str], ssh_key_id: Optional[str], jupyter: Optional[bool],
143
+ port_count: Optional[int], auto_terminate_hours: Optional[int], wait: bool, timeout: int,
144
+ yes: bool, as_json: bool) -> None:
145
+ """Deploy a standard pod: a whole machine, no enclave, for non-sensitive workloads."""
146
+ if bool(machine_id) == bool(cheapest):
147
+ fail("Give exactly one of --machine MACHINE_ID or --cheapest.", code=2)
148
+ if cheapest and yes and max_price is None:
149
+ fail("With --cheapest --yes, set --max-price so a script never rents an expensive machine by surprise.", code=2)
150
+ pod_name = check_name(name) if name else default_name()
151
+ client = state.client()
152
+ try:
153
+ machine = pick_machine(client.list_machines(STANDARD), machine_id, cheapest, gpu, max_price)
154
+ except LookupError as exc:
155
+ fail(str(exc))
156
+ if not as_json:
157
+ where = f" ({esc(machine.location)})" if machine.location else ""
158
+ info(f"Standard pod [bold]{esc(pod_name)}[/bold] on {machine.gpu_count}x {esc(machine.gpu_type)}{where}, "
159
+ f"{money(machine.price_per_hour)}/hour")
160
+ hint(f"machine {esc(machine.id)}. No enclave: use a Confidential VM for sensitive data.")
161
+ _confirm_charge(machine.price_per_hour, yes)
162
+ result = _deploy(lambda: client.deploy_standard(
163
+ machine.id, pod_name, template_id=template_id, ssh_key_id=ssh_key_id, gpu_count=None,
164
+ jupyter=jupyter, port_count=port_count, auto_terminate_hours=auto_terminate_hours,
165
+ ))
166
+ _check_price(machine.price_per_hour, result, result.pod_id)
167
+ if not as_json:
168
+ console.print(f"[green]Deployed.[/green] Pod {esc(result.pod_id)}, {money(result.hourly_price)}/hour, "
169
+ f"{money(result.prepaid_amount)} prepaid.")
170
+ _after_deploy(state, result, wait, timeout, as_json)
171
+
172
+
173
+ @deploy_group.command("confidential")
174
+ @click.option("--tier", required=True, help="Tier from `voltagegpu machines --confidential`, e.g. rtx6000b-small.")
175
+ @click.option("--name", help="VM name: lowercase letters, digits, hyphens (default: pod-xxxxxx).")
176
+ @click.option("--hardstop", "hardstop_hours", type=click.IntRange(0, 720), help="Release automatically after N hours.")
177
+ @click.option("--port", "ports", multiple=True, metavar="PORT[/tcp|udp]", help="Extra inbound port, repeatable (single-GPU tiers).")
178
+ @click.option("--wait", is_flag=True, help="Wait until SSH is ready and print the command.")
179
+ @click.option("--timeout", type=click.IntRange(30, 3600), default=900, show_default=True, help="Seconds to wait with --wait.")
180
+ @click.option("-y", "--yes", is_flag=True, help="Do not ask for confirmation before charging.")
181
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output (includes the one-time sudo password).")
182
+ @pass_state
183
+ def deploy_confidential(state: AppState, tier: str, name: Optional[str], hardstop_hours: Optional[int], ports: Tuple[str, ...],
184
+ wait: bool, timeout: int, yes: bool, as_json: bool) -> None:
185
+ """Deploy a Confidential VM: Intel TDX, your SSH keys only, attestation you verify yourself."""
186
+ pod_name = check_name(name) if name else default_name()
187
+ port_list = [parse_port_spec(p) for p in ports]
188
+ client = state.client()
189
+ tiers = {m.id: m for m in client.list_machines(CONFIDENTIAL)}
190
+ machine = tiers.get(tier)
191
+ if machine is None:
192
+ fail(f"'{tier}' is not an available Confidential VM tier right now. List tiers with: voltagegpu machines --confidential")
193
+ if not client.list_ssh_keys():
194
+ fail("Add an SSH key first (voltagegpu ssh-keys add). A Confidential VM binds your keys at creation "
195
+ "and cannot be given one afterwards.")
196
+ if not as_json:
197
+ info(f"Confidential VM [bold]{esc(pod_name)}[/bold] on {esc(machine.id)} ({machine.gpu_count}x {esc(machine.gpu_type)}), "
198
+ f"{money(machine.price_per_hour)}/hour")
199
+ hint("Every SSH key on your account is bound to the VM. We keep no key on it.")
200
+ _confirm_charge(machine.price_per_hour, yes)
201
+ result = _deploy(lambda: client.deploy_confidential(tier, pod_name, hardstop_hours=hardstop_hours, ports=port_list))
202
+ _check_price(machine.price_per_hour, result, result.pod_id)
203
+ if not as_json:
204
+ console.print(f"[green]Deployed.[/green] VM {esc(result.pod_id)}, {money(result.hourly_price)}/hour, booting.")
205
+ if result.sudo_password:
206
+ info(" sudo password (shown once, we do not keep it):")
207
+ plain(f" {result.sudo_password}") # no markup or emoji parsing: printed exactly
208
+ if result.hard_stop_at:
209
+ info(f" automatic release at {esc(result.hard_stop_at)}")
210
+ commands = (result.attestation or {}).get("verifyInsideTheVm")
211
+ if isinstance(commands, list) and commands:
212
+ hint("Verify the attestation inside the VM (then check the bundle with `voltagegpu verify`):")
213
+ for line in commands:
214
+ hint(f" {esc(strip_controls(str(line)))}")
215
+ _after_deploy(state, result, wait, timeout, as_json)
216
+
217
+
218
+ __all__ = ["deploy_group", "parse_port_spec", "pick_machine", "check_name", "default_name", "ApiError"]
@@ -0,0 +1,103 @@
1
+ """`voltagegpu machines` and `voltagegpu templates`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Optional
6
+
7
+ import click
8
+
9
+ from ..sdk.models import CONFIDENTIAL, STANDARD, Machine
10
+ from .output import echo_json, hint, info, money, table
11
+ from .state import AppState, pass_state
12
+
13
+
14
+ def filter_machines(
15
+ machines: List[Machine],
16
+ gpu: Optional[str] = None,
17
+ max_price: Optional[float] = None,
18
+ min_gpus: Optional[int] = None,
19
+ ) -> List[Machine]:
20
+ """Pure filter used by `machines` and `deploy standard --cheapest`."""
21
+ needle = (gpu or "").lower().replace(" ", "")
22
+ out = []
23
+ for m in machines:
24
+ if needle and needle not in f"{m.gpu_type} {m.name}".lower().replace(" ", ""):
25
+ continue
26
+ if max_price is not None and (m.price_per_hour is None or m.price_per_hour > max_price):
27
+ continue
28
+ if min_gpus is not None and m.gpu_count < min_gpus:
29
+ continue
30
+ out.append(m)
31
+ return out
32
+
33
+
34
+ def _print_confidential(machines: List[Machine]) -> None:
35
+ table(
36
+ "Confidential VMs (Intel TDX)",
37
+ [("TIER", {"style": "cyan"}), ("GPU",), ("GPUS", {"justify": "right"}), ("VCPU", {"justify": "right"}),
38
+ ("RAM GB", {"justify": "right"}), ("$/HOUR", {"justify": "right", "style": "green"}), ("AVAILABLE", {"justify": "right"})],
39
+ [(m.id, m.gpu_type, m.gpu_count, m.vcpu, m.ram_gb, money(m.price_per_hour), m.available) for m in machines],
40
+ )
41
+
42
+
43
+ def _print_standard(machines: List[Machine], total: int) -> None:
44
+ title = "Standard machines (no enclave, for non-sensitive workloads)"
45
+ if total > len(machines):
46
+ title += f", {len(machines)} of {total} shown"
47
+ table(
48
+ title,
49
+ [("MACHINE ID", {"style": "cyan", "no_wrap": True}), ("GPU", {"no_wrap": True}), ("GPUS", {"justify": "right"}),
50
+ ("VRAM GB", {"justify": "right"}), ("$/HOUR", {"justify": "right", "style": "green"}),
51
+ ("LOCATION", {"no_wrap": True, "max_width": 22, "overflow": "ellipsis"})],
52
+ [(m.id, m.gpu_type, m.gpu_count, m.gpu_memory_gb, money(m.price_per_hour), m.location) for m in machines],
53
+ )
54
+
55
+
56
+ @click.command("machines")
57
+ @click.option("--standard", "kind", flag_value=STANDARD, help="Standard machines only (no enclave).")
58
+ @click.option("--confidential", "kind", flag_value=CONFIDENTIAL, help="Confidential VM tiers only (Intel TDX).")
59
+ @click.option("--gpu", help="Filter by GPU model, e.g. H100, A6000, 4090.")
60
+ @click.option("--max-price", type=float, help="Maximum price per hour (USD).")
61
+ @click.option("--min-gpus", type=click.IntRange(1, 64), help="Minimum number of GPUs.")
62
+ @click.option("--limit", type=click.IntRange(1, 1000), default=15, show_default=True, help="Rows per kind.")
63
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output (no row limit).")
64
+ @pass_state
65
+ def machines_cmd(state: AppState, kind: Optional[str], gpu: Optional[str], max_price: Optional[float],
66
+ min_gpus: Optional[int], limit: int, as_json: bool) -> None:
67
+ """List deployable machines with the hourly price you are charged."""
68
+ found = filter_machines(state.client().list_machines(kind or "all"), gpu, max_price, min_gpus)
69
+ if as_json:
70
+ echo_json([m.to_dict() for m in found])
71
+ return
72
+ conf = [m for m in found if m.confidential]
73
+ std = [m for m in found if not m.confidential]
74
+ if not found:
75
+ info("No machine matches these filters right now.")
76
+ return
77
+ if conf:
78
+ _print_confidential(conf[:limit])
79
+ hint("Deploy: voltagegpu deploy confidential --tier TIER")
80
+ if conf and std:
81
+ info("")
82
+ if std:
83
+ _print_standard(std[:limit], len(std))
84
+ hint("Deploy: voltagegpu deploy standard --machine MACHINE_ID (or --cheapest)")
85
+ hint("Prices are per hour for the whole machine. The first hour is charged at deploy, then per second; "
86
+ "the unused part is refunded when you stop a standard pod.")
87
+
88
+
89
+ @click.command("templates")
90
+ @click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
91
+ @pass_state
92
+ def templates_cmd(state: AppState, as_json: bool) -> None:
93
+ """List the images available for standard pods (--template of `deploy standard`)."""
94
+ items = state.client().list_templates()
95
+ if as_json:
96
+ echo_json([t.to_dict() for t in items])
97
+ return
98
+ table(
99
+ "Standard pod templates",
100
+ [("TEMPLATE ID", {"style": "cyan", "no_wrap": True}), ("NAME",), ("DEFAULT", {"justify": "center"})],
101
+ [(t.id, t.name, "yes" if t.default else "") for t in items],
102
+ )
103
+ hint("Confidential VMs run Ubuntu 24.04 LTS; they take no template.")
volt/cli/cmd_misc.py ADDED
@@ -0,0 +1,102 @@
1
+ """`voltagegpu verify` (delegates to voltage-verify) and retired commands."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import importlib.util
7
+ from typing import List, Sequence, Tuple
8
+
9
+ import click
10
+
11
+ from .output import fail, info
12
+ from .state import AppState, pass_state
13
+
14
+ VERIFY_SUBCOMMANDS = ("manifest", "attest", "verify", "quote", "inspect", "selftest")
15
+
16
+
17
+ def verify_argv(args: Sequence[str]) -> List[str]:
18
+ """`voltagegpu verify bundle.json --offline` -> voltage-verify's `verify bundle.json --offline`.
19
+
20
+ Any voltage-verify subcommand (manifest, attest, quote, ...) passes through
21
+ unchanged; with no argument, voltage-verify prints its own help.
22
+ """
23
+ rest = list(args)
24
+ if rest and rest[0] not in VERIFY_SUBCOMMANDS and not rest[0].startswith("-"):
25
+ rest = ["verify", *rest]
26
+ return rest
27
+
28
+
29
+ def run_voltage_verify(argv: List[str]) -> int:
30
+ """Call voltage-verify's entry point in this process.
31
+
32
+ Not `python -m voltage_verify`: that puts the current directory first on
33
+ sys.path, so a `voltage_verify.py` planted next to a downloaded bundle
34
+ would run instead of the real verifier.
35
+ """
36
+ module = importlib.import_module("voltage_verify.cli")
37
+ try:
38
+ return int(module.main(argv) or 0)
39
+ except SystemExit as exc: # argparse --help / usage errors
40
+ code = exc.code
41
+ return code if isinstance(code, int) else (0 if code is None else 1)
42
+
43
+
44
+ @click.command("verify", context_settings={"ignore_unknown_options": True, "allow_extra_args": True, "help_option_names": []})
45
+ @click.argument("args", nargs=-1, type=click.UNPROCESSED)
46
+ def verify_cmd(args: Tuple[str, ...]) -> None:
47
+ """Verify a Confidential VM attestation bundle offline (runs voltage-verify).
48
+
49
+ \b
50
+ Examples:
51
+ voltagegpu verify bundle.json --offline
52
+ voltagegpu verify bundle.json --challenge <hex> --gpus 1
53
+ voltagegpu verify quote quote.bin
54
+ voltagegpu verify --help # voltage-verify's own help
55
+ \b
56
+ Needs: pip install voltage-verify (or: pip install "voltagegpu-cli[verify]")
57
+ """
58
+ if importlib.util.find_spec("voltage_verify") is None:
59
+ fail('voltage-verify is not installed in this environment. Run: pip install voltage-verify', code=2)
60
+ # Arguments reach voltage-verify exactly as typed; no shell, no subprocess.
61
+ raise click.exceptions.Exit(run_voltage_verify(verify_argv(args)))
62
+
63
+
64
+ _RETIRED = (
65
+ "Confidential containers were retired on 2026-10-01. Use a Confidential VM instead:\n"
66
+ " voltagegpu machines --confidential\n"
67
+ " voltagegpu deploy confidential --tier rtx6000b-small"
68
+ )
69
+
70
+
71
+ @click.group("cc", hidden=True)
72
+ def cc_group() -> None:
73
+ """Retired: Confidential containers. Use `voltagegpu deploy confidential`."""
74
+
75
+
76
+ @cc_group.command("inventory", context_settings={"ignore_unknown_options": True, "allow_extra_args": True})
77
+ def cc_inventory() -> None:
78
+ fail(_RETIRED, code=2)
79
+
80
+
81
+ @cc_group.command("deploy", context_settings={"ignore_unknown_options": True, "allow_extra_args": True})
82
+ def cc_deploy() -> None:
83
+ fail(_RETIRED, code=2)
84
+
85
+
86
+ @click.group("account", hidden=True)
87
+ def account_group() -> None:
88
+ """Earlier releases: use `voltagegpu balance`."""
89
+
90
+
91
+ @account_group.command("balance")
92
+ @click.pass_context
93
+ def account_balance(ctx: click.Context) -> None:
94
+ from .cmd_account import balance_cmd
95
+
96
+ ctx.invoke(balance_cmd, as_json=False)
97
+
98
+
99
+ @account_group.command("info")
100
+ @pass_state
101
+ def account_info(state: AppState) -> None:
102
+ info("Account details are on https://voltagegpu.com/settings. Balance: voltagegpu balance")