diff options
author | Cole Robinson <crobinso@redhat.com> | 2013-09-20 10:47:36 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2013-09-20 10:55:48 -0400 |
commit | a23f1794d00ed1d78e16859c800b66cb87555796 (patch) | |
tree | 0c5a786cd440136b7871c428d3e15a0061e0e49e /virtinst/xmlbuilder.py | |
parent | 38f110954db9818bba0524ee255abbd1376e862b (diff) | |
download | virt-manager-a23f1794d00ed1d78e16859c800b66cb87555796.tar.gz |
guest stuff
Diffstat (limited to 'virtinst/xmlbuilder.py')
-rw-r--r-- | virtinst/xmlbuilder.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py index 7eb9834a..50e1524f 100644 --- a/virtinst/xmlbuilder.py +++ b/virtinst/xmlbuilder.py @@ -293,8 +293,23 @@ class XMLChildProperty(property): for obj in self._get(xmlbuilder)[:]: xmlbuilder._remove_child(obj) - def append(self, xmlbuilder, obj): - self._get(xmlbuilder).append(obj) + def append(self, xmlbuilder, newobj): + # Keep the list ordered by the order of passed in child classes + objlist = self._get(xmlbuilder) + if len(self.child_classes) == 1: + objlist.append(newobj) + return + + idx = 0 + for idx in range(len(objlist)): + obj = objlist[idx] + if (obj.__class__ not in self.child_classes or + (self.child_classes.index(newobj.__class__) < + self.child_classes.index(obj.__class__))): + break + idx += 1 + + objlist.insert(idx, newobj) def remove(self, xmlbuilder, obj): self._get(xmlbuilder).remove(obj) def set(self, xmlbuilder, obj): |