mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
guest: Remove default_cb usage
This lets us simplify things in create.py a bit, since we don't need to manually encode a UUID
This commit is contained in:
parent
e6219504ce
commit
d5bff2c987
@ -1566,13 +1566,6 @@ class vmmCreate(vmmGObjectUI):
|
||||
if machine:
|
||||
guest.os.machine = machine
|
||||
|
||||
# Generate UUID (makes customize dialog happy)
|
||||
try:
|
||||
guest.uuid = util.randomUUID(guest.conn)
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error setting UUID: %s") % str(e))
|
||||
return None
|
||||
|
||||
# OS distro/variant validation
|
||||
try:
|
||||
if variant:
|
||||
@ -2142,19 +2135,22 @@ class vmmCreate(vmmGObjectUI):
|
||||
return False
|
||||
|
||||
logging.debug("Starting create finish() sequence")
|
||||
guest = self._guest
|
||||
|
||||
# Start the install
|
||||
self._failed_guest = None
|
||||
self.set_finish_cursor()
|
||||
|
||||
if not self.widget("summary-customize").get_active():
|
||||
self._start_install(guest)
|
||||
return
|
||||
|
||||
logging.debug("User requested 'customize', launching dialog")
|
||||
try:
|
||||
self._show_customize_dialog(guest)
|
||||
self.set_finish_cursor()
|
||||
|
||||
# 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()
|
||||
|
||||
if not self.widget("summary-customize").get_active():
|
||||
self._start_install(self._guest)
|
||||
return
|
||||
|
||||
logging.debug("User requested 'customize', launching dialog")
|
||||
self._show_customize_dialog()
|
||||
except Exception as e:
|
||||
self.reset_finish_cursor()
|
||||
self.err.show_err(_("Error starting installation: ") + str(e))
|
||||
@ -2169,8 +2165,9 @@ class vmmCreate(vmmGObjectUI):
|
||||
self._customize_window = None
|
||||
window.cleanup()
|
||||
|
||||
def _show_customize_dialog(self, guest):
|
||||
virtinst_guest = vmmDomainVirtinst(self.conn, guest, self._guest.uuid)
|
||||
def _show_customize_dialog(self):
|
||||
guest = self._guest
|
||||
virtinst_guest = vmmDomainVirtinst(self.conn, guest, guest.uuid)
|
||||
|
||||
def start_install_wrapper(ignore, guest):
|
||||
if not self.is_visible():
|
||||
|
@ -1909,10 +1909,6 @@ class vmmDomainVirtinst(vmmDomain):
|
||||
vmmDomain.__init__(self, conn, backend, key)
|
||||
self._orig_xml = None
|
||||
|
||||
# This encodes all the virtinst defaults up front, so the customize
|
||||
# dialog actually shows disk buses, cache values, default devices, etc.
|
||||
backend.set_install_defaults()
|
||||
|
||||
self._refresh_status()
|
||||
logging.debug("%s initialized with XML=\n%s", self, self._XMLDesc(0))
|
||||
|
||||
|
@ -138,7 +138,6 @@ class Guest(XMLBuilder):
|
||||
self.x86_cpu_default = self.cpu.SPECIAL_MODE_HOST_MODEL_ONLY
|
||||
|
||||
self.__osinfo = None
|
||||
self._random_uuid = None
|
||||
self._install_cdrom_device = None
|
||||
self._defaults_are_set = False
|
||||
|
||||
@ -169,7 +168,6 @@ class Guest(XMLBuilder):
|
||||
self.maxmemory = val
|
||||
return val
|
||||
memory = XMLProperty("./currentMemory", is_int=True,
|
||||
default_cb=lambda s: 1,
|
||||
set_converter=_set_memory)
|
||||
maxmemory = XMLProperty("./memory", is_int=True)
|
||||
hotplugmemorymax = XMLProperty("./maxMemory", is_int=True)
|
||||
@ -184,21 +182,14 @@ class Guest(XMLBuilder):
|
||||
self.curvcpus = val
|
||||
return val
|
||||
vcpus = XMLProperty("./vcpu", is_int=True,
|
||||
set_converter=_set_vcpus,
|
||||
default_cb=lambda s: 1)
|
||||
set_converter=_set_vcpus)
|
||||
curvcpus = XMLProperty("./vcpu/@current", is_int=True)
|
||||
vcpu_placement = XMLProperty("./vcpu/@placement")
|
||||
cpuset = XMLProperty("./vcpu/@cpuset")
|
||||
|
||||
def _get_default_uuid(self):
|
||||
if self._random_uuid is None:
|
||||
self._random_uuid = util.generate_uuid(self.conn)
|
||||
return self._random_uuid
|
||||
uuid = XMLProperty("./uuid", default_cb=_get_default_uuid)
|
||||
|
||||
|
||||
uuid = XMLProperty("./uuid")
|
||||
id = XMLProperty("./@id", is_int=True)
|
||||
type = XMLProperty("./@type", default_cb=lambda s: "xen")
|
||||
type = XMLProperty("./@type")
|
||||
bootloader = XMLProperty("./bootloader")
|
||||
description = XMLProperty("./description")
|
||||
title = XMLProperty("./title")
|
||||
@ -749,6 +740,10 @@ class Guest(XMLBuilder):
|
||||
dev.path = None
|
||||
|
||||
def _set_defaults(self):
|
||||
if not self.uuid:
|
||||
self.uuid = util.generate_uuid(self.conn)
|
||||
if not self.vcpus:
|
||||
self.vcpus = 1
|
||||
if self.os.is_xenpv() or self.type == "vz":
|
||||
self.emulator = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user