request-vm-on-golem 0.1.36__py3-none-any.whl → 0.1.38__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.
- {request_vm_on_golem-0.1.36.dist-info → request_vm_on_golem-0.1.38.dist-info}/METADATA +1 -1
- {request_vm_on_golem-0.1.36.dist-info → request_vm_on_golem-0.1.38.dist-info}/RECORD +6 -6
- requestor/cli/commands.py +18 -3
- requestor/config.py +44 -11
- {request_vm_on_golem-0.1.36.dist-info → request_vm_on_golem-0.1.38.dist-info}/WHEEL +0 -0
- {request_vm_on_golem-0.1.36.dist-info → request_vm_on_golem-0.1.38.dist-info}/entry_points.txt +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
requestor/__init__.py,sha256=OqSUAh1uZBMx7GW0MoSMg967PVdmT8XdPJx3QYjwkak,116
|
2
2
|
requestor/api/main.py,sha256=7utCzFNbh5Ol-vsBWeSwT4lXeHD7zdA-GFZuS3rHMWc,2180
|
3
3
|
requestor/cli/__init__.py,sha256=e3E4oEGxmGj-STPtFkQwg_qIWhR0JAiAQdw3G1hXciU,37
|
4
|
-
requestor/cli/commands.py,sha256=
|
5
|
-
requestor/config.py,sha256=
|
4
|
+
requestor/cli/commands.py,sha256=1ETYhZJWOjzZXtHx4CAMvURX_icO5u-MCZ4e7iMkJag,26484
|
5
|
+
requestor/config.py,sha256=O39E-Wa-ewqdC9XP5nvj3zkOs52mevvFMyQGtHaqANk,4668
|
6
6
|
requestor/db/__init__.py,sha256=Gm5DfWls6uvCZZ3HGGnyRHswbUQdeA5OGN8yPwH0hc8,88
|
7
7
|
requestor/db/sqlite.py,sha256=l5pWbx2qlHuar1N_a0B9tVnmumLJY1w5rp3yZ7jmsC0,4146
|
8
8
|
requestor/errors.py,sha256=wVpHBuYgQx5pTe_SamugfK-k768noikY1RxvPOjQGko,665
|
@@ -18,7 +18,7 @@ requestor/ssh/__init__.py,sha256=hNgSqJ5s1_AwwxVRyFjUqh_LTBpI4Hmzq0F-f_wXN9g,119
|
|
18
18
|
requestor/ssh/manager.py,sha256=XhZjz7_BRPnmpu-zxqnGHLCq0b2JZ8Xr8zc1OlMNDkc,9355
|
19
19
|
requestor/utils/logging.py,sha256=oFNpO8pJboYM8Wp7g3HOU4HFyBTKypVdY15lUiz1a4I,3721
|
20
20
|
requestor/utils/spinner.py,sha256=PUHJdTD9jpUHur__01_qxXy87WFfNmjQbD_sLG-KlGo,2459
|
21
|
-
request_vm_on_golem-0.1.
|
22
|
-
request_vm_on_golem-0.1.
|
23
|
-
request_vm_on_golem-0.1.
|
24
|
-
request_vm_on_golem-0.1.
|
21
|
+
request_vm_on_golem-0.1.38.dist-info/METADATA,sha256=atnrLF9Phe9qcOvZ0S8MJyLAdULykpPKgK_KUls-gew,9950
|
22
|
+
request_vm_on_golem-0.1.38.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
23
|
+
request_vm_on_golem-0.1.38.dist-info/entry_points.txt,sha256=Z-skRNpJ8aZcIl_En9mEm1ygkp9FKy0bzQoL3zO52-0,44
|
24
|
+
request_vm_on_golem-0.1.38.dist-info/RECORD,,
|
requestor/cli/commands.py
CHANGED
@@ -14,7 +14,7 @@ except ImportError:
|
|
14
14
|
# Python < 3.8
|
15
15
|
import importlib_metadata as metadata
|
16
16
|
|
17
|
-
from ..config import config
|
17
|
+
from ..config import config, ensure_config
|
18
18
|
from ..provider.client import ProviderClient
|
19
19
|
from ..errors import RequestorError
|
20
20
|
from ..utils.logging import setup_logger
|
@@ -56,6 +56,7 @@ def print_version(ctx, param, value):
|
|
56
56
|
expose_value=False, is_eager=True, help="Show the version and exit.")
|
57
57
|
def cli():
|
58
58
|
"""VM on Golem management CLI"""
|
59
|
+
ensure_config()
|
59
60
|
pass
|
60
61
|
|
61
62
|
|
@@ -238,7 +239,7 @@ async def create_vm(name: str, provider_id: str, cpu: int, memory: int, storage:
|
|
238
239
|
@click.argument('name')
|
239
240
|
@async_command
|
240
241
|
async def ssh_vm(name: str):
|
241
|
-
"""SSH into a VM."""
|
242
|
+
"""SSH into a VM (alias: connect)."""
|
242
243
|
try:
|
243
244
|
logger.command(f"🔌 Connecting to VM '{name}'")
|
244
245
|
|
@@ -283,6 +284,13 @@ async def ssh_vm(name: str):
|
|
283
284
|
raise click.Abort()
|
284
285
|
|
285
286
|
|
287
|
+
@vm.command(name="connect")
|
288
|
+
@click.argument("name")
|
289
|
+
def connect_vm(name: str):
|
290
|
+
"""Connect to a VM via SSH (alias of ssh)."""
|
291
|
+
return ssh_vm.callback(name)
|
292
|
+
|
293
|
+
|
286
294
|
@vm.command(name='info')
|
287
295
|
@click.argument('name')
|
288
296
|
@click.option('--json', 'as_json', is_flag=True, help='Output in JSON format')
|
@@ -337,7 +345,7 @@ async def info_vm(name: str, as_json: bool):
|
|
337
345
|
@click.argument('name')
|
338
346
|
@async_command
|
339
347
|
async def destroy_vm(name: str):
|
340
|
-
"""Destroy a VM."""
|
348
|
+
"""Destroy a VM (alias: delete)."""
|
341
349
|
try:
|
342
350
|
logger.command(f"💥 Destroying VM '{name}'")
|
343
351
|
|
@@ -376,6 +384,13 @@ async def destroy_vm(name: str):
|
|
376
384
|
raise click.Abort()
|
377
385
|
|
378
386
|
|
387
|
+
@vm.command(name="delete")
|
388
|
+
@click.argument("name")
|
389
|
+
def delete_vm(name: str):
|
390
|
+
"""Delete a VM (alias of destroy)."""
|
391
|
+
return destroy_vm.callback(name)
|
392
|
+
|
393
|
+
|
379
394
|
@vm.command(name='purge')
|
380
395
|
@click.option('--force', is_flag=True, help='Force purge even if other errors occur')
|
381
396
|
@click.confirmation_option(prompt='Are you sure you want to purge all VMs?')
|
requestor/config.py
CHANGED
@@ -1,14 +1,46 @@
|
|
1
1
|
from pathlib import Path
|
2
2
|
from typing import Optional, Dict
|
3
3
|
import os
|
4
|
-
from pydantic_settings import BaseSettings
|
5
|
-
from pydantic import Field,
|
4
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
5
|
+
from pydantic import Field, field_validator, ValidationInfo
|
6
|
+
|
7
|
+
|
8
|
+
def ensure_config() -> None:
|
9
|
+
"""Ensure the requestor configuration directory and defaults exist."""
|
10
|
+
base_dir = Path.home() / ".golem" / "requestor"
|
11
|
+
ssh_dir = base_dir / "ssh"
|
12
|
+
env_file = base_dir / ".env"
|
13
|
+
created = False
|
14
|
+
|
15
|
+
if not base_dir.exists():
|
16
|
+
base_dir.mkdir(parents=True, exist_ok=True)
|
17
|
+
created = True
|
18
|
+
if not ssh_dir.exists():
|
19
|
+
ssh_dir.mkdir(parents=True, exist_ok=True)
|
20
|
+
created = True
|
21
|
+
|
22
|
+
if not env_file.exists():
|
23
|
+
env_file.write_text("GOLEM_REQUESTOR_ENVIRONMENT=production\n")
|
24
|
+
created = True
|
25
|
+
|
26
|
+
private_key = ssh_dir / "id_rsa"
|
27
|
+
public_key = ssh_dir / "id_rsa.pub"
|
28
|
+
if not private_key.exists():
|
29
|
+
private_key.write_text("placeholder-private-key")
|
30
|
+
private_key.chmod(0o600)
|
31
|
+
public_key.write_text("placeholder-public-key")
|
32
|
+
created = True
|
33
|
+
|
34
|
+
if created:
|
35
|
+
print("Using default settings – run with --help to customize")
|
36
|
+
|
37
|
+
|
38
|
+
ensure_config()
|
6
39
|
|
7
40
|
class RequestorConfig(BaseSettings):
|
8
41
|
"""Configuration settings for the requestor node."""
|
9
|
-
|
10
|
-
|
11
|
-
env_prefix = "GOLEM_REQUESTOR_"
|
42
|
+
|
43
|
+
model_config = SettingsConfigDict(env_prefix="GOLEM_REQUESTOR_")
|
12
44
|
|
13
45
|
# Environment
|
14
46
|
environment: str = Field(
|
@@ -36,10 +68,11 @@ class RequestorConfig(BaseSettings):
|
|
36
68
|
description="URL of the discovery service (for 'central' driver)"
|
37
69
|
)
|
38
70
|
|
39
|
-
@
|
40
|
-
|
71
|
+
@field_validator("discovery_url")
|
72
|
+
@classmethod
|
73
|
+
def set_discovery_url(cls, v: str, info: ValidationInfo) -> str:
|
41
74
|
"""Prefix discovery URL with DEVMODE if in development."""
|
42
|
-
if
|
75
|
+
if info.data.get("environment") == "development":
|
43
76
|
return f"DEVMODE-{v}"
|
44
77
|
return v
|
45
78
|
|
@@ -63,7 +96,7 @@ class RequestorConfig(BaseSettings):
|
|
63
96
|
|
64
97
|
# Base Directory
|
65
98
|
base_dir: Path = Field(
|
66
|
-
default_factory=lambda: Path.home() / ".golem",
|
99
|
+
default_factory=lambda: Path.home() / ".golem" / "requestor",
|
67
100
|
description="Base directory for all Golem requestor files"
|
68
101
|
)
|
69
102
|
|
@@ -86,10 +119,10 @@ class RequestorConfig(BaseSettings):
|
|
86
119
|
|
87
120
|
# Set dependent paths before validation
|
88
121
|
if 'ssh_key_dir' not in kwargs:
|
89
|
-
base_dir = kwargs.get('base_dir', Path.home() / ".golem")
|
122
|
+
base_dir = kwargs.get('base_dir', Path.home() / ".golem" / "requestor")
|
90
123
|
kwargs['ssh_key_dir'] = base_dir / "ssh"
|
91
124
|
if 'db_path' not in kwargs:
|
92
|
-
base_dir = kwargs.get('base_dir', Path.home() / ".golem")
|
125
|
+
base_dir = kwargs.get('base_dir', Path.home() / ".golem" / "requestor")
|
93
126
|
kwargs['db_path'] = base_dir / "vms.db"
|
94
127
|
super().__init__(**kwargs)
|
95
128
|
|
File without changes
|
{request_vm_on_golem-0.1.36.dist-info → request_vm_on_golem-0.1.38.dist-info}/entry_points.txt
RENAMED
File without changes
|