'returns a DiskFile'

def _get_open_disk_file(self, invalid_type=None, obj_name='o', fsize=1024, csize=8, mark_deleted=False, prealloc=False, ts=None, mount_check=False, extra_metadata=None, policy=None, frag_index=None, data=None, commit=True):

    policy = (policy or POLICIES.legacy)
    df = self._simple_get_diskfile(obj=obj_name, policy=policy, frag_index=frag_index)
    data = (data or ('0' * fsize))
    if (policy.policy_type == EC_POLICY):
        archives = encode_frag_archive_bodies(policy, data)
        try:
            data = archives[df._frag_index]
        except IndexError:
            data = archives[0]
    etag = md5()
    if ts:
        timestamp = Timestamp(ts)
    else:
        timestamp = Timestamp.now()
    if prealloc:
        prealloc_size = fsize
    else:
        prealloc_size = None
    with df.create(size=prealloc_size) as writer:
        upload_size = writer.write(data)
        etag.update(data)
        etag = etag.hexdigest()
        metadata = {'ETag': etag, 'X-Timestamp': timestamp.internal, 'Content-Length': str(upload_size)}
        metadata.update((extra_metadata or {}))
        writer.put(metadata)
        if (invalid_type == 'ETag'):
            etag = md5()
            etag.update(('1' + ('0' * (fsize - 1))))
            etag = etag.hexdigest()
            metadata['ETag'] = etag
            diskfile.write_metadata(writer._fd, metadata)
        elif (invalid_type == 'Content-Length'):
            metadata['Content-Length'] = (fsize - 1)
            diskfile.write_metadata(writer._fd, metadata)
        elif (invalid_type == 'Bad-Content-Length'):
            metadata['Content-Length'] = 'zero'
            diskfile.write_metadata(writer._fd, metadata)
        elif (invalid_type == 'Missing-Content-Length'):
            del metadata['Content-Length']
            diskfile.write_metadata(writer._fd, metadata)
        elif (invalid_type == 'Bad-X-Delete-At'):
            metadata['X-Delete-At'] = 'bad    integer'
            diskfile.write_metadata(writer._fd, metadata)
        if commit:
            writer.commit(timestamp)
    if mark_deleted:
        df.delete(timestamp)
    data_files = [os.path.join(df._datadir, fname) for fname in sorted(os.listdir(df._datadir), reverse=True) if fname.endswith('.data')]
    if (invalid_type == 'Corrupt-Xattrs'):
        meta_xattr = xattr.getxattr(data_files[0], 'user.swift.metadata')
        wrong_byte = ('X' if (meta_xattr[0] != 'X') else 'Y')
        xattr.setxattr(data_files[0], 'user.swift.metadata', (wrong_byte + meta_xattr[1:]))
    elif (invalid_type == 'Truncated-Xattrs'):
        meta_xattr = xattr.getxattr(data_files[0], 'user.swift.metadata')
        xattr.setxattr(data_files[0], 'user.swift.metadata', meta_xattr[:(-1)])
    elif (invalid_type == 'Missing-Name'):
        md = diskfile.read_metadata(data_files[0])
        del md['name']
        diskfile.write_metadata(data_files[0], md)
    elif (invalid_type == 'Bad-Name'):
        md = diskfile.read_metadata(data_files[0])
        md['name'] = (md['name'] + 'garbage')
        diskfile.write_metadata(data_files[0], md)
    self.conf['disk_chunk_size'] = csize
    self.conf['mount_check'] = mount_check
    self.df_mgr = self.mgr_cls(self.conf, self.logger)
    self.df_router = diskfile.DiskFileRouter(self.conf, self.logger)
    frag_index = metadata.get('X-Object-Sysmeta-Ec-Frag-Index', frag_index)
    df = self._simple_get_diskfile(obj=obj_name, policy=policy, frag_index=frag_index)
    df.open()
    if (invalid_type == 'Zero-Byte'):
        fp = open(df._data_file, 'w')
        fp.close()
    df.unit_test_len = fsize
    return df
