39 lines
994 B
Python
39 lines
994 B
Python
from pathlib import Path
|
|
from fastapi import Depends
|
|
from pydantic import BaseModel
|
|
from typing import Annotated
|
|
|
|
class _OpenEC2InstanceType(BaseModel):
|
|
memory: int # MiB
|
|
vcpu: float
|
|
disk: int # Gi
|
|
|
|
class _OpenEC2InstanceConfig(BaseModel):
|
|
location: Path
|
|
|
|
types: dict[str, _OpenEC2InstanceType]
|
|
|
|
class _OpenEC2Config(BaseModel):
|
|
images: Path
|
|
seed: Path
|
|
instances: _OpenEC2InstanceConfig
|
|
|
|
def get_config() -> _OpenEC2Config:
|
|
# TODO: Read from disk
|
|
return _OpenEC2Config(
|
|
images=Path("/home/alexander/openec2/images"),
|
|
seed=Path("/home/alexander/openec2/seed"),
|
|
instances=_OpenEC2InstanceConfig(
|
|
location=Path("/home/alexander/openec2/instances"),
|
|
types={
|
|
"micro": _OpenEC2InstanceType(
|
|
memory=1024,
|
|
vcpu=1,
|
|
disk=10,
|
|
),
|
|
},
|
|
),
|
|
)
|
|
|
|
OpenEC2Config = Annotated[_OpenEC2Config, Depends(get_config)]
|