Commit 5aff102d authored by Georgios Katsikas's avatar Georgios Katsikas
Browse files

Merge branch 'fix/device-p4' into 'develop'

Enable P4 Driver to control multiple switches

See merge request !26
parents feea6f16 7a6a6bad
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4,5 +4,5 @@ export POD_NAME=$(kubectl get pods -n=tfs | grep device | awk '{print $1}')


kubectl exec ${POD_NAME} -n=tfs -- mkdir /root/p4
kubectl exec ${POD_NAME} -n=tfs -- mkdir /root/p4


kubectl cp src/tests/netx22-p4/p4/p4info.txt tfs/${POD_NAME}:/root/p4
kubectl cp hackfest/p4/p4/p4info.txt tfs/${POD_NAME}:/root/p4
kubectl cp src/tests/netx22-p4/p4/bmv2.json tfs/${POD_NAME}:/root/p4
kubectl cp hackfest/p4/p4/bmv2.json tfs/${POD_NAME}:/root/p4
+38 −3
Original line number Original line Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# You may obtain a copy of the License at
@@ -42,6 +43,8 @@ PACKET_PORT_SAMPLE_TYPES = [
    KpiSampleType.KPISAMPLETYPE_BYTES_RECEIVED,
    KpiSampleType.KPISAMPLETYPE_BYTES_RECEIVED,
]
]


# ----- Device Credentials and Settings --------------------------------------------------------------------------------



# ----- Devices --------------------------------------------------------------------------------------------------------
# ----- Devices --------------------------------------------------------------------------------------------------------


@@ -54,7 +57,7 @@ DEVICE_SW1 = json_device_p4_disabled(DEVICE_SW1_UUID)


DEVICE_SW1_DPID             = 1
DEVICE_SW1_DPID             = 1
DEVICE_SW1_NAME             = DEVICE_SW1_UUID
DEVICE_SW1_NAME             = DEVICE_SW1_UUID
DEVICE_SW1_IP_ADDR          = '10.0.2.10'
DEVICE_SW1_IP_ADDR          = 'localhost'
DEVICE_SW1_PORT             = '50001'
DEVICE_SW1_PORT             = '50001'
DEVICE_SW1_VENDOR           = 'Open Networking Foundation'
DEVICE_SW1_VENDOR           = 'Open Networking Foundation'
DEVICE_SW1_HW_VER           = 'BMv2 simple_switch'
DEVICE_SW1_HW_VER           = 'BMv2 simple_switch'
@@ -78,9 +81,38 @@ DEVICE_SW1_CONNECT_RULES = json_device_connect_rules(
    }
    }
)
)


DEVICE_SW2_UUID             = 'SW2'
DEVICE_SW2_TIMEOUT          = 60
DEVICE_SW2_ID               = json_device_id(DEVICE_SW2_UUID)
DEVICE_SW2                  = json_device_p4_disabled(DEVICE_SW2_UUID)


################################## TABLE ENTRIES ##################################
DEVICE_SW2_DPID             = 1
DEVICE_SW2_NAME             = DEVICE_SW2_UUID
DEVICE_SW2_IP_ADDR          = 'localhost'
DEVICE_SW2_PORT             = '50002'
DEVICE_SW2_VENDOR           = 'Open Networking Foundation'
DEVICE_SW2_HW_VER           = 'BMv2 simple_switch'
DEVICE_SW2_SW_VER           = 'Stratum'


DEVICE_SW2_BIN_PATH         = '/root/p4/bmv2.json'
DEVICE_SW2_INFO_PATH        = '/root/p4/p4info.txt'

DEVICE_SW2_CONNECT_RULES    = json_device_connect_rules(
    DEVICE_SW2_IP_ADDR,
    DEVICE_SW2_PORT,
    {
        'id':       DEVICE_SW2_DPID,
        'name':     DEVICE_SW2_NAME,
        'vendor':   DEVICE_SW2_VENDOR,
        'hw_ver':   DEVICE_SW2_HW_VER,
        'sw_ver':   DEVICE_SW2_SW_VER,
        'timeout':  DEVICE_SW2_TIMEOUT,
        'p4bin':    DEVICE_SW2_BIN_PATH,
        'p4info':   DEVICE_SW2_INFO_PATH
    }
)

################################## TABLE ENTRIES ##################################


DEVICE_SW1_CONFIG_TABLE_ENTRIES = [
DEVICE_SW1_CONFIG_TABLE_ENTRIES = [
    json_config_rule_set(
    json_config_rule_set(
@@ -123,6 +155,8 @@ DEVICE_SW1_CONFIG_TABLE_ENTRIES = [
    )
    )
]
]


DEVICE_SW2_CONFIG_TABLE_ENTRIES = DEVICE_SW1_CONFIG_TABLE_ENTRIES 



"""
"""
DEVICE_SW1_CONFIG_TABLE_ENTRIES = [
DEVICE_SW1_CONFIG_TABLE_ENTRIES = [
@@ -171,7 +205,6 @@ DEVICE_SW1_CONFIG_TABLE_ENTRIES = [


################################## TABLE DECONF ##################################
################################## TABLE DECONF ##################################



DEVICE_SW1_DECONF_TABLE_ENTRIES = [
DEVICE_SW1_DECONF_TABLE_ENTRIES = [
    json_config_rule_delete(
    json_config_rule_delete(
        'table',
        'table',
@@ -213,6 +246,7 @@ DEVICE_SW1_DECONF_TABLE_ENTRIES = [
    )
    )
]
]


DEVICE_SW2_DECONF_TABLE_ENTRIES = DEVICE_SW1_DECONF_TABLE_ENTRIES 




"""
"""
@@ -271,6 +305,7 @@ TOPOLOGIES = [TOPOLOGY]


DEVICES = [
DEVICES = [
    (DEVICE_SW1, DEVICE_SW1_CONNECT_RULES, DEVICE_SW1_CONFIG_TABLE_ENTRIES, DEVICE_SW1_DECONF_TABLE_ENTRIES),
    (DEVICE_SW1, DEVICE_SW1_CONNECT_RULES, DEVICE_SW1_CONFIG_TABLE_ENTRIES, DEVICE_SW1_DECONF_TABLE_ENTRIES),
    (DEVICE_SW2, DEVICE_SW2_CONNECT_RULES, DEVICE_SW2_CONFIG_TABLE_ENTRIES, DEVICE_SW2_DECONF_TABLE_ENTRIES),
]
]


LINKS = []
LINKS = []
+2 −3
Original line number Original line Diff line number Diff line
@@ -28,7 +28,7 @@ from .p4_common import matches_ipv4, matches_ipv6, valid_port,\
    P4_ATTR_DEV_P4BIN, P4_ATTR_DEV_P4INFO, P4_ATTR_DEV_TIMEOUT,\
    P4_ATTR_DEV_P4BIN, P4_ATTR_DEV_P4INFO, P4_ATTR_DEV_TIMEOUT,\
    P4_VAL_DEF_VENDOR, P4_VAL_DEF_HW_VER, P4_VAL_DEF_SW_VER,\
    P4_VAL_DEF_VENDOR, P4_VAL_DEF_HW_VER, P4_VAL_DEF_SW_VER,\
    P4_VAL_DEF_TIMEOUT
    P4_VAL_DEF_TIMEOUT
from .p4_manager import P4Manager, get_api_version, KEY_TABLE,\
from .p4_manager import P4Manager, KEY_TABLE,\
    KEY_ACTION_PROFILE, KEY_COUNTER, KEY_DIR_COUNTER, KEY_METER, KEY_DIR_METER,\
    KEY_ACTION_PROFILE, KEY_COUNTER, KEY_DIR_COUNTER, KEY_METER, KEY_DIR_METER,\
    KEY_CTL_PKT_METADATA
    KEY_CTL_PKT_METADATA
from .p4_client import WriteOperation
from .p4_client import WriteOperation
@@ -127,8 +127,7 @@ class P4Driver(_Driver):
            except Exception as ex:  # pylint: disable=broad-except
            except Exception as ex:  # pylint: disable=broad-except
                raise Exception(ex) from ex
                raise Exception(ex) from ex


            LOGGER.info("\tConnected via P4Runtime version %s",
            LOGGER.info("\tConnected via P4Runtime")
                        get_api_version())
            self.__started.set()
            self.__started.set()


            return True
            return True
+254 −254

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2

File changed.

Contains only whitespace changes.