guest: move set_install_defaults to installer class
It's only called explicitly in one place, so update the caller
This commit is contained in:
parent
8a6a491306
commit
f1bbc5f67a
|
@ -2143,7 +2143,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
# This encodes all the virtinst defaults up front, so the customize
|
||||
# dialog actually shows disk buses, cache values, default devices,
|
||||
# etc. Not required for straight start_install but doesn't hurt.
|
||||
self._guest.set_install_defaults()
|
||||
self._guest.installer.set_install_defaults(self._guest)
|
||||
|
||||
if not self.widget("summary-customize").get_active():
|
||||
self._start_install(self._guest)
|
||||
|
|
|
@ -134,7 +134,6 @@ class Guest(XMLBuilder):
|
|||
self.x86_cpu_default = self.cpu.SPECIAL_MODE_HOST_MODEL_ONLY
|
||||
|
||||
self.__osinfo = None
|
||||
self._defaults_are_set = False
|
||||
|
||||
# This is set via Capabilities.build_virtinst_guest
|
||||
self.capsinfo = None
|
||||
|
@ -343,21 +342,6 @@ class Guest(XMLBuilder):
|
|||
# Device defaults #
|
||||
###################
|
||||
|
||||
def set_install_defaults(self):
|
||||
"""
|
||||
Allow API users to set defaults ahead of time if they want it.
|
||||
Used by vmmDomainVirtinst so the 'Customize before install' dialog
|
||||
shows accurate values.
|
||||
|
||||
If the user doesn't explicitly call this, it will be called by
|
||||
start_install()
|
||||
"""
|
||||
if self._defaults_are_set:
|
||||
return
|
||||
|
||||
self._set_defaults()
|
||||
self._defaults_are_set = True
|
||||
|
||||
def stable_defaults(self, *args, **kwargs):
|
||||
return self.conn.stable_defaults(self.emulator, *args, **kwargs)
|
||||
|
||||
|
@ -504,7 +488,7 @@ class Guest(XMLBuilder):
|
|||
self.add_default_channels()
|
||||
self.add_default_rng()
|
||||
|
||||
def _set_defaults(self):
|
||||
def set_defaults(self, _guest):
|
||||
if not self.uuid:
|
||||
self.uuid = util.generate_uuid(self.conn)
|
||||
if not self.vcpus:
|
||||
|
@ -512,12 +496,6 @@ class Guest(XMLBuilder):
|
|||
if self.os.is_xenpv() or self.type == "vz":
|
||||
self.emulator = None
|
||||
|
||||
if (not self.os.is_container() and
|
||||
not self.os.kernel and
|
||||
not self.os.bootorder and
|
||||
not any([d.boot.order for d in self.devices.get_all()])):
|
||||
self.os.bootorder = self.installer.get_postinstall_bootorder(self)
|
||||
|
||||
self.clock.set_defaults(self)
|
||||
self.cpu.set_defaults(self)
|
||||
self.features.set_defaults(self)
|
||||
|
|
|
@ -55,6 +55,7 @@ class Installer(object):
|
|||
self._install_kernel = None
|
||||
self._install_initrd = None
|
||||
self._install_cdrom_device = None
|
||||
self._defaults_are_set = False
|
||||
|
||||
self._tmpfiles = []
|
||||
self._tmpvols = []
|
||||
|
@ -119,6 +120,11 @@ class Installer(object):
|
|||
break
|
||||
return bootorder
|
||||
|
||||
def _can_set_guest_bootorder(self, guest):
|
||||
return (not guest.os.is_container() and
|
||||
not guest.os.kernel and
|
||||
not any([d.boot.order for d in guest.devices.get_all()]))
|
||||
|
||||
def _alter_bootconfig(self, guest):
|
||||
"""
|
||||
Generate the portion of the guest xml that determines boot devices
|
||||
|
@ -136,10 +142,7 @@ class Installer(object):
|
|||
guest.os.kernel_args = " ".join(self.extraargs)
|
||||
|
||||
bootdev = self._get_install_bootdev(guest)
|
||||
if (bootdev and
|
||||
not guest.os.is_container() and
|
||||
not guest.os.kernel and
|
||||
not any(d.boot.order for d in guest.devices.get_all())):
|
||||
if bootdev and self._can_set_guest_bootorder(guest):
|
||||
guest.os.bootorder = self._build_boot_order(guest, bootdev)
|
||||
else:
|
||||
guest.os.bootorder = []
|
||||
|
@ -188,12 +191,26 @@ class Installer(object):
|
|||
# Public API #
|
||||
##############
|
||||
|
||||
def get_postinstall_bootorder(self, guest):
|
||||
def set_install_defaults(self, guest):
|
||||
"""
|
||||
Return the preferred guest postinstall bootorder
|
||||
Allow API users to set defaults ahead of time if they want it.
|
||||
Used by vmmDomainVirtinst so the 'Customize before install' dialog
|
||||
shows accurate values.
|
||||
|
||||
If the user doesn't explicitly call this, it will be called by
|
||||
start_install()
|
||||
"""
|
||||
if self._defaults_are_set:
|
||||
return
|
||||
|
||||
self._add_install_cdrom_device(guest)
|
||||
|
||||
if not guest.os.bootorder and self._can_set_guest_bootorder(guest):
|
||||
bootdev = self._get_postinstall_bootdev(guest)
|
||||
return self._build_boot_order(guest, bootdev)
|
||||
guest.os.bootorder = self._build_boot_order(guest, bootdev)
|
||||
|
||||
guest.set_defaults(None)
|
||||
self._defaults_are_set = True
|
||||
|
||||
def scratchdir_required(self):
|
||||
"""
|
||||
|
@ -272,7 +289,6 @@ class Installer(object):
|
|||
self._remove_install_cdrom_media(guest)
|
||||
self._finish_get_install_xml(guest, data)
|
||||
|
||||
|
||||
def _build_xml(self, guest):
|
||||
install_xml = None
|
||||
if self.has_install_phase():
|
||||
|
@ -370,8 +386,7 @@ class Installer(object):
|
|||
:param return_xml: Don't create the guest, just return generated XML
|
||||
:param autostart: If True, mark the VM to autostart on host boot
|
||||
"""
|
||||
self._add_install_cdrom_device(guest)
|
||||
guest.set_install_defaults()
|
||||
self.set_install_defaults(guest)
|
||||
|
||||
try:
|
||||
self._cleanup(guest)
|
||||
|
|
Loading…
Reference in New Issue