Beispiel #1
0
def fetch_desired_state(oc_map):
    desired_state = []
    flat_rolebindings_desired_state = \
        openshift_rolebindings.fetch_desired_state(ri=None, oc_map=oc_map)
    desired_state.extend(flat_rolebindings_desired_state)

    groups_desired_state = openshift_groups.fetch_desired_state(oc_map)
    flat_groups_desired_state = \
        [{'cluster': s['cluster'], 'user': s['user']}
         for s in groups_desired_state]
    desired_state.extend(flat_groups_desired_state)

    return desired_state
Beispiel #2
0
def run(dry_run=False, thread_pool_size=10):
    ocm_map, current_state = fetch_current_state(thread_pool_size)
    desired_state = openshift_groups.fetch_desired_state(oc_map=ocm_map)

    diffs = openshift_groups.calculate_diff(current_state, desired_state)
    validate_diffs(diffs)
    openshift_groups.validate_diffs(diffs)

    for diff in diffs:
        logging.info(list(diff.values()))

        if not dry_run:
            act(diff, ocm_map)
Beispiel #3
0
def fetch_desired_state(oc_map):
    desired_state = []
    flat_rolebindings_desired_state = openshift_rolebindings.fetch_desired_state(
        ri=None, oc_map=oc_map
    )
    desired_state.extend(flat_rolebindings_desired_state)

    groups_desired_state = openshift_groups.fetch_desired_state(oc_map)
    flat_groups_desired_state = [
        {"cluster": s["cluster"], "user": s["user"]} for s in groups_desired_state
    ]
    desired_state.extend(flat_groups_desired_state)

    return desired_state
def run(dry_run, thread_pool_size=10):
    ocm_map, current_state = fetch_current_state(thread_pool_size)
    desired_state = openshift_groups.fetch_desired_state(oc_map=ocm_map)

    # we only manage dedicated-admins via OCM
    current_state = [s for s in current_state
                     if s['group'] == 'dedicated-admins']
    desired_state = [s for s in desired_state
                     if s['group'] == 'dedicated-admins']

    diffs = openshift_groups.calculate_diff(current_state, desired_state)
    openshift_groups.validate_diffs(diffs)

    for diff in diffs:
        # we do not need to create/delete groups in OCM
        if diff['action'] in ['create_group', 'delete_group']:
            continue
        logging.info(list(diff.values()))

        if not dry_run:
            act(diff, ocm_map)