Beispiel #1
0
def delete_object_config(obj_type, obj_id):
    before_metasection, metasection, after_metasection = extract_config_sections(
    )

    metasection = remove_object_from_metasection(metasection, obj_type, obj_id)

    merge_config_sections(before_metasection, metasection, after_metasection)
Beispiel #2
0
def delete_transient_object_configs():
    before_metasection, metasection, after_metasection = extract_config_sections(
    )

    new_metasection = remove_transient_conflines_from_metasection(metasection)

    merge_config_sections(before_metasection, new_metasection,
                          after_metasection)
Beispiel #3
0
def add_object_config(obj_type, obj):

     before_metasection, metasection, after_metasection = extract_config_sections()

     metasection, obj_id = update_metasection_with_new_object(metasection, obj_type, obj)

     merge_config_sections(before_metasection, metasection, after_metasection)

     return obj_id
Beispiel #4
0
def add_object_config(obj_type, obj):

    before_metasection, metasection, after_metasection = extract_config_sections(
    )

    metasection, obj_id = update_metasection_with_new_object(
        metasection, obj_type, obj)

    merge_config_sections(before_metasection, metasection, after_metasection)

    return obj_id
Beispiel #5
0
def get_objects_config(obj_type):
     before_metasection, metasection, after_metasection = extract_config_sections()

     matching_lines = retrieve_conflines_from_metasection(metasection, obj_type)

     obj_list = []

     for confline in matching_lines:
         obj = _convert_string_to_obj(confline)

         obj[ID_META_FIELD] = confline[ID_META_FIELD]
         obj_list.append(obj)

     return obj_list
Beispiel #6
0
def get_objects_config(obj_type):
    before_metasection, metasection, after_metasection = extract_config_sections(
    )

    matching_lines = retrieve_conflines_from_metasection(metasection, obj_type)

    obj_list = []

    for confline in matching_lines:
        obj = _convert_string_to_obj(confline)

        obj[ID_META_FIELD] = confline[ID_META_FIELD]
        obj_list.append(obj)

    return obj_list
Beispiel #7
0
def update_object_config(obj_type, obj_id, current_obj, obj_updates):
    # Before merging current state with new state, remove any 
    # meta-attributes added during get_object_config()
    if TRANSIENT_META_FIELD in current_obj:
        del current_obj[TRANSIENT_META_FIELD]

    updated_obj = _merge_updates_into_new_obj(current_obj, obj_updates)

    before_metasection, metasection, after_metasection = extract_config_sections()

    updated_obj_str = _convert_obj_to_string(obj_type, obj_id, updated_obj)

    metasection = update_metasection_with_updated_object(metasection, obj_type, obj_id, updated_obj_str)

    merge_config_sections(before_metasection, metasection, after_metasection)

    return updated_obj
Beispiel #8
0
def get_object_config(obj_type, obj_id):
    before_metasection, metasection, after_metasection = extract_config_sections()

    matching_line = retrieve_confline_from_metasection(metasection, obj_type, obj_id)

    if obj_id and not matching_line:
        error = "Cannot find a %s object  with id %s in the stored configuration" % (obj_type, str(obj_id))
        errors = [error]
        raise ResourceException(errors, 400)

    if matching_line:
        obj = _convert_string_to_obj(matching_line)

        if not obj_id:
            obj[ID_META_FIELD] = matching_line[ID_META_FIELD]

        return obj

    return None
Beispiel #9
0
def update_object_config(obj_type, obj_id, current_obj, obj_updates):
    # Before merging current state with new state, remove any
    # meta-attributes added during get_object_config()
    if TRANSIENT_META_FIELD in current_obj:
        del current_obj[TRANSIENT_META_FIELD]

    updated_obj = _merge_updates_into_new_obj(current_obj, obj_updates)

    before_metasection, metasection, after_metasection = extract_config_sections(
    )

    updated_obj_str = _convert_obj_to_string(obj_type, obj_id, updated_obj)

    metasection = update_metasection_with_updated_object(
        metasection, obj_type, obj_id, updated_obj_str)

    merge_config_sections(before_metasection, metasection, after_metasection)

    return updated_obj
Beispiel #10
0
def get_object_config(obj_type, obj_id):
    before_metasection, metasection, after_metasection = extract_config_sections(
    )

    matching_line = retrieve_confline_from_metasection(metasection, obj_type,
                                                       obj_id)

    if obj_id and not matching_line:
        error = "Cannot find a %s object  with id %s in the stored configuration" % (
            obj_type, str(obj_id))
        errors = [error]
        raise ResourceException(errors, 400)

    if matching_line:
        obj = _convert_string_to_obj(matching_line)

        if not obj_id:
            obj[ID_META_FIELD] = matching_line[ID_META_FIELD]

        return obj

    return None
Beispiel #11
0
def delete_transient_object_configs():
    before_metasection, metasection, after_metasection = extract_config_sections()
    
    new_metasection = remove_transient_conflines_from_metasection(metasection)
    
    merge_config_sections(before_metasection, new_metasection, after_metasection)
Beispiel #12
0
def delete_object_config(obj_type, obj_id):
     before_metasection, metasection, after_metasection = extract_config_sections()

     metasection = remove_object_from_metasection(metasection, obj_type, obj_id)
     
     merge_config_sections(before_metasection, metasection, after_metasection)