Skip to content

Commit 1635821

Browse files
feat(cli): install rawstor packages in core VM when requested by bootstrap
Reads the with_rawstor flag from spec.json (set by exordos CLI's `bootstrap --with-rawstor --pool-agent-placement=core`) and installs librawstor + python3.12-rawstor during first-boot bootstrap, alongside the existing element installation steps.
1 parent 54eeb7e commit 1635821

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

exordos_core/cmd/bootstrap.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
REPO_ELEMENT_COLLECTION = "/v1/repo/elements/"
5252
BOOTSTRAP_REPO_NAME = "bootstrap_repo_975aab1b"
5353
MAIN_SUBNET_UUID = sys_uuid.UUID("c910a7e1-61ae-4d56-bdd6-a59faa3cbda3")
54+
RAWSTOR_RELEASES_URL = "https://github.com/rawstor/librawstor/releases/download"
55+
RAWSTOR_PYTHON_VERSION = "3.12"
5456

5557

5658
cli_opts = [
@@ -612,6 +614,31 @@ def _ensure_repositories_from_spec(spec: dict[str, tp.Any]) -> None:
612614
LOG.exception("Failed to ensure repository %s (%s)", repo_name, repo_url)
613615

614616

617+
def _install_rawstor_packages(packages: tp.Sequence[str], version: str) -> None:
618+
"""Download and install the given rawstor .deb packages.
619+
620+
Runs as root inside the core VM during first-boot bootstrap, so no
621+
sudo is needed here.
622+
"""
623+
deb_dir = "/tmp/rawstor-packages"
624+
os.makedirs(deb_dir, exist_ok=True)
625+
626+
deb_paths = []
627+
for package in packages:
628+
deb_name = f"{package}_{version}_amd64.deb"
629+
url = f"{RAWSTOR_RELEASES_URL}/v{version}/{deb_name}"
630+
deb_path = os.path.join(deb_dir, deb_name)
631+
subprocess.run(["wget", url, "-P", deb_dir], check=True)
632+
deb_paths.append(deb_path)
633+
634+
subprocess.run(["dpkg", "-i", *deb_paths], check=True)
635+
subprocess.run(
636+
["apt-get", "install", "-f", "-y"],
637+
env={**os.environ, "DEBIAN_FRONTEND": "noninteractive"},
638+
check=True,
639+
)
640+
641+
615642
def _install_element_from_bootstrap_repo(element_name: str, manifests_dir: str):
616643
"""Idempotent element manifest installation."""
617644
migration_repo = repo_models.Repository.objects.get_one_or_none(
@@ -759,6 +786,11 @@ def main() -> None:
759786
)
760787
bootstrap_defaults.add_core_set(spec)
761788
_ensure_exordos_config(spec)
789+
if spec.get("with_rawstor"):
790+
_install_rawstor_packages(
791+
["librawstor", f"python{RAWSTOR_PYTHON_VERSION}-rawstor"],
792+
spec["rawstor_version"],
793+
)
762794
_install_element_from_bootstrap_repo("core", CONF.manifests_dir)
763795
_install_element_from_bootstrap_repo("ecosystem_realm", CONF.manifests_dir)
764796
_ensure_repositories_from_spec(spec)

0 commit comments

Comments
 (0)