Martin Sivák has posted comments on this change.
Change subject: Introduction for caching the parsed domain XML
......................................................................
Patch Set 10:
(3 comments)
http://gerrit.ovirt.org/#/c/17694/10/vdsm/vm.py
File vdsm/vm.py:
Line 461: class ParsedDomXML(object):
Line 462: def __init__(self, xml):
Line 463: self.set(xml)
Line 464:
Line 465: def set(self, xml):
I would probably make the class "read-only" by moving this to the constructor
and requiring the user to create a new instance of the class every time a new XML is
needed.
Line 466: self._xml = xml
Line 467: self._dom = _domParseStr(xml)
Line 468: devices = self.firstElementByTagName('devices')
Line 469: self._devices = devices
Line 476:
Line 477: def firstElementByTagName(self, tagName):
Line 478: return self._dom.childNodes[0].getElementsByTagName(tagName)[0]
Line 479:
Line 480: def devs(self):
nit: 'devices' is better IMO.
I agree. Properties would
make it nicer.
Line 481: return self._devices
Line 482:
Line 483: def getDeviceElements(self, tagName):
Line 484: return self._devices.getElementsByTagName(tagName)
Line 4631: return pid
Line 4632:
Line 4633: def _getUnderlyingVmInfo(self):
Line 4634: self._lastXMLDesc.set(self._dom.XMLDesc(0))
Line 4635: self._devXmlHash = str(hash(self._lastXMLDesc.devs().toxml()))
You can add the hash to the ParsedXMLDom class as a property and compute it when it is
accessed for the first time.
Line 4636:
Line 4637: def _ejectFloppy(self):
Line 4638: if 'volatileFloppy' in self.conf:
Line 4639: utils.rmFile(self.conf['floppy'])
--
To view, visit
http://gerrit.ovirt.org/17694
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I7e106b2f2d3f4160d4e882f1a2880cb1b52fbb22
Gerrit-PatchSet: 10
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Itamar Heim <iheim(a)redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek(a)redhat.com>
Gerrit-Reviewer: Peter V. Saveliev <peet(a)redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes