installer: Remove cloudinit media after initial boot

We do this by faking an install phase whenever cloudinit media is
specified, which isn't really the right abstraction and will leak
into virt-install behavior (like doing 2 boots), but it's the simplest
fix for now

Fixes: #178

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-11-10 10:35:14 -05:00
parent b132820244
commit d9c6df951f
3 changed files with 110 additions and 2 deletions

View File

@ -11,12 +11,12 @@
<vcpu>2</vcpu>
<os>
<type arch="i686">hvm</type>
<boot dev="hd"/>
</os>
<features>
<pae/>
</features>
<clock offset="utc"/>
<on_reboot>destroy</on_reboot>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
@ -49,3 +49,53 @@
<console type="pty"/>
</devices>
</domain>
<domain type="test">
<name>fedora28</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://fedoraproject.org/fedora/28"/>
</libosinfo:libosinfo>
</metadata>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch="i686">hvm</type>
<boot dev="hd"/>
</os>
<features>
<pae/>
</features>
<clock offset="utc"/>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/test-hv</emulator>
<disk type="file" device="disk">
<source file="/dev/default-pool/testvol1.img"/>
<target dev="hda" bus="ide"/>
</disk>
<disk type="file" device="cdrom">
<target dev="hdb" bus="ide"/>
<readonly/>
</disk>
<controller type="usb" model="ich9-ehci1"/>
<controller type="usb" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="user">
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<console type="pty"/>
</devices>
</domain>

View File

@ -11,12 +11,12 @@
<vcpu>2</vcpu>
<os>
<type arch="i686">hvm</type>
<boot dev="hd"/>
</os>
<features>
<pae/>
</features>
<clock offset="utc"/>
<on_reboot>destroy</on_reboot>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
@ -49,3 +49,53 @@
<console type="pty"/>
</devices>
</domain>
<domain type="test">
<name>fedora28</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://fedoraproject.org/fedora/28"/>
</libosinfo:libosinfo>
</metadata>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch="i686">hvm</type>
<boot dev="hd"/>
</os>
<features>
<pae/>
</features>
<clock offset="utc"/>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/test-hv</emulator>
<disk type="file" device="disk">
<source file="/dev/default-pool/testvol1.img"/>
<target dev="hda" bus="ide"/>
</disk>
<disk type="file" device="cdrom">
<target dev="hdb" bus="ide"/>
<readonly/>
</disk>
<controller type="usb" model="ich9-ehci1"/>
<controller type="usb" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="user">
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<console type="pty"/>
</devices>
</domain>

View File

@ -496,6 +496,12 @@ class Installer(object):
into the guest. Things like LiveCDs, Import, or a manually specified
bootorder do not have an install phase.
"""
if self.has_cloudinit() or self.has_unattended():
# These cases require post-boot altering to remove the
# temporary media. It isn't really an install phase and more
# like a 'final_xml' phase but we don't have a real abstraction
# for that yet
return True
if self._no_install:
return False
return bool(self._cdrom or
@ -544,6 +550,8 @@ class Installer(object):
def has_cloudinit(self):
return bool(self._cloudinit_data)
def has_unattended(self):
return bool(self._unattended_data)
def get_generated_password(self):
if self._cloudinit_data: