示例#1
0
    def test_correct_disk_and_metadata(self):
        vmParams = {
            'vmId': '627f1f31-752b-4e7c-bfb5-4313d191ed7b',  # from XML
            'restoreState': '/dev/null',  # unused here
            'restoreFromSnapshot': True,
            '_srcDomXML': read_data('vm_replace_md_base.xml'),
            'xml': read_data('vm_replace_md_update.xml'),
        }
        with fake.VM(vmParams) as testvm:
            updated_dom_xml = testvm.conf['xml']

        # shortcut
        make_params = vmdevices.common.storage_device_params_from_domain_xml

        dom_desc = domain_descriptor.DomainDescriptor(updated_dom_xml)
        with dom_desc.metadata_descriptor() as md_desc:

            disk_params = make_params(
                dom_desc.id, dom_desc, md_desc, self._log)

        sda = find_drive_conf_by_name(disk_params, 'sda')

        self.assertIsNotNone(sda)
        self.assertEqual(sda['path'], '/rhev/data-center/path/updated')
        self.assertEqual(sda['imageID'], 'imageID_updated')
        self.assertEqual(sda['poolID'], 'poolID_updated')
        self.assertEqual(sda['domainID'], 'domainID_updated')
        self.assertEqual(sda['volumeID'], 'volumeID_updated')
示例#2
0
    def test_correct_disk_and_metadata(self):
        vmParams = {
            'vmId': '627f1f31-752b-4e7c-bfb5-4313d191ed7b',  # from XML
            'restoreState': '/dev/null',  # unused here
            'restoreFromSnapshot': True,
            '_srcDomXML': read_data('vm_replace_md_base.xml'),
            'xml': read_data('vm_replace_md_update.xml'),
        }
        with fake.VM(vmParams) as testvm:
            updated_dom_xml = testvm.conf['xml']

        # shortcut
        make_params = vmdevices.common.storage_device_params_from_domain_xml

        dom_desc = domain_descriptor.DomainDescriptor(updated_dom_xml)
        with dom_desc.metadata_descriptor() as md_desc:

            disk_params = make_params(dom_desc.id, dom_desc, md_desc,
                                      self._log)

        sda = find_drive_conf_by_name(disk_params, 'sda')

        self.assertIsNotNone(sda)
        self.assertEqual(sda['path'], '/rhev/data-center/path/updated')
        self.assertEqual(sda['imageID'], 'imageID_updated')
        self.assertEqual(sda['poolID'], 'poolID_updated')
        self.assertEqual(sda['domainID'], 'domainID_updated')
        self.assertEqual(sda['volumeID'], 'volumeID_updated')
示例#3
0
 def test_replace_values(self):
     xml_str = read_data('sysinfo_snippet_template.xml')
     dom = xmlutils.fromstring(xml_str)
     with MonkeyPatchScope([
         (osinfo, 'version', self._version),
     ]):
         domxml_preprocess.replace_placeholders(dom,
                                                cpuarch.X86_64,
                                                serial='test-serial')
     self.assertXMLEqual(xmlutils.tostring(dom, pretty=True),
                         read_data('sysinfo_snippet_filled.xml'))
示例#4
0
 def test_replace_values(self):
     xml_str = read_data('sysinfo_snippet_template.xml')
     dom = xmlutils.fromstring(xml_str)
     with MonkeyPatchScope([
         (osinfo, 'version', self._version),
         (constants, 'SMBIOS_OSNAME', 'test-product'),
     ]):
         domxml_preprocess.replace_placeholders(
             dom, cpuarch.X86_64, serial='test-serial')
     self.assertXMLEqual(
         xmlutils.tostring(dom, pretty=True),
         read_data('sysinfo_snippet_filled.xml')
     )
示例#5
0
 def test_replace_cdrom_withoutource_file(self):
     dom_str = read_data('vm_hibernated.xml')
     dom = xmlutils.fromstring(dom_str)
     cdrom_xml = u'''<disk device="cdrom" type="file">
         <driver error_policy="report" name="qemu" type="raw" />
         <source {file_src}startupPolicy="optional">
             <seclabel model="dac" relabel="no" type="none" />
         </source>
         <backingStore />
         <target bus="ide" dev="hdc" />
         <readonly />
         <alias name="ide0-1-0" />
         <address bus="1" controller="0" target="0"
             type="drive" unit="0" />
     </disk>'''
     cdrom_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(cdrom_xml.format(file_src='')), {})
     disk_devs = [
         vmdevices.storage.Drive(self.log, **cdrom_params),
     ]
     domxml_preprocess.update_disks_xml_from_objs(FakeVM(self.log), dom,
                                                  disk_devs)
     cdrom_elem = dom.find('./devices/disk[@device="cdrom"]')
     self.assertXMLEqual(xmlutils.tostring(cdrom_elem, pretty=True),
                         cdrom_xml.format(file_src="file='' "))
示例#6
0
    def test_with_sysprep_floppy(self):
        dom_str = read_data('vm_sysprep_floppy.xml')
        dom = xmlutils.fromstring(dom_str)
        # taken and amended from vm_sysprep_floppy.xml
        floppy_params = {
            'index': 0,
            'iface': 'fdc',
            'name': 'fda',
            'alias': 'ua-cc9acd76-7b44-4adf-881d-e98e1cf4e639',
            'vmid': 'e9252f48-6b22-4c9b-8d9a-8531fcf71f4c',
            'diskType': 'file',
            'readonly': True,
            'device': 'floppy',
            'path': 'PAYLOAD:',
            'propagateErrors': 'off',
            'type': 'disk'
        }
        floppy_obj = vmdevices.storage.Drive(self.log, **floppy_params)
        disk_devs = [floppy_obj]
        domxml_preprocess.update_disks_xml_from_objs(
            FakeVM(self.log), dom, disk_devs)

        floppy_elem = dom.find('./devices/disk[@device="floppy"]')
        self.assertXMLEqual(
            xmlutils.tostring(floppy_elem, pretty=True),
            xmlutils.tostring(floppy_obj.getXML(), pretty=True),
        )
示例#7
0
    def test_replace_device_xml_with_hook_xml_empty_custom(self):
        """
        Try to replace device XML if custom properties are declared.
        """
        # invoked even if custom properties exist, but are empty.
        dom_disk_file_str = read_data('vm_replace_md_base.xml')
        dom = xmlutils.fromstring(dom_disk_file_str)

        with MonkeyPatchScope([
            (hooks, 'before_device_create', self._hook),
        ]):
            domxml_preprocess.replace_device_xml_with_hooks_xml(
                dom, 'test', {})

        addr = (
            '<address bus="0x00" domain="0x0000"'
            ' function="0x0" slot="0x03" type="pci" />'
        )
        expected_xml = u'''<?xml version='1.0' encoding='utf-8'?>
<interface type="bridge">
    <model type="virtio" />
    <link state="up" />
    <source bridge="ovirtmgmt" />
    {addr}
    <mac address="00:1a:4a:16:01:12" />
    <filterref filter="vdsm-no-mac-spoofing" />
    <bandwidth />
</interface>
'''.format(addr=addr)
        self.assertEqual(
            self._hook_params,
            [(expected_xml, {}, {})]
        )
示例#8
0
 def test_replace_disks_xml(self):
     dom, disk_devs = self._make_env()
     domxml_preprocess.replace_disks_xml(dom, disk_devs)
     self.assertXMLEqual(
         xmlutils.tostring(dom, pretty=True),
         read_data('domain_disk_block.xml')
     )
示例#9
0
 def test_replace_cdrom_with_minimal_drive(self):
     dom_str = read_data('vm_hibernated_390.xml')
     dom = xmlutils.fromstring(dom_str)
     # taken from the test XML and amended manually
     # please note:
     # - the lack of empty 'backingStore' element
     # - the 'driver' elements lack name="qemu" (default)
     cdrom_xml = u'''<disk device="cdrom" type="file">
         <driver error_policy="report" type="raw" />
         <source file="" startupPolicy="optional">
             <seclabel model="dac" relabel="no" type="none" />
         </source>
         <target bus="ide" dev="hdc" />
         <readonly />
         <alias name="ua-096534a7-5fbd-4bd1-add0-65501bce51f9" />
         <address bus="1" controller="0" target="0"
             type="drive" unit="0" />
     </disk>'''
     cdrom_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(cdrom_xml), {})
     disk_devs = [
         vmdevices.storage.Drive(self.log, **cdrom_params),
     ]
     domxml_preprocess.update_disks_xml_from_objs(FakeVM(self.log), dom,
                                                  disk_devs)
     cdrom_elem = dom.find('./devices/disk[@device="cdrom"]')
     self.assertXMLEqual(xmlutils.tostring(cdrom_elem, pretty=True),
                         cdrom_xml)
示例#10
0
 def test_replace_cdrom_withoutource_file(self):
     dom_str = read_data('vm_hibernated.xml')
     dom = xmlutils.fromstring(dom_str)
     cdrom_xml = u'''<disk device="cdrom" type="file">
         <driver error_policy="report" name="qemu" type="raw" />
         <source {file_src}startupPolicy="optional">
             <seclabel model="dac" relabel="no" type="none" />
         </source>
         <backingStore />
         <target bus="ide" dev="hdc" />
         <readonly />
         <alias name="ide0-1-0" />
         <address bus="1" controller="0" target="0"
             type="drive" unit="0" />
     </disk>'''
     cdrom_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(cdrom_xml.format(file_src='')), {}
     )
     disk_devs = [
         vmdevices.storage.Drive(self.log, **cdrom_params),
     ]
     domxml_preprocess.update_disks_xml_from_objs(
         FakeVM(self.log), dom, disk_devs)
     cdrom_elem = dom.find('./devices/disk[@device="cdrom"]')
     self.assertXMLEqual(
         xmlutils.tostring(cdrom_elem, pretty=True),
         cdrom_xml.format(file_src="file='' ")
     )
示例#11
0
    def test_with_sysprep_floppy(self):
        dom_str = read_data('vm_sysprep_floppy.xml')
        dom = xmlutils.fromstring(dom_str)
        # taken and amended from vm_sysprep_floppy.xml
        floppy_params = {
            'index': 0,
            'iface': 'fdc',
            'name': 'fda',
            'alias': 'ua-cc9acd76-7b44-4adf-881d-e98e1cf4e639',
            'vmid': 'e9252f48-6b22-4c9b-8d9a-8531fcf71f4c',
            'diskType': 'file',
            'readonly': True,
            'device': 'floppy',
            'path': 'PAYLOAD:',
            'propagateErrors': 'off',
            'type': 'disk'
        }
        floppy_obj = vmdevices.storage.Drive(self.log, **floppy_params)
        disk_devs = [floppy_obj]
        domxml_preprocess.update_disks_xml_from_objs(FakeVM(self.log), dom,
                                                     disk_devs)

        floppy_elem = dom.find('./devices/disk[@device="floppy"]')
        self.assertXMLEqual(
            xmlutils.tostring(floppy_elem, pretty=True),
            xmlutils.tostring(floppy_obj.getXML(), pretty=True),
        )
示例#12
0
 def test_replace_cdrom_with_minimal_drive(self):
     dom_str = read_data('vm_hibernated_390.xml')
     dom = xmlutils.fromstring(dom_str)
     # taken from the test XML and amended manually
     # please note:
     # - the lack of empty 'backingStore' element
     # - the 'driver' elements lack name="qemu" (default)
     cdrom_xml = u'''<disk device="cdrom" type="file">
         <driver error_policy="report" type="raw" />
         <source file="" startupPolicy="optional">
             <seclabel model="dac" relabel="no" type="none" />
         </source>
         <target bus="ide" dev="hdc" />
         <readonly />
         <alias name="ua-096534a7-5fbd-4bd1-add0-65501bce51f9" />
         <address bus="1" controller="0" target="0"
             type="drive" unit="0" />
     </disk>'''
     cdrom_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(cdrom_xml), {}
     )
     disk_devs = [
         vmdevices.storage.Drive(self.log, **cdrom_params),
     ]
     domxml_preprocess.update_disks_xml_from_objs(
         FakeVM(self.log), dom, disk_devs)
     cdrom_elem = dom.find('./devices/disk[@device="cdrom"]')
     self.assertXMLEqual(
         xmlutils.tostring(cdrom_elem, pretty=True),
         cdrom_xml
     )
示例#13
0
 def test_replace_disks_xml(self):
     dom, disk_devs = self._make_env()
     domxml_preprocess.replace_disks_xml(dom, disk_devs)
     self.assertXMLEqual(
         xmlutils.tostring(dom, pretty=True),
         read_data('domain_disk_block.xml')
     )
示例#14
0
    def test_replace_device_xml_with_hook_xml_empty_custom(self):
        """
        Try to replace device XML if custom properties are declared.
        """
        # invoked even if custom properties exist, but are empty.
        dom_disk_file_str = read_data('vm_replace_md_base.xml')
        dom = xmlutils.fromstring(dom_disk_file_str)

        with MonkeyPatchScope([
            (hooks, 'before_device_create', self._hook),
        ]):
            domxml_preprocess.replace_device_xml_with_hooks_xml(
                dom, 'test', {})

        addr = ('<address bus="0x00" domain="0x0000"'
                ' function="0x0" slot="0x03" type="pci" />')
        expected_xml = u'''<?xml version='1.0' encoding='utf-8'?>
<interface type="bridge">
    <model type="virtio" />
    <link state="up" />
    <source bridge="ovirtmgmt" />
    {addr}
    <mac address="00:1a:4a:16:01:12" />
    <filterref filter="vdsm-no-mac-spoofing" />
    <bandwidth />
</interface>
'''.format(addr=addr)
        self.assertEqual(self._hook_params, [(expected_xml, {}, {})])
示例#15
0
    def test_no_leases(self):
        """
        without leases, do nothing
        """
        # any VM without leases is fine
        xml_str = read_data('vm_compat41.xml')
        self.assertXMLEqual(
            extract_device_snippet('lease', xml_str=xml_str),
            u'''<?xml version='1.0' encoding='utf-8'?><devices />'''
        )

        dom = xmlutils.fromstring(xml_str)
        disk_devs = domxml_preprocess._make_disk_devices(
            xml_str, self.log)
        disk_devs = self._inject_volume_chain(
            disk_devs, self.driveVolInfo,
            domainID='unknwonDomainID',
            volumeID='unknownVolumeID')

        domxml_preprocess.update_leases_xml_from_disk_objs(
            self.vm, dom, disk_devs)

        self.assertXMLEqual(
            extract_device_snippet('lease', dom=dom),
            u'''<?xml version='1.0' encoding='utf-8'?><devices />'''
        )
示例#16
0
    def test_no_leases(self):
        """
        without leases, do nothing
        """
        # any VM without leases is fine
        xml_str = read_data('vm_compat41.xml')
        self.assertXMLEqual(
            extract_device_snippet('lease', xml_str=xml_str),
            u'''<?xml version='1.0' encoding='utf-8'?><devices />'''
        )

        dom = xmlutils.fromstring(xml_str)
        disk_devs = domxml_preprocess._make_disk_devices(
            xml_str, self.log)
        disk_devs = self._inject_volume_chain(
            disk_devs, self.driveVolInfo,
            domainID='unknwonDomainID',
            volumeID='unknownVolumeID')

        domxml_preprocess.update_leases_xml_from_disk_objs(
            self.vm, dom, disk_devs)

        self.assertXMLEqual(
            extract_device_snippet('lease', dom=dom),
            u'''<?xml version='1.0' encoding='utf-8'?><devices />'''
        )
示例#17
0
 def test_update_disks_xml(self):
     """
     Replace one disk, moving from file to block; no changes to CDROM
     """
     dom, disk_devs = self._make_env()
     domxml_preprocess.update_disks_xml_from_objs(FakeVM(self.log), dom,
                                                  disk_devs)
     self.assertXMLEqual(extract_device_snippet('disk', dom=dom),
                         read_data('disk_updated_snippet.xml'))
示例#18
0
    def test_compat41(self):
        expected_conf = json.loads(read_data('vm_compat41.json'))[0]

        vm_params = recovery._recovery_params(expected_conf['vmId'],
                                              read_data('vm_compat41.xml'),
                                              False)

        vm_obj = vm.Vm(fake.ClientIF(), vm_params, recover=True)
        # TODO: ugly hack, but we don't have APIs to do that
        vm_obj._devices = vm_obj._make_devices()

        recovered_conf = vm_obj.status(fullStatus=True)

        self.assert_conf_equal(recovered_conf, expected_conf,
                               filter_vm_conf_keys)

        self.assert_devices_conf_equal(recovered_conf['devices'],
                                       expected_conf['devices'],
                                       IGNORED_DEVICE_TYPES)
示例#19
0
 def test_skip_without_placeholders(self):
     # any domain without placeholders is fine, picked random one
     xml_str = read_data('vm_hosted_engine_42.xml')
     dom = xmlutils.fromstring(xml_str)
     with MonkeyPatchScope([
         (osinfo, 'version', self._version),
     ]):
         domxml_preprocess.replace_placeholders(dom,
                                                cpuarch.X86_64,
                                                serial='test-serial')
     self.assertXMLEqual(xmlutils.tostring(dom, pretty=True), xml_str)
示例#20
0
    def test_compat41(self):
        expected_conf = json.loads(
            read_data('vm_compat41.json'))[0]

        vm_params = recovery._recovery_params(
            expected_conf['vmId'],
            read_data('vm_compat41.xml'),
            False)

        vm_obj = vm.Vm(fake.ClientIF(), vm_params, recover=True)
        # TODO: ugly hack, but we don't have APIs to do that
        vm_obj._devices = vm_obj._make_devices()

        recovered_conf = vm_obj.status(fullStatus=True)

        self.assert_conf_equal(
            recovered_conf, expected_conf, filter_vm_conf_keys)

        self.assert_devices_conf_equal(
            recovered_conf['devices'], expected_conf['devices'],
            IGNORED_DEVICE_TYPES)
示例#21
0
 def test_device_core_attributes_present_and_never_none(self):
     he_xml = read_data('hostedengine.xml')
     dom_desc = DomainDescriptor(he_xml)
     md_desc = metadata.Descriptor.from_xml(he_xml)
     dev_objs = vmdevices.common.dev_map_from_domain_xml(
         'HE', dom_desc, md_desc, self.log
     )
     for devices in dev_objs.values():
         for dev in devices:
             print(dev)  # debug aid
             assert dev.type is not None
             assert dev.device is not None
示例#22
0
    def test_replace_device_xml_with_hook_xml_no_custom(self):
        """
        Don't replace devices if they lack custom properties
        """
        dom = xmlutils.fromstring(read_data('domain_disk_file.xml'))

        with MonkeyPatchScope([
            (hooks, 'before_device_create', self._hook),
        ]):
            domxml_preprocess.replace_device_xml_with_hooks_xml(
                dom, 'test', {})

        self.assertEqual(self._hook_params, [])
示例#23
0
 def test_skip_without_placeholders(self):
     # any domain without placeholders is fine, picked random one
     xml_str = read_data('vm_hosted_engine_42.xml')
     dom = xmlutils.fromstring(xml_str)
     with MonkeyPatchScope([
         (osinfo, 'version', self._version),
     ]):
         domxml_preprocess.replace_placeholders(
             dom, cpuarch.X86_64, serial='test-serial')
     self.assertXMLEqual(
         xmlutils.tostring(dom, pretty=True),
         xml_str
     )
示例#24
0
 def test_update_disks_xml(self):
     """
     Replace one disk, moving from file to block; no changes to CDROM
     """
     dom, disk_devs = self._make_env()
     domxml_preprocess.update_disks_xml_from_objs(
         FakeVM(self.log), dom, disk_devs)
     self.assertXMLEqual(
         extract_device_snippet(
             'disk',
             dom=dom),
         read_data('disk_updated_snippet.xml')
     )
示例#25
0
    def test_replace_device_xml_with_hook_xml_no_custom(self):
        """
        Don't replace devices if they lack custom properties
        """
        dom = xmlutils.fromstring(read_data('domain_disk_file.xml'))

        with MonkeyPatchScope([
            (hooks, 'before_device_create', self._hook),
        ]):
            domxml_preprocess.replace_device_xml_with_hooks_xml(
                dom, 'test', {})

        self.assertEqual(self._hook_params, [])
示例#26
0
 def _make_env(self):
     dom_disk_file_str = read_data('domain_disk_file.xml')
     dom = xmlutils.fromstring(dom_disk_file_str)
     # taken from domain_disk_file.xml
     disk_meta = {
         'domainID': 'f3f6e278-47a1-4048-b9a5-0cf4d6ba455f',
         'imageID': 'c9865ca8-f6d2-4363-bec2-af870a87a819',
         'poolID': '59c4c3ee-0205-0227-0229-000000000155',
         'volumeID': '1dfad482-c65c-436c-aa59-87e020b63302',
     }
     disk_path = (
         '/rhev/data-center/mnt/blockSD/'
         'a67a8671-05fc-4e42-b147-f7d3a0496cd6/images/'
         'b07a37de-95d6-4682-84cd-c8c9201327e3/'
         'b3335e60-6d27-46e0-bed8-50e75cca6786'
     )
     disk_xml = u'''<disk type='block' device='disk' snapshot='no'>
         <driver name='qemu' type='qcow2' cache='none'
             error_policy='stop' io='native'/>
         <source dev='{path}'/>
       <backingStore/>
       <target dev='sda' bus='scsi'/>
       <serial>b07a37de-95d6-4682-84cd-c8c9201327e3</serial>
       <boot order='1'/>
       <alias name='scsi0-0-0-0'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>'''.format(path=disk_path)
     disk_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(disk_xml), disk_meta
     )
     cdrom_xml = u'''<disk device="cdrom" type="file">
         <driver error_policy="report" name="qemu" type="raw" />
         <source startupPolicy="optional" />
         <backingStore />
         <target bus="ide" dev="hdc" />
         <readonly />
         <alias name="ide0-1-0" />
         <address bus="1" controller="0" target="0"
             type="drive" unit="0" />
     </disk>'''
     cdrom_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(cdrom_xml), {}
     )
     disk_devs = [
         vmdevices.storage.Drive(self.log, **cdrom_params),
         vmdevices.storage.Drive(self.log, **disk_params)
     ]
     return dom, disk_devs
示例#27
0
 def _make_env(self):
     dom_disk_file_str = read_data('domain_disk_file.xml')
     dom = xmlutils.fromstring(dom_disk_file_str)
     # taken from domain_disk_file.xml
     disk_meta = {
         'domainID': 'f3f6e278-47a1-4048-b9a5-0cf4d6ba455f',
         'imageID': 'c9865ca8-f6d2-4363-bec2-af870a87a819',
         'poolID': '59c4c3ee-0205-0227-0229-000000000155',
         'volumeID': '1dfad482-c65c-436c-aa59-87e020b63302',
     }
     disk_path = (
         '/rhev/data-center/mnt/blockSD/'
         'a67a8671-05fc-4e42-b147-f7d3a0496cd6/images/'
         'b07a37de-95d6-4682-84cd-c8c9201327e3/'
         'b3335e60-6d27-46e0-bed8-50e75cca6786'
     )
     disk_xml = u'''<disk type='block' device='disk' snapshot='no'>
         <driver name='qemu' type='qcow2' cache='none'
             error_policy='stop' io='native'/>
         <source dev='{path}'/>
       <backingStore/>
       <target dev='sda' bus='scsi'/>
       <serial>b07a37de-95d6-4682-84cd-c8c9201327e3</serial>
       <boot order='1'/>
       <alias name='scsi0-0-0-0'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>'''.format(path=disk_path)
     disk_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(disk_xml), disk_meta
     )
     cdrom_xml = u'''<disk device="cdrom" type="file">
         <driver error_policy="report" name="qemu" type="raw" />
         <source startupPolicy="optional" />
         <backingStore />
         <target bus="ide" dev="hdc" />
         <readonly />
         <alias name="ide0-1-0" />
         <address bus="1" controller="0" target="0"
             type="drive" unit="0" />
     </disk>'''
     cdrom_params = vmdevices.storagexml.parse(
         xmlutils.fromstring(cdrom_xml), {}
     )
     disk_devs = [
         vmdevices.storage.Drive(self.log, **cdrom_params),
         vmdevices.storage.Drive(self.log, **disk_params)
     ]
     return dom, disk_devs
示例#28
0
    def setUp(self):
        self.vm = FakeVM(self.log)
        self.cif = fake.ClientIF()
        self.xml_str = read_data('hostedengine_lease.xml')
        self.dom = xmlutils.fromstring(self.xml_str)
        self.disk_devs = domxml_preprocess._make_disk_devices(
            self.xml_str, self.log)

        self.driveVolInfo = {
            'leasePath': '/fake/drive/lease/path',
            'leaseOffset': 42,
        }
        self.vmVolInfo = {
            # from XML
            'leasePath': 'LEASE-PATH:'
                         '9eaa286e-37d6-429e-a46b-63bec1dd4868:'
                         '4f0a775f-ed16-4832-ab9f-f0427f33ab92',
            'leaseOffset': 'LEASE-OFFSET:'
                           '9eaa286e-37d6-429e-a46b-63bec1dd4868:'
                           '4f0a775f-ed16-4832-ab9f-f0427f33ab92',
        }
示例#29
0
    def setUp(self):
        self.vm = FakeVM(self.log)
        self.cif = fake.ClientIF()
        self.xml_str = read_data('hostedengine_lease.xml')
        self.dom = xmlutils.fromstring(self.xml_str)
        self.disk_devs = domxml_preprocess._make_disk_devices(
            self.xml_str, self.log)

        self.driveVolInfo = {
            'leasePath': '/fake/drive/lease/path',
            'leaseOffset': 42,
        }
        self.vmVolInfo = {
            # from XML
            'leasePath': 'LEASE-PATH:'
                         '9eaa286e-37d6-429e-a46b-63bec1dd4868:'
                         '4f0a775f-ed16-4832-ab9f-f0427f33ab92',
            'leaseOffset': 'LEASE-OFFSET:'
                           '9eaa286e-37d6-429e-a46b-63bec1dd4868:'
                           '4f0a775f-ed16-4832-ab9f-f0427f33ab92',
        }
示例#30
0
 def test_vm_compat_41(self):
     dom_xml = read_data('vm_compat41.xml')
     conf = libvirtxml.parse_domain(dom_xml, cpuarch.X86_64)
     self.assertEqual(int(conf['smp']), 2)
示例#31
0
 def test_overall_timeout(self):
     with fake.VM(xmldevices=read_data('disk_devices.xml')) as testvm:
         timeout = testvm._migration_destination_prepare_timeout()
         assert timeout == 46.0
示例#32
0
 def test_hosted_engine_42(self):
     dom_xml = read_data('vm_hosted_engine_42.xml')
     conf = libvirtxml.parse_domain(dom_xml, cpuarch.X86_64)
     self.assertEqual(int(conf['smp']), 2)
示例#33
0
 def __init__(self, name):
     self.values = yaml.safe_load(
         read_data(os.path.join(name, "values.yml")))
     self.xmls = read_files(os.path.join(name, '*.xml'))
示例#34
0
 def testHasSpiceEngineXML(self):
     conf = {}
     conf.update(self.conf)
     conf['xml'] = read_data('domain.xml')
     with fake.VM(conf) as testvm:
         self.assertTrue(testvm.hasSpice)
示例#35
0
 def test_disk_timeout_needed(self):
     with fake.VM(xmldevices=read_data('disk_devices.xml')) as testvm:
         timeout = testvm._disk_preparation_timeout()
         assert timeout == 10.0