voltagegpu-cli 2.0.2__tar.gz → 2.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/.gitignore +14 -14
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/LICENSE +21 -21
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/PKG-INFO +20 -6
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/README.md +18 -4
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/pyproject.toml +3 -2
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/__init__.py +1 -1
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/__main__.py +5 -5
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/__init__.py +5 -5
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/cmd_account.py +179 -179
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/cmd_deploy.py +218 -218
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/cmd_machines.py +103 -103
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/cmd_misc.py +105 -102
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/cmd_pods.py +188 -188
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/main.py +132 -132
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/output.py +98 -98
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/state.py +35 -35
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/cli/vgpu.py +500 -485
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/mcp/__init__.py +1 -1
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/mcp/server.py +351 -344
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/__init__.py +36 -36
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/attest.py +317 -296
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/catalog.py +163 -163
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/client.py +240 -240
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/config.py +202 -202
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/errors.py +82 -82
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/fleet.py +220 -220
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/models.py +336 -336
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/remote.py +140 -140
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/ssh.py +157 -157
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/ttl.py +104 -104
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/scripts/snp-proof-in-the-vm.sh +0 -0
- {voltagegpu_cli-2.0.2 → voltagegpu_cli-2.0.4}/volt/sdk/scripts/two-proofs-in-the-vm.sh +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
__pycache__/
|
|
2
|
-
*.py[cod]
|
|
3
|
-
*.egg-info/
|
|
4
|
-
.venv*/
|
|
5
|
-
venv*/
|
|
6
|
-
build/
|
|
7
|
-
dist/
|
|
8
|
-
.pytest_cache/
|
|
9
|
-
.ruff_cache/
|
|
10
|
-
.coverage
|
|
11
|
-
htmlcov/
|
|
12
|
-
.env
|
|
13
|
-
*.ini
|
|
14
|
-
!pytest.ini
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.venv*/
|
|
5
|
+
venv*/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
.coverage
|
|
11
|
+
htmlcov/
|
|
12
|
+
.env
|
|
13
|
+
*.ini
|
|
14
|
+
!pytest.ini
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2026 VOLTAGE EI (VoltageGPU)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 VOLTAGE EI (VoltageGPU)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: voltagegpu-cli
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: VoltageGPU CLI and Python SDK: Confidential VMs (Intel TDX), Confidential CPU (AMD SEV-SNP), standard GPU pods, dedicated machines and sandboxes, with the vgpu command for scripts and AI agents.
|
|
5
5
|
Project-URL: Homepage, https://voltagegpu.com
|
|
6
6
|
Project-URL: Documentation, https://docs.voltagegpu.com/cli
|
|
@@ -59,7 +59,7 @@ Requires-Dist: pytest>=8; extra == 'dev'
|
|
|
59
59
|
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
60
60
|
Requires-Dist: twine>=5; extra == 'dev'
|
|
61
61
|
Provides-Extra: verify
|
|
62
|
-
Requires-Dist: voltage-verify>=0.
|
|
62
|
+
Requires-Dist: voltage-verify>=0.3.0; extra == 'verify'
|
|
63
63
|
Description-Content-Type: text/markdown
|
|
64
64
|
|
|
65
65
|
# voltagegpu-cli
|
|
@@ -155,13 +155,17 @@ commands). On your own machine:
|
|
|
155
155
|
|
|
156
156
|
```bash
|
|
157
157
|
pip install "voltagegpu-cli[verify]" # installs voltage-verify
|
|
158
|
-
voltagegpu verify bundle.json --offline
|
|
159
158
|
voltagegpu verify bundle.json --challenge <hex-you-issued> --gpus 1
|
|
159
|
+
voltagegpu verify bundle.json --challenge <hex-you-issued> --offline --accept-offline-tcb
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
`voltagegpu verify` runs [voltage-verify](https://pypi.org/project/voltage-verify/),
|
|
163
163
|
which checks the Intel TDX quote up to Intel's root and the NVIDIA GPU
|
|
164
|
-
attestation tokens, without trusting VoltageGPU.
|
|
164
|
+
attestation tokens, without trusting VoltageGPU. Online, the TCB status and
|
|
165
|
+
revocation are checked against Intel's collateral of today. `--offline` uses
|
|
166
|
+
the Intel collateral inside the bundle: the verdict names that limit and the
|
|
167
|
+
exit code is 3, unless `--accept-offline-tcb` (voltage-verify 0.3.0 or later).
|
|
168
|
+
`voltagegpu verify` returns voltage-verify's own exit code.
|
|
165
169
|
|
|
166
170
|
## Scripting
|
|
167
171
|
|
|
@@ -223,8 +227,11 @@ balance` show the balance as hidden: only a full key reads it.
|
|
|
223
227
|
script in the machine (`two-proofs-in-the-vm.sh` for a Confidential VM,
|
|
224
228
|
`snp-proof-in-the-vm.sh` for a Confidential CPU tier, both embedded and pinned
|
|
225
229
|
by SHA-256), copies the archive back and verifies it here: `voltage-verify`
|
|
226
|
-
for Intel TDX + NVIDIA (`pip install 'voltagegpu-cli[verify]'
|
|
227
|
-
|
|
230
|
+
for Intel TDX + NVIDIA (`pip install 'voltagegpu-cli[verify]'`). `--offline`
|
|
231
|
+
verifies without network, with the Intel collateral inside the bundle: the TCB
|
|
232
|
+
and revocation are then not checked against Intel today, so the result stays
|
|
233
|
+
`VERIFIED` but names that limit (`limits` in `--json`) and exits with 10,
|
|
234
|
+
unless `--accept-offline-tcb`. For SEV-SNP: the report is requested at `--vmpl` (0 by
|
|
228
235
|
default, sent as `SNP_VMPL`; if VMPL 0 is refused, the script says so and asks
|
|
229
236
|
again at 1, and the result reports it), REPORT_DATA equals the challenge, the
|
|
230
237
|
report policy forbids debug and its VMPL field is the level requested (the
|
|
@@ -249,12 +256,15 @@ attestation and are refused.
|
|
|
249
256
|
| 7 | unavailable: sold out, over `--max-price`, rate limited, offer closed |
|
|
250
257
|
| 8 | attestation failed |
|
|
251
258
|
| 9 | attestation incomplete, or a local tool is missing (ssh, scp, voltage-verify) |
|
|
259
|
+
| 10 | attestation verified with a limit: `--offline`, TCB and revocation not checked against Intel today (`--accept-offline-tcb` accepts it; local MCP server: `ATTESTATION_LIMITED`) |
|
|
252
260
|
|
|
253
261
|
With `--json`, an error is also printed on stdout as
|
|
254
262
|
`{"error": {"code", "message", "exit_code", ...}}`.
|
|
255
263
|
|
|
256
264
|
### Local MCP server
|
|
257
265
|
|
|
266
|
+
<!-- mcp-name: io.github.VoltageGPU/voltagegpu-cli -->
|
|
267
|
+
|
|
258
268
|
`vgpu mcp` serves the tools `ls`, `up`, `ps`, `exec`, `scp`, `rm`, `attest`,
|
|
259
269
|
`inference` and `whoami` over stdio. It runs on your machine because `exec`,
|
|
260
270
|
`scp` and `attest` use your SSH private key, which never leaves it. Same
|
|
@@ -270,6 +280,10 @@ which takes the `volt_` key from `VOLT_API_KEY`.
|
|
|
270
280
|
claude mcp add voltagegpu -e VOLT_API_KEY=volt_... -- vgpu mcp # Claude Code
|
|
271
281
|
```
|
|
272
282
|
|
|
283
|
+
A client that starts servers from the package name runs the same program with
|
|
284
|
+
`uvx voltagegpu-cli mcp`: the package installs a `voltagegpu-cli` executable,
|
|
285
|
+
the same entry point as `vgpu`.
|
|
286
|
+
|
|
273
287
|
```toml
|
|
274
288
|
# Codex: ~/.codex/config.toml
|
|
275
289
|
[mcp_servers.voltagegpu]
|
|
@@ -91,13 +91,17 @@ commands). On your own machine:
|
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
93
|
pip install "voltagegpu-cli[verify]" # installs voltage-verify
|
|
94
|
-
voltagegpu verify bundle.json --offline
|
|
95
94
|
voltagegpu verify bundle.json --challenge <hex-you-issued> --gpus 1
|
|
95
|
+
voltagegpu verify bundle.json --challenge <hex-you-issued> --offline --accept-offline-tcb
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
`voltagegpu verify` runs [voltage-verify](https://pypi.org/project/voltage-verify/),
|
|
99
99
|
which checks the Intel TDX quote up to Intel's root and the NVIDIA GPU
|
|
100
|
-
attestation tokens, without trusting VoltageGPU.
|
|
100
|
+
attestation tokens, without trusting VoltageGPU. Online, the TCB status and
|
|
101
|
+
revocation are checked against Intel's collateral of today. `--offline` uses
|
|
102
|
+
the Intel collateral inside the bundle: the verdict names that limit and the
|
|
103
|
+
exit code is 3, unless `--accept-offline-tcb` (voltage-verify 0.3.0 or later).
|
|
104
|
+
`voltagegpu verify` returns voltage-verify's own exit code.
|
|
101
105
|
|
|
102
106
|
## Scripting
|
|
103
107
|
|
|
@@ -159,8 +163,11 @@ balance` show the balance as hidden: only a full key reads it.
|
|
|
159
163
|
script in the machine (`two-proofs-in-the-vm.sh` for a Confidential VM,
|
|
160
164
|
`snp-proof-in-the-vm.sh` for a Confidential CPU tier, both embedded and pinned
|
|
161
165
|
by SHA-256), copies the archive back and verifies it here: `voltage-verify`
|
|
162
|
-
for Intel TDX + NVIDIA (`pip install 'voltagegpu-cli[verify]'
|
|
163
|
-
|
|
166
|
+
for Intel TDX + NVIDIA (`pip install 'voltagegpu-cli[verify]'`). `--offline`
|
|
167
|
+
verifies without network, with the Intel collateral inside the bundle: the TCB
|
|
168
|
+
and revocation are then not checked against Intel today, so the result stays
|
|
169
|
+
`VERIFIED` but names that limit (`limits` in `--json`) and exits with 10,
|
|
170
|
+
unless `--accept-offline-tcb`. For SEV-SNP: the report is requested at `--vmpl` (0 by
|
|
164
171
|
default, sent as `SNP_VMPL`; if VMPL 0 is refused, the script says so and asks
|
|
165
172
|
again at 1, and the result reports it), REPORT_DATA equals the challenge, the
|
|
166
173
|
report policy forbids debug and its VMPL field is the level requested (the
|
|
@@ -185,12 +192,15 @@ attestation and are refused.
|
|
|
185
192
|
| 7 | unavailable: sold out, over `--max-price`, rate limited, offer closed |
|
|
186
193
|
| 8 | attestation failed |
|
|
187
194
|
| 9 | attestation incomplete, or a local tool is missing (ssh, scp, voltage-verify) |
|
|
195
|
+
| 10 | attestation verified with a limit: `--offline`, TCB and revocation not checked against Intel today (`--accept-offline-tcb` accepts it; local MCP server: `ATTESTATION_LIMITED`) |
|
|
188
196
|
|
|
189
197
|
With `--json`, an error is also printed on stdout as
|
|
190
198
|
`{"error": {"code", "message", "exit_code", ...}}`.
|
|
191
199
|
|
|
192
200
|
### Local MCP server
|
|
193
201
|
|
|
202
|
+
<!-- mcp-name: io.github.VoltageGPU/voltagegpu-cli -->
|
|
203
|
+
|
|
194
204
|
`vgpu mcp` serves the tools `ls`, `up`, `ps`, `exec`, `scp`, `rm`, `attest`,
|
|
195
205
|
`inference` and `whoami` over stdio. It runs on your machine because `exec`,
|
|
196
206
|
`scp` and `attest` use your SSH private key, which never leaves it. Same
|
|
@@ -206,6 +216,10 @@ which takes the `volt_` key from `VOLT_API_KEY`.
|
|
|
206
216
|
claude mcp add voltagegpu -e VOLT_API_KEY=volt_... -- vgpu mcp # Claude Code
|
|
207
217
|
```
|
|
208
218
|
|
|
219
|
+
A client that starts servers from the package name runs the same program with
|
|
220
|
+
`uvx voltagegpu-cli mcp`: the package installs a `voltagegpu-cli` executable,
|
|
221
|
+
the same entry point as `vgpu`.
|
|
222
|
+
|
|
209
223
|
```toml
|
|
210
224
|
# Codex: ~/.codex/config.toml
|
|
211
225
|
[mcp_servers.voltagegpu]
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "voltagegpu-cli"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.4"
|
|
8
8
|
description = "VoltageGPU CLI and Python SDK: Confidential VMs (Intel TDX), Confidential CPU (AMD SEV-SNP), standard GPU pods, dedicated machines and sandboxes, with the vgpu command for scripts and AI agents."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -46,13 +46,14 @@ dependencies = [
|
|
|
46
46
|
]
|
|
47
47
|
|
|
48
48
|
[project.optional-dependencies]
|
|
49
|
-
verify = ["voltage-verify>=0.
|
|
49
|
+
verify = ["voltage-verify>=0.3.0"]
|
|
50
50
|
dev = ["pytest>=8", "pytest-cov>=5", "ruff>=0.6", "build>=1.2", "twine>=5"]
|
|
51
51
|
|
|
52
52
|
[project.scripts]
|
|
53
53
|
voltagegpu = "volt.cli.main:main"
|
|
54
54
|
volt = "volt.cli.main:main"
|
|
55
55
|
vgpu = "volt.cli.vgpu:main"
|
|
56
|
+
voltagegpu-cli = "volt.cli.vgpu:main"
|
|
56
57
|
|
|
57
58
|
[project.urls]
|
|
58
59
|
Homepage = "https://voltagegpu.com"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""`python -m volt` runs the CLI."""
|
|
2
|
-
|
|
3
|
-
from .cli.main import main
|
|
4
|
-
|
|
5
|
-
main()
|
|
1
|
+
"""`python -m volt` runs the CLI."""
|
|
2
|
+
|
|
3
|
+
from .cli.main import main
|
|
4
|
+
|
|
5
|
+
main()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""The `voltagegpu` command line."""
|
|
2
|
-
|
|
3
|
-
from .main import cli, main
|
|
4
|
-
|
|
5
|
-
__all__ = ["cli", "main"]
|
|
1
|
+
"""The `voltagegpu` command line."""
|
|
2
|
+
|
|
3
|
+
from .main import cli, main
|
|
4
|
+
|
|
5
|
+
__all__ = ["cli", "main"]
|
|
@@ -1,179 +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, 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)}")
|
|
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)}")
|