mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
xmlbuilder: Remove get_xml_config prep wrappers
The only user was Guest, and in fact it's not needed for the standard get_xml_config, only for the custom _get_install_xml. So drop it
This commit is contained in:
parent
472a52b170
commit
6f578ffeff
@ -317,7 +317,7 @@ class Guest(XMLBuilder):
|
||||
self._install_cdrom_device.path = self.installer.cdrom_path()
|
||||
self._install_cdrom_device.validate()
|
||||
|
||||
def _prepare_get_xml(self):
|
||||
def _prepare_get_install_xml(self):
|
||||
# We do a shallow copy of the OS block here, so that we can
|
||||
# set the install time properties but not permanently overwrite
|
||||
# any config the user explicitly requested.
|
||||
@ -325,16 +325,16 @@ class Guest(XMLBuilder):
|
||||
self.os.kernel_args, self.on_reboot)
|
||||
return data
|
||||
|
||||
def _finish_get_xml(self, data):
|
||||
def _finish_get_install_xml(self, data):
|
||||
(self.os.bootorder, self.os.kernel, self.os.initrd,
|
||||
self.os.kernel_args, self.on_reboot) = data
|
||||
|
||||
def _get_install_xml(self, *args, **kwargs):
|
||||
data = self._prepare_get_xml()
|
||||
data = self._prepare_get_install_xml()
|
||||
try:
|
||||
return self._do_get_install_xml(*args, **kwargs)
|
||||
finally:
|
||||
self._finish_get_xml(data)
|
||||
self._finish_get_install_xml(data)
|
||||
|
||||
def _do_get_install_xml(self, install):
|
||||
"""
|
||||
|
@ -592,11 +592,16 @@ class XMLBuilder(object):
|
||||
"""
|
||||
Return XML string of the object
|
||||
"""
|
||||
data = self._prepare_get_xml()
|
||||
try:
|
||||
return self._do_get_xml_config()
|
||||
finally:
|
||||
self._finish_get_xml(data)
|
||||
xmlapi = self._xmlstate.xmlapi
|
||||
if self._xmlstate.is_build:
|
||||
xmlapi = xmlapi.copy_api()
|
||||
|
||||
self._add_parse_bits(xmlapi)
|
||||
ret = xmlapi.get_xml(self._xmlstate.make_abs_xpath("."))
|
||||
|
||||
if ret and not ret.endswith("\n"):
|
||||
ret += "\n"
|
||||
return ret
|
||||
|
||||
def clear(self, leave_stub=False):
|
||||
"""
|
||||
@ -644,25 +649,6 @@ class XMLBuilder(object):
|
||||
return self._xmlstate.abs_xpath()
|
||||
|
||||
|
||||
###################
|
||||
# Child overrides #
|
||||
###################
|
||||
|
||||
def _prepare_get_xml(self):
|
||||
"""
|
||||
Subclasses can override this to do any pre-get_xml_config setup.
|
||||
Returns data to pass to finish_get_xml
|
||||
"""
|
||||
return None
|
||||
|
||||
def _finish_get_xml(self, data):
|
||||
"""
|
||||
Called after get_xml_config. Data is whatever was returned by
|
||||
_prepare_get_xml
|
||||
"""
|
||||
ignore = data
|
||||
|
||||
|
||||
################
|
||||
# Internal API #
|
||||
################
|
||||
@ -797,18 +783,6 @@ class XMLBuilder(object):
|
||||
# Private XML building routines #
|
||||
#################################
|
||||
|
||||
def _do_get_xml_config(self):
|
||||
xmlapi = self._xmlstate.xmlapi
|
||||
if self._xmlstate.is_build:
|
||||
xmlapi = xmlapi.copy_api()
|
||||
|
||||
self._add_parse_bits(xmlapi)
|
||||
ret = xmlapi.get_xml(self._xmlstate.make_abs_xpath("."))
|
||||
|
||||
if ret and not ret.endswith("\n"):
|
||||
ret += "\n"
|
||||
return ret
|
||||
|
||||
def _add_parse_bits(self, xmlapi):
|
||||
"""
|
||||
Callback that adds the implicitly tracked XML properties to
|
||||
|
Loading…
Reference in New Issue
Block a user