'Make a base file for testing.'

@contextlib.contextmanager
def _make_base_file(self, lock=True, info=False):

    with utils.tempdir() as tmpdir:
        self.flags(instances_path=tmpdir)
        self.flags(image_info_filename_pattern='$instances_path/%(image)s.info', group='libvirt')
        fname = os.path.join(tmpdir, 'aaa')
        base_file = open(fname, 'w')
        base_file.write('data')
        base_file.close()
        if lock:
            lockdir = os.path.join(tmpdir, 'locks')
            lockname = os.path.join(lockdir, 'nova-aaa')
            os.mkdir(lockdir)
            lock_file = open(lockname, 'w')
            lock_file.write('data')
            lock_file.close()
        base_file = open(fname, 'r')
        if info:
            open(imagecache.get_info_filename(fname), 'w').close()
        base_file.close()
        (yield fname)
