예제 #1
0
 def test_pretty_format_safety(self):
     # Check that dom is not modified in format_xml; we check that by
     # comparing the exported forms of `dom' created before and after
     # format_xml call.
     xml = re.sub(' *\n *', '', self._XML)
     dom = vmxml.parse_xml(xml)
     exported_1 = etree.tostring(dom)
     vmxml.format_xml(dom, pretty=True)
     exported_2 = etree.tostring(dom)
     self.assertEqual(exported_1, exported_2)
예제 #2
0
 def testCreateSRIOVVF(self):
     dev_spec = {'type': hwclass.NIC, 'device': 'hostdev',
                 'hostdev': _SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff',
                 'specParams': {'vlanid': 3},
                 'bootOrder': '9'}
     device = network.Interface(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(vmxml.format_xml(device.getXML()),
                         _DEVICE_XML[_SRIOV_VF] % ('',))
예제 #3
0
 def testCreatePCIHostDeviceWithAddress(self, device_name):
     dev_spec = {'type': 'hostdev', 'device': device_name, 'address':
                 self._PCI_ADDRESS}
     device = hostdevice.HostDevice(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(
         vmxml.format_xml(device.getXML()),
         _DEVICE_XML[device_name] %
         (self._PCI_ADDRESS_XML))
예제 #4
0
 def testCreatePCIHostDeviceWithAddress(self, device_name):
     dev_spec = {
         'type': 'hostdev',
         'device': device_name,
         'address': self._PCI_ADDRESS
     }
     device = hostdevice.HostDevice(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(vmxml.format_xml(device.getXML()),
                         _DEVICE_XML[device_name] % (self._PCI_ADDRESS_XML))
예제 #5
0
 def testNumaTuneXMLMultiNode(self):
     domxml = vmxml.Domain(self.conf, self.log, cpuarch.X86_64)
     devices = [hostdevice.HostDevice(
         self.conf, self.log, **{'type': 'hostdev', 'device': device}) for
         device in [_SRIOV_PF, _SRIOV_VF, 'pci_0000_00_02_0']]
     domxml.appendHostdevNumaTune(devices)
     xml = vmxml.format_xml(domxml.dom)
     self.assertRaises(AssertionError,
                       lambda: find_xml_element(xml, './numatune'))
예제 #6
0
 def testCreateSRIOVVFWithAddress(self):
     dev_spec = {'type': hwclass.NIC, 'device': 'hostdev',
                 'hostdev': _SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff',
                 'specParams': {'vlanid': 3},
                 'bootOrder': '9', 'address':
                 {'slot': '0x02', 'bus': '0x01', 'domain': '0x0000',
                  'function': '0x0', 'type': 'pci'}}
     device = network.Interface(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(
         vmxml.format_xml(device.getXML()),
         _DEVICE_XML[_SRIOV_VF] % (self._PCI_ADDRESS_XML))
예제 #7
0
 def testNumaTuneXMLMultiNode(self):
     domxml = vmxml.Domain(self.conf, self.log, cpuarch.X86_64)
     devices = [
         hostdevice.HostDevice(self.conf, self.log, **{
             'type': 'hostdev',
             'device': device
         }) for device in [_SRIOV_PF, _SRIOV_VF, 'pci_0000_00_02_0']
     ]
     domxml.appendHostdevNumaTune(devices)
     xml = vmxml.format_xml(domxml.dom)
     self.assertRaises(AssertionError,
                       lambda: find_xml_element(xml, './numatune'))
예제 #8
0
 def check_leases(self, conf):
     drive = Drive({}, self.log, **conf)
     leases = list(drive.getLeasesXML())
     self.assertEqual(1, len(leases))
     xml = """
     <lease>
         <key>vol_id</key>
         <lockspace>dom_id</lockspace>
         <target offset="0" path="path" />
     </lease>
     """
     self.assertXMLEqual(vmxml.format_xml(leases[0]), xml)
예제 #9
0
 def check_leases(self, conf):
     drive = Drive({}, self.log, **conf)
     leases = list(drive.getLeasesXML())
     self.assertEqual(1, len(leases))
     xml = """
     <lease>
         <key>vol_id</key>
         <lockspace>dom_id</lockspace>
         <target offset="0" path="path" />
     </lease>
     """
     self.assertXMLEqual(vmxml.format_xml(leases[0]), xml)
예제 #10
0
    def testNumaTuneXMLSingleNode(self, devices, numa_node):
        numatuneXML = """
          <numatune>
              <memory mode="preferred" nodeset="{}" />
          </numatune> """.format(numa_node)

        domxml = vmxml.Domain(self.conf, self.log, cpuarch.X86_64)
        devices = [hostdevice.HostDevice(
            self.conf, self.log, **{'type': 'hostdev', 'device': device}) for
            device in devices]
        domxml.appendHostdevNumaTune(devices)
        xml = vmxml.format_xml(domxml.dom)
        self.assertXMLEqual(find_xml_element(xml, './numatune'), numatuneXML)
예제 #11
0
 def test_getxml(self):
     spec = dict(sd_id="sd_id", lease_id="lease_id", path="/path",
                 offset=1048576)
     lease = vmdevices.lease.Device({}, self.log, **spec)
     lease_xml = vmxml.format_xml(lease.getXML())
     xml = """
     <lease>
         <key>lease_id</key>
         <lockspace>sd_id</lockspace>
         <target offset="1048576" path="/path" />
     </lease>
     """
     self.assertXMLEqual(lease_xml, xml)
예제 #12
0
 def testCreateSRIOVVF(self):
     dev_spec = {
         'type': hwclass.NIC,
         'device': 'hostdev',
         'hostdev': _SRIOV_VF,
         'macAddr': 'ff:ff:ff:ff:ff:ff',
         'specParams': {
             'vlanid': 3
         },
         'bootOrder': '9'
     }
     device = network.Interface(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(vmxml.format_xml(device.getXML()),
                         _DEVICE_XML[_SRIOV_VF] % ('', ))
예제 #13
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_namespaces(self):
     expected_xml = '''
     <domain xmlns:ovirt="http://ovirt.org/vm/tune/1.0">
       <metadata>
         <ovirt:qos/>
       </metadata>
     </domain>
     '''
     domain = vmxml.Element('domain')
     metadata = vmxml.Element('metadata')
     domain.appendChild(metadata)
     qos = vmxml.Element('qos', namespace='ovirt',
                         namespace_uri='http://ovirt.org/vm/tune/1.0')
     metadata.appendChild(qos)
     self.assertXMLEqual(vmxml.format_xml(domain), expected_xml)
예제 #14
0
 def test_namespaces(self):
     expected_xml = '''
     <domain xmlns:ovirt="http://ovirt.org/vm/tune/1.0">
       <metadata>
         <ovirt:qos/>
       </metadata>
     </domain>
     '''
     domain = vmxml.Element('domain')
     metadata = vmxml.Element('metadata')
     domain.appendChild(metadata)
     qos = vmxml.Element('qos', namespace='ovirt',
                         namespace_uri='http://ovirt.org/vm/tune/1.0')
     metadata.appendChild(qos)
     self.assertXMLEqual(vmxml.format_xml(domain), expected_xml)
예제 #15
0
    def testNumaTuneXMLSingleNode(self, devices, numa_node):
        numatuneXML = """
          <numatune>
              <memory mode="preferred" nodeset="{}" />
          </numatune> """.format(numa_node)

        domxml = vmxml.Domain(self.conf, self.log, cpuarch.X86_64)
        devices = [
            hostdevice.HostDevice(self.conf, self.log, **{
                'type': 'hostdev',
                'device': device
            }) for device in devices
        ]
        domxml.appendHostdevNumaTune(devices)
        xml = vmxml.format_xml(domxml.dom)
        self.assertXMLEqual(find_xml_element(xml, './numatune'), numatuneXML)
예제 #16
0
    def test_pretty_format_formatting(self):
        xml = re.sub(' *\n *', '', self._XML)
        dom = vmxml.parse_xml(xml)
        pretty = vmxml.format_xml(dom, pretty=True)
        self.assertEqual(pretty, '''<?xml version='1.0' encoding='UTF-8'?>
<topelement>
    <hello lang="english">hello</hello>
    <hello cyrillic="yes" lang="русский">здра́вствуйте</hello>
    <bye>good bye<hello lang="čeština">dobrý den</hello>
    </bye>
    <container>
        <subelement />
    </container>
    <container>
        <subelement>some content</subelement>
    </container>
    <empty />
</topelement>
''')
예제 #17
0
 def testCreateSRIOVVFWithAddress(self):
     dev_spec = {
         'type': hwclass.NIC,
         'device': 'hostdev',
         'hostdev': _SRIOV_VF,
         'macAddr': 'ff:ff:ff:ff:ff:ff',
         'specParams': {
             'vlanid': 3
         },
         'bootOrder': '9',
         'address': {
             'slot': '0x02',
             'bus': '0x01',
             'domain': '0x0000',
             'function': '0x0',
             'type': 'pci'
         }
     }
     device = network.Interface(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(vmxml.format_xml(device.getXML()),
                         _DEVICE_XML[_SRIOV_VF] % (self._PCI_ADDRESS_XML))
예제 #18
0
 def testCreateHostDevice(self, device_name):
     dev_spec = {'type': 'hostdev', 'device': device_name}
     device = hostdevice.HostDevice(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(vmxml.format_xml(device.getXML()),
                         _DEVICE_XML[device_name] % ('',))
예제 #19
0
 def test_import_export(self):
     xml = vmxml.format_xml(self._dom)
     self.assertXMLEqual(xml, self._XML)
예제 #20
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def toxml(self):
     return vmxml.format_xml(self.dom)
예제 #21
0
 def testCreateHostDevice(self, device_name):
     dev_spec = {'type': 'hostdev', 'device': device_name}
     device = hostdevice.HostDevice(self.conf, self.log, **dev_spec)
     self.assertXMLEqual(vmxml.format_xml(device.getXML()),
                         _DEVICE_XML[device_name] % ('', ))
예제 #22
0
 def check(self, vm_conf, device_conf, xml, is_block_device=False):
     drive = Drive(vm_conf, self.log, **device_conf)
     # Patch to skip the block device checking.
     drive._blockDev = is_block_device
     self.assertXMLEqual(vmxml.format_xml(drive.getReplicaXML()), xml)
예제 #23
0
 def assert_dom_xml_equal(self, dom, expected_xml):
     xml = vmxml.format_xml(dom)
     self.assertXMLEqual(xml, expected_xml)
예제 #24
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_import_export(self):
     xml = vmxml.format_xml(self._dom)
     self.assertXMLEqual(xml, self._XML)
예제 #25
0
 def toxml(self):
     return vmxml.format_xml(self.dom)
예제 #26
0
 def check(self, vm_conf, device_conf, xml, is_block_device=False):
     drive = Drive(vm_conf, self.log, **device_conf)
     # Patch to skip the block device checking.
     drive._blockDev = is_block_device
     self.assertXMLEqual(vmxml.format_xml(drive.getReplicaXML()), xml)
예제 #27
0
 def assert_dom_xml_equal(self, dom, expected_xml):
     xml = vmxml.format_xml(dom)
     self.assertXMLEqual(xml, expected_xml)