installer: Make test suite override paths a bit more descriptive
Have them incorporate the basename of the path we are replacing. This gives some validation that we are manipulating the correct files
This commit is contained in:
parent
aafbca9e75
commit
34f42cc673
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>method=ftp://example.com</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>method=https://foobar.com</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>console=ttyS0</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<os>
|
||||
<type arch="i686" machine="pc">hvm</type>
|
||||
<loader readonly="yes" type="pflash">/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd</loader>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/httpkernel</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/ftpinitrd</initrd>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/fake-win7.iso</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/fake-centos65-label.iso</initrd>
|
||||
<cmdline>foo bar</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>test overwrite</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/frib.img</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/frob.img</initrd>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>method=http://example.com</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>ks=file:/fedora.ks inst.repo=</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>ks=file:/fedora.ks inst.repo=http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/Server/x86_64/os/</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
<cmdline>method=http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/Server/x86_64/os/</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</disk>
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu"/>
|
||||
<source file="/TESTSUITE_UNATTENDED_ISO"/>
|
||||
<source file="/VIRTINST-TESTSUITE/unattended.iso"/>
|
||||
<target dev="sdb" bus="sata"/>
|
||||
<readonly/>
|
||||
</disk>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="xenpv">xen</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<kernel>/VIRTINST-TESTSUITE/vmlinuz</kernel>
|
||||
<initrd>/VIRTINST-TESTSUITE/initrd.img</initrd>
|
||||
</os>
|
||||
<on_reboot>destroy</on_reboot>
|
||||
<devices>
|
||||
|
|
|
@ -18,6 +18,11 @@ from .installertreemedia import InstallerTreeMedia
|
|||
from .installerinject import perform_cdrom_injections
|
||||
|
||||
|
||||
def _make_testsuite_path(path):
|
||||
return os.path.join("/VIRTINST-TESTSUITE",
|
||||
os.path.basename(path).split("-", 2)[-1])
|
||||
|
||||
|
||||
class Installer(object):
|
||||
"""
|
||||
Class for kicking off VM installs. The VM is set up separately in a Guest
|
||||
|
@ -131,7 +136,7 @@ class Installer(object):
|
|||
# pylint: disable=protected-access
|
||||
# Hack to set just the XML path differently for the test suite.
|
||||
# Setting this via regular 'path' will error that it doesn't exist
|
||||
dev._source_file = "/TESTSUITE_UNATTENDED_ISO"
|
||||
dev._source_file = _make_testsuite_path(location)
|
||||
|
||||
def _remove_unattended_install_cdrom_device(self, guest):
|
||||
dummy = guest
|
||||
|
@ -167,10 +172,10 @@ class Installer(object):
|
|||
kernel, initrd, kernel_args = self._treemedia_bootconfig
|
||||
if kernel:
|
||||
guest.os.kernel = (self.conn.in_testsuite() and
|
||||
"/TESTSUITE_KERNEL_PATH" or kernel)
|
||||
_make_testsuite_path(kernel) or kernel)
|
||||
if initrd:
|
||||
guest.os.initrd = (self.conn.in_testsuite() and
|
||||
"/TESTSUITE_INITRD_PATH" or initrd)
|
||||
_make_testsuite_path(initrd) or initrd)
|
||||
if kernel_args:
|
||||
guest.os.kernel_args = kernel_args
|
||||
|
||||
|
@ -219,11 +224,11 @@ class Installer(object):
|
|||
unattended_cmdline = script.generate_cmdline()
|
||||
logging.debug("Generated unattended cmdline: %s", unattended_cmdline)
|
||||
|
||||
scriptpath = script.write(guest)
|
||||
scriptpath = script.write()
|
||||
self._tmpfiles.append(scriptpath)
|
||||
|
||||
iso = perform_cdrom_injections([(scriptpath, expected_filename)],
|
||||
guest.conn.get_app_cache_dir())
|
||||
InstallerTreeMedia.make_scratchdir(guest))
|
||||
self._tmpfiles.append(iso)
|
||||
self._add_unattended_install_cdrom_device(guest, iso)
|
||||
|
||||
|
|
|
@ -91,7 +91,8 @@ def perform_cdrom_injections(injections, scratchdir):
|
|||
Insert files into the root directory of a generated cdrom
|
||||
"""
|
||||
fileobj = tempfile.NamedTemporaryFile(
|
||||
dir=scratchdir, prefix="virtinst-unattended-iso", delete=False)
|
||||
prefix="virtinst-", suffix="-unattended.iso",
|
||||
dir=scratchdir, delete=False)
|
||||
iso = fileobj.name
|
||||
|
||||
try:
|
||||
|
|
|
@ -228,11 +228,11 @@ class InstallerTreeMedia(object):
|
|||
# Public API #
|
||||
##############
|
||||
|
||||
def _prepare_unattended_data(self, guest, script):
|
||||
def _prepare_unattended_data(self, script):
|
||||
if not script:
|
||||
return
|
||||
expected_filename = script.get_expected_filename()
|
||||
scriptpath = script.write(guest)
|
||||
scriptpath = script.write()
|
||||
self._tmpfiles.append(scriptpath)
|
||||
self._initrd_injections.append((scriptpath, expected_filename))
|
||||
|
||||
|
@ -255,7 +255,7 @@ class InstallerTreeMedia(object):
|
|||
fetcher = self._get_fetcher(guest, meter)
|
||||
cache = self._get_cached_data(guest, fetcher)
|
||||
|
||||
self._prepare_unattended_data(guest, unattended_script)
|
||||
self._prepare_unattended_data(unattended_script)
|
||||
kernel_args = self._prepare_kernel_args(cache, unattended_script)
|
||||
|
||||
kernel, initrd = self._prepare_kernel_url(guest, cache, fetcher)
|
||||
|
|
|
@ -188,10 +188,9 @@ class OSInstallScript:
|
|||
return self._script.generate_command_line(
|
||||
self._osobj.get_handle(), self._config)
|
||||
|
||||
def write(self, guest):
|
||||
scratch = guest.conn.get_app_cache_dir()
|
||||
def write(self):
|
||||
fileobj = tempfile.NamedTemporaryFile(
|
||||
dir=scratch, prefix="virtinst-unattended-script", delete=False)
|
||||
prefix="virtinst-unattended-script", delete=False)
|
||||
scriptpath = fileobj.name
|
||||
|
||||
content = self.generate()
|
||||
|
|
|
@ -211,13 +211,12 @@ class _URLFetcher(object):
|
|||
Grab the passed filename from self.location and save it to
|
||||
a temporary file, returning the temp filename
|
||||
"""
|
||||
prefix = "virtinst-" + os.path.basename(filename) + "."
|
||||
|
||||
# pylint: disable=redefined-variable-type
|
||||
fn = None
|
||||
try:
|
||||
fileobj = tempfile.NamedTemporaryFile(
|
||||
dir=self.scratchdir, prefix=prefix, delete=False)
|
||||
prefix="virtinst-", suffix="-" + os.path.basename(filename),
|
||||
dir=self.scratchdir, delete=False)
|
||||
fn = fileobj.name
|
||||
|
||||
self._grabURL(filename, fileobj, fullurl=fullurl)
|
||||
|
|
Loading…
Reference in New Issue