voltagegpu-cli 1.3.0__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 +1 -1
- volt/cli/cmd_account.py +176 -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/sdk/client.py +2 -0
- volt/sdk/config.py +47 -31
- volt/sdk/errors.py +2 -1
- volt/sdk/models.py +14 -2
- volt/sdk/ssh.py +48 -3
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-1.3.1.dist-info}/METADATA +7 -6
- voltagegpu_cli-1.3.1.dist-info/RECORD +22 -0
- voltagegpu_cli-1.3.0.dist-info/RECORD +0 -22
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-1.3.1.dist-info}/WHEEL +0 -0
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-1.3.1.dist-info}/entry_points.txt +0 -0
- {voltagegpu_cli-1.3.0.dist-info → voltagegpu_cli-1.3.1.dist-info}/licenses/LICENSE +0 -0
volt/__init__.py
CHANGED
volt/cli/cmd_account.py
CHANGED
|
@@ -1,176 +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, 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
|
-
console.print(f"Balance [bold green]{money(bal.balance)}[/bold green] {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: {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] {key.name} ({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] {key_id}")
|
|
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
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 = (
|
volt/cli/cmd_pods.py
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import shutil
|
|
6
5
|
import subprocess
|
|
7
6
|
from typing import Optional, Tuple
|
|
8
7
|
|
|
9
8
|
import click
|
|
10
9
|
|
|
10
|
+
from ..sdk import ssh as ssh_lookup
|
|
11
11
|
from ..sdk.models import Pod
|
|
12
12
|
from ..sdk.ssh import UnsafeSshCommand, parse_ssh_command
|
|
13
|
-
from .output import console, echo_json, fail, hint, info, is_interactive, money, status_style, table
|
|
13
|
+
from .output import console, echo_json, esc, fail, hint, info, is_interactive, money, status_style, styled, table
|
|
14
14
|
from .state import AppState, pass_state
|
|
15
15
|
|
|
16
|
+
REJECTED_SSH = ("The API returned an SSH command of an unexpected form, so it is not shown or run. "
|
|
17
|
+
"Contact contact@voltagegpu.com.")
|
|
18
|
+
|
|
16
19
|
|
|
17
20
|
class AliasedGroup(click.Group):
|
|
18
21
|
"""`pods get` = `pods show`, `pods delete` / `pods release` = `pods stop` (earlier releases)."""
|
|
@@ -50,7 +53,7 @@ def pods_list(state: AppState, as_json: bool) -> None:
|
|
|
50
53
|
[("POD ID", {"style": "cyan", "no_wrap": True}), ("TYPE",), ("STATUS",), ("GPU",),
|
|
51
54
|
("$/HOUR", {"justify": "right", "style": "green"}), ("SSH",)],
|
|
52
55
|
[
|
|
53
|
-
(p.id, "confidential VM" if p.confidential else "standard",
|
|
56
|
+
(p.id, "confidential VM" if p.confidential else "standard", styled(p.provider_status or p.status, status_style(p.status)),
|
|
54
57
|
f"{p.gpu_count}x {p.gpu_type}" if p.gpu_count and p.gpu_type else (p.resource_name or p.gpu_type),
|
|
55
58
|
money(p.hourly_price), "ready" if p.reachable else "not yet")
|
|
56
59
|
for p in pods
|
|
@@ -60,17 +63,19 @@ def pods_list(state: AppState, as_json: bool) -> None:
|
|
|
60
63
|
|
|
61
64
|
|
|
62
65
|
def _show(pod: Pod) -> None:
|
|
66
|
+
status = f"[{status_style(pod.status)}]{esc(pod.status)}[/]" + (f" ({esc(pod.provider_status)})" if pod.provider_status else "")
|
|
67
|
+
ssh = "rejected (unexpected form from the API)" if pod.ssh_command_rejected else (pod.ssh_command if pod.reachable else "not ready yet")
|
|
63
68
|
rows = [
|
|
64
|
-
("Pod", pod.id),
|
|
69
|
+
("Pod", esc(pod.id)),
|
|
65
70
|
("Type", "Confidential VM (Intel TDX)" if pod.confidential else "Standard pod (no enclave)"),
|
|
66
|
-
("Status",
|
|
67
|
-
("Name", pod.name),
|
|
68
|
-
("Tier", pod.resource_name if pod.confidential else None),
|
|
69
|
-
("GPU", f"{pod.gpu_count}x {pod.gpu_type}" if pod.gpu_count and pod.gpu_type else pod.gpu_type),
|
|
71
|
+
("Status", status),
|
|
72
|
+
("Name", esc(pod.name) if pod.name else None),
|
|
73
|
+
("Tier", esc(pod.resource_name) if pod.confidential and pod.resource_name else None),
|
|
74
|
+
("GPU", esc(f"{pod.gpu_count}x {pod.gpu_type}" if pod.gpu_count and pod.gpu_type else pod.gpu_type or "") or None),
|
|
70
75
|
("Price", f"{money(pod.hourly_price)}/hour" if pod.hourly_price is not None else None),
|
|
71
|
-
("SSH",
|
|
72
|
-
("Jupyter", pod.jupyter_url),
|
|
73
|
-
("Created", pod.created_at),
|
|
76
|
+
("SSH", esc(ssh)),
|
|
77
|
+
("Jupyter", esc(pod.jupyter_url) if pod.jupyter_url else None),
|
|
78
|
+
("Created", esc(pod.created_at) if pod.created_at else None),
|
|
74
79
|
]
|
|
75
80
|
for label, value in rows:
|
|
76
81
|
if value:
|
|
@@ -101,9 +106,11 @@ def pods_wait(state: AppState, pod_id: str, timeout: int, as_json: bool) -> None
|
|
|
101
106
|
|
|
102
107
|
def on_poll(pod: Pod) -> None:
|
|
103
108
|
label = pod.provider_status or pod.status
|
|
109
|
+
if pod.ssh_command_rejected:
|
|
110
|
+
fail(REJECTED_SSH)
|
|
104
111
|
if not as_json and label != last["s"]:
|
|
105
112
|
last["s"] = label
|
|
106
|
-
console.print(f" status: [{status_style(pod.status)}]{label}[/]")
|
|
113
|
+
console.print(f" status: [{status_style(pod.status)}]{esc(label)}[/]")
|
|
107
114
|
|
|
108
115
|
try:
|
|
109
116
|
pod = state.client().wait_until_reachable(pod_id, timeout=timeout, interval=10.0, on_poll=on_poll)
|
|
@@ -112,7 +119,7 @@ def pods_wait(state: AppState, pod_id: str, timeout: int, as_json: bool) -> None
|
|
|
112
119
|
if as_json:
|
|
113
120
|
echo_json(pod.to_dict())
|
|
114
121
|
else:
|
|
115
|
-
console.print(f"[green]Ready.[/green] {pod.ssh_command}")
|
|
122
|
+
console.print(f"[green]Ready.[/green] {esc(pod.ssh_command)}")
|
|
116
123
|
|
|
117
124
|
|
|
118
125
|
@pods_group.command("stop")
|
|
@@ -131,7 +138,7 @@ def pods_stop(state: AppState, pod_id: str, yes: bool, as_json: bool) -> None:
|
|
|
131
138
|
if as_json:
|
|
132
139
|
echo_json(result.to_dict())
|
|
133
140
|
return
|
|
134
|
-
console.print(f"[green]Released.[/green] {pod_id}")
|
|
141
|
+
console.print(f"[green]Released.[/green] {esc(pod_id)}")
|
|
135
142
|
if result.prepaid_refund is not None:
|
|
136
143
|
info(f"Unused prepaid time refunded: {money(result.prepaid_refund, 4)}")
|
|
137
144
|
|
|
@@ -159,6 +166,8 @@ def ssh_cmd(state: AppState, pod_id: str, remote_command: Tuple[str, ...], ident
|
|
|
159
166
|
if "=" not in opt or opt.startswith("-"):
|
|
160
167
|
fail(f"--ssh-option expects KEY=VALUE, got {opt!r}", code=2)
|
|
161
168
|
pod = state.client().get_pod(pod_id)
|
|
169
|
+
if pod.ssh_command_rejected:
|
|
170
|
+
fail("Refusing to run it: " + REJECTED_SSH)
|
|
162
171
|
if not pod.reachable or not pod.ssh_command:
|
|
163
172
|
fail(f"SSH is not ready on {pod_id} yet (status {pod.provider_status or pod.status}). "
|
|
164
173
|
f"Wait with: voltagegpu pods wait {pod_id}")
|
|
@@ -169,7 +178,7 @@ def ssh_cmd(state: AppState, pod_id: str, remote_command: Tuple[str, ...], ident
|
|
|
169
178
|
if print_only:
|
|
170
179
|
click.echo(target.display(identity))
|
|
171
180
|
return
|
|
172
|
-
binary =
|
|
181
|
+
binary = ssh_lookup.find_ssh_binary() # PATH only, never the current directory
|
|
173
182
|
if not binary:
|
|
174
183
|
fail("No ssh client found on PATH. Install OpenSSH, or use: voltagegpu ssh POD_ID --print")
|
|
175
184
|
argv = target.argv(identity_file=identity, remote_command=remote_command, options=ssh_options)
|
volt/cli/main.py
CHANGED
|
@@ -8,6 +8,7 @@ import sys
|
|
|
8
8
|
from typing import List, Optional
|
|
9
9
|
|
|
10
10
|
import click
|
|
11
|
+
from rich.errors import MarkupError
|
|
11
12
|
|
|
12
13
|
from .. import __version__
|
|
13
14
|
from ..sdk.config import API_KEYS_PAGE
|
|
@@ -17,7 +18,7 @@ from .cmd_deploy import deploy_group
|
|
|
17
18
|
from .cmd_machines import machines_cmd, templates_cmd
|
|
18
19
|
from .cmd_misc import account_group, cc_group, verify_cmd
|
|
19
20
|
from .cmd_pods import pods_group, ssh_cmd
|
|
20
|
-
from .output import err_console
|
|
21
|
+
from .output import err_console, esc
|
|
21
22
|
from .state import AppState
|
|
22
23
|
|
|
23
24
|
EPILOG = """\b
|
|
@@ -50,21 +51,21 @@ for command in (machines_cmd, templates_cmd, deploy_group, pods_group, ssh_cmd,
|
|
|
50
51
|
|
|
51
52
|
def _report(exc: BaseException) -> int:
|
|
52
53
|
if isinstance(exc, ConfigError):
|
|
53
|
-
err_console.print(f"[red]Error:[/red] {exc}")
|
|
54
|
+
err_console.print(f"[red]Error:[/red] {esc(exc)}")
|
|
54
55
|
return 2
|
|
55
56
|
if isinstance(exc, ApiError):
|
|
56
57
|
if exc.is_auth_error:
|
|
57
58
|
err_console.print(
|
|
58
|
-
f"[red]Error:[/red] the API refused your key (HTTP {exc.status_code}: {exc.message}).\n"
|
|
59
|
+
f"[red]Error:[/red] the API refused your key (HTTP {exc.status_code}: {esc(exc.message)}).\n"
|
|
59
60
|
f"Create or check a key at {API_KEYS_PAGE}, then run `voltagegpu login`."
|
|
60
61
|
)
|
|
61
62
|
elif exc.status_code:
|
|
62
|
-
err_console.print(f"[red]Error (HTTP {exc.status_code}):[/red] {exc.message}")
|
|
63
|
+
err_console.print(f"[red]Error (HTTP {exc.status_code}):[/red] {esc(exc.message)}")
|
|
63
64
|
else:
|
|
64
|
-
err_console.print(f"[red]Error:[/red] {exc.message}")
|
|
65
|
+
err_console.print(f"[red]Error:[/red] {esc(exc.message)}")
|
|
65
66
|
return 1
|
|
66
67
|
if isinstance(exc, ValueError):
|
|
67
|
-
err_console.print(f"[red]Error:[/red] {exc}")
|
|
68
|
+
err_console.print(f"[red]Error:[/red] {esc(exc)}")
|
|
68
69
|
return 2
|
|
69
70
|
return 1
|
|
70
71
|
|
|
@@ -117,6 +118,11 @@ def main(argv: Optional[List[str]] = None) -> None:
|
|
|
117
118
|
if debug:
|
|
118
119
|
raise
|
|
119
120
|
sys.exit(_report(exc))
|
|
121
|
+
except MarkupError as exc: # last resort: never a traceback because of odd text
|
|
122
|
+
if debug:
|
|
123
|
+
raise
|
|
124
|
+
print(f"Error: could not display a message ({type(exc).__name__}).", file=sys.stderr)
|
|
125
|
+
sys.exit(1)
|
|
120
126
|
except KeyboardInterrupt:
|
|
121
127
|
err_console.print("Interrupted.")
|
|
122
128
|
sys.exit(130)
|
volt/cli/output.py
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"""Console helpers shared by every command. ASCII only: legacy Windows consoles
|
|
2
|
-
render anything else as replacement characters.
|
|
2
|
+
render anything else as replacement characters.
|
|
3
|
+
|
|
4
|
+
Server text (machine names, locations, error messages...) is never parsed as
|
|
5
|
+
rich markup: table cells are plain Text, and anything interpolated into a
|
|
6
|
+
markup string goes through ``esc()``. Control characters are already removed
|
|
7
|
+
by the SDK models.
|
|
8
|
+
"""
|
|
3
9
|
|
|
4
10
|
from __future__ import annotations
|
|
5
11
|
|
|
@@ -9,7 +15,9 @@ from typing import Any, Iterable, Optional
|
|
|
9
15
|
|
|
10
16
|
import click
|
|
11
17
|
from rich.console import Console
|
|
18
|
+
from rich.markup import escape
|
|
12
19
|
from rich.table import Table
|
|
20
|
+
from rich.text import Text
|
|
13
21
|
|
|
14
22
|
|
|
15
23
|
def _width(stream: Any) -> Optional[int]:
|
|
@@ -20,8 +28,13 @@ def _width(stream: Any) -> Optional[int]:
|
|
|
20
28
|
return 140
|
|
21
29
|
|
|
22
30
|
|
|
23
|
-
console = Console(highlight=False, soft_wrap=False, width=_width(sys.stdout))
|
|
24
|
-
err_console = Console(stderr=True, highlight=False, width=_width(sys.stderr))
|
|
31
|
+
console = Console(highlight=False, soft_wrap=False, emoji=False, width=_width(sys.stdout))
|
|
32
|
+
err_console = Console(stderr=True, highlight=False, emoji=False, width=_width(sys.stderr))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def esc(value: Any) -> str:
|
|
36
|
+
"""Escape a value before putting it into a rich markup string."""
|
|
37
|
+
return escape("" if value is None else str(value))
|
|
25
38
|
|
|
26
39
|
|
|
27
40
|
def money(value: Optional[float], digits: int = 2) -> str:
|
|
@@ -32,13 +45,18 @@ def echo_json(data: Any) -> None:
|
|
|
32
45
|
click.echo(json.dumps(data, indent=2, ensure_ascii=False, default=str))
|
|
33
46
|
|
|
34
47
|
|
|
48
|
+
def styled(text: Any, style: str) -> Text:
|
|
49
|
+
"""A table cell with a style and no markup parsing."""
|
|
50
|
+
return Text("" if text is None else str(text), style=style)
|
|
51
|
+
|
|
52
|
+
|
|
35
53
|
def table(title: Optional[str], columns: Iterable[tuple], rows: Iterable[Iterable[Any]]) -> None:
|
|
36
54
|
t = Table(title=title, title_justify="left", header_style="bold", box=None, pad_edge=False)
|
|
37
55
|
for col in columns:
|
|
38
56
|
name, *opts = col
|
|
39
57
|
t.add_column(name, **(opts[0] if opts else {}))
|
|
40
58
|
for row in rows:
|
|
41
|
-
t.add_row(*["-" if v is None or v == "" else str(v) for v in row])
|
|
59
|
+
t.add_row(*[v if isinstance(v, Text) else Text("-" if v is None or v == "" else str(v)) for v in row])
|
|
42
60
|
console.print(t)
|
|
43
61
|
|
|
44
62
|
|
|
@@ -46,16 +64,21 @@ def info(message: str) -> None:
|
|
|
46
64
|
console.print(message)
|
|
47
65
|
|
|
48
66
|
|
|
67
|
+
def plain(message: str) -> None:
|
|
68
|
+
"""Print text exactly as given: no markup, no emoji codes."""
|
|
69
|
+
console.print(Text(message), markup=False, emoji=False)
|
|
70
|
+
|
|
71
|
+
|
|
49
72
|
def hint(message: str) -> None:
|
|
50
73
|
console.print(f"[dim]{message}[/dim]")
|
|
51
74
|
|
|
52
75
|
|
|
53
76
|
def warn(message: str) -> None:
|
|
54
|
-
err_console.print(f"[yellow]Warning:[/yellow] {message}")
|
|
77
|
+
err_console.print(f"[yellow]Warning:[/yellow] {esc(message)}")
|
|
55
78
|
|
|
56
79
|
|
|
57
80
|
def fail(message: str, code: int = 1) -> "click.exceptions.Exit":
|
|
58
|
-
err_console.print(f"[red]Error:[/red] {message}")
|
|
81
|
+
err_console.print(f"[red]Error:[/red] {esc(message)}")
|
|
59
82
|
raise click.exceptions.Exit(code)
|
|
60
83
|
|
|
61
84
|
|
volt/sdk/client.py
CHANGED
|
@@ -196,6 +196,8 @@ class VoltageGPUClient:
|
|
|
196
196
|
pod = self.get_pod(pod_id)
|
|
197
197
|
if on_poll:
|
|
198
198
|
on_poll(pod)
|
|
199
|
+
if pod.ssh_command_rejected:
|
|
200
|
+
raise ApiError(502, f"The API returned an SSH command of an unexpected form for {pod_id}; it was not used.")
|
|
199
201
|
if pod.reachable:
|
|
200
202
|
return pod
|
|
201
203
|
if pod.status.upper() in ("STOPPED", "TERMINATED", "FAILED", "DELETED"):
|
volt/sdk/config.py
CHANGED
|
@@ -22,8 +22,9 @@ API_KEYS_PAGE = "https://voltagegpu.com/api-keys"
|
|
|
22
22
|
# Keys look like volt_<32 hex>_<32 hex>; the server only requires the prefix,
|
|
23
23
|
# so the client stays tolerant but refuses anything that could smuggle a
|
|
24
24
|
# header break or whitespace into a request.
|
|
25
|
-
_API_KEY_RE = re.compile(r"
|
|
25
|
+
_API_KEY_RE = re.compile(r"volt_[A-Za-z0-9_-]{8,200}")
|
|
26
26
|
_LOCAL_HOSTS = {"localhost", "127.0.0.1", "::1"}
|
|
27
|
+
ALLOW_CUSTOM_BASE_URL_ENV_VAR = "VOLT_ALLOW_CUSTOM_BASE_URL"
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
def default_config_path() -> Path:
|
|
@@ -32,7 +33,7 @@ def default_config_path() -> Path:
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
def is_valid_api_key(key: str) -> bool:
|
|
35
|
-
return bool(_API_KEY_RE.
|
|
36
|
+
return bool(_API_KEY_RE.fullmatch(key or ""))
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
def mask_api_key(key: str) -> str:
|
|
@@ -42,11 +43,13 @@ def mask_api_key(key: str) -> str:
|
|
|
42
43
|
return f"volt_****{key[-4:]}" if len(key) > 12 else "****"
|
|
43
44
|
|
|
44
45
|
|
|
45
|
-
def validate_base_url(url: str) -> str:
|
|
46
|
+
def validate_base_url(url: str, allow_custom: bool = False) -> str:
|
|
46
47
|
"""Return a normalised base URL, refusing anything that would leak the key.
|
|
47
48
|
|
|
48
|
-
The API key travels in a header on every request
|
|
49
|
-
accepted for a local development server
|
|
49
|
+
The API key travels in a header on every request: plain HTTP is only
|
|
50
|
+
accepted for a local development server, and a host outside
|
|
51
|
+
voltagegpu.com needs an explicit opt-in (VOLT_ALLOW_CUSTOM_BASE_URL=1), so
|
|
52
|
+
a poisoned environment variable cannot quietly send the key elsewhere.
|
|
50
53
|
"""
|
|
51
54
|
candidate = (url or "").strip().rstrip("/")
|
|
52
55
|
parts = urlsplit(candidate)
|
|
@@ -54,20 +57,40 @@ def validate_base_url(url: str) -> str:
|
|
|
54
57
|
raise ConfigError(f"Invalid base URL {candidate!r}: expected https://host/path.")
|
|
55
58
|
if parts.username or parts.password:
|
|
56
59
|
raise ConfigError("The base URL must not contain credentials.")
|
|
57
|
-
|
|
60
|
+
host = parts.hostname.lower()
|
|
61
|
+
if parts.scheme == "http" and host not in _LOCAL_HOSTS:
|
|
58
62
|
raise ConfigError("Refusing a plain http:// base URL: the API key would be sent unencrypted. Use https://.")
|
|
63
|
+
ours = host == "voltagegpu.com" or host.endswith(".voltagegpu.com") or host in _LOCAL_HOSTS
|
|
64
|
+
if not ours and not allow_custom:
|
|
65
|
+
raise ConfigError(
|
|
66
|
+
f"Refusing to send your API key to {host}: only voltagegpu.com hosts are allowed. "
|
|
67
|
+
f"Set {ALLOW_CUSTOM_BASE_URL_ENV_VAR}=1 if this is intended."
|
|
68
|
+
)
|
|
59
69
|
return candidate
|
|
60
70
|
|
|
61
71
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
def _load(path: Path) -> ConfigParser:
|
|
73
|
+
"""Parse the config file without ever echoing its content in an error
|
|
74
|
+
(configparser messages quote the offending line, which may be the key)."""
|
|
65
75
|
parser = ConfigParser()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
if path.exists():
|
|
77
|
+
try:
|
|
78
|
+
parser.read(path, encoding="utf-8")
|
|
79
|
+
except Exception as exc: # configparser raises several unrelated types
|
|
80
|
+
raise ConfigError(f"Cannot read {path} ({type(exc).__name__}). Fix or delete it, then run `voltagegpu login`.") from None
|
|
81
|
+
return parser
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _write_private(path: Path, parser: ConfigParser) -> None:
|
|
85
|
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
|
86
|
+
if hasattr(os, "fchmod"):
|
|
87
|
+
os.fchmod(fd, 0o600) # an existing 0644 file is tightened before the key is written
|
|
88
|
+
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
89
|
+
parser.write(handle)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _read_key_file(path: Path) -> Optional[str]:
|
|
93
|
+
value = _load(path).get("api", "api_key", fallback=None)
|
|
71
94
|
return value.strip() if value else None
|
|
72
95
|
|
|
73
96
|
|
|
@@ -91,20 +114,13 @@ def save_api_key(key: str, path: Optional[Path] = None) -> Path:
|
|
|
91
114
|
os.chmod(target.parent, 0o700)
|
|
92
115
|
except OSError:
|
|
93
116
|
pass
|
|
94
|
-
parser =
|
|
95
|
-
if target.exists():
|
|
96
|
-
parser.read(target, encoding="utf-8")
|
|
117
|
+
parser = _load(target)
|
|
97
118
|
if not parser.has_section("api"):
|
|
98
119
|
parser.add_section("api")
|
|
99
120
|
parser.set("api", "api_key", key)
|
|
100
|
-
# O_CREAT with 0o600 so the file is never
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
parser.write(handle)
|
|
104
|
-
try:
|
|
105
|
-
os.chmod(target, 0o600)
|
|
106
|
-
except OSError:
|
|
107
|
-
pass
|
|
121
|
+
# O_CREAT with 0o600 (+ fchmod) so the file is never readable by others, not even briefly.
|
|
122
|
+
# On Windows the file inherits the ACL of the user profile folder.
|
|
123
|
+
_write_private(target, parser)
|
|
108
124
|
return target
|
|
109
125
|
|
|
110
126
|
|
|
@@ -113,14 +129,11 @@ def remove_api_key(path: Optional[Path] = None) -> bool:
|
|
|
113
129
|
target = path or default_config_path()
|
|
114
130
|
if not target.exists():
|
|
115
131
|
return False
|
|
116
|
-
parser =
|
|
117
|
-
parser.read(target, encoding="utf-8")
|
|
132
|
+
parser = _load(target)
|
|
118
133
|
if not parser.has_option("api", "api_key"):
|
|
119
134
|
return False
|
|
120
135
|
parser.remove_option("api", "api_key")
|
|
121
|
-
|
|
122
|
-
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
123
|
-
parser.write(handle)
|
|
136
|
+
_write_private(target, parser)
|
|
124
137
|
return True
|
|
125
138
|
|
|
126
139
|
|
|
@@ -166,7 +179,10 @@ class Config:
|
|
|
166
179
|
)
|
|
167
180
|
if not is_valid_api_key(key):
|
|
168
181
|
raise ConfigError(f"The API key from {source} is malformed: VoltageGPU keys start with volt_.")
|
|
169
|
-
url = validate_base_url(
|
|
182
|
+
url = validate_base_url(
|
|
183
|
+
base_url or environ.get(BASE_URL_ENV_VAR) or DEFAULT_BASE_URL,
|
|
184
|
+
allow_custom=environ.get(ALLOW_CUSTOM_BASE_URL_ENV_VAR) == "1",
|
|
185
|
+
)
|
|
170
186
|
return cls(api_key=key, base_url=url, source=source)
|
|
171
187
|
|
|
172
188
|
|
volt/sdk/errors.py
CHANGED
|
@@ -14,7 +14,8 @@ _MAX_MESSAGE = 600
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def scrub(text: str) -> str:
|
|
17
|
-
"""Return ``text`` without internal supplier names, trimmed to a sane length."""
|
|
17
|
+
"""Return ``text`` without control characters or internal supplier names, trimmed to a sane length."""
|
|
18
|
+
text = "".join(ch for ch in text if not (ord(ch) < 32 or 127 <= ord(ch) < 160) or ch in "\t\n")
|
|
18
19
|
cleaned = _DECENTRALIZED.sub("", _INTERNAL_NAMES.sub("provider", text))
|
|
19
20
|
cleaned = " ".join(cleaned.split())
|
|
20
21
|
if len(cleaned) > _MAX_MESSAGE:
|
volt/sdk/models.py
CHANGED
|
@@ -9,6 +9,8 @@ from __future__ import annotations
|
|
|
9
9
|
from dataclasses import asdict, dataclass, field
|
|
10
10
|
from typing import Any, Dict, Mapping, Optional, Tuple
|
|
11
11
|
|
|
12
|
+
from .ssh import safe_ssh_command
|
|
13
|
+
|
|
12
14
|
STANDARD = "standard"
|
|
13
15
|
CONFIDENTIAL = "confidential"
|
|
14
16
|
|
|
@@ -26,10 +28,16 @@ def _int(value: Any) -> Optional[int]:
|
|
|
26
28
|
return int(n) if n is not None else None
|
|
27
29
|
|
|
28
30
|
|
|
31
|
+
def strip_controls(text: str) -> str:
|
|
32
|
+
"""Drop C0/C1 control characters (ESC sequences, BEL...) from server text,
|
|
33
|
+
so nothing the API returns can drive the terminal."""
|
|
34
|
+
return "".join(ch for ch in text if ch in "\t\n" or not (ord(ch) < 32 or 127 <= ord(ch) < 160))
|
|
35
|
+
|
|
36
|
+
|
|
29
37
|
def _str(value: Any) -> Optional[str]:
|
|
30
38
|
if value is None:
|
|
31
39
|
return None
|
|
32
|
-
text = str(value).strip()
|
|
40
|
+
text = strip_controls(str(value)).strip()
|
|
33
41
|
return text or None
|
|
34
42
|
|
|
35
43
|
|
|
@@ -155,6 +163,7 @@ class Pod:
|
|
|
155
163
|
resource_name: Optional[str] = None
|
|
156
164
|
jupyter_url: Optional[str] = None
|
|
157
165
|
created_at: Optional[str] = None
|
|
166
|
+
ssh_command_rejected: bool = False # the API sent an SSH command of an unexpected form
|
|
158
167
|
|
|
159
168
|
@property
|
|
160
169
|
def confidential(self) -> bool:
|
|
@@ -171,6 +180,8 @@ class Pod:
|
|
|
171
180
|
def from_api(cls, raw: Mapping[str, Any]) -> "Pod":
|
|
172
181
|
kind = _kind(raw)
|
|
173
182
|
gpu = _str(raw.get("gpu_type") or raw.get("gpuType"))
|
|
183
|
+
raw_ssh = _str(raw.get("ssh_command"))
|
|
184
|
+
ssh = safe_ssh_command(raw_ssh)
|
|
174
185
|
return cls(
|
|
175
186
|
id=str(raw.get("id") or raw.get("workloadUid") or raw.get("podId") or ""),
|
|
176
187
|
kind=kind,
|
|
@@ -179,12 +190,13 @@ class Pod:
|
|
|
179
190
|
gpu_type=clean_gpu_name(gpu) if gpu else None,
|
|
180
191
|
gpu_count=_int(raw.get("gpu_count")),
|
|
181
192
|
hourly_price=_num(raw.get("hourly_price", raw.get("hourlyPrice"))),
|
|
182
|
-
ssh_command=
|
|
193
|
+
ssh_command=ssh,
|
|
183
194
|
ssh_ready=raw.get("ssh_ready") if isinstance(raw.get("ssh_ready"), bool) else None,
|
|
184
195
|
provider_status=_str(raw.get("provider_status") or raw.get("phase")),
|
|
185
196
|
resource_name=_str(raw.get("resource_name")),
|
|
186
197
|
jupyter_url=_str(raw.get("jupyter_url")),
|
|
187
198
|
created_at=_str(raw.get("created_at") or raw.get("createdAt")),
|
|
199
|
+
ssh_command_rejected=bool(raw_ssh) and ssh is None,
|
|
188
200
|
)
|
|
189
201
|
|
|
190
202
|
def to_dict(self) -> Dict[str, Any]:
|
volt/sdk/ssh.py
CHANGED
|
@@ -63,7 +63,7 @@ class SshTarget:
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def _valid_host(host: str) -> bool:
|
|
66
|
-
return bool(_HOST_RE.
|
|
66
|
+
return bool(_HOST_RE.fullmatch(host) or _IPV6_RE.fullmatch(host))
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def parse_ssh_command(command: str) -> SshTarget:
|
|
@@ -104,9 +104,54 @@ def parse_ssh_command(command: str) -> SshTarget:
|
|
|
104
104
|
if destination is None or destination.count("@") != 1:
|
|
105
105
|
raise UnsafeSshCommand("SSH command has no user@host destination")
|
|
106
106
|
user, host = destination.split("@")
|
|
107
|
-
if not _USER_RE.
|
|
107
|
+
if not _USER_RE.fullmatch(user) or not _valid_host(host):
|
|
108
108
|
raise UnsafeSshCommand("SSH destination has an unexpected user or host")
|
|
109
109
|
return SshTarget(user=user, host=host, port=port or 22)
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
def safe_ssh_command(command: Optional[str]) -> Optional[str]:
|
|
113
|
+
"""The normalised, validated form of a server SSH command, or None.
|
|
114
|
+
|
|
115
|
+
Only this form is ever shown to the user: a tampered answer such as
|
|
116
|
+
``ssh -o ProxyCommand=... root@h`` must not end up on screen where it would
|
|
117
|
+
be copied and pasted into a shell.
|
|
118
|
+
"""
|
|
119
|
+
if not command:
|
|
120
|
+
return None
|
|
121
|
+
try:
|
|
122
|
+
return parse_ssh_command(command).display()
|
|
123
|
+
except UnsafeSshCommand:
|
|
124
|
+
return None
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def find_ssh_binary(env_path: Optional[str] = None, cwd: Optional[str] = None) -> Optional[str]:
|
|
128
|
+
"""Locate ``ssh`` on PATH, never in the current directory.
|
|
129
|
+
|
|
130
|
+
``shutil.which`` on Windows looks in the current directory first, so a
|
|
131
|
+
``ssh.exe`` or ``ssh.bat`` planted in a downloaded folder would run. Only
|
|
132
|
+
absolute PATH entries other than the current directory are searched.
|
|
133
|
+
"""
|
|
134
|
+
import os
|
|
135
|
+
import sys
|
|
136
|
+
|
|
137
|
+
here = os.path.normcase(os.path.realpath(cwd or os.getcwd()))
|
|
138
|
+
raw = os.environ.get("PATH", "") if env_path is None else env_path
|
|
139
|
+
if sys.platform.startswith("win"):
|
|
140
|
+
exts = [e.lower() for e in os.environ.get("PATHEXT", ".COM;.EXE;.BAT;.CMD").split(";") if e]
|
|
141
|
+
names = [f"ssh{e}" for e in exts if e in (".exe", ".com")] # never a .bat/.cmd script
|
|
142
|
+
else:
|
|
143
|
+
names = ["ssh"]
|
|
144
|
+
for entry in raw.split(os.pathsep):
|
|
145
|
+
entry = entry.strip().strip('"')
|
|
146
|
+
if not entry or not os.path.isabs(entry):
|
|
147
|
+
continue
|
|
148
|
+
if os.path.normcase(os.path.realpath(entry)) == here:
|
|
149
|
+
continue
|
|
150
|
+
for name in names:
|
|
151
|
+
candidate = os.path.join(entry, name)
|
|
152
|
+
if os.path.isfile(candidate) and os.access(candidate, os.X_OK):
|
|
153
|
+
return candidate
|
|
154
|
+
return None
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
__all__ = ["SshTarget", "UnsafeSshCommand", "find_ssh_binary", "parse_ssh_command", "safe_ssh_command"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: voltagegpu-cli
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: VoltageGPU CLI and Python SDK: deploy Confidential VMs (Intel TDX) and standard GPU pods, SSH in, stop them, check your balance.
|
|
5
5
|
Project-URL: Homepage, https://voltagegpu.com
|
|
6
6
|
Project-URL: Documentation, https://docs.voltagegpu.com/cli
|
|
@@ -169,7 +169,7 @@ Every list command takes `--json`; deploys and stops take `--yes`.
|
|
|
169
169
|
|
|
170
170
|
```bash
|
|
171
171
|
# Deploy the cheapest standard machine, wait for SSH, run a job, release it.
|
|
172
|
-
POD=$(voltagegpu deploy standard --cheapest --yes --json | jq -r .deploy.pod_id)
|
|
172
|
+
POD=$(voltagegpu deploy standard --cheapest --max-price 1 --yes --json | jq -r .deploy.pod_id)
|
|
173
173
|
voltagegpu pods wait "$POD"
|
|
174
174
|
voltagegpu ssh "$POD" -o StrictHostKeyChecking=accept-new -- nvidia-smi
|
|
175
175
|
voltagegpu pods stop "$POD" --yes
|
|
@@ -211,7 +211,7 @@ curl https://api.voltagegpu.com/api/volt/pods -H "X-API-Key: $VOLT_API_KEY"
|
|
|
211
211
|
| Setting | Where |
|
|
212
212
|
| --- | --- |
|
|
213
213
|
| API key | `--api-key` of `login`, `VOLT_API_KEY` (or `VOLTAGEGPU_API_KEY`), then `~/.volt/config.ini` |
|
|
214
|
-
| API base URL | `VOLT_BASE_URL` (https only
|
|
214
|
+
| API base URL | `VOLT_BASE_URL` (https only, voltagegpu.com hosts unless `VOLT_ALLOW_CUSTOM_BASE_URL=1`; default `https://api.voltagegpu.com/api`) |
|
|
215
215
|
| Debug | `VOLT_DEBUG=1` shows tracebacks |
|
|
216
216
|
|
|
217
217
|
`voltagegpu config` shows where the key comes from, masked.
|
|
@@ -222,9 +222,10 @@ curl https://api.voltagegpu.com/api/volt/pods -H "X-API-Key: $VOLT_API_KEY"
|
|
|
222
222
|
never followed and certificates are always verified.
|
|
223
223
|
- The key is never printed. `~/.volt/config.ini` is created readable by you
|
|
224
224
|
only, and `voltagegpu config` warns if its permissions are too open.
|
|
225
|
-
- The SSH command returned by the API is parsed into user, host and port
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
- The SSH command returned by the API is parsed into user, host and port, only
|
|
226
|
+
that rebuilt form is ever shown, and ssh is started without a shell (and never
|
|
227
|
+
from the current directory), so a tampered answer cannot run a command on
|
|
228
|
+
your machine. Server text is printed literally, without terminal escapes.
|
|
228
229
|
- `ssh-keys add` refuses private keys.
|
|
229
230
|
|
|
230
231
|
Report a vulnerability to contact@voltagegpu.com.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
volt/__init__.py,sha256=a4h47PUy2MHdtdypsE7-6wAp2mpcdsKLBvra3yug_Vo,106
|
|
2
|
+
volt/__main__.py,sha256=mxzyZJsRIIjJ39O6PLrxBQYskEekGI7ZrS-bOjwqakw,73
|
|
3
|
+
volt/cli/__init__.py,sha256=AOR6FpkQfm5WaS_yMyneHgc_6xxMA8UTERqyrAOw-3g,93
|
|
4
|
+
volt/cli/cmd_account.py,sha256=OL_2XN2Bc1pFqr-Xea_jpnfnoDcSNfHSZsrNbIcaxdI,7395
|
|
5
|
+
volt/cli/cmd_deploy.py,sha256=WTDzG2rG-iV_7tq_QXqSbRK_rTrXy5I3fYNz1FLR7xw,12122
|
|
6
|
+
volt/cli/cmd_machines.py,sha256=CHBVFDPSpTc1xLSMaz_SSXiOW5e_SZf2xtK6caOd8yk,4649
|
|
7
|
+
volt/cli/cmd_misc.py,sha256=VJWSklkhS9ovgXbCqGi9ZeISLUoQwjV87K6T4t9Dw30,3567
|
|
8
|
+
volt/cli/cmd_pods.py,sha256=6mSmjDEfN_onaq5r2MzNgQFiaRCPrViwcuOzv1CvQ2I,8280
|
|
9
|
+
volt/cli/main.py,sha256=l7--Qz60E8lMpppAOh05WiRN6Rk8ZnBoguBO1MDkejk,4872
|
|
10
|
+
volt/cli/output.py,sha256=G9Ibq84rjnMsrJyUr4Glg2Sdy6PuNMBVzxSxk_FtDmo,2997
|
|
11
|
+
volt/cli/state.py,sha256=8YmCYUUbJnJvkFRL-muVjqXD5w0r9OTYbMYzmBM0-LA,1057
|
|
12
|
+
volt/sdk/__init__.py,sha256=3E9TIM3bGK-q3FSUZNdqFgk8EujMtG6TyWvPvQyVyXE,1026
|
|
13
|
+
volt/sdk/client.py,sha256=bSt4tg9ZaHP4D8eDePoCxusZhBZG0L_ribECqXTscTc,9564
|
|
14
|
+
volt/sdk/config.py,sha256=mhTw4CYgwrdsQwMzEPe0q7_8qO_kr6k7-crXHbGvX1A,7550
|
|
15
|
+
volt/sdk/errors.py,sha256=btO10yGOf8qz9bH4s6Li2bVBcqJdZm2tmiACgu4aQHQ,2787
|
|
16
|
+
volt/sdk/models.py,sha256=WscdWvbprppgjnTVDfupHV36NN-pikIin-_8wM5a9QY,11724
|
|
17
|
+
volt/sdk/ssh.py,sha256=QyvZ4KKSZYO_-4HqoWSX77stR5QktsBXvDfK3IG2Rqk,5933
|
|
18
|
+
voltagegpu_cli-1.3.1.dist-info/METADATA,sha256=XDpk5vquvEbmqSSWwdoqayJu2Hf5JATM0oO-A5rxKmI,9970
|
|
19
|
+
voltagegpu_cli-1.3.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
20
|
+
voltagegpu_cli-1.3.1.dist-info/entry_points.txt,sha256=osdknBzyIGLtQ063VrJsU-RH8EftptJBcrzLkRAMEeo,76
|
|
21
|
+
voltagegpu_cli-1.3.1.dist-info/licenses/LICENSE,sha256=cM60JdixftzR7QJjOPPYi2itdqg7qqFXu0I3mO2IrEU,1085
|
|
22
|
+
voltagegpu_cli-1.3.1.dist-info/RECORD,,
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
volt/__init__.py,sha256=ehAEI1mOuoVMfz-OWidttIHLk5pKdIVP4fKNGziPIbs,106
|
|
2
|
-
volt/__main__.py,sha256=mxzyZJsRIIjJ39O6PLrxBQYskEekGI7ZrS-bOjwqakw,73
|
|
3
|
-
volt/cli/__init__.py,sha256=AOR6FpkQfm5WaS_yMyneHgc_6xxMA8UTERqyrAOw-3g,93
|
|
4
|
-
volt/cli/cmd_account.py,sha256=DLCL_OP4n6b3zr_upjT5xEta_DRzUeApTER4JHJu33U,7164
|
|
5
|
-
volt/cli/cmd_deploy.py,sha256=laNSSsbGB-bty83n-wHv3IaFglstttNq2LTl_k2dHsA,10560
|
|
6
|
-
volt/cli/cmd_machines.py,sha256=CHBVFDPSpTc1xLSMaz_SSXiOW5e_SZf2xtK6caOd8yk,4649
|
|
7
|
-
volt/cli/cmd_misc.py,sha256=SnU_Md2PSltH8Deaw4i1ER2RJGSoHcWdkGEj9jGe5-M,3040
|
|
8
|
-
volt/cli/cmd_pods.py,sha256=GHfub6RUL0t5ysEx_5PQvc-NtFxstKr6SFL7hkgRYFQ,7604
|
|
9
|
-
volt/cli/main.py,sha256=H1MMO8c6z3egv4ggk-C3I4nyz4hU70BCAvkrdRNKqrQ,4571
|
|
10
|
-
volt/cli/output.py,sha256=Qil8L80q4h-Bngq9oOKg2NWq4IlccSoV7eFzYBXvRfw,2134
|
|
11
|
-
volt/cli/state.py,sha256=8YmCYUUbJnJvkFRL-muVjqXD5w0r9OTYbMYzmBM0-LA,1057
|
|
12
|
-
volt/sdk/__init__.py,sha256=3E9TIM3bGK-q3FSUZNdqFgk8EujMtG6TyWvPvQyVyXE,1026
|
|
13
|
-
volt/sdk/client.py,sha256=RSjACKcrYblXY6Gn3aL2sQ2ZgACAv1-SxzIGebaw778,9398
|
|
14
|
-
volt/sdk/config.py,sha256=AgcnSQEyIhw8nEC45pu0faDjHenwS3zHcTs_B816yaU,6572
|
|
15
|
-
volt/sdk/errors.py,sha256=2V7iCiAnWmFT38WHRsYqorV3mTCfH8YRMCe-Stju_UA,2665
|
|
16
|
-
volt/sdk/models.py,sha256=2e0KkpwGLXli-Qii4rtXHYbKKIiamiNb83XEkU-jYS4,11178
|
|
17
|
-
volt/sdk/ssh.py,sha256=0EMMDG50bYqFW8AUniBmreFaBP-kzPNfWHD8qS_XQmU,4125
|
|
18
|
-
voltagegpu_cli-1.3.0.dist-info/METADATA,sha256=Nrc0N6g0x0XATuulKnSCbSzXgoK5VTAH_oBRANpOa30,9756
|
|
19
|
-
voltagegpu_cli-1.3.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
20
|
-
voltagegpu_cli-1.3.0.dist-info/entry_points.txt,sha256=osdknBzyIGLtQ063VrJsU-RH8EftptJBcrzLkRAMEeo,76
|
|
21
|
-
voltagegpu_cli-1.3.0.dist-info/licenses/LICENSE,sha256=cM60JdixftzR7QJjOPPYi2itdqg7qqFXu0I3mO2IrEU,1085
|
|
22
|
-
voltagegpu_cli-1.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|