'Delete a GPFS file and cleanup clone children.'

def _delete_gpfs_file(self, fchild, mount_point=None):

    if (mount_point is None):
        if (not os.path.exists(fchild)):
            return
    else:
        fchild_local_path = os.path.join(mount_point, os.path.basename(fchild))
        if (not os.path.exists(fchild_local_path)):
            return
    (out, err) = self.gpfs_execute((self.GPFS_PATH + 'mmclone'), 'show', fchild)
    fparent = None
    delete_parent = False
    inode_regex = re.compile('.*\\s+(?:yes|no)\\s+\\d+\\s+(?P<inode>\\d+)', (re.M | re.S))
    match = inode_regex.match(out)
    if match:
        inode = match.group('inode')
        if (mount_point is None):
            path = os.path.dirname(fchild)
        else:
            path = mount_point
        (out, err) = self._execute('find', path, '-maxdepth', '1', '-ignore_readdir_race', '-inum', inode, '-print0', '-quit', run_as_root=True)
        if out:
            fparent = out.split('\x00', 1)[0]
    if (mount_point is None):
        self._execute('rm', '-f', fchild, check_exit_code=False, run_as_root=True)
    else:
        self._execute('rm', '-f', fchild_local_path, check_exit_code=False, run_as_root=True)
    if (mount_point is None):
        if ((not os.path.exists(fchild)) and fparent):
            delete_parent = True
    elif ((not os.path.exists(fchild_local_path)) and fparent):
        delete_parent = True
    if delete_parent:
        fpbase = os.path.basename(fparent)
        if (fpbase.endswith('.snap') or fpbase.endswith('.ts')):
            if (mount_point is None):
                self._delete_gpfs_file(fparent)
            else:
                fparent_remote_path = os.path.join(os.path.dirname(fchild), fpbase)
                fparent_mount_path = os.path.dirname(fparent)
                self._delete_gpfs_file(fparent_remote_path, fparent_mount_path)
