golem-vm-provider 0.1.12__py3-none-any.whl → 0.1.13__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.
- {golem_vm_provider-0.1.12.dist-info → golem_vm_provider-0.1.13.dist-info}/METADATA +1 -1
- {golem_vm_provider-0.1.12.dist-info → golem_vm_provider-0.1.13.dist-info}/RECORD +5 -5
- provider/config.py +119 -84
- {golem_vm_provider-0.1.12.dist-info → golem_vm_provider-0.1.13.dist-info}/WHEEL +0 -0
- {golem_vm_provider-0.1.12.dist-info → golem_vm_provider-0.1.13.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,7 @@ provider/__init__.py,sha256=HO1fkPpZqPO3z8O8-eVIyx8xXSMIVuTR_b1YF0RtXOg,45
|
|
2
2
|
provider/api/__init__.py,sha256=ssX1ugDqEPt8Fn04IymgmG-Ev8PiXLsCSaiZVvHQnec,344
|
3
3
|
provider/api/models.py,sha256=JOzoNf1oE5N97UqTN5xuIrTkqn2tCHqPDaIzGA3jUyo,3513
|
4
4
|
provider/api/routes.py,sha256=P27RQvNqFWn6PacRwr1PaVz-yv5KAWsp9KeORejkXSI,6452
|
5
|
-
provider/config.py,sha256=
|
5
|
+
provider/config.py,sha256=41FhWAzPJrbyu1VJC4YOMLl79RzYmzFpOjEuS2MZSm4,9128
|
6
6
|
provider/discovery/__init__.py,sha256=VR3NRoQtZRH5Vs8FG7jnGLR7p7wn7XeZdLaBb3t8e1g,123
|
7
7
|
provider/discovery/advertiser.py,sha256=yv7RbRf1K43qOLAEa2Olj9hhN8etl2qsBuoHok0xoVs,6784
|
8
8
|
provider/discovery/resource_tracker.py,sha256=8dYhJxoe_jLRwisHoA0jr575YhUKmLIqSXfW88KshcQ,6000
|
@@ -20,7 +20,7 @@ provider/vm/multipass.py,sha256=RLUqCeoYz4PG8RL7dBu_TzjNEAmgIz9NonBtSuYc4kw,1643
|
|
20
20
|
provider/vm/name_mapper.py,sha256=MrshNeJ4Dw-WBsyiIVcn9N5xyOxaBKX4Yqhyh_m5IFg,4103
|
21
21
|
provider/vm/port_manager.py,sha256=d03uwU76vx6LgADMN8ffBT9t400XQ3vtYlXr6cLIFN0,9831
|
22
22
|
provider/vm/proxy_manager.py,sha256=cu0FPPbeCc3CR6NRE_CnLjiRg7xVdSFUylVUOL1g1sI,10154
|
23
|
-
golem_vm_provider-0.1.
|
24
|
-
golem_vm_provider-0.1.
|
25
|
-
golem_vm_provider-0.1.
|
26
|
-
golem_vm_provider-0.1.
|
23
|
+
golem_vm_provider-0.1.13.dist-info/METADATA,sha256=zaGnsTHOW6OEZAOOpl-a3gchR9ESFbDNNfOR35JJUSQ,10594
|
24
|
+
golem_vm_provider-0.1.13.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
25
|
+
golem_vm_provider-0.1.13.dist-info/entry_points.txt,sha256=E4rCWo_Do_2zCG_GewNuftfVlHF_8b_OvioZre0dfeA,54
|
26
|
+
golem_vm_provider-0.1.13.dist-info/RECORD,,
|
provider/config.py
CHANGED
@@ -3,7 +3,10 @@ from pathlib import Path
|
|
3
3
|
from typing import Optional
|
4
4
|
import uuid
|
5
5
|
|
6
|
-
from pydantic import BaseSettings, validator
|
6
|
+
from pydantic import BaseSettings, validator, Field
|
7
|
+
from .utils.logging import setup_logger
|
8
|
+
|
9
|
+
logger = setup_logger(__name__)
|
7
10
|
|
8
11
|
|
9
12
|
class Settings(BaseSettings):
|
@@ -88,98 +91,130 @@ class Settings(BaseSettings):
|
|
88
91
|
RATE_LIMIT_PER_MINUTE: int = 100
|
89
92
|
|
90
93
|
# Multipass Settings
|
91
|
-
MULTIPASS_BINARY_PATH: str =
|
94
|
+
MULTIPASS_BINARY_PATH: str = Field(
|
95
|
+
default="",
|
96
|
+
description="Path to multipass binary"
|
97
|
+
)
|
92
98
|
|
93
|
-
@validator("MULTIPASS_BINARY_PATH"
|
99
|
+
@validator("MULTIPASS_BINARY_PATH")
|
94
100
|
def detect_multipass_path(cls, v: str) -> str:
|
95
101
|
"""Detect and validate Multipass binary path."""
|
102
|
+
import platform
|
103
|
+
import subprocess
|
104
|
+
|
105
|
+
def validate_path(path: str) -> bool:
|
106
|
+
"""Validate that a path exists and is executable."""
|
107
|
+
return os.path.isfile(path) and os.access(path, os.X_OK)
|
108
|
+
|
109
|
+
# If path provided via environment variable, ONLY validate that path
|
96
110
|
if v:
|
97
|
-
path
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
111
|
+
logger.debug(f"Using provided multipass path: {v}")
|
112
|
+
if not validate_path(v):
|
113
|
+
logger.error(f"Provided path {v} is invalid or not executable")
|
114
|
+
raise ValueError(f"Invalid multipass binary path: {v}")
|
115
|
+
return v
|
116
|
+
|
117
|
+
logger.debug("No multipass path provided, attempting auto-detection")
|
118
|
+
system = platform.system().lower()
|
119
|
+
logger.debug(f"Detected OS: {system}")
|
120
|
+
binary_name = "multipass.exe" if system == "windows" else "multipass"
|
121
|
+
|
122
|
+
# Try to find multipass based on OS
|
123
|
+
if system == "linux":
|
124
|
+
logger.debug("Checking for snap installation on Linux")
|
125
|
+
# First try to find snap and check if multipass is installed
|
126
|
+
try:
|
127
|
+
# Check if snap exists
|
128
|
+
snap_result = subprocess.run(
|
129
|
+
["which", "snap"],
|
130
|
+
capture_output=True,
|
131
|
+
text=True,
|
132
|
+
check=True
|
133
|
+
)
|
134
|
+
if snap_result.returncode == 0:
|
135
|
+
logger.debug("Found snap, checking for multipass installation")
|
136
|
+
# Check if multipass is installed via snap
|
137
|
+
try:
|
138
|
+
snap_list = subprocess.run(
|
139
|
+
["snap", "list", "multipass"],
|
140
|
+
capture_output=True,
|
141
|
+
text=True,
|
142
|
+
check=True
|
143
|
+
)
|
144
|
+
if snap_list.returncode == 0:
|
145
|
+
snap_path = "/snap/bin/multipass"
|
146
|
+
if validate_path(snap_path):
|
147
|
+
logger.debug(f"Found multipass via snap at {snap_path}")
|
148
|
+
return snap_path
|
149
|
+
except subprocess.CalledProcessError:
|
150
|
+
logger.debug("Multipass not installed via snap")
|
151
|
+
pass
|
152
|
+
except subprocess.CalledProcessError:
|
153
|
+
logger.debug("Snap not found")
|
154
|
+
pass
|
121
155
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
156
|
+
# Common Linux paths if snap installation not found
|
157
|
+
search_paths = [
|
158
|
+
"/usr/local/bin",
|
159
|
+
"/usr/bin",
|
160
|
+
"/snap/bin"
|
161
|
+
]
|
162
|
+
logger.debug(f"Checking common Linux paths: {search_paths}")
|
128
163
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
164
|
+
elif system == "darwin": # macOS
|
165
|
+
search_paths = [
|
166
|
+
"/opt/homebrew/bin", # M1 Mac
|
167
|
+
"/usr/local/bin", # Intel Mac
|
168
|
+
"/opt/local/bin" # MacPorts
|
169
|
+
]
|
170
|
+
logger.debug(f"Checking macOS paths: {search_paths}")
|
135
171
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
172
|
+
elif system == "windows":
|
173
|
+
search_paths = [
|
174
|
+
os.path.expandvars(r"%ProgramFiles%\Multipass"),
|
175
|
+
os.path.expandvars(r"%ProgramFiles(x86)%\Multipass"),
|
176
|
+
os.path.expandvars(r"%LocalAppData%\Multipass")
|
177
|
+
]
|
178
|
+
logger.debug(f"Checking Windows paths: {search_paths}")
|
142
179
|
|
180
|
+
else:
|
181
|
+
search_paths = ["/usr/local/bin", "/usr/bin"]
|
182
|
+
logger.debug(f"Checking default paths: {search_paths}")
|
183
|
+
|
184
|
+
# Search for multipass binary in OS-specific paths
|
185
|
+
for directory in search_paths:
|
186
|
+
path = os.path.join(directory, binary_name)
|
187
|
+
logger.debug(f"Checking path: {path}")
|
188
|
+
if validate_path(path):
|
189
|
+
logger.debug(f"Found valid multipass binary at: {path}")
|
190
|
+
return path
|
143
191
|
else:
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
)
|
171
|
-
else:
|
172
|
-
raise ValueError(
|
173
|
-
"Multipass binary not found. Please install Multipass or set "
|
174
|
-
"GOLEM_PROVIDER_MULTIPASS_BINARY_PATH to your Multipass binary path."
|
175
|
-
)
|
176
|
-
|
177
|
-
# Validate the path
|
178
|
-
if not os.path.isfile(path):
|
179
|
-
raise ValueError(f"Multipass binary not found at: {path}")
|
180
|
-
if not os.access(path, os.X_OK):
|
181
|
-
raise ValueError(f"Multipass binary at {path} is not executable")
|
182
|
-
return path
|
192
|
+
logger.debug(f"No valid multipass binary at: {path}")
|
193
|
+
|
194
|
+
# OS-specific installation instructions
|
195
|
+
if system == "linux":
|
196
|
+
raise ValueError(
|
197
|
+
"Multipass binary not found. Please install using:\n"
|
198
|
+
"sudo snap install multipass\n"
|
199
|
+
"Or set GOLEM_PROVIDER_MULTIPASS_BINARY_PATH to your Multipass binary path."
|
200
|
+
)
|
201
|
+
elif system == "darwin":
|
202
|
+
raise ValueError(
|
203
|
+
"Multipass binary not found. Please install using:\n"
|
204
|
+
"brew install multipass\n"
|
205
|
+
"Or set GOLEM_PROVIDER_MULTIPASS_BINARY_PATH to your Multipass binary path."
|
206
|
+
)
|
207
|
+
elif system == "windows":
|
208
|
+
raise ValueError(
|
209
|
+
"Multipass binary not found. Please install from:\n"
|
210
|
+
"Microsoft Store or https://multipass.run/download/windows\n"
|
211
|
+
"Or set GOLEM_PROVIDER_MULTIPASS_BINARY_PATH to your Multipass binary path."
|
212
|
+
)
|
213
|
+
else:
|
214
|
+
raise ValueError(
|
215
|
+
"Multipass binary not found. Please install Multipass or set "
|
216
|
+
"GOLEM_PROVIDER_MULTIPASS_BINARY_PATH to your Multipass binary path."
|
217
|
+
)
|
183
218
|
|
184
219
|
# Proxy Settings
|
185
220
|
PORT_RANGE_START: int = 50800
|
File without changes
|
File without changes
|