Пример #1
0
def acl_ut_entry_create(table_id, prio=None, counter_id=None):
    global total, passed
    total.append(sys._getframe().f_code.co_name)
    filters = {
        'SRC_IP': {'addr': '23.0.0.1', 'mask': '255.0.0.255'},
        'SRC_MAC': '01:80:c2:00:00:05',
        'IPV6_FLOW_LABEL': 34456,
        'TCP_FLAGS': {'data': '0x17', 'mask': '0x3f'},
        'ECN': {'data': '0x2', 'mask': '0x2'},
        'IP_TYPE': 'IP',
        'IN_PORTS': [a_utl.get_if_name(2), a_utl.get_if_name(3)],
    }

    actions = {
        'SET_SRC_MAC': '01:00:79:08:78:BC',
        'PACKET_ACTION': 'COPY_TO_CPU',
        'REDIRECT_PORT': a_utl.get_if_name(4),
    }
    if (counter_id):
        actions['SET_COUNTER'] = counter_id

    global meter_id
    try:
        meter_id, meter_opaque = a_utl.qos_meter_create(
            m_type='BYTE', cir=300000,
            cbs=800000, pbs=900000)
    except:
        print "Meter install Failed"
        return

    actions['SET_POLICER'] = {'index': meter_id, 'data': meter_opaque}

    global mirror_id_1, mir_opq_1
    global mirror_id_2, mir_opq_2
    try:
        mirror_id_1, mir_opq_1 = a_utl.mirror_create(13)
        mirror_id_2, mir_opq_2 = a_utl.mirror_create(16)
    except:
        print "Mirror Create Failed"
        return

    actions['MIRROR_INGRESS'] = [{'index': mirror_id_1, 'data': mir_opq_1},
                                 {'index': mirror_id_2, 'data': mir_opq_2}]

    try:
        entry_id = nas_acl.create_entry(table_id=table_id, prio=prio,
                                        filter_map=filters, action_map=actions)
    except RuntimeError:
        print (sys._getframe().f_code.co_name + " - Error creating Entry")
        return None

    print (sys._getframe().f_code.co_name +
           " - Created Entry " + str(entry_id))
    raw_input("Check entry is created and Press Enter to continue...")
    passed.append(sys._getframe().f_code.co_name)
    return entry_id
Пример #2
0
def acl_ut_entry_create(table_id, prio=None, counter_id=None):
    global total, passed
    total.append(sys._getframe().f_code.co_name)
    filters = {
        'SRC_IP': {'addr': '23.0.0.1', 'mask': '255.0.0.255'},
        'SRC_MAC': '01:80:c2:00:00:05',
        'IPV6_FLOW_LABEL': 34456,
        'TCP_FLAGS': {'data': '0x17', 'mask': '0x3f'},
        'ECN': {'data': '0x2', 'mask': '0x2'},
        'IP_TYPE': 'IP',
        'IN_PORTS': [a_utl.get_if_name(2), a_utl.get_if_name(3)],
    }

    actions = {
        'SET_SRC_MAC': '01:00:79:08:78:BC',
        'PACKET_ACTION': 'COPY_TO_CPU',
        'REDIRECT_PORT': a_utl.get_if_name(4),
    }
    if (counter_id):
        actions['SET_COUNTER'] = counter_id

    global meter_id
    try:
        meter_id, meter_opaque = a_utl.qos_meter_create(
            m_type='BYTE', cir=300000,
            cbs=800000, pbs=900000)
    except:
        print "Meter install Failed"
        return

    actions['SET_POLICER'] = {'index': meter_id, 'data': meter_opaque}

    global mirror_id_1, mir_opq_1
    global mirror_id_2, mir_opq_2
    try:
        mirror_id_1, mir_opq_1 = a_utl.mirror_create(13)
        mirror_id_2, mir_opq_2 = a_utl.mirror_create(16)
    except:
        print "Mirror Create Failed"
        return

    actions['MIRROR_INGRESS'] = [{'index': mirror_id_1, 'data': mir_opq_1},
                                 {'index': mirror_id_2, 'data': mir_opq_2}]

    try:
        entry_id = nas_acl.create_entry(table_id=table_id, prio=prio,
                                        filter_map=filters, action_map=actions)
    except RuntimeError:
        print (sys._getframe().f_code.co_name + " - Error creating Entry")
        return None

    print (sys._getframe().f_code.co_name +
           " - Created Entry " + str(entry_id))
    raw_input("Check entry is created and Press Enter to continue...")
    passed.append(sys._getframe().f_code.co_name)
    return entry_id
Пример #3
0
def acl_ut_entry_incr_modify(table_id, entry_id):
    global total, passed
    total.append(sys._getframe().f_code.co_name)

    # Transaction with multiple updates
    upd = []
    # First add DSCP filter
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        filter_type='DSCP')
    e.set_filter_val({'data': '0x37'})
    upd.append(('create', e.data()))

    # Modify counter - use another counter object
    new_counter_id = acl_ut_counter_create(table_id, ['BYTE'])
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        action_type='SET_COUNTER')
    e.set_action_val(new_counter_id)
    upd.append(('set', e.data()))

    # Delete IP Type filter
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        filter_type='IP_TYPE')
    upd.append(('delete', e.data()))

    # Add mirror action
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        action_type='MIRROR_INGRESS')
    e.set_action_val(
        [{'index': mirror_id_1,
          'data': mir_opq_1},
         {'index': mirror_id_2,
          'data': mir_opq_2}])
    upd.append(('create', e.data()))

    # Change meter
    try:
        new_meter_id, meter_opaque = a_utl.qos_meter_create(
            m_type='BYTE', pir=40000,
            cir=35000, cbs=85000, pbs=95000)
    except:
        print "Meter install Failed"
        return

    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        action_type='SET_POLICER')
    e.set_action_val({'index': new_meter_id, 'data': meter_opaque})
    upd.append(('set', e.data()))

    print upd
    r = cps_utils.CPSTransaction(upd).commit()
    if r == False:
        print sys._getframe().f_code.co_name + " - Error modifying Entry"
        return None

    global meter_id
    a_utl.qos_meter_delete(meter_id)
    meter_id = new_meter_id

    raw_input(
        "Check entry is modified (New DSCP, Changed Policer,Counter and Removed IPType - Press Enter to continue...")
    passed.append(sys._getframe().f_code.co_name)
    return new_counter_id
Пример #4
0
def acl_ut_entry_incr_modify(table_id, entry_id):
    global total, passed
    total.append(sys._getframe().f_code.co_name)

    # Transaction with multiple updates
    upd = []
    # First add DSCP filter
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        filter_type='DSCP')
    e.set_filter_val({'data': '0x37'})
    upd.append(('create', e.data()))

    # Modify counter - use another counter object
    new_counter_id = acl_ut_counter_create(table_id, ['BYTE'])
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        action_type='SET_COUNTER')
    e.set_action_val(new_counter_id)
    upd.append(('set', e.data()))

    # Delete IP Type filter
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        filter_type='IP_TYPE')
    upd.append(('delete', e.data()))

    # Add mirror action
    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        action_type='MIRROR_INGRESS')
    e.set_action_val(
        [{'index': mirror_id_1,
          'data': mir_opq_1},
         {'index': mirror_id_2,
          'data': mir_opq_2}])
    upd.append(('create', e.data()))

    # Change meter
    try:
        new_meter_id, meter_opaque = a_utl.qos_meter_create(
            m_type='BYTE', pir=40000,
            cir=35000, cbs=85000, pbs=95000)
    except:
        print "Meter install Failed"
        return

    e = nas_acl.EntryCPSObj(
        table_id=table_id,
        entry_id=entry_id,
        action_type='SET_POLICER')
    e.set_action_val({'index': new_meter_id, 'data': meter_opaque})
    upd.append(('set', e.data()))

    print upd
    r = cps_utils.CPSTransaction(upd).commit()
    if r == False:
        print sys._getframe().f_code.co_name + " - Error modifying Entry"
        return None

    global meter_id
    a_utl.qos_meter_delete(meter_id)
    meter_id = new_meter_id

    raw_input(
        "Check entry is modified (New DSCP, Changed Policer,Counter and Removed IPType - Press Enter to continue...")
    passed.append(sys._getframe().f_code.co_name)
    return new_counter_id