Ejemplo n.º 1
0
def priority_group_get_example(port_id, local_id):
    return_data_list = []

    priority_group_obj = nas_qos.PriorityGroupCPSObj(local_id=local_id,
                                                     port_id=port_id)
    ret = cps.get([priority_group_obj.data()], return_data_list)

    if ret:
        print '#### PG Show ####'
        for cps_ret_data in return_data_list:
            m = nas_qos.PriorityGroupCPSObj(port_id=port_id,
                                            local_id=local_id,
                                            cps_data=cps_ret_data)
            m.print_obj()
    else:
        print "Error in Get"
def priority_group_modify_buffer_profile_example (port_id, local_id, buffer_profile_id):
    m = nas_qos.PriorityGroupCPSObj (local_id=local_id, port_id=port_id)
    m.set_attr ('buffer-profile-id', buffer_profile_id)

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

    if ret_cps_data == False:
        print "PG modify Failed"
        return None

    print 'Return = ', ret_cps_data
    m = nas_qos.PriorityGroupCPSObj(None, None, cps_data=ret_cps_data[0])
    port_id = m.extract_attr('port-id')
    local_id = m.extract_attr('local-id')
    print "Successfully modified PG of Port %d local-id %d" % (port_id, local_id)

    return ret_cps_data
Ejemplo n.º 3
0
def init_pg_on_port(xnode_obj, lookup_buf_prof, ifidx, ifname, iftype, speed):

    local_id = xnode_obj.attrib['local-id']
    if (iftype == 'base-if:cpu'):
        speed_str = 'cpu'
    elif speed == 1000:
        speed_str = '1g'
    elif speed == 10000:
        speed_str = '10g'
    elif speed == 40000:
        speed_str = '40g'
    else:
        speed_str = 'unsupported'
    buffer_profile_name = xnode_obj.attrib['buffer-profile'] + '-ing-' + speed_str
    buffer_profile_id = None
    if (buffer_profile_name in lookup_buf_prof):
        buffer_profile_id = lookup_buf_prof[buffer_profile_name]

    if (dbg_on):
        print "speed: {0}, buffer_profile_id: {1}".format(speed, buffer_profile_id)

    if (buffer_profile_id is None):
        # no matching buffer profile is defined, no configuration
        return

    m = nas_qos.PriorityGroupCPSObj(local_id=local_id, port_id = ifidx)
    m.set_attr('buffer-profile-id', buffer_profile_id)

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

    if ret_cps_data == False:
        syslog.syslog("PG modify Failed for port {0} local_id {1}".format(ifidx, local_id))
        return None

    if (dbg_on):
        print 'Return = ', ret_cps_data
    m = nas_qos.PriorityGroupCPSObj(None, None, cps_data=ret_cps_data[0])
    port_id = m.extract_attr('port-id')
    local_id = m.extract_attr('local-id')
    if (dbg_on):
        print "Successfully modified PG of Port %d local-id %d" % (port_id, local_id)