voltagegpu-cli 1.3.0__py3-none-any.whl → 2.0.0__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 +5 -5
- volt/cli/cmd_account.py +179 -176
- volt/cli/cmd_deploy.py +50 -24
- volt/cli/cmd_misc.py +20 -6
- volt/cli/cmd_pods.py +24 -15
- volt/cli/main.py +12 -6
- volt/cli/output.py +29 -6
- volt/cli/vgpu.py +475 -0
- volt/mcp/__init__.py +1 -0
- volt/mcp/server.py +344 -0
- volt/sdk/attest.py +296 -0
- volt/sdk/catalog.py +163 -0
- volt/sdk/client.py +240 -234
- volt/sdk/config.py +49 -32
- volt/sdk/errors.py +2 -1
- volt/sdk/fleet.py +220 -0
- volt/sdk/models.py +336 -320
- volt/sdk/remote.py +129 -0
- volt/sdk/scripts/snp-proof-in-the-vm.sh +216 -0
- volt/sdk/scripts/two-proofs-in-the-vm.sh +51 -0
- volt/sdk/ssh.py +157 -112
- volt/sdk/ttl.py +104 -0
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-2.0.0.dist-info}/METADATA +111 -10
- voltagegpu_cli-2.0.0.dist-info/RECORD +32 -0
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-2.0.0.dist-info}/entry_points.txt +1 -0
- voltagegpu_cli-1.3.0.dist-info/RECORD +0 -22
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-2.0.0.dist-info}/WHEEL +0 -0
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-2.0.0.dist-info}/licenses/LICENSE +0 -0
volt/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""VoltageGPU command-line interface and Python SDK."""
|
|
2
|
-
|
|
3
|
-
__version__ = "
|
|
4
|
-
|
|
5
|
-
__all__ = ["__version__"]
|
|
1
|
+
"""VoltageGPU command-line interface and Python SDK."""
|
|
2
|
+
|
|
3
|
+
__version__ = "2.0.0"
|
|
4
|
+
|
|
5
|
+
__all__ = ["__version__"]
|
volt/cli/cmd_account.py
CHANGED
|
@@ -1,176 +1,179 @@
|
|
|
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, 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 {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 {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 {cfg.base_url}")
|
|
90
|
-
info(f"API key {cfg.masked_key} from {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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
@click.option("--
|
|
142
|
-
@click.option("--
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
if bal.balance is None:
|
|
111
|
+
info(f"Balance hidden: {esc(bal.balance_hidden or 'this key cannot read the account balance')}")
|
|
112
|
+
else:
|
|
113
|
+
console.print(f"Balance [bold green]{money(bal.balance)}[/bold green] {esc(bal.currency)}")
|
|
114
|
+
if bal.active_pods is not None:
|
|
115
|
+
info(f"Running {bal.active_pods} pod{'s' if bal.active_pods != 1 else ''}")
|
|
116
|
+
hint(f"Top up: {esc(bal.top_up_url)}")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@click.group("ssh-keys")
|
|
120
|
+
def ssh_keys_group() -> None:
|
|
121
|
+
"""Manage the SSH public keys injected into your pods."""
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@ssh_keys_group.command("list")
|
|
125
|
+
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
126
|
+
@pass_state
|
|
127
|
+
def ssh_keys_list(state: AppState, as_json: bool) -> None:
|
|
128
|
+
"""List your SSH keys."""
|
|
129
|
+
keys = state.client().list_ssh_keys()
|
|
130
|
+
if as_json:
|
|
131
|
+
echo_json([k.to_dict() for k in keys])
|
|
132
|
+
return
|
|
133
|
+
if not keys:
|
|
134
|
+
info("No SSH key yet. Add one: voltagegpu ssh-keys add")
|
|
135
|
+
return
|
|
136
|
+
table("SSH keys", [("KEY ID", {"style": "cyan", "no_wrap": True}), ("NAME",), ("KEY",), ("ADDED",)],
|
|
137
|
+
[(k.id, k.name, k.summary, (k.created_at or "")[:10]) for k in keys])
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@ssh_keys_group.command("add")
|
|
141
|
+
@click.option("--name", help="Label for the key (default: the file name).")
|
|
142
|
+
@click.option("--file", "key_file", type=click.Path(exists=True, dir_okay=False, path_type=Path),
|
|
143
|
+
help="Public key file (default: ~/.ssh/id_ed25519.pub, id_ecdsa.pub or id_rsa.pub).")
|
|
144
|
+
@click.option("--key", "key_text", help="Public key string instead of a file.")
|
|
145
|
+
@click.option("--json", "as_json", is_flag=True, help="Machine-readable output.")
|
|
146
|
+
@pass_state
|
|
147
|
+
def ssh_keys_add(state: AppState, name: Optional[str], key_file: Optional[Path], key_text: Optional[str], as_json: bool) -> None:
|
|
148
|
+
"""Register an SSH public key."""
|
|
149
|
+
if key_file and key_text:
|
|
150
|
+
fail("Give --file or --key, not both.", code=2)
|
|
151
|
+
if not key_text:
|
|
152
|
+
path = key_file or default_public_key_file()
|
|
153
|
+
if path is None:
|
|
154
|
+
fail("No public key found in ~/.ssh. Create one with: ssh-keygen -t ed25519", code=2)
|
|
155
|
+
if path.suffix != ".pub" and path.with_suffix(path.suffix + ".pub").exists():
|
|
156
|
+
fail(f"{path} looks like a private key. Use {path}.pub", code=2)
|
|
157
|
+
key_text = path.read_text(encoding="utf-8", errors="replace")
|
|
158
|
+
name = name or path.name
|
|
159
|
+
public_key = read_public_key(key_text)
|
|
160
|
+
key = state.client().add_ssh_key(name or "cli-key", public_key)
|
|
161
|
+
if as_json:
|
|
162
|
+
echo_json(key.to_dict())
|
|
163
|
+
else:
|
|
164
|
+
console.print(f"[green]Added.[/green] {esc(key.name)} ({esc(key.id)})")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@ssh_keys_group.command("delete")
|
|
168
|
+
@click.argument("key_id")
|
|
169
|
+
@click.option("-y", "--yes", is_flag=True, help="Do not ask for confirmation.")
|
|
170
|
+
@pass_state
|
|
171
|
+
def ssh_keys_delete(state: AppState, key_id: str, yes: bool) -> None:
|
|
172
|
+
"""Delete an SSH key (running pods keep the keys they were created with)."""
|
|
173
|
+
if not yes:
|
|
174
|
+
if not is_interactive():
|
|
175
|
+
fail("Re-run with --yes to confirm in a script.", code=2)
|
|
176
|
+
if not click.confirm(f"Delete SSH key {key_id}?", default=False):
|
|
177
|
+
raise click.exceptions.Exit(1)
|
|
178
|
+
state.client().delete_ssh_key(key_id)
|
|
179
|
+
console.print(f"[green]Deleted.[/green] {esc(key_id)}")
|
volt/cli/cmd_deploy.py
CHANGED
|
@@ -9,12 +9,14 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
|
9
9
|
import click
|
|
10
10
|
|
|
11
11
|
from ..sdk.errors import ApiError
|
|
12
|
-
from ..sdk.models import CONFIDENTIAL, STANDARD, DeployResult, Machine, Pod
|
|
12
|
+
from ..sdk.models import CONFIDENTIAL, STANDARD, DeployResult, Machine, Pod, strip_controls
|
|
13
13
|
from .cmd_machines import filter_machines
|
|
14
|
-
from .output import console, echo_json, fail, hint, info, is_interactive, money, status_style, warn
|
|
14
|
+
from .output import console, echo_json, esc, fail, hint, info, is_interactive, money, plain, status_style, warn
|
|
15
15
|
from .state import AppState, pass_state
|
|
16
16
|
|
|
17
|
-
NAME_RE = re.compile(r"
|
|
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.")
|
|
18
20
|
_PORT_RE = re.compile(r"^(\d{1,5})(?:/(tcp|udp))?$", re.IGNORECASE)
|
|
19
21
|
|
|
20
22
|
|
|
@@ -23,14 +25,14 @@ def default_name() -> str:
|
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
def check_name(name: str) -> str:
|
|
26
|
-
if not NAME_RE.
|
|
28
|
+
if not NAME_RE.fullmatch(name):
|
|
27
29
|
raise click.BadParameter("use 1-40 lowercase letters, digits and hyphens, starting with a letter or digit", param_hint="--name")
|
|
28
30
|
return name
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def parse_port_spec(spec: str) -> Dict[str, Any]:
|
|
32
34
|
"""'8000' / '8000/tcp' / '53/udp' -> {"port": 8000, "protocol": "tcp"}."""
|
|
33
|
-
match = _PORT_RE.
|
|
35
|
+
match = _PORT_RE.fullmatch(spec.strip())
|
|
34
36
|
if not match:
|
|
35
37
|
raise click.BadParameter(f"{spec!r}: expected PORT or PORT/tcp or PORT/udp", param_hint="--port")
|
|
36
38
|
port = int(match.group(1))
|
|
@@ -66,6 +68,23 @@ def _confirm_charge(amount: Optional[float], yes: bool) -> None:
|
|
|
66
68
|
raise click.exceptions.Exit(1)
|
|
67
69
|
|
|
68
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
|
+
|
|
69
88
|
def _wait(state: AppState, pod_id: str, timeout: int) -> Pod:
|
|
70
89
|
seen: Dict[str, str] = {}
|
|
71
90
|
|
|
@@ -73,9 +92,9 @@ def _wait(state: AppState, pod_id: str, timeout: int) -> Pod:
|
|
|
73
92
|
label = pod.provider_status or pod.status
|
|
74
93
|
if seen.get("s") != label:
|
|
75
94
|
seen["s"] = label
|
|
76
|
-
console.print(f" status: [{status_style(pod.status)}]{label}[/]")
|
|
95
|
+
console.print(f" status: [{status_style(pod.status)}]{esc(label)}[/]")
|
|
77
96
|
|
|
78
|
-
info(f"Waiting for SSH on {pod_id} (up to {timeout} s)...")
|
|
97
|
+
info(f"Waiting for SSH on {esc(pod_id)} (up to {timeout} s)...")
|
|
79
98
|
return state.client().wait_until_reachable(pod_id, timeout=timeout, interval=10.0, on_poll=on_poll)
|
|
80
99
|
|
|
81
100
|
|
|
@@ -84,17 +103,18 @@ def _after_deploy(state: AppState, result: DeployResult, wait: bool, timeout: in
|
|
|
84
103
|
if wait:
|
|
85
104
|
try:
|
|
86
105
|
pod = _wait(state, result.pod_id, timeout) if not as_json else state.client().wait_until_reachable(result.pod_id, timeout=timeout)
|
|
87
|
-
except TimeoutError as exc:
|
|
88
|
-
warn(
|
|
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.")
|
|
89
108
|
if as_json:
|
|
90
109
|
echo_json({"deploy": result.to_dict(), "pod": pod.to_dict() if pod else None})
|
|
91
110
|
return
|
|
92
111
|
if pod and pod.ssh_command:
|
|
93
|
-
console.print(f"[green]Ready.[/green] SSH: {pod.ssh_command}")
|
|
112
|
+
console.print(f"[green]Ready.[/green] SSH: {esc(pod.ssh_command)}")
|
|
113
|
+
pid = esc(result.pod_id)
|
|
94
114
|
info("")
|
|
95
115
|
info("Next:")
|
|
96
|
-
info(f" voltagegpu pods wait {
|
|
97
|
-
info(f" voltagegpu pods stop {
|
|
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)")
|
|
98
118
|
|
|
99
119
|
|
|
100
120
|
@click.group("deploy")
|
|
@@ -125,6 +145,8 @@ def deploy_standard(state: AppState, machine_id: Optional[str], cheapest: bool,
|
|
|
125
145
|
"""Deploy a standard pod: a whole machine, no enclave, for non-sensitive workloads."""
|
|
126
146
|
if bool(machine_id) == bool(cheapest):
|
|
127
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)
|
|
128
150
|
pod_name = check_name(name) if name else default_name()
|
|
129
151
|
client = state.client()
|
|
130
152
|
try:
|
|
@@ -132,16 +154,18 @@ def deploy_standard(state: AppState, machine_id: Optional[str], cheapest: bool,
|
|
|
132
154
|
except LookupError as exc:
|
|
133
155
|
fail(str(exc))
|
|
134
156
|
if not as_json:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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.")
|
|
138
161
|
_confirm_charge(machine.price_per_hour, yes)
|
|
139
|
-
result = client.deploy_standard(
|
|
162
|
+
result = _deploy(lambda: client.deploy_standard(
|
|
140
163
|
machine.id, pod_name, template_id=template_id, ssh_key_id=ssh_key_id, gpu_count=None,
|
|
141
164
|
jupyter=jupyter, port_count=port_count, auto_terminate_hours=auto_terminate_hours,
|
|
142
|
-
)
|
|
165
|
+
))
|
|
166
|
+
_check_price(machine.price_per_hour, result, result.pod_id)
|
|
143
167
|
if not as_json:
|
|
144
|
-
console.print(f"[green]Deployed.[/green] Pod {result.pod_id}, {money(result.hourly_price)}/hour, "
|
|
168
|
+
console.print(f"[green]Deployed.[/green] Pod {esc(result.pod_id)}, {money(result.hourly_price)}/hour, "
|
|
145
169
|
f"{money(result.prepaid_amount)} prepaid.")
|
|
146
170
|
_after_deploy(state, result, wait, timeout, as_json)
|
|
147
171
|
|
|
@@ -170,22 +194,24 @@ def deploy_confidential(state: AppState, tier: str, name: Optional[str], hardsto
|
|
|
170
194
|
fail("Add an SSH key first (voltagegpu ssh-keys add). A Confidential VM binds your keys at creation "
|
|
171
195
|
"and cannot be given one afterwards.")
|
|
172
196
|
if not as_json:
|
|
173
|
-
info(f"Confidential VM [bold]{pod_name}[/bold] on {machine.id} ({machine.gpu_count}x {machine.gpu_type}), "
|
|
197
|
+
info(f"Confidential VM [bold]{esc(pod_name)}[/bold] on {esc(machine.id)} ({machine.gpu_count}x {esc(machine.gpu_type)}), "
|
|
174
198
|
f"{money(machine.price_per_hour)}/hour")
|
|
175
199
|
hint("Every SSH key on your account is bound to the VM. We keep no key on it.")
|
|
176
200
|
_confirm_charge(machine.price_per_hour, yes)
|
|
177
|
-
result = client.deploy_confidential(tier, pod_name, hardstop_hours=hardstop_hours, ports=port_list)
|
|
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)
|
|
178
203
|
if not as_json:
|
|
179
|
-
console.print(f"[green]Deployed.[/green] VM {result.pod_id}, {money(result.hourly_price)}/hour, booting.")
|
|
204
|
+
console.print(f"[green]Deployed.[/green] VM {esc(result.pod_id)}, {money(result.hourly_price)}/hour, booting.")
|
|
180
205
|
if result.sudo_password:
|
|
181
|
-
|
|
206
|
+
info(" sudo password (shown once, we do not keep it):")
|
|
207
|
+
plain(f" {result.sudo_password}") # no markup or emoji parsing: printed exactly
|
|
182
208
|
if result.hard_stop_at:
|
|
183
|
-
info(f" automatic release at {result.hard_stop_at}")
|
|
209
|
+
info(f" automatic release at {esc(result.hard_stop_at)}")
|
|
184
210
|
commands = (result.attestation or {}).get("verifyInsideTheVm")
|
|
185
211
|
if isinstance(commands, list) and commands:
|
|
186
212
|
hint("Verify the attestation inside the VM (then check the bundle with `voltagegpu verify`):")
|
|
187
213
|
for line in commands:
|
|
188
|
-
hint(f" {line}")
|
|
214
|
+
hint(f" {esc(strip_controls(str(line)))}")
|
|
189
215
|
_after_deploy(state, result, wait, timeout, as_json)
|
|
190
216
|
|
|
191
217
|
|
volt/cli/cmd_misc.py
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import importlib
|
|
5
6
|
import importlib.util
|
|
6
|
-
import subprocess
|
|
7
|
-
import sys
|
|
8
7
|
from typing import List, Sequence, Tuple
|
|
9
8
|
|
|
10
9
|
import click
|
|
@@ -16,7 +15,7 @@ VERIFY_SUBCOMMANDS = ("manifest", "attest", "verify", "quote", "inspect", "selft
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
def verify_argv(args: Sequence[str]) -> List[str]:
|
|
19
|
-
"""`voltagegpu verify bundle.json --offline` ->
|
|
18
|
+
"""`voltagegpu verify bundle.json --offline` -> voltage-verify's `verify bundle.json --offline`.
|
|
20
19
|
|
|
21
20
|
Any voltage-verify subcommand (manifest, attest, quote, ...) passes through
|
|
22
21
|
unchanged; with no argument, voltage-verify prints its own help.
|
|
@@ -24,7 +23,22 @@ def verify_argv(args: Sequence[str]) -> List[str]:
|
|
|
24
23
|
rest = list(args)
|
|
25
24
|
if rest and rest[0] not in VERIFY_SUBCOMMANDS and not rest[0].startswith("-"):
|
|
26
25
|
rest = ["verify", *rest]
|
|
27
|
-
return
|
|
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)
|
|
28
42
|
|
|
29
43
|
|
|
30
44
|
@click.command("verify", context_settings={"ignore_unknown_options": True, "allow_extra_args": True, "help_option_names": []})
|
|
@@ -43,8 +57,8 @@ def verify_cmd(args: Tuple[str, ...]) -> None:
|
|
|
43
57
|
"""
|
|
44
58
|
if importlib.util.find_spec("voltage_verify") is None:
|
|
45
59
|
fail('voltage-verify is not installed in this environment. Run: pip install voltage-verify', code=2)
|
|
46
|
-
#
|
|
47
|
-
raise click.exceptions.Exit(
|
|
60
|
+
# Arguments reach voltage-verify exactly as typed; no shell, no subprocess.
|
|
61
|
+
raise click.exceptions.Exit(run_voltage_verify(verify_argv(args)))
|
|
48
62
|
|
|
49
63
|
|
|
50
64
|
_RETIRED = (
|