Commit b6e0cacb authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into fix/ofc22

parents acc602d7 03fa01a5
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 = []
+15 −5
Original line number Original line Diff line number Diff line
@@ -19,6 +19,16 @@ enum KpiSampleType {
    KPISAMPLETYPE_UNKNOWN                       = 0;
    KPISAMPLETYPE_UNKNOWN                       = 0;
    KPISAMPLETYPE_PACKETS_TRANSMITTED           = 101;
    KPISAMPLETYPE_PACKETS_TRANSMITTED           = 101;
    KPISAMPLETYPE_PACKETS_RECEIVED              = 102;
    KPISAMPLETYPE_PACKETS_RECEIVED              = 102;
    KPISAMPLETYPE_PACKETS_DROPPED               = 103;
    KPISAMPLETYPE_BYTES_TRANSMITTED             = 201;
    KPISAMPLETYPE_BYTES_TRANSMITTED             = 201;
    KPISAMPLETYPE_BYTES_RECEIVED                = 202;
    KPISAMPLETYPE_BYTES_RECEIVED                = 202;
    KPISAMPLETYPE_BYTES_DROPPED                 = 203;
    KPISAMPLETYPE_ML_CONFIDENCE                 = 401;  //. can be used by both optical and L3 without any issue
    KPISAMPLETYPE_OPTICAL_SECURITY_STATUS       = 501;  //. can be used by both optical and L3 without any issue
    KPISAMPLETYPE_L3_UNIQUE_ATTACK_CONNS        = 601;
    KPISAMPLETYPE_L3_TOTAL_DROPPED_PACKTS       = 602;
    KPISAMPLETYPE_L3_UNIQUE_ATTACKERS           = 603;
    KPISAMPLETYPE_L3_UNIQUE_COMPROMISED_CLIENTS = 604;
    KPISAMPLETYPE_L3_SECURITY_STATUS_CRYPTO     = 605;
    KPISAMPLETYPE_SERVICE_LATENCY_MS            = 701;
}
}
+22 −8
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@ service MonitoringService {
  rpc GetKpiDescriptorList  (context.Empty      ) returns (KpiDescriptorList   ) {} // Stable and final
  rpc GetKpiDescriptorList  (context.Empty      ) returns (KpiDescriptorList   ) {} // Stable and final
  rpc IncludeKpi            (Kpi                ) returns (context.Empty       ) {} // Stable and final
  rpc IncludeKpi            (Kpi                ) returns (context.Empty       ) {} // Stable and final
  rpc MonitorKpi            (MonitorKpiRequest  ) returns (context.Empty       ) {} // Stable and final
  rpc MonitorKpi            (MonitorKpiRequest  ) returns (context.Empty       ) {} // Stable and final
  rpc QueryKpiData          (KpiQuery           ) returns (KpiList             ) {} // Not implemented
  rpc QueryKpiData          (KpiQuery           ) returns (RawKpiTable         ) {} // Not implemented
  rpc SetKpiSubscription    (SubsDescriptor     ) returns (stream SubsResponse ) {} // Stable not final
  rpc SetKpiSubscription    (SubsDescriptor     ) returns (stream SubsResponse ) {} // Stable not final
  rpc GetSubsDescriptor     (SubscriptionID     ) returns (SubsDescriptor      ) {} // Stable and final
  rpc GetSubsDescriptor     (SubscriptionID     ) returns (SubsDescriptor      ) {} // Stable and final
  rpc GetSubscriptions      (context.Empty      ) returns (SubsList            ) {} // Stable and final
  rpc GetSubscriptions      (context.Empty      ) returns (SubsList            ) {} // Stable and final
@@ -48,6 +48,7 @@ message KpiDescriptor {
  context.EndPointId             endpoint_id     = 6;
  context.EndPointId             endpoint_id     = 6;
  context.ServiceId              service_id      = 7;
  context.ServiceId              service_id      = 7;
  context.SliceId                slice_id        = 8;
  context.SliceId                slice_id        = 8;
  context.ConnectionId           connection_id   = 9;
}
}


message MonitorKpiRequest {
message MonitorKpiRequest {
@@ -58,13 +59,26 @@ message MonitorKpiRequest {
}
}


message KpiQuery {
message KpiQuery {
  KpiId    kpi_id              = 1;
  repeated KpiId    kpi_ids             = 1;
  float             monitoring_window_s = 2;
  float             monitoring_window_s = 2;
  float             sampling_rate_s     = 3;
  uint32            last_n_samples      = 3;  // used when you want something like "get the last N many samples
  uint32            last_n_samples      = 4;  // used when you want something like "get the last N many samples
  context.Timestamp start_timestamp     = 4;  // used when you want something like "get the samples since X date/time"
  context.Timestamp start_timestamp     = 5;  // used when you want something like "get the samples since X date/time"
  context.Timestamp end_timestamp       = 5;  // used when you want something like "get the samples until X date/time"
  context.Timestamp end_timestamp       = 6;  // used when you want something like "get the samples until X date/time"
}
  // Pending add field to reflect Available Device Protocols


message RawKpi { // cell
  context.Timestamp timestamp = 1;
  KpiValue          kpi_value = 2;
}

message RawKpiList { // column
  KpiId           kpi_id    = 1;
  repeated RawKpi raw_kpis  = 2;
}

message RawKpiTable { // table
  repeated RawKpiList raw_kpi_lists = 1;
}
}


message KpiId {
message KpiId {
+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
Loading