|
51 | 51 | REPO_ELEMENT_COLLECTION = "/v1/repo/elements/" |
52 | 52 | BOOTSTRAP_REPO_NAME = "bootstrap_repo_975aab1b" |
53 | 53 | 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" |
54 | 56 |
|
55 | 57 |
|
56 | 58 | cli_opts = [ |
@@ -612,6 +614,31 @@ def _ensure_repositories_from_spec(spec: dict[str, tp.Any]) -> None: |
612 | 614 | LOG.exception("Failed to ensure repository %s (%s)", repo_name, repo_url) |
613 | 615 |
|
614 | 616 |
|
| 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 | + |
615 | 642 | def _install_element_from_bootstrap_repo(element_name: str, manifests_dir: str): |
616 | 643 | """Idempotent element manifest installation.""" |
617 | 644 | migration_repo = repo_models.Repository.objects.get_one_or_none( |
@@ -759,6 +786,11 @@ def main() -> None: |
759 | 786 | ) |
760 | 787 | bootstrap_defaults.add_core_set(spec) |
761 | 788 | _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 | + ) |
762 | 794 | _install_element_from_bootstrap_repo("core", CONF.manifests_dir) |
763 | 795 | _install_element_from_bootstrap_repo("ecosystem_realm", CONF.manifests_dir) |
764 | 796 | _ensure_repositories_from_spec(spec) |
|
0 commit comments