Skip to content

Commit

Permalink
Fix libvirt for mariner if already present
Browse files Browse the repository at this point in the history
If libvirt not present, install it and fix if distro is mariner
If libvirt is present, fix it if distro is mariner

Signed-off-by: Smit Gardhariya <[email protected]>
  • Loading branch information
smit-gardhariya committed Sep 5, 2024
1 parent 225fb52 commit ab76e31
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions lisa/sut_orchestrator/libvirt/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from lisa import schema
from lisa.node import Node, quick_connect
from lisa.operating_system import CBLMariner, Linux, Ubuntu
from lisa.tools import Git, Sed, Service, Usermod, Wget, Whoami
from lisa.tools import Git, Reboot, Sed, Service, Usermod, Wget, Whoami
from lisa.transformer import Transformer
from lisa.util import (
UnsupportedDistroException,
Expand Down Expand Up @@ -213,23 +213,9 @@ def install(self) -> str:
packages_list = self._distro_package_mapping[type(linux).__name__]
self._log.info(f"installing packages: {packages_list}")
linux.install_packages(packages_list)
self._fix_mariner_installation()
_fix_mariner_installation(node=self._node)
return self._get_version()

# Some fixes to the libvirt installation on Mariner.
# Can be removed once the issues have been addressed in Mariner.
def _fix_mariner_installation(self) -> None:
if not isinstance(self._node.os, CBLMariner):
return

self._node.tools[Usermod].add_user_to_group("libvirt", sudo=True)
self._node.tools[Sed].substitute(
"hidepid=2",
"hidepid=0",
"/etc/fstab",
sudo=True,
)


class QemuPackageInstaller(QemuInstaller):
_distro_package_mapping = {
Expand Down Expand Up @@ -584,3 +570,21 @@ def _install_libvirt(runbook: schema.TypedSchema, node: Node, log: Logger) -> No
else:
libvirt_version = libvirt_installer._get_version()
log.info(f"Already installed! libvirt version: {libvirt_version}")
log.info("Applying fixes if Mariner")
_fix_mariner_installation(node=node)
node.tools[Reboot].reboot()


# Some fixes to the libvirt installation on Mariner.
# Can be removed once the issues have been addressed in Mariner.
def _fix_mariner_installation(node: Node) -> None:
if not isinstance(node.os, CBLMariner):
return

node.tools[Usermod].add_user_to_group("libvirt", sudo=True)
node.tools[Sed].substitute(
"hidepid=2",
"hidepid=0",
"/etc/fstab",
sudo=True,
)

0 comments on commit ab76e31

Please sign in to comment.