Skip to content

Commit c8c49a1

Browse files
author
Spencer Rak
committed
Add LibvirtServerCustomization
1 parent 8de2479 commit c8c49a1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

carthage_base/customizations.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sh
2+
3+
from carthage.machine import MachineCustomization
4+
5+
class LibvirtServerCustomization(MachineCustomization):
6+
@setup_task("Install Libvirt")
7+
async def install_libvirt(self):
8+
await self.run_command("sh", "-c", "apt update && apt install -y nfs-common libvirt-daemon-system ovmf git dosfstools tmux fai-server")
9+
10+
@install_libvirt.check_completed()
11+
async def install_libvirt(self):
12+
try:
13+
rc = await self.run_command("dpkg", "-l", "libvirt-daemon-system")
14+
return True
15+
except sh.ErrorReturnCode_1:
16+
return False
17+
18+
@setup_task("Enable nested virtualization")
19+
async def enable_nested_virt(self):
20+
with self.host.filesystem_access() as fs:
21+
return (fs/"etc/modprobe.d/10-carthage-kvm-intel.conf").write_text("options kvm_intel nested=y")
22+
23+
@enable_nested_virt.check_completed()
24+
async def enable_nested_virt(self):
25+
with self.host.filesystem_access() as fs:
26+
return (fs/"etc/modprobe.d/10-carthage-kvm-intel.conf").is_file()

0 commit comments

Comments
 (0)