From 6655cdbeda5d4188454590bd803aaf1a401be56c Mon Sep 17 00:00:00 2001
From: ismaeel <mohammad.ismaael@cnit.it>
Date: Wed, 24 Apr 2024 07:33:25 +0000
Subject: [PATCH] Integral optical link with optical controller

---
 .context.log.swp                              |  Bin 8192 -> 16384 bytes
 my_deploy.sh                                  |    2 +-
 proto/context.proto                           |    1 +
 .../tools/context_queries/OpticalConfig.py    |   11 +-
 .../service/ContextServiceServicerImpl.py     |    4 +-
 src/context/service/database/Device.py        |   51 +-
 src/context/service/database/OpticalConfig.py |   29 +-
 .../service/database/models/DeviceModel.py    |    2 +-
 .../service/database/models/EndPointModel.py  |    1 +
 .../database/models/OpticalConfigModel.py     |    9 +-
 .../database/models/OpticalEndPointModel.py   |    2 +-
 .../database/models/OpticalLinkModel.py       |    6 +-
 .../service/database/uuids/OpticalConfig.py   |   12 +-
 src/device/service/OpenConfigServicer.py      |    2 +-
 .../service/drivers/oc_driver/OCDriver.py     |    4 +-
 src/opticalcontroller/OpticalController.py    |    2 +-
 .../json_files/tfs_dict_modified.json         | 1458 +++++++++++++++++
 src/opticalcontroller/variables.py            |    2 +-
 .../service/ServiceServiceServicerImpl.py     |    1 +
 src/service/service/__main__.py               |   13 +-
 src/webui/service/opticalconfig/routes.py     |   11 +-
 .../templates/opticalconfig/details.html      |   39 +-
 .../service/templates/opticalconfig/home.html |    2 +
 23 files changed, 1587 insertions(+), 77 deletions(-)
 create mode 100644 src/opticalcontroller/json_files/tfs_dict_modified.json

diff --git a/.context.log.swp b/.context.log.swp
index bab7729c124bd1a470885e2307011e49de2ddb1e..1d5d6b23da8cf9d7348152649f7e75767b1dbe64 100644
GIT binary patch
literal 16384
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

delta 96
zcmZo@U~F)ZPcjJe^i{CXGhzS&0S1Q3c%?MmPz#22pV$~m(uyZeRNd&Zk6)dUp&lsz
e9|{CPih+O;LNPGG=!uHrn-c^V@NHb6zz6{Q4;cRd

diff --git a/my_deploy.sh b/my_deploy.sh
index 7bb15dd96..d84430ecb 100755
--- a/my_deploy.sh
+++ b/my_deploy.sh
@@ -102,7 +102,7 @@ export CRDB_DEPLOY_MODE="single"
 export CRDB_DROP_DATABASE_IF_EXISTS=""
 
 # Disable flag for re-deploying CockroachDB from scratch.
-export CRDB_REDEPLOY="YES"
+export CRDB_REDEPLOY=""
 
 
 # ----- NATS -------------------------------------------------------------------
diff --git a/proto/context.proto b/proto/context.proto
index 465e235d4..f881bca5f 100644
--- a/proto/context.proto
+++ b/proto/context.proto
@@ -638,6 +638,7 @@ message OpticalConfigId {
 message OpticalConfig {
   OpticalConfigId opticalconfig_id = 1;
   string config = 2;
+  DeviceId device_id = 3;
 }
 
 message OpticalConfigList {
diff --git a/src/common/tools/context_queries/OpticalConfig.py b/src/common/tools/context_queries/OpticalConfig.py
index 52727c45d..0082a1dea 100644
--- a/src/common/tools/context_queries/OpticalConfig.py
+++ b/src/common/tools/context_queries/OpticalConfig.py
@@ -44,13 +44,22 @@ def channel_get_uuid(
         ('channel uuid', channel_name),
        
     ], extra_details=['Channel name is required to produce a channel UUID'])
+    
+def device_get_uuid (device_name) : 
+    if (len(device_name)> 0):
+        return  get_uuid_from_string(device_name)
+    raise InvalidArgumentsException([
+        ('name', device_name),
+    ], extra_details=['Device Name is required to produce Device UUID'])
+
 
 def opticalconfig_get_uuid(
     device_name : str = '', allow_random : bool = False
 ) -> str:
     
     if len(device_name) > 0:
-        return get_uuid_from_string(device_name)
+        device_uuid= device_get_uuid(device_name=device_name)
+        return get_uuid_from_string(f"{device_uuid}_opticalconfig")
     if allow_random: return get_uuid_random()
 
     raise InvalidArgumentsException([
diff --git a/src/context/service/ContextServiceServicerImpl.py b/src/context/service/ContextServiceServicerImpl.py
index e75f3a5c7..454a65fe2 100644
--- a/src/context/service/ContextServiceServicerImpl.py
+++ b/src/context/service/ContextServiceServicerImpl.py
@@ -317,8 +317,10 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer
     def SelectOpticalConfig(self, request : OpticalConfigId, context : grpc.ServicerContext) -> OpticalConfig:
         result = select_opticalconfig(self.db_engine, request)
         optical_config_id = OpticalConfigId()
+        device_id = DeviceId()
         optical_config_id.CopyFrom(result.opticalconfig_id)
-        return OpticalConfig(config=result.config, opticalconfig_id=optical_config_id)
+        device_id.CopyFrom(result.device_id)
+        return OpticalConfig(config=result.config, opticalconfig_id=optical_config_id , device_id=device_id)
    
     @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
     def DeleteOpticalConfig (self, request : OpticalConfigId, context : grpc.ServicerContext) -> Empty:
diff --git a/src/context/service/database/Device.py b/src/context/service/database/Device.py
index 942e6f115..3664e4002 100644
--- a/src/context/service/database/Device.py
+++ b/src/context/service/database/Device.py
@@ -107,7 +107,7 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
     topology_uuids.add(topology_uuid)
 
     is_oc_driver = DeviceDriverEnum.DEVICEDRIVER_OC in set(request.device_drivers)
-    optical_endpoints_data : List[Dict] = list()
+    #optical_endpoints_data : List[Dict] = list()
     LOGGER.info(f"is_oc_driver {is_oc_driver}")
     endpoints_data : List[Dict] = list()
     for i, endpoint in enumerate(request.device_endpoints):
@@ -138,18 +138,18 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
             'created_at'       : now,
             'updated_at'       : now,
         })
-        # ------------------- Experimental -----------------------
+        # # ------------------- Experimental -----------------------
        
-        if is_oc_driver:
+        # if is_oc_driver:
             
-            optical_endpoints_data.append({
-                    'endpoint_uuid'    : endpoint_uuid,
-                    'device_uuid'      : endpoint_device_uuid,
-                    'name'             : endpoint_name,
-                    'endpoint_type'    : endpoint.endpoint_type,
-                    'created_at'       : now,
-                    'updated_at'       : now,
-            })
+        #     optical_endpoints_data.append({
+        #             'endpoint_uuid'    : endpoint_uuid,
+        #             'device_uuid'      : endpoint_device_uuid,
+        #             'name'             : endpoint_name,
+        #             'endpoint_type'    : endpoint.endpoint_type,
+        #             'created_at'       : now,
+        #             'updated_at'       : now,
+        #     })
         
         
         
@@ -211,20 +211,20 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
         
         #---------------------- Experimental ---------------------------------
         
-        if len(optical_endpoints_data) > 0:
-            LOGGER.info(f"Optical endpoint data_ device_model {optical_endpoints_data}")
-            stmt = insert(OpticalEndPointModel).values(optical_endpoints_data)
-            stmt = stmt.on_conflict_do_update(
-                index_elements=[OpticalEndPointModel.endpoint_uuid],
-                set_=dict(
-                    name             = stmt.excluded.name,
-                    endpoint_type    = stmt.excluded.endpoint_type,
-                    updated_at       = stmt.excluded.updated_at,
-                )
-            )
-            stmt = stmt.returning(OpticalEndPointModel.created_at, OpticalEndPointModel.updated_at)
-            optical_endpoint_updates = session.execute(stmt).fetchall()
-            updated_optical_endpoints = any([(updated_at > created_at) for created_at,updated_at in endpoint_updates])    
+        # if len(optical_endpoints_data) > 0:
+        #     LOGGER.info(f"Optical endpoint data_ device_model {optical_endpoints_data}")
+        #     stmt = insert(OpticalEndPointModel).values(optical_endpoints_data)
+        #     stmt = stmt.on_conflict_do_update(
+        #         index_elements=[OpticalEndPointModel.endpoint_uuid],
+        #         set_=dict(
+        #             name             = stmt.excluded.name,
+        #             endpoint_type    = stmt.excluded.endpoint_type,
+        #             updated_at       = stmt.excluded.updated_at,
+        #         )
+        #     )
+        #     stmt = stmt.returning(OpticalEndPointModel.created_at, OpticalEndPointModel.updated_at)
+        #     optical_endpoint_updates = session.execute(stmt).fetchall()
+        #     updated_optical_endpoints = any([(updated_at > created_at) for created_at,updated_at in endpoint_updates])    
 
         device_topology_ids = []
         if not updated or len(related_topologies) > 1:
@@ -323,6 +323,7 @@ def device_delete(db_engine : Engine, messagebroker : MessageBroker, request : D
     return Empty()
 
 def device_select(db_engine : Engine, request : DeviceFilter) -> DeviceList:
+   
     device_uuids = [
         device_get_uuid(device_id, allow_random=False)
         for device_id in request.device_ids.device_ids
diff --git a/src/context/service/database/OpticalConfig.py b/src/context/service/database/OpticalConfig.py
index 281634df8..f4a32a29c 100644
--- a/src/context/service/database/OpticalConfig.py
+++ b/src/context/service/database/OpticalConfig.py
@@ -20,7 +20,7 @@ from sqlalchemy.orm import Session, sessionmaker
 from sqlalchemy_cockroachdb import run_transaction
 from common.proto.context_pb2 import OpticalConfig, OpticalConfigId , Empty , EventTypeEnum
 from .models.OpticalConfigModel import OpticalConfigModel , OpticalChannelModel
-from context.service.database.uuids.OpticalConfig import channel_get_uuid
+from context.service.database.uuids.OpticalConfig import channel_get_uuid , opticalconfig_get_uuid
 from .Events import notify_event_opticalconfig
 
 LOGGER = logging.getLogger(__name__)
@@ -35,32 +35,37 @@ def get_opticalconfig(db_engine : Engine):
      
             optical_config = OpticalConfig()
             optical_config.config = json.dumps(obj.dump())
-            optical_config.opticalconfig_id.opticalconfig_uuid = obj.dump_id()["opticalconfig_uuid"]
+            ids_obj = obj.dump_id()
+            LOGGER.info(f"ids {ids_obj}")
+            optical_config.opticalconfig_id.opticalconfig_uuid = ids_obj["opticalconfig_uuid"]
+            optical_config.device_id.device_uuid.uuid=ids_obj["device_uuid"]
             optical_configs.append(optical_config)
         return optical_configs
     obj = run_transaction(sessionmaker(bind=db_engine), callback)
     return obj
 
 def set_opticalconfig(db_engine : Engine, request : OpticalConfig):
-   
+ 
     opticalconfig_id = OpticalConfigId()
-    opticalconfig_id.opticalconfig_uuid = request.opticalconfig_id.opticalconfig_uuid
+    device_id = request.device_id
+    device_uuid =  request.device_id.device_uuid.uuid
     OpticalConfig_data = []
     if request.config:
         channels = []
         transceivers = []
         config = json.loads(request.config)
-                 
+        opticalconfig_uuid =opticalconfig_get_uuid(device_id)         
         if 'transceivers' in config and len(config['transceivers']['transceiver']) > 0:
             transceivers = [transceiver for transceiver in config['transceivers']['transceiver']]
             
         if 'channels' in config and len(config['channels']) > 0:
             #channels = [channel['name']['index'] for channel in config['channels']]
+       
             for channel_params in config['channels']:
                  channels.append(
                                 {
+                                    "opticalconfig_uuid":opticalconfig_uuid,
                                     "channel_uuid":channel_get_uuid(channel_params['name']['index']),
-                                    "opticalconfig_uuid": request.opticalconfig_id.opticalconfig_uuid,
                                     "channel_name"          : channel_params['name']['index'],
                                     "frequency"         : int(channel_params["frequency"]) if "frequency" in channel_params  else 0,
                                     "operational_mode"  : int(channel_params["operational-mode"]) if "operational-mode" in channel_params else 0,
@@ -70,12 +75,12 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig):
                   
         OpticalConfig_data.append(
            {
-                                    "opticalconfig_uuid": request.opticalconfig_id.opticalconfig_uuid,
+                                    "opticalconfig_uuid":opticalconfig_uuid,
                                     "transcievers"      : transceivers,
                                     "interfaces"        :"",
                                     "channel_namespace" : config.get("channel_namespace",None),
-                                    "endpoints"         : [json.dumps(endpoint) for endpoint in config.get("endpoints",[])],}
-                                   
+                                    "endpoints"         : [json.dumps(endpoint) for endpoint in config.get("endpoints",[])],
+                                     "device_uuid": device_uuid}
         )
             
        
@@ -120,7 +125,11 @@ def select_opticalconfig(db_engine:Engine,request:OpticalConfigId):
         obj = stmt.first()
         if obj is not None:
             result.config = json.dumps(obj.dump())
-            result.opticalconfig_id.opticalconfig_uuid = obj.opticalconfig_uuid
+            ids_obj = obj.dump_id()
+           
+            result.opticalconfig_id.opticalconfig_uuid = ids_obj["opticalconfig_uuid"]
+            result.device_id.device_uuid.uuid=ids_obj["device_uuid"]
+            LOGGER.info(f"select_opticalconfig {result}")
         return result
     return run_transaction(sessionmaker(bind=db_engine, expire_on_commit=False), callback)
 
diff --git a/src/context/service/database/models/DeviceModel.py b/src/context/service/database/models/DeviceModel.py
index fb7f80e71..de3a916e9 100644
--- a/src/context/service/database/models/DeviceModel.py
+++ b/src/context/service/database/models/DeviceModel.py
@@ -40,7 +40,7 @@ class DeviceModel(_Base):
     controller   = relationship('DeviceModel', remote_side=[device_uuid], passive_deletes=True) # lazy='joined', back_populates='device'
     
     # ------------------- Experimental -----------------------------------
-    optical_endpoints= relationship('OpticalEndPointModel',passive_deletes=True)
+    optical_config= relationship('OpticalConfigModel',passive_deletes=True)
 
     def dump_id(self) -> Dict:
         return {'device_uuid': {'uuid': self.device_uuid}}
diff --git a/src/context/service/database/models/EndPointModel.py b/src/context/service/database/models/EndPointModel.py
index 9bb2adb2d..423263f87 100644
--- a/src/context/service/database/models/EndPointModel.py
+++ b/src/context/service/database/models/EndPointModel.py
@@ -35,6 +35,7 @@ class EndPointModel(_Base):
 
     device            = relationship('DeviceModel',          back_populates='endpoints') # lazy='selectin'
     topology          = relationship('TopologyModel', lazy='selectin')
+    optical_link_endpoints    = relationship('OpticalLinkEndPointModel',    back_populates='endpoint' )
     #link_endpoints    = relationship('LinkEndPointModel',    back_populates='endpoint' )
     #service_endpoints = relationship('ServiceEndPointModel', back_populates='endpoint' )
 
diff --git a/src/context/service/database/models/OpticalConfigModel.py b/src/context/service/database/models/OpticalConfigModel.py
index a2007886c..6af2d0bf5 100644
--- a/src/context/service/database/models/OpticalConfigModel.py
+++ b/src/context/service/database/models/OpticalConfigModel.py
@@ -27,11 +27,16 @@ class OpticalConfigModel(_Base):
     channel_namespace  = Column(String, nullable=True)
     endpoints          = Column(ARRAY(String), nullable=True)
     channels           = relationship("OpticalChannelModel")
+    
+    device_uuid = Column(ForeignKey("device.device_uuid",ondelete="CASCADE"),index=True ,nullable=False)
+    device= relationship("DeviceModel",  back_populates='optical_config')
+    
 
     
     def dump_id (self ):
         return {
-            "opticalconfig_uuid":self.opticalconfig_uuid
+            "opticalconfig_uuid":self.opticalconfig_uuid,
+            "device_uuid" :self.device_uuid
         }
 
     def dump(self):
@@ -41,7 +46,7 @@ class OpticalConfigModel(_Base):
             "interfaces"        : {"interface":json.loads(self.interfaces) if self.interfaces else ''},
             "channel_namespace" : self.channel_namespace,
             "endpoints"         : [json.loads(endpoint) for endpoint in self.endpoints if endpoint],
-            
+            "device_name": self.device.device_name
         }
         
         
diff --git a/src/context/service/database/models/OpticalEndPointModel.py b/src/context/service/database/models/OpticalEndPointModel.py
index 0500bedf3..1500dbc60 100644
--- a/src/context/service/database/models/OpticalEndPointModel.py
+++ b/src/context/service/database/models/OpticalEndPointModel.py
@@ -39,7 +39,7 @@ class OpticalEndPointModel(_Base):
     created_at        = Column(DateTime, nullable=False)
     updated_at        = Column(DateTime, nullable=False)
    
-    device            = relationship('DeviceModel',          back_populates='optical_endpoints') # lazy='selectin'
+    #device            = relationship('DeviceModel',          back_populates='optical_endpoints') # lazy='selectin'
    
     #link_endpoints    = relationship('LinkEndPointModel',    back_populates='endpoint' )
     #service_endpoints = relationship('ServiceEndPointModel', back_populates='endpoint' )
diff --git a/src/context/service/database/models/OpticalLinkModel.py b/src/context/service/database/models/OpticalLinkModel.py
index 28c71675e..3015f445b 100644
--- a/src/context/service/database/models/OpticalLinkModel.py
+++ b/src/context/service/database/models/OpticalLinkModel.py
@@ -107,11 +107,11 @@ class OpticalLinkEndPointModel(_Base):
     __tablename__ = 'opticallink_endpoint'
 
     link_uuid     = Column(ForeignKey('opticallink.opticallink_uuid',         ondelete='CASCADE' ), primary_key=True)
-    endpoint_uuid = Column(ForeignKey('optical_endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True)
+    endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True)
 
 
-    optical_link     = relationship('OpticalLinkModel',     back_populates='opticallink_endpoints') #, lazy='selectin'
-    endpoint = relationship('OpticalEndPointModel', lazy='selectin') # back_populates='link_endpoints'
+    optical_link     = relationship('OpticalLinkModel',     back_populates='opticallink_endpoints') 
+    endpoint = relationship('EndPointModel', lazy='selectin') 
 
 
 
diff --git a/src/context/service/database/uuids/OpticalConfig.py b/src/context/service/database/uuids/OpticalConfig.py
index 0003b5712..4bff2fc35 100644
--- a/src/context/service/database/uuids/OpticalConfig.py
+++ b/src/context/service/database/uuids/OpticalConfig.py
@@ -1,7 +1,7 @@
 
 from common.method_wrappers.ServiceExceptions import InvalidArgumentsException
 from ._Builder import get_uuid_from_string, get_uuid_random
-
+from common.proto.context_pb2 import DeviceId
 def channel_get_uuid(
     channel_name :str , allow_random : bool = False
 ) -> str:
@@ -15,3 +15,13 @@ def channel_get_uuid(
         ('channel uuid', channel_name),
        
     ], extra_details=['Channel name is required to produce a channel UUID'])
+
+def opticalconfig_get_uuid ( device_id: DeviceId, allow_random : bool = False) -> str : 
+    device_uuid = device_id.device_uuid.uuid
+    if (len(device_uuid)>0):
+        return get_uuid_from_string(f"{device_uuid}_opticalconfig")
+    if allow_random: return get_uuid_random()
+    raise InvalidArgumentsException([
+        ('DeviceId ', device_id),
+       
+    ], extra_details=['device_id is required to produce a OpticalConfig UUID'])
\ No newline at end of file
diff --git a/src/device/service/OpenConfigServicer.py b/src/device/service/OpenConfigServicer.py
index e0b7c5be9..12a644563 100644
--- a/src/device/service/OpenConfigServicer.py
+++ b/src/device/service/OpenConfigServicer.py
@@ -75,7 +75,7 @@ class OpenConfigServicer(DeviceServiceServicer):
 
     @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
     def ConfigureOpticalDevice (self, request : OpticalConfig, context : grpc.ServicerContext) -> Empty:
-        device_uuid = request.opticalconfig_id.opticalconfig_uuid
+        device_uuid = request.device_id.device_uuid.uuid
         resources=[]
         is_all_good=True
         config =json.loads(request.config)
diff --git a/src/device/service/drivers/oc_driver/OCDriver.py b/src/device/service/drivers/oc_driver/OCDriver.py
index 3f91df18c..cbc10a7dd 100644
--- a/src/device/service/drivers/oc_driver/OCDriver.py
+++ b/src/device/service/drivers/oc_driver/OCDriver.py
@@ -295,7 +295,9 @@ class OCDriver(_Driver):
            
             logging.info(f"parameters {oc_values}")
             opticalConfig.config=json.dumps(oc_values)
-            opticalConfig.opticalconfig_id.opticalconfig_uuid=self.__device_uuid if self.__device_uuid is not None else ""
+            if self.__device_uuid is not None:
+
+                opticalConfig.device_id.device_uuid.uuid=self.__device_uuid
             config_id=context_client.SetOpticalConfig(opticalConfig)
            
             context_client.close()
diff --git a/src/opticalcontroller/OpticalController.py b/src/opticalcontroller/OpticalController.py
index c91c76e9f..262cf115e 100644
--- a/src/opticalcontroller/OpticalController.py
+++ b/src/opticalcontroller/OpticalController.py
@@ -235,4 +235,4 @@ if __name__ == '__main__':
     rsa = RSA(nodes_dict, links_dict)
     #print(rsa.init_link_slots2(testing))
 
-    app.run(host='0.0.0.0', port=5000,debug=True)
+    app.run(host='0.0.0.0', port=10060)
diff --git a/src/opticalcontroller/json_files/tfs_dict_modified.json b/src/opticalcontroller/json_files/tfs_dict_modified.json
new file mode 100644
index 000000000..80176b067
--- /dev/null
+++ b/src/opticalcontroller/json_files/tfs_dict_modified.json
@@ -0,0 +1,1458 @@
+{
+	"optical_links": [
+		{
+			"name": "T1.1-R1",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "T1.1->R1"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T1.1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "1"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "12"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "1",
+				"dst_port": "12",
+				"local_peer_port": "1",
+				"remote_peer_port": "2",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "T1.2-R1",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "T1.2->R1"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T1.2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "1"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "13"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "1",
+				"dst_port": "13",
+				"local_peer_port": "1",
+				"remote_peer_port": "3",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "T1.3-R1",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "T1.3->R1"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T1.3"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "1"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "14"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "1",
+				"dst_port": "14",
+				"local_peer_port": "1",
+				"remote_peer_port": "4",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R1-T1.1",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R1->T1.1"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "2"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T1.1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "1"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "2",
+				"dst_port": "1",
+				"local_peer_port": "12",
+				"remote_peer_port": "1",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R1-T1.2",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R1->T1.2"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "3"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T1.2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "1"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "3",
+				"dst_port": "1",
+				"local_peer_port": "13",
+				"remote_peer_port": "1",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R1-T1.3",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R1->T1.3"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "4"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T1.3"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "1"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "4",
+				"dst_port": "1",
+				"local_peer_port": "14",
+				"remote_peer_port": "1",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R1-R2",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R1->R2"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "101"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "111"
+					}
+				}
+			],
+            "optical_details": {
+				"length": 0,
+				"src_port": "101",
+				"dst_port": "111",
+				"local_peer_port": "111",
+				"remote_peer_port": "101",
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R2-R1",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R2->R1"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "101"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "111"
+					}
+				}
+			],
+            "optical_details": {
+				"length": 0,
+				"src_port": "101",
+				"dst_port": "111",
+				"local_peer_port": "111",
+				"remote_peer_port": "101",
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "T2.1-R2",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "T2.1->R2"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T2.1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "6"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "12"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "6",
+				"dst_port": "12",
+				"local_peer_port": "6",
+				"remote_peer_port": "2",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "T2.2-R2",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "T2.2->R2"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T2.2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "6"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "13"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "6",
+				"dst_port": "13",
+				"local_peer_port": "6",
+				"remote_peer_port": "3",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "T2.3-R2",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "T2.3->R2"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T2.3"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "6"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "14"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "6",
+				"dst_port": "14",
+				"local_peer_port": "6",
+				"remote_peer_port": "4",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R2-T2.1",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R2->T2.1"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "2"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T2.1"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "6"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "2",
+				"dst_port": "6",
+				"local_peer_port": "12",
+				"remote_peer_port": "6",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R2-T2.2",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R1->T2.2"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "3"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T2.2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "6"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "3",
+				"dst_port": "6",
+				"local_peer_port": "13",
+				"remote_peer_port": "6",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		},
+		{
+			"name": "R2-T2.3",
+			"link_id": {
+				"link_uuid": {
+					"uuid": "R2->T2.3"
+				}
+			},
+			"link_endpoint_ids": [
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "R2"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "4"
+					}
+				},
+				{
+					"device_id": {
+						"device_uuid": {
+							"uuid": "T2.3"
+						}
+					},
+					"endpoint_uuid": {
+						"uuid": "6"
+					}
+				}
+			],
+			"optical_details": {
+				"length": 0,
+				"src_port": "4",
+				"dst_port": "6",
+				"local_peer_port": "14",
+				"remote_peer_port": "6",
+				"used": false,
+				"c_slots": {
+					"1": 1,
+					"2": 1,
+					"3": 1,
+					"4": 1,
+					"5": 1,
+					"6": 1,
+					"7": 1,
+					"8": 1,
+					"9": 1,
+					"10": 1,
+					"11": 1,
+					"12": 1,
+					"13": 1,
+					"14": 1,
+					"15": 1,
+					"16": 1,
+					"17": 1,
+					"18": 1,
+					"19": 1,
+					"20": 1
+				},
+				"l_slots": {
+					"101": 1,
+					"102": 1,
+					"103": 1,
+					"104": 1,
+					"105": 1,
+					"106": 1,
+					"107": 1,
+					"108": 1,
+					"109": 1,
+					"110": 1,
+					"111": 1,
+					"112": 1,
+					"113": 1,
+					"114": 1,
+					"115": 1,
+					"116": 1,
+					"117": 1,
+					"118": 1,
+					"119": 1,
+					"120": 1
+				},
+				"s_slots": {
+					"501": 1,
+					"502": 1,
+					"503": 1,
+					"504": 1,
+					"505": 1,
+					"506": 1,
+					"507": 1,
+					"508": 1,
+					"509": 1,
+					"510": 1,
+					"511": 1,
+					"512": 1,
+					"513": 1,
+					"514": 1,
+					"515": 1,
+					"516": 1,
+					"517": 1,
+					"518": 1,
+					"519": 1,
+					"520": 1
+				}
+			}
+		}
+	]
+}
\ No newline at end of file
diff --git a/src/opticalcontroller/variables.py b/src/opticalcontroller/variables.py
index 28ee66208..04d2fe98d 100644
--- a/src/opticalcontroller/variables.py
+++ b/src/opticalcontroller/variables.py
@@ -10,7 +10,7 @@ Nc = 320
 Ns = 720
 
 nodes_json = 'json_files/nodes.json'
-topology_json = 'json_files/tfs_dict.json' #LAST
+topology_json = 'json_files/tfs_dict_modified.json' #LAST
 #topology_json = 'json_files/optical_TFSworking.json' #LAST
 #topology_json = 'json_files/optical_topoTFS.json'
 #topology_json = 'json_files/topo_2_links.json'
diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py
index 94f200bbb..880c0525c 100644
--- a/src/service/service/ServiceServiceServicerImpl.py
+++ b/src/service/service/ServiceServiceServicerImpl.py
@@ -254,6 +254,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
                 DEFAULT_TOPOLOGY_NAME, context_id_x)
             topology_details = context_client.GetTopologyDetails(
                 TopologyId(**topology_id_x))
+            
             #refresh_opticalcontroller(TopologyId(**topology_id_x))
             # devices = get_devices_in_topology(context_client, TopologyId(**topology_id_x), ContextId(**context_id_x))
             devices = topology_details.devices
diff --git a/src/service/service/__main__.py b/src/service/service/__main__.py
index 5a700b57d..c4b0f2a7a 100644
--- a/src/service/service/__main__.py
+++ b/src/service/service/__main__.py
@@ -16,7 +16,7 @@ import logging, signal, sys, threading , os
 from prometheus_client import start_http_server
 from common.Constants import ServiceNameEnum
 from common.Settings import (
-    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port,
+    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, find_environment_variables, get_env_var_name, get_log_level, get_metrics_port,
     wait_for_environment_variables
 )
 from .ServiceService import ServiceService
@@ -48,7 +48,16 @@ def main():
         get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_HOST     ),
         
     ])
-    LOGGER.info(os.environ)
+    VAR_NAME_OPTICAL_CONTROLLER_HOST = get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_HOST)
+    VAR_NAME_OPTICAL_CONTROLLER_PORT = get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_PORT_GRPC)
+    opticalcontrollers_url = find_environment_variables([
+    VAR_NAME_OPTICAL_CONTROLLER_HOST,
+    VAR_NAME_OPTICAL_CONTROLLER_PORT,
+])
+    OPTICAL_IP   = opticalcontrollers_url.get(VAR_NAME_OPTICAL_CONTROLLER_HOST)
+    OPTICAL_PORT = opticalcontrollers_url.get(VAR_NAME_OPTICAL_CONTROLLER_PORT)
+    LOGGER.info(f"OPTICAL_IP:{OPTICAL_IP} OPTICAL_PORT:{OPTICAL_PORT}")
+
     signal.signal(signal.SIGINT,  signal_handler)
     signal.signal(signal.SIGTERM, signal_handler)
 
diff --git a/src/webui/service/opticalconfig/routes.py b/src/webui/service/opticalconfig/routes.py
index b20c15e0d..d55c44105 100644
--- a/src/webui/service/opticalconfig/routes.py
+++ b/src/webui/service/opticalconfig/routes.py
@@ -8,7 +8,7 @@ from device.client.DeviceClient import DeviceClient
 from service.client.ServiceClient import ServiceClient
 from slice.client.SliceClient import SliceClient
 from .forms import UpdateDeviceForm ,AddTrancseiver ,UpdateInterfaceForm
-from common.tools.context_queries.OpticalConfig import opticalconfig_get_uuid
+from common.tools.context_queries.OpticalConfig import opticalconfig_get_uuid , device_get_uuid
 
 
 opticalconfig = Blueprint('opticalconfig', __name__,url_prefix="/opticalconfig")
@@ -68,12 +68,14 @@ def show_details(config_uuid):
             LOGGER.info("response %s",response)
             opticalConfig = OpticalConfig()
             opticalConfig.CopyFrom(response)
-            
+           
             config =json.loads(opticalConfig.config)
             LOGGER.info("config details %s",config)
             interfaces=config["interfaces"]
             new_config={}
-      
+            device_name=""
+            if ("device_name" in config):
+               device_name= config["device_name"]
             for channel in config['channels'] :
                 
                 new_config["name"]=channel['name']
@@ -85,7 +87,7 @@ def show_details(config_uuid):
                 device_details.append(new_config)
         LOGGER.info("config details %s",device_details)
         
-        return render_template('opticalconfig/details.html', device=device_details,config_id=config_uuid,interfaces=interfaces)
+        return render_template('opticalconfig/details.html', device=device_details,config_id=config_uuid,device_name=device_name)
 
 @opticalconfig.route('<path:opticalconfig_uuid>/delete', methods=['GET'])
 def delete_opitcalconfig (opticalconfig_uuid)  :
@@ -119,6 +121,7 @@ def update_externally ()  :
             LOGGER.info(f"device from post {device}")
         
             if (device_name):
+                
                 opticalconfig_uuid = opticalconfig_get_uuid(device_name=device_name)
                 opticalconfigId=OpticalConfigId()
                 opticalconfigId.opticalconfig_uuid=opticalconfig_uuid
diff --git a/src/webui/service/templates/opticalconfig/details.html b/src/webui/service/templates/opticalconfig/details.html
index 58f4bb6b1..85aafb3a4 100644
--- a/src/webui/service/templates/opticalconfig/details.html
+++ b/src/webui/service/templates/opticalconfig/details.html
@@ -33,29 +33,26 @@
   </div>
   <div class="col-sm-12">
   <div class="col-sm-12">
-    <div class="col-sm-3">
-      <!-- <button type="button" class="btn btn-danger"><i class="bi bi-x-square"></i>Delete device</button> -->
-      <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
-          <i class="bi bi-x-square"></i>
-          Delete Optical Config
-      </button>
-  </div>
+    <div class="row">
+
+      <div class="col-sm-3">
+        <button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('opticalconfig.home') }}'">
+            <i class="bi bi-box-arrow-in-left"></i>
+            Back to device list
+        </button>
+      </div>
+      <div class="col-sm-3">
+        <!-- <button type="button" class="btn btn-danger"><i class="bi bi-x-square"></i>Delete device</button> -->
+        <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
+            <i class="bi bi-x-square"></i>
+            Delete Optical Config
+        </button>
+    </div>
+    </div>
   </div>
   <div class="col-sm-12">
-    <span>Interface:</span>
-    <span>
-      <ul>
-        <li><span>Name:</span><span class="font-weight-bold" style="font-weight: 700;">{{ interfaces.interface.name
-            }}</span> </li>
-        <li><span>Ip:</span> <span class="font-weight-bold" style="font-weight: 700;">{{ interfaces.interface.ip }}</span>
-          <li><span>Ip:</span> <span class="font-weight-bold" style="font-weight: 700;">{{ interfaces.interface["prefix-legnth"] }}</span>
-        </li>
-        <li><span>Enabled:</span> <span class="font-weight-bold" style="font-weight: 700;"> {{ interfaces.interface.enabled
-            }}</span></li>
-
-
-      </ul>
-    </span>
+    <span>Device Name:</span>
+    <span>{{device_name}}</span>
     </div>
   
   </div>
diff --git a/src/webui/service/templates/opticalconfig/home.html b/src/webui/service/templates/opticalconfig/home.html
index 349c25e36..581024cd7 100644
--- a/src/webui/service/templates/opticalconfig/home.html
+++ b/src/webui/service/templates/opticalconfig/home.html
@@ -26,6 +26,7 @@
             <thead>
               <tr>
                 <th scope="col">UUID</th>
+                <th scope="col">Device Name</th>
                 <th scope="col">Channels Number</th>
                
               </tr>
@@ -35,6 +36,7 @@
                     {% for device in config %}
                     <tr>
                         <td>{{device.opticalconfig_id.opticalconfig_uuid}}</td>
+                        <td>{{device.device_name}}</td>
                         <td>{{ device.channels_number }}</td>
                      
                         <td>
-- 
GitLab