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:
Cole Robinson 2018-02-22 19:49:08 -05:00
parent 472a52b170
commit 6f578ffeff
2 changed files with 14 additions and 40 deletions

View File

@ -317,7 +317,7 @@ class Guest(XMLBuilder):
self._install_cdrom_device.path = self.installer.cdrom_path() self._install_cdrom_device.path = self.installer.cdrom_path()
self._install_cdrom_device.validate() 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 # We do a shallow copy of the OS block here, so that we can
# set the install time properties but not permanently overwrite # set the install time properties but not permanently overwrite
# any config the user explicitly requested. # any config the user explicitly requested.
@ -325,16 +325,16 @@ class Guest(XMLBuilder):
self.os.kernel_args, self.on_reboot) self.os.kernel_args, self.on_reboot)
return data 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.bootorder, self.os.kernel, self.os.initrd,
self.os.kernel_args, self.on_reboot) = data self.os.kernel_args, self.on_reboot) = data
def _get_install_xml(self, *args, **kwargs): def _get_install_xml(self, *args, **kwargs):
data = self._prepare_get_xml() data = self._prepare_get_install_xml()
try: try:
return self._do_get_install_xml(*args, **kwargs) return self._do_get_install_xml(*args, **kwargs)
finally: finally:
self._finish_get_xml(data) self._finish_get_install_xml(data)
def _do_get_install_xml(self, install): def _do_get_install_xml(self, install):
""" """

View File

@ -592,11 +592,16 @@ class XMLBuilder(object):
""" """
Return XML string of the object Return XML string of the object
""" """
data = self._prepare_get_xml() xmlapi = self._xmlstate.xmlapi
try: if self._xmlstate.is_build:
return self._do_get_xml_config() xmlapi = xmlapi.copy_api()
finally:
self._finish_get_xml(data) 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): def clear(self, leave_stub=False):
""" """
@ -644,25 +649,6 @@ class XMLBuilder(object):
return self._xmlstate.abs_xpath() 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 # # Internal API #
################ ################
@ -797,18 +783,6 @@ class XMLBuilder(object):
# Private XML building routines # # 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): def _add_parse_bits(self, xmlapi):
""" """
Callback that adds the implicitly tracked XML properties to Callback that adds the implicitly tracked XML properties to