Example #1
0
def wred_profile_create_example():
    attr_list = {
        'green-enable': 1,
        'green-min-threshold': 20,
        'green-max-threshold': 80,
        'green-drop-probability': 10,
        'yellow-enable': 1,
        'yellow-min-threshold': 40,
        'yellow-max-threshold': 60,
        'yellow-drop-probability': 30,
        'weight': 8,
        'ecn-enable': 1,
        'npu-id-list': [0],
    }

    wred_obj = nas_qos.WredCPSObj(map_of_attr=attr_list)
    upd = ('create', wred_obj.data())
    ret_cps_data = cps_utils.CPSTransaction([upd]).commit()

    if ret_cps_data == False:
        print "WRED profile creation failed"
        return None

    print 'Return = ', ret_cps_data
    wred_obj = nas_qos.WredCPSObj(cps_data=ret_cps_data[0])
    wred_id = wred_obj.extract_attr('id')
    print "Successfully installed WRED id = ", wred_id

    return wred_id
Example #2
0
def wred_profile_get_example(wred_id):
    return_data_list = []

    wred_obj = nas_qos.WredCPSObj(wred_id=wred_id)
    ret = cps.get([wred_obj.data()], return_data_list)

    if ret:
        print '#### WRED Profile Show ####'
        for cps_ret_data in return_data_list:
            m = nas_qos.WredCPSObj(cps_data=cps_ret_data)
            m.print_obj()
    else:
        print 'Error in get'
Example #3
0
def wred_profile_modify_attrs(wred_id, mod_attr_list):
    wred_obj = nas_qos.WredCPSObj(wred_id=wred_id)
    for attr in mod_attr_list:
        wred_obj.set_attr(attr[0], attr[1])

    upd = ('set', wred_obj.data())
    ret_cps_data = cps_utils.CPSTransaction([upd]).commit()

    if ret_cps_data == False:
        print "WRED profile modification failed"
        return None

    print 'Return = ', ret_cps_data
    wred_obj = nas_qos.WredCPSObj(cps_data=ret_cps_data[0])
    wred_id = wred_obj.extract_attr('id')
    print "Successfully modified WRED id = ", wred_id

    return wred_id
Example #4
0
def wred_profile_delete_example(wred_id):
    wred_obj = nas_qos.WredCPSObj(wred_id=wred_id)
    upd = ('delete', wred_obj.data())
    ret_cps_data = cps_utils.CPSTransaction([upd]).commit()

    if ret_cps_data == False:
        print "WRED profile delete failed"
        return None

    print 'Return = ', ret_cps_data
    print "Successfully deleted WRED id = ", wred_id