mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
tests: Add clitest coverage for network-install resources
This commit is contained in:
parent
f6a4326a9a
commit
d9b41bf887
@ -0,0 +1,97 @@
|
||||
<domain type="kvm">
|
||||
<name>foobar</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/silverblue/29"/>
|
||||
</libosinfo:libosinfo>
|
||||
</metadata>
|
||||
<memory>5242880</memory>
|
||||
<currentMemory>5242880</currentMemory>
|
||||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<kernel>/TESTSUITE_KERNEL_PATH</kernel>
|
||||
<initrd>/TESTSUITE_INITRD_PATH</initrd>
|
||||
<cmdline>method=http://example.com</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
</features>
|
||||
<cpu mode="host-model"/>
|
||||
<clock offset="utc">
|
||||
<timer name="rtc" tickpolicy="catchup"/>
|
||||
<timer name="pit" tickpolicy="delay"/>
|
||||
<timer name="hpet" present="no"/>
|
||||
</clock>
|
||||
<on_reboot>destroy</on_reboot>
|
||||
<pm>
|
||||
<suspend-to-mem enabled="no"/>
|
||||
<suspend-to-disk enabled="no"/>
|
||||
</pm>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<controller type="usb" index="0" model="qemu-xhci" ports="15"/>
|
||||
<interface type="bridge">
|
||||
<source bridge="testsuitebr0"/>
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="virtio"/>
|
||||
</interface>
|
||||
<console type="pty"/>
|
||||
<channel type="unix">
|
||||
<source mode="bind"/>
|
||||
<target type="virtio" name="org.qemu.guest_agent.0"/>
|
||||
</channel>
|
||||
<rng model="virtio">
|
||||
<backend model="random">/dev/urandom</backend>
|
||||
</rng>
|
||||
</devices>
|
||||
</domain>
|
||||
<domain type="kvm">
|
||||
<name>foobar</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/silverblue/29"/>
|
||||
</libosinfo:libosinfo>
|
||||
</metadata>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
</features>
|
||||
<cpu mode="host-model"/>
|
||||
<clock offset="utc">
|
||||
<timer name="rtc" tickpolicy="catchup"/>
|
||||
<timer name="pit" tickpolicy="delay"/>
|
||||
<timer name="hpet" present="no"/>
|
||||
</clock>
|
||||
<pm>
|
||||
<suspend-to-mem enabled="no"/>
|
||||
<suspend-to-disk enabled="no"/>
|
||||
</pm>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<controller type="usb" index="0" model="qemu-xhci" ports="15"/>
|
||||
<interface type="bridge">
|
||||
<source bridge="testsuitebr0"/>
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="virtio"/>
|
||||
</interface>
|
||||
<console type="pty"/>
|
||||
<channel type="unix">
|
||||
<source mode="bind"/>
|
||||
<target type="virtio" name="org.qemu.guest_agent.0"/>
|
||||
</channel>
|
||||
<rng model="virtio">
|
||||
<backend model="random">/dev/urandom</backend>
|
||||
</rng>
|
||||
</devices>
|
||||
</domain>
|
@ -789,6 +789,7 @@ c.add_compare("--location https://foobar.com", "fake-http") # fake https:// ins
|
||||
c.add_compare("--connect %(URI-KVM)s --os-variant fedora26,install=location", "osinfo-url") # getting URL from osinfo
|
||||
c.add_compare("--connect %(URI-KVM)s --os-variant fedora26 --unattended profile=desktop,admin-password=foobar", "osinfo-url-unattended") # unattended install for fedora, using initrd injection
|
||||
c.add_compare("--connect %(URI-KVM)s --os-variant win7 --cdrom %(ISO-WIN7)s --unattended profile=desktop,admin-password=foobar", "osinfo-win7-unattended") # unattended install for win7
|
||||
c.add_compare("--connect %(URI-KVM)s --os-variant silverblue29 --location http://example.com", "network-install-resources") # triggering network-install resources override
|
||||
c.add_invalid("--pxe --virt-type bogus") # Bogus virt-type
|
||||
c.add_invalid("--pxe --arch bogus") # Bogus arch
|
||||
c.add_invalid("--livecd") # LiveCD with no media
|
||||
|
@ -198,12 +198,12 @@ class Installer(object):
|
||||
if not self._treemedia.requires_internet(guest, meter):
|
||||
return
|
||||
|
||||
res = guest.osinfo.get_network_install_resources(guest)
|
||||
if (res and res.get("ram") > 0 and
|
||||
res["ram"] // 1024 > guest.currentMemory):
|
||||
ram = guest.osinfo.get_network_install_required_ram(guest)
|
||||
ram = (ram or 0) // 1024
|
||||
if ram > guest.currentMemory:
|
||||
logging.debug("Setting ram from libosinfo network-install "
|
||||
"resources: '%d'", res["ram"] // 1024)
|
||||
guest.currentMemory = res["ram"] // 1024
|
||||
"resources to %s", ram)
|
||||
guest.currentMemory = ram
|
||||
|
||||
|
||||
##########################
|
||||
|
@ -526,20 +526,13 @@ class _OsVariant(object):
|
||||
recommended = self._os and self._os.get_recommended_resources() or None
|
||||
return _OsResources(minimum, recommended)
|
||||
|
||||
def get_network_install_resources(self, guest):
|
||||
ret = {}
|
||||
|
||||
if not hasattr(self._os, "get_network_install_resources"):
|
||||
return ret
|
||||
|
||||
resources = self._os.get_network_install_resources()
|
||||
for r in _OsinfoIter(resources):
|
||||
arch = r.get_architecture()
|
||||
if arch == guest.os.arch or arch == "all":
|
||||
ret["ram"] = r.get_ram()
|
||||
break
|
||||
|
||||
return ret
|
||||
def get_network_install_required_ram(self, guest):
|
||||
if hasattr(self._os, "get_network_install_resources"):
|
||||
resources = self._os.get_network_install_resources()
|
||||
for r in _OsinfoIter(resources):
|
||||
arch = r.get_architecture()
|
||||
if arch == guest.os.arch or arch == "all":
|
||||
return r.get_ram()
|
||||
|
||||
def get_kernel_url_arg(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user