def modify_api_levels(level_list, remove, ensure, msg_prepend='',
                      msg_append=''):
    changed = False
    changes = []

    if not isinstance(remove, list):
        remove = []

    if not isinstance(ensure, list):
        ensure = []

    if not isinstance(level_list, list):
        new_list = []
        changed = True
        changes.append("%s created missing %s" % (msg_prepend, msg_append))
    else:
        new_list = level_list
        for level in remove:
            if level in new_list:
                new_list.remove(level)
                changed = True
                changes.append("%s removed %s %s" % (msg_prepend, level, msg_append))

    for level in ensure:
        if level not in new_list:
            new_list.append(level)
            changed = True
            changes.append("%s added %s %s" % (msg_prepend, level, msg_append))

    return {'new_list': new_list, 'changed': changed, 'changes': changes}
modify_api_levels
dataset/ETHPy150Open openshift/openshift-ansible/playbooks/common/openshift-cluster/upgrades/library/openshift_upgrade_config.py/modify_api_levels