Commit 43a85ab7 authored by Georgios P. Katsikas's avatar Georgios P. Katsikas
Browse files

fix: forgotten P4 config file and misc style fixes

parent e02a42b5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ def get_slice_by_defualt_id(
        include_subslice_ids=include_subslice_ids, include_config_rules=include_config_rules)


def get_slice_by_defualt_name(
def get_slice_by_default_name(
    context_client : ContextClient, slice_name : str, context_uuid : str = DEFAULT_CONTEXT_NAME,
    rw_copy : bool = False, include_endpoint_ids : bool = True, include_constraints : bool = True,
    include_service_ids : bool = True, include_subslice_ids : bool = True, include_config_rules : bool = True
+9 −9
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ from common.proto.context_pb2 import (
    Slice,
    SliceStatusEnum,
)
from common.tools.context_queries.Slice import get_slice_by_defualt_name
from common.tools.context_queries.Slice import get_slice_by_default_name
from common.tools.grpc.ConfigRules import update_config_rule_custom
from common.tools.object_factory.Device import json_device_id
from common.DeviceTypes import DeviceTypeEnum
@@ -474,7 +474,7 @@ class IETFSliceHandler:
            raise Exception("Number of SDPs to create must be exactly 1")

        new_sdp = sdps[0]
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_uuid, rw_copy=False
        )
        ietf_data = get_ietf_data_from_config(slice_request, CANDIDATE_RESOURCE_KEY)
@@ -494,7 +494,7 @@ class IETFSliceHandler:
        """
        Delete the specified SDP from an existing slice's candidate IETF data.
        """
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_uuid, rw_copy=False
        )
        ietf_data = get_ietf_data_from_config(slice_request, CANDIDATE_RESOURCE_KEY)
@@ -525,7 +525,7 @@ class IETFSliceHandler:
            raise Exception("Number of connection groups to create must be exactly 1")

        new_connection_group = connection_groups[0]
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_id, rw_copy=False
        )
        ietf_data = get_ietf_data_from_config(slice_request, CANDIDATE_RESOURCE_KEY)
@@ -548,7 +548,7 @@ class IETFSliceHandler:
        """
        Update an existing connection group in the candidate IETF data.
        """
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_name, rw_copy=False
        )
        candidate_ietf_data = get_ietf_data_from_config(
@@ -583,7 +583,7 @@ class IETFSliceHandler:
        """
        Remove an existing connection group from the candidate IETF data of a slice.
        """
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_uuid, rw_copy=False
        )
        candidate_ietf_data = get_ietf_data_from_config(
@@ -632,7 +632,7 @@ class IETFSliceHandler:
        new_match_criterion = match_criteria[0]
        target_connection_group_id = new_match_criterion["target-connection-group-id"]

        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_name, rw_copy=False
        )
        ietf_data = get_ietf_data_from_config(slice_request, CANDIDATE_RESOURCE_KEY)
@@ -681,7 +681,7 @@ class IETFSliceHandler:
        """
        Delete the specified match-criterion from an SDP in the slice's candidate IETF data.
        """
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_uuid, rw_copy=False
        )
        ietf_data = get_ietf_data_from_config(slice_request, CANDIDATE_RESOURCE_KEY)
@@ -719,7 +719,7 @@ class IETFSliceHandler:
        """
        Copy candidate IETF slice data to the running IETF slice data for a given slice.
        """
        slice_request = get_slice_by_defualt_name(
        slice_request = get_slice_by_default_name(
            context_client, slice_uuid, rw_copy=False
        )
        candidate_ietf_data = get_ietf_data_from_config(
+0 −78
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from common.Constants import DEFAULT_CONTEXT_NAME
from common.proto.context_pb2 import ContextId, DeviceOperationalStatusEnum,\
    DeviceDriverEnum, ServiceTypeEnum, ServiceStatusEnum
@@ -25,89 +24,12 @@ ADMIN_CONTEXT_ID = ContextId(**json_context_id(CONTEXT_NAME_P4))
# Device and rule cardinality variables
DEV_NB = 4
P4_DEV_NB = 1
CONNECTION_RULES = 3
ENDPOINT_RULES = 3
INT_RULES = 19
L2_RULES = 10
L3_RULES = 4
ACL_RULES = 1

DATAPLANE_RULES_NB_INT_B1 = 5
DATAPLANE_RULES_NB_INT_B2 = 6
DATAPLANE_RULES_NB_INT_B3 = 8
DATAPLANE_RULES_NB_RT_WEST = 7
DATAPLANE_RULES_NB_RT_EAST = 7
DATAPLANE_RULES_NB_ACL = 1
DATAPLANE_RULES_NB_TOT = \
    DATAPLANE_RULES_NB_INT_B1 +\
    DATAPLANE_RULES_NB_INT_B2 +\
    DATAPLANE_RULES_NB_INT_B3 +\
    DATAPLANE_RULES_NB_RT_WEST +\
    DATAPLANE_RULES_NB_RT_EAST +\
    DATAPLANE_RULES_NB_ACL

# Service-related variables
SVC_NB = 1
NO_SERVICES = 0
NO_SLICES = 0

TEST_PATH = os.path.join(
    os.path.dirname(os.path.dirname(
        os.path.abspath(__file__)
    )) + '/p4-fabric-tna/descriptors')
assert os.path.exists(TEST_PATH), "Invalid path to P4 SD-Fabric tests"

# Topology descriptor
DESC_TOPO = os.path.join(TEST_PATH, 'topology.json')
assert os.path.exists(DESC_TOPO), "Invalid path to the SD-Fabric topology descriptor"

# SBI descriptors
# The switch cannot digest all rules at once, hence we insert in batches
DESC_FILE_RULES_INSERT_INT_B1 = os.path.join(TEST_PATH, 'sbi-rules-insert-int-b1.json')
assert os.path.exists(DESC_FILE_RULES_INSERT_INT_B1),\
    "Invalid path to the SD-Fabric INT SBI descriptor (batch #1)"

DESC_FILE_RULES_INSERT_INT_B2 = os.path.join(TEST_PATH, 'sbi-rules-insert-int-b2.json')
assert os.path.exists(DESC_FILE_RULES_INSERT_INT_B2),\
    "Invalid path to the SD-Fabric INT SBI descriptor (batch #2)"

DESC_FILE_RULES_INSERT_INT_B3 = os.path.join(TEST_PATH, 'sbi-rules-insert-int-b3.json')
assert os.path.exists(DESC_FILE_RULES_INSERT_INT_B3),\
    "Invalid path to the SD-Fabric INT SBI descriptor (batch #3)"

DESC_FILE_RULES_INSERT_ROUTING_WEST = os.path.join(TEST_PATH, 'sbi-rules-insert-routing-west.json')
assert os.path.exists(DESC_FILE_RULES_INSERT_ROUTING_WEST),\
    "Invalid path to the SD-Fabric routing SBI descriptor (domain1-side)"

DESC_FILE_RULES_INSERT_ROUTING_EAST = os.path.join(TEST_PATH, 'sbi-rules-insert-routing-east.json')
assert os.path.exists(DESC_FILE_RULES_INSERT_ROUTING_EAST),\
    "Invalid path to the SD-Fabric routing SBI descriptor (domain2-side)"

DESC_FILE_RULES_INSERT_ACL = os.path.join(TEST_PATH, 'sbi-rules-insert-acl.json')
assert os.path.exists(DESC_FILE_RULES_INSERT_ACL),\
    "Invalid path to the SD-Fabric ACL SBI descriptor"

DESC_FILE_RULES_DELETE_ALL = os.path.join(TEST_PATH, 'sbi-rules-remove.json')
assert os.path.exists(DESC_FILE_RULES_DELETE_ALL),\
    "Invalid path to the SD-Fabric rule removal SBI descriptor"

# Service descriptors
DESC_FILE_SERVICE_P4_INT = os.path.join(TEST_PATH, 'service-p4-int.json')
assert os.path.exists(DESC_FILE_SERVICE_P4_INT),\
    "Invalid path to the SD-Fabric INT service descriptor"

DESC_FILE_SERVICE_P4_L2_SIMPLE = os.path.join(TEST_PATH, 'service-p4-l2-simple.json')
assert os.path.exists(DESC_FILE_SERVICE_P4_L2_SIMPLE),\
    "Invalid path to the SD-Fabric L2 simple service descriptor"

DESC_FILE_SERVICE_P4_L3 = os.path.join(TEST_PATH, 'service-p4-l3.json')
assert os.path.exists(DESC_FILE_SERVICE_P4_L3),\
    "Invalid path to the SD-Fabric L3 service descriptor"

DESC_FILE_SERVICE_P4_ACL = os.path.join(TEST_PATH, 'service-p4-acl.json')
assert os.path.exists(DESC_FILE_SERVICE_P4_ACL),\
    "Invalid path to the SD-Fabric ACL service descriptor"

def identify_number_of_p4_devices(devices) -> int:
    p4_dev_no = 0