diff --git a/virtinst/storage.py b/virtinst/storage.py index 73b0fa6b5..8f3f3ae85 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -177,7 +177,8 @@ class StoragePool(_StorageObject): for source in sources.sources: source_xml = source.get_xml_config() - pool_xml = "\n%s\n" % (util.xml_indent(source_xml, 2)) + pool_xml = "\n%s\n" % ( + XMLBuilder.xml_indent(source_xml, 2)) parseobj = StoragePool(conn, parsexml=pool_xml) parseobj.type = pool_type diff --git a/virtinst/util.py b/virtinst/util.py index fc420d931..57c81497f 100644 --- a/virtinst/util.py +++ b/virtinst/util.py @@ -36,15 +36,6 @@ def listify(l): return l -def xml_indent(xmlstr, level): - xml = "" - if not xmlstr: - return xml - if not level: - return xmlstr - return "\n".join((" " * level + l) for l in xmlstr.splitlines()) - - def vm_uuid_collision(conn, uuid): """ Check if passed UUID string is in use by another guest of the connection diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py index 039662e63..5183b3230 100644 --- a/virtinst/xmlbuilder.py +++ b/virtinst/xmlbuilder.py @@ -775,6 +775,20 @@ class XMLBuilder(object): # https://bugzilla.redhat.com/show_bug.cgi?id=1184131 _XML_SANITIZE = False + + @staticmethod + def xml_indent(xmlstr, level): + """ + Indent the passed str the specified number of spaces + """ + xml = "" + if not xmlstr: + return xml + if not level: + return xmlstr + return "\n".join((" " * level + l) for l in xmlstr.splitlines()) + + def __init__(self, conn, parsexml=None, parsexmlnode=None, parent_xpath=None, relative_object_xpath=None): """ @@ -1020,7 +1034,7 @@ class XMLBuilder(object): if not obj._xmlstate.is_build: use_xpath = obj.get_root_xpath().rsplit("/", 1)[0] indent = 2 * obj.get_root_xpath().count("/") - newnode = libxml2.parseDoc(util.xml_indent(xml, indent)).children + newnode = libxml2.parseDoc(self.xml_indent(xml, indent)).children parentnode = _build_xpath_node(self._xmlstate.xml_ctx, use_xpath) # Tack newnode on the end _add_pretty_child(parentnode, newnode)