Martin Sivák has uploaded a new change for review.

Change subject: Refactor XMLElement to virt.utils
......................................................................

Refactor XMLElement to virt.utils

This is needed to avoid cyclic dependencies when other files
need the xml helper class.

Change-Id: I74528a597ace8148adbb0295a810ba7972b1270c
Signed-off-by: Martin Sivak <[email protected]>
---
M vdsm/virt/utils.py
M vdsm/virt/vm.py
2 files changed, 31 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/29630/1

diff --git a/vdsm/virt/utils.py b/vdsm/virt/utils.py
index f771606..48f9a37 100644
--- a/vdsm/virt/utils.py
+++ b/vdsm/virt/utils.py
@@ -22,6 +22,8 @@
 shared utilities and common code for the virt package
 """
 
+import xml
+
 
 def isVdsmImage(drive):
     """
@@ -33,3 +35,31 @@
     """
     required = ('domainID', 'imageID', 'poolID', 'volumeID')
     return all(k in drive for k in required)
+
+
+class XMLElement(object):
+
+    def __init__(self, tagName, text=None, **attrs):
+        self._elem = xml.dom.minidom.Document().createElement(tagName)
+        self.setAttrs(**attrs)
+        if text is not None:
+            self.appendTextNode(text)
+
+    def __getattr__(self, name):
+        return getattr(self._elem, name)
+
+    def setAttrs(self, **attrs):
+        for attrName, attrValue in attrs.iteritems():
+            self._elem.setAttribute(attrName, attrValue)
+
+    def appendTextNode(self, text):
+        textNode = xml.dom.minidom.Document().createTextNode(text)
+        self._elem.appendChild(textNode)
+
+    def appendChild(self, element):
+        self._elem.appendChild(element)
+
+    def appendChildWithArgs(self, childName, text=None, **attrs):
+        child = XMLElement(childName, text, **attrs)
+        self._elem.appendChild(child)
+        return child
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 4eea4b5..a0fe535 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -65,7 +65,7 @@
 from . import vmstatus
 
 from .sampling import AdvancedStatsFunction, AdvancedStatsThread
-from .utils import isVdsmImage
+from .utils import isVdsmImage, XMLElement
 from vmpowerdown import VmShutdown, VmReboot
 
 _VMCHANNEL_DEVICE_NAME = 'com.redhat.rhevm.vdsm'
@@ -641,34 +641,6 @@
                     raise toe
                 raise
         return f
-
-
-class XMLElement(object):
-
-    def __init__(self, tagName, text=None, **attrs):
-        self._elem = xml.dom.minidom.Document().createElement(tagName)
-        self.setAttrs(**attrs)
-        if text is not None:
-            self.appendTextNode(text)
-
-    def __getattr__(self, name):
-        return getattr(self._elem, name)
-
-    def setAttrs(self, **attrs):
-        for attrName, attrValue in attrs.iteritems():
-            self._elem.setAttribute(attrName, attrValue)
-
-    def appendTextNode(self, text):
-        textNode = xml.dom.minidom.Document().createTextNode(text)
-        self._elem.appendChild(textNode)
-
-    def appendChild(self, element):
-        self._elem.appendChild(element)
-
-    def appendChildWithArgs(self, childName, text=None, **attrs):
-        child = XMLElement(childName, text, **attrs)
-        self._elem.appendChild(child)
-        return child
 
 
 class _DomXML:


-- 
To view, visit http://gerrit.ovirt.org/29630
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I74528a597ace8148adbb0295a810ba7972b1270c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to