qubes: change names of XML generating methods

Methods returning lxml.etree.Elements are called xml_ or lvxml_, meant for
qubes.xml or libvirt respectively.

Acknowledgement:
This commit is a result of core3 review by Marek.
This commit is contained in:
Wojtek Porczyk 2015-01-13 15:56:10 +01:00
parent 92eca8edb9
commit af154b53fe
4 changed files with 13 additions and 13 deletions

View File

@ -841,7 +841,7 @@ class PropertyHolder(qubes.events.Emitter):
self.fire_event('property-loaded') self.fire_event('property-loaded')
def save_properties(self, with_defaults=False): def xml_properties(self, with_defaults=False):
'''Iterator that yields XML nodes representing set properties. '''Iterator that yields XML nodes representing set properties.
:param bool with_defaults: If :py:obj:`True`, then it also includes properties which were not set explicite, but have default values filled. :param bool with_defaults: If :py:obj:`True`, then it also includes properties which were not set explicite, but have default values filled.
@ -1144,8 +1144,8 @@ class Qubes(PropertyHolder):
def __xml__(self): def __xml__(self):
element = lxml.etree.Element('qubes') element = lxml.etree.Element('qubes')
element.append(self.save_labels()) element.append(self.xml_labels())
element.append(self.save_properties()) element.append(self.xml_properties())
domains = lxml.etree.Element('domains') domains = lxml.etree.Element('domains')
for vm in self.domains: for vm in self.domains:
@ -1167,7 +1167,7 @@ class Qubes(PropertyHolder):
os.chown(self._store, -1, grp.getgrnam('qubes').gr_gid) os.chown(self._store, -1, grp.getgrnam('qubes').gr_gid)
def save_labels(self): def xml_labels(self):
'''Serialise labels '''Serialise labels
:rtype: lxml.etree._Element :rtype: lxml.etree._Element

View File

@ -190,8 +190,8 @@ class TC_20_PropertyHolder(qubes.tests.QubesTestCase):
def test_001_save_properties(self): def test_001_save_properties(self):
self.holder.load_properties() self.holder.load_properties()
elements = self.holder.save_properties() elements = self.holder.xml_properties()
elements_with_defaults = self.holder.save_properties(with_defaults=True) elements_with_defaults = self.holder.xml_properties(with_defaults=True)
self.assertEqual(len(elements), 2) self.assertEqual(len(elements), 2)
self.assertEqual(len(elements_with_defaults), 3) self.assertEqual(len(elements_with_defaults), 3)

View File

@ -256,7 +256,7 @@ class BaseVM(qubes.PropertyHolder):
element.set('id', 'domain-' + str(self.qid)) element.set('id', 'domain-' + str(self.qid))
element.set('class', self.__class__.__name__) element.set('class', self.__class__.__name__)
element.append(self.save_properties()) element.append(self.xml_properties())
services = lxml.etree.Element('services') services = lxml.etree.Element('services')
for service in self.services: for service in self.services:
@ -303,7 +303,7 @@ class BaseVM(qubes.PropertyHolder):
# #
@staticmethod @staticmethod
def xml_net_dev(ip, mac, backend): def lvxml_net_dev(ip, mac, backend):
'''Return ``<interface>`` node for libvirt xml. '''Return ``<interface>`` node for libvirt xml.
This was previously _format_net_dev This was previously _format_net_dev
@ -323,7 +323,7 @@ class BaseVM(qubes.PropertyHolder):
@staticmethod @staticmethod
def xml_pci_dev(address): def lvxml_pci_dev(address):
'''Return ``<hostdev>`` node for libvirt xml. '''Return ``<hostdev>`` node for libvirt xml.
This was previously _format_pci_dev This was previously _format_pci_dev
@ -365,7 +365,7 @@ class BaseVM(qubes.PropertyHolder):
args['uuidnode'] = '<uuid>{!r}</uuid>'.format(self.uuid) \ args['uuidnode'] = '<uuid>{!r}</uuid>'.format(self.uuid) \
if hasattr(self, 'uuid') else '' if hasattr(self, 'uuid') else ''
args['vmdir'] = self.dir_path args['vmdir'] = self.dir_path
args['pcidevs'] = ''.join(lxml.etree.tostring(self.xml_pci_dev(dev)) args['pcidevs'] = ''.join(lxml.etree.tostring(self.lvxml_pci_dev(dev))
for dev in self.devices['pci']) for dev in self.devices['pci'])
args['maxmem'] = str(self.maxmem) args['maxmem'] = str(self.maxmem)
args['vcpus'] = str(self.vcpus) args['vcpus'] = str(self.vcpus)
@ -382,7 +382,7 @@ class BaseVM(qubes.PropertyHolder):
args['dns1'] = self.netvm.gateway args['dns1'] = self.netvm.gateway
args['dns2'] = self.secondary_dns args['dns2'] = self.secondary_dns
args['netmask'] = self.netmask args['netmask'] = self.netmask
args['netdev'] = lxml.etree.tostring(self.xml_net_dev(self.ip, self.mac, self.netvm)) args['netdev'] = lxml.etree.tostring(self.lvxml_net_dev(self.ip, self.mac, self.netvm))
args['disable_network1'] = ''; args['disable_network1'] = '';
args['disable_network2'] = ''; args['disable_network2'] = '';
else: else:

View File

@ -1058,7 +1058,7 @@ class QubesVM(qubes.vm.BaseVM):
netvm.start() netvm.start()
self.libvirt_domain.attachDevice(lxml.etree.ElementTree( self.libvirt_domain.attachDevice(lxml.etree.ElementTree(
self.xml_net_dev(self.ip, self.mac, self.netvm)).tostring()) self.lvxml_net_dev(self.ip, self.mac, self.netvm)).tostring())
def detach_network(self): def detach_network(self):
@ -1072,7 +1072,7 @@ class QubesVM(qubes.vm.BaseVM):
self.libvirt_domain.detachDevice(lxml.etree.ElementTree( self.libvirt_domain.detachDevice(lxml.etree.ElementTree(
self.xml_net_dev(self.ip, self.mac, self.netvm)).tostring()) self.lvxml_net_dev(self.ip, self.mac, self.netvm)).tostring())
# #