Commit 6b78db9e authored by Pablo Armingol's avatar Pablo Armingol
Browse files

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

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into feat/416-tid-new-put-call-for-ipowdm-nbi
parents 6790b1f2 fcd571ae
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -276,7 +276,8 @@ if LOAD_ALL_DEVICE_DRIVERS:
        (CustomIpowdmDriver, [
            {
                FilterFieldEnum.DEVICE_TYPE: [
                    DeviceTypeEnum.PACKET_ROUTER
                    DeviceTypeEnum.PACKET_ROUTER,
                    DeviceTypeEnum.EMULATED_PACKET_ROUTER
                ],
                FilterFieldEnum.DRIVER     : DeviceDriverEnum.DEVICEDRIVER_CUSTOM_IPOWDM,
            }
+2 −2
Original line number Diff line number Diff line
@@ -591,7 +591,7 @@ class PolicyRule(_Resource):
    def get(self, policy_rule_uuid : str):
        return format_grpc_to_json(self.context_client.GetPolicyRule(grpc_policy_rule_id(policy_rule_uuid)))

class E2epathcomp(Resource):
class E2EOpticalPathComputation(Resource):
    def __init__(self):
        super().__init__()
        self.e2e_client = E2EOrchestratorClient()
@@ -636,7 +636,7 @@ class E2epathcomp(Resource):
            LOGGER.error(f"Error calling E2E Orchestrator: {str(e)}", exc_info=True)
            return {"status": "error", "message": str(e)}, 500

class RecomputeOpticalPath(Resource):
class E2EOpticalPathRecomputation(Resource):
    def __init__(self):
        super().__init__()
        self.e2e_client = E2EOrchestratorClient()
+4 −3
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ from .Resources import (
    Service, ServiceIds, Services, OpticalServiceAllocation,
    Slice, SliceIds, Slices,
    Topologies, Topology, TopologyDetails, TopologyIds,
    E2epathcomp, RecomputeOpticalPath
    E2EOpticalPathComputation, E2EOpticalPathRecomputation
)
 

@@ -37,8 +37,6 @@ URL_PREFIX = '/tfs-api'
# Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type.
_RESOURCES = [
    # (endpoint_name, resource_class, resource_url)
    ('api.e2e_path_computation', E2epathcomp, '/e2e_path_computation'),
    ('api.recompute_optical_path', RecomputeOpticalPath, '/recompute_optical_path'),
    ('api.context_ids',      ContextIds,      '/context_ids'),
    ('api.contexts',         Contexts,        '/contexts'),
    ('api.dummy_contexts',   DummyContexts,   '/dummy_contexts'),
@@ -86,6 +84,9 @@ _RESOURCES = [
    ('api.policyrule_ids',   PolicyRuleIds,   '/policyrule_ids'),
    ('api.policyrules',      PolicyRules,     '/policyrules'),
    ('api.policyrule',       PolicyRule,      '/policyrule/<path:policyrule_uuid>'),

    ('api.e2e_optical_path_computation',   E2EOpticalPathComputation, '/e2e_optical_path_computation'),
    ('api.e2e_optical_path_recomputation', E2EOpticalPathRecomputation,'/e2e_optical_path_recomputation'),
]
RESOURCES = [
    (ENDPOINT_PREFIX + endpoint_name, resource_class, URL_PREFIX + resource_url)
+2 −221
Original line number Diff line number Diff line
@@ -134,221 +134,6 @@ def _optical_path_computation(service: Service, is_recompute: bool = False) -> P
    resp_json = resp.json()
    LOGGER.info(f"Optical Path Computation Response: {resp_json}") 
        
    # MOCK RESPONSE (If the Optical Controller is down)
    # if is_recompute:
    #     resp_json = {
    #         "overridden_records": {
    #             "T2.1": {
    #             "sources": [
    #                 "T1.1",
    #                 "T1.3"
    #             ],
    #             "destinations": [
    #                 "T2.1"
    #             ],
    #             "flow_id": 5,
    #             "established_via": "ComputeP2MP",
    #             "timestamp": "2026-06-29T14:45:33.546337+00:00",
    #             "bitrate": 100,
    #             "bidirectional": False,
    #             "frequency": 0,
    #             "band": 100,
    #             "subcarriers_per_source": [
    #                 4,
    #                 4
    #             ]
    #             }
    #         },
    #         "tapi-connectivity:connectivity-service": {
    #             "connection": [
    #             {
    #                 "optical-connection-attributes": {
    #                 "central-frequency": 195000000000000,
    #                 "Tx-power": 0,
    #                 "modulation": {
    #                     "modulation-technique": "DP-16QAM",
    #                     "operational-mode": 9,
    #                     "port": "port-1"
    #                 },
    #                 "digital-subcarrier-spacing": 300000000,
    #                 "subcarrier-attributes": {
    #                     "digital-subcarrier-group": [
    #                     {
    #                         "group-id": 1,
    #                         "modulation-technique": "DP-QPSK",
    #                         "central-frequency": 195006250,
    #                         "operational-mode": 4,
    #                         "Tx-power": -99,
    #                         "group-size": 4,
    #                         "port": "port-1",
    #                         "subcarrier-id": [1, 2, 3, 4]
    #                     },
    #                     {
    #                         "group-id": 2,
    #                         "modulation-technique": "DP-QPSK",
    #                         "central-frequency": 195018750,
    #                         "operational-mode": 4,
    #                         "Tx-power": -99,
    #                         "group-size": 4,
    #                         "port": "port-3",
    #                         "subcarrier-id": [5, 6, 7, 8]
    #                     },
    #                     {
    #                         "group-id": 3,
    #                         "modulation-technique": "DP-QPSK",
    #                         "central-frequency": 195031250,
    #                         "operational-mode": 4,
    #                         "Tx-power": -99,
    #                         "group-size": 4,
    #                         "port": "port-5",
    #                         "subcarrier-id": [9, 10, 11, 12]
    #                     }
    #                     ]
    #                 }
    #                 },
    #                 "end-point": [
    #                 {
    #                     "direction": "BIDIRECTIONAL",
    #                     "layer-protocol-name": "PHOTONIC_MEDIA",
    #                     "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_MC",
    #                     "local-id": "T1.3",
    #                     "service-interface-point": {
    #                         "service-interface-point-uuid": "T2.1"
    #                     },
    #                     "tapi-photonic-media:media-channel-connectivity-service-end-point-spec": {
    #                     "mc-config": {
    #                         "spectrum": {
    #                         "center-frequency": 195000000000000,
    #                         "frequency-constraint": {
    #                             "adjustment-granularity": "G_6_25GHZ",
    #                             "grid-type": "FLEX"
    #                         }
    #                         }
    #                     }
    #                     }
    #                 },
    #                 {
    #                     "direction": "BIDIRECTIONAL",
    #                     "layer-protocol-name": "PHOTONIC_MEDIA",
    #                     "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_MC",
    #                     "local-id": "T2.1",
    #                     "service-interface-point": {
    #                         "service-interface-point-uuid": "T1.1"
    #                     },
    #                     "tapi-photonic-media:media-channel-connectivity-service-end-point-spec": {
    #                     "mc-config": {
    #                         "spectrum": {
    #                         "center-frequency": 195036250,
    #                         "frequency-constraint": {
    #                             "adjustment-granularity": "G_6_25GHZ",
    #                             "grid-type": "FLEX"
    #                         }
    #                         }
    #                     }
    #                     }
    #                 }
    #                 ]
    #             }
    #             ]
    #         }
    #     }
    # else:
    #     resp_json = {
    #         "tapi-connectivity:connectivity-service": {
    #             "connection": [
    #             {
    #                 "optical-connection-attributes": {
    #                 "central-frequency": 195000000000000,
    #                 "Tx-power": 0,
    #                 "modulation": {
    #                     "modulation-technique": "DP-16QAM",
    #                     "operational-mode": 9,
    #                     "port": "port-1"
    #                 },
    #                 "digital-subcarrier-spacing": 300000000,
    #                 "subcarrier-attributes": {
    #                     "digital-subcarrier-group": [
    #                     {
    #                         "group-id": 1,
    #                         "modulation-technique": "DP-QPSK",
    #                         "central-frequency": 195006250,
    #                         "operational-mode": 4,
    #                         "Tx-power": -99,
    #                         "group-size": 4,
    #                         "port": "port-1",
    #                         "subcarrier-id": [1, 2, 3, 4]
    #                     },
    #                     {
    #                         "group-id": 2,
    #                         "modulation-technique": "DP-QPSK",
    #                         "central-frequency": 195018750,
    #                         "operational-mode": 4,
    #                         "Tx-power": -99,
    #                         "group-size": 4,
    #                         "port": "port-3",
    #                         "subcarrier-id": [5, 6, 7, 8]
    #                     },
    #                     {
    #                         "group-id": 3,
    #                         "modulation-technique": "DP-QPSK",
    #                         "central-frequency": 195031250,
    #                         "operational-mode": 4,
    #                         "Tx-power": -99,
    #                         "group-size": 4,
    #                         "port": "port-5",
    #                         "subcarrier-id": [9, 10, 11, 12]
    #                     }
    #                     ]
    #                 }
    #                 },
    #                 "end-point": [
    #                 {
    #                     "direction": "BIDIRECTIONAL",
    #                     "layer-protocol-name": "PHOTONIC_MEDIA",
    #                     "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_MC",
    #                     "local-id": "T1.1",
    #                     "service-interface-point": {
    #                         "service-interface-point-uuid": "T2.1"
    #                     },
    #                     "tapi-photonic-media:media-channel-connectivity-service-end-point-spec": {
    #                     "mc-config": {
    #                         "spectrum": {
    #                         "center-frequency": 195000000000000,
    #                         "frequency-constraint": {
    #                             "adjustment-granularity": "G_6_25GHZ",
    #                             "grid-type": "FLEX"
    #                         }
    #                         }
    #                     }
    #                     }
    #                 },
    #                 {
    #                     "direction": "BIDIRECTIONAL",
    #                     "layer-protocol-name": "PHOTONIC_MEDIA",
    #                     "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_MC",
    #                     "local-id": "T2.1",
    #                     "service-interface-point": {
    #                         "service-interface-point-uuid": "T1.1"
    #                     },
    #                     "tapi-photonic-media:media-channel-connectivity-service-end-point-spec": {
    #                     "mc-config": {
    #                         "spectrum": {
    #                         "center-frequency": 195006250,
    #                         "frequency-constraint": {
    #                             "adjustment-granularity": "G_6_25GHZ",
    #                             "grid-type": "FLEX"
    #                         }
    #                         }
    #                     }
    #                     }
    #                 }
    #                 ]
    #             }
    #             ]
    #         }
    #     }
    
        
    # Generate Rules
    src_name = source  # T2.1
    dest_list = destinations_list  # T1.1, T1.2
@@ -418,11 +203,7 @@ def _optical_path_computation(service: Service, is_recompute: bool = False) -> P
                name = "channel-1"
            
        freq_raw = group.get("central-frequency", 195006250)
        freq_val = int(freq_raw / 1e6) if freq_raw > 1e10 else int(freq_raw)
        # if freq_val == hub_freq:
        #     freq = hub_freq + 6250 + index * 12500
        # else:
        freq = freq_val
        freq = int(freq_raw / 1e6) if freq_raw > 1e10 else int(freq_raw)
            
        leaf = {
            "name": name,