Example #1
0
def create_buf_profile(xnode_profile, ingress_pool_id, egress_pool_id):
    attrs = copy.deepcopy(xnode_profile.attrib)
    if "-egr-" in attrs['name']:
        pool_id = egress_pool_id
    else:
        pool_id = ingress_pool_id

    list_of_attrs_in_kb = {'buffer-size', 'shared-static-threshold',
                           'shared-dynamic-threshold', 'xoff-threshold', 'xon-threshold'}
    for key in attrs:
        if key in list_of_attrs_in_kb:
            if attrs[key] != '0':
                attrs[key] = attrs[key] + '000'

    attrs.update({'pool-id': pool_id})
    buf_prof_obj = nas_qos.BufferProfileCPSObj(map_of_attr=attrs)
    upd = ('create', buf_prof_obj.data())
    ret_cps_data = cps_utils.CPSTransaction([upd]).commit()

    if ret_cps_data == False:
        raise RuntimeError(
            'Buffer profile {0} creation failed'.format(xnode_profile.attrib['name']))

    buf_prof_obj = nas_qos.BufferProfileCPSObj(cps_data=ret_cps_data[0])
    buf_prof_id = buf_prof_obj.extract_id()
    dbg_print(' Buffer profile {0} = {1}'.format(
        xnode_profile.attrib['name'], buf_prof_id))

    return buf_prof_id
Example #2
0
def buffer_profile_create_example(pool_id, pool_type = 'INGRESS'):
    if (pool_type == 'EGRESS'):
        attr_list = {
            'pool-id': pool_id,
            'buffer-size': 2000,
            'threshold-mode': 'DYNAMIC',
            'shared-dynamic-threshold': 0,
            'name': 'default-egress-buffer-profile',
        }
    else :
        attr_list = {
            'pool-id': pool_id,
            'buffer-size': 2000,
            'threshold-mode': 'STATIC',
            'shared-static-threshold': 500,
            'xoff-threshold': 1000,
            'xon-threshold':  5000,
            'name': 'default-ingress-buffer-profile',
        }

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

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

    print 'Return = ', ret_cps_data
    buffer_profile_obj = nas_qos.BufferProfileCPSObj(cps_data=ret_cps_data[0])
    buffer_profile_id = buffer_profile_obj.extract_attr('id')
    print "Successfully installed buffer profile id = ", buffer_profile_id

    return buffer_profile_id
Example #3
0
def buffer_profile_get_example(buffer_profile_id):
    return_data_list = []

    buffer_profile_obj = nas_qos.BufferProfileCPSObj(buffer_profile_id=buffer_profile_id)
    ret = cps.get([buffer_profile_obj.data()], return_data_list)

    if ret:
        print '#### buffer profile Profile Show ####'
        for cps_ret_data in return_data_list:
            m = nas_qos.BufferProfileCPSObj(cps_data=cps_ret_data)
            m.print_obj()
    else:
        print 'Error in get'
Example #4
0
def read_current_buf_prof(lookup_buf_prof):
    buf_prof_obj = nas_qos.BufferProfileCPSObj(buffer_profile_id=0)
    ret_list = []
    ret = cps.get([buf_prof_obj.data()], ret_list)

    if ret:
        for cps_ret_data in ret_list:
            m = nas_qos.BufferProfileCPSObj(cps_data=cps_ret_data)
            if (dbg_on):
                m.print_obj()
            bp_name = m.extract_attr('name')
            bp_id = m.extract_attr('id')
            if (bp_name):
                lookup_buf_prof[bp_name] = bp_id;
    else:
        syslog.syslog('Error in get buffer profiles')
Example #5
0
def buffer_profile_modify_attrs(buffer_profile_id, mod_attr_list):
    buffer_profile_obj = nas_qos.BufferProfileCPSObj(buffer_profile_id=buffer_profile_id)
    for attr in mod_attr_list:
        buffer_profile_obj.set_attr(attr[0], attr[1])

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

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

    print 'Return = ', ret_cps_data
    buffer_profile_obj = nas_qos.BufferProfileCPSObj(cps_data=ret_cps_data[0])
    buffer_profile_id = buffer_profile_obj.extract_attr('id')
    print "Successfully modified buffer profile id = ", buffer_profile_id

    return buffer_profile_id
Example #6
0
def buffer_profile_delete_example(buffer_profile_id):
    buffer_profile_obj = nas_qos.BufferProfileCPSObj(buffer_profile_id=buffer_profile_id)
    upd = ('delete', buffer_profile_obj.data())
    ret_cps_data = cps_utils.CPSTransaction([upd]).commit()

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

    print 'Return = ', ret_cps_data
    print "Successfully deleted buffer profile id = ", buffer_profile_id