def test_block(self): drive = Drive(self.log, **self.conf) drive._blockDev = True expected = """ <disk name='vda' snapshot='external' type='block'> <source dev='/dev/dm-1' type='block'/> </disk> """ snap_info = {'path': '/dev/dm-1', 'device': 'disk'} actual = drive.get_snapshot_xml(snap_info) self.assertXMLEqual(vmxml.format_xml(actual), expected)
def make_env(self): with namedTemporaryDir() as tmpdir: """ Below we imitate that behaviour by providing two different directories under /rhv/data-center root and one of those directories is a symlink to another one. We fill VolumeChain with real directory and use symlinked directory in XML, emulating libvirt reply. """ dc_base = os.path.join(tmpdir, "dc") run_base = os.path.join(tmpdir, "run") images_path = os.path.join(dc_base, "images") os.makedirs(images_path) os.symlink(dc_base, run_base) dc_top_vol = os.path.join( images_path, "11111111-1111-1111-1111-111111111111") dc_base_vol = os.path.join( images_path, "22222222-2222-2222-2222-222222222222") make_file(dc_top_vol) make_file(dc_base_vol) run_top_vol = os.path.join( run_base, "images", "11111111-1111-1111-1111-111111111111") run_base_vol = os.path.join( run_base, "images", "22222222-2222-2222-2222-222222222222") volume_chain = [ {'path': dc_top_vol, 'volumeID': '11111111-1111-1111-1111-111111111111'}, {'path': dc_base_vol, 'volumeID': '22222222-2222-2222-2222-222222222222'} ] conf = drive_config(volumeChain=volume_chain) drive = Drive(self.log, **conf) drive._blockDev = True yield VolumeChainEnv( drive, run_top_vol, run_base_vol )
def make_env(self): with namedTemporaryDir() as tmpdir: """ Below we imitate that behaviour by providing two different directories under /rhv/data-center root and one of those directories is a symlink to another one. We fill VolumeChain with real directory and use symlinked directory in XML, emulating libvirt reply. """ dc_base = os.path.join(tmpdir, "dc") run_base = os.path.join(tmpdir, "run") images_path = os.path.join(dc_base, "images") os.makedirs(images_path) os.symlink(dc_base, run_base) dc_top_vol = os.path.join(images_path, "11111111-1111-1111-1111-111111111111") dc_base_vol = os.path.join(images_path, "22222222-2222-2222-2222-222222222222") make_file(dc_top_vol) make_file(dc_base_vol) run_top_vol = os.path.join(run_base, "images", "11111111-1111-1111-1111-111111111111") run_base_vol = os.path.join( run_base, "images", "22222222-2222-2222-2222-222222222222") volume_chain = [{ 'path': dc_top_vol, 'volumeID': '11111111-1111-1111-1111-111111111111' }, { 'path': dc_base_vol, 'volumeID': '22222222-2222-2222-2222-222222222222' }] conf = drive_config(volumeChain=volume_chain) drive = Drive(self.log, **conf) drive._blockDev = True yield VolumeChainEnv(drive, run_top_vol, run_base_vol)
def test_replica(self, diskType, format): conf = drive_config(diskReplicate=replica(diskType, format=format)) drive = Drive(self.log, **conf) drive._blockDev = False self.assertEqual(drive.chunked, False)
def test_drive(self, device, blockDev, format, chunked): conf = drive_config(device=device, format=format) drive = Drive(self.log, **conf) drive._blockDev = blockDev self.assertEqual(drive.chunked, chunked)
def check(self, device_conf, xml, is_block_device=False): drive = Drive(self.log, **device_conf) # Patch to skip the block device checking. drive._blockDev = is_block_device self.assertXMLEqual(vmxml.format_xml(drive.getReplicaXML()), xml)