diff --git a/.context.log.swp b/.context.log.swp index bab7729c124bd1a470885e2307011e49de2ddb1e..1d5d6b23da8cf9d7348152649f7e75767b1dbe64 100644 Binary files a/.context.log.swp and b/.context.log.swp differ diff --git a/my_deploy.sh b/my_deploy.sh index 7bb15dd968ff4876705e8fdc87103e723c5a74dd..d84430ecb258363868650b586d8796281e232642 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 465e235d4f89fbe283499c95c0b67d60f2497fd3..f881bca5fd4740d5bdd4ddcf78a3d493b4b59772 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 52727c45df00ca84e1fc6070d922fc1eaecc51c9..0082a1deae17cd2129cfa591cb0121e54b4ef197 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 e75f3a5c7c5b76112a529d4d9ac1b9fdf145a525..454a65fe2509e4498957d8ebd5c40e1a7681793a 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 942e6f115f285baf72da57ad4250d44983f1e7b5..3664e400219391edb18bfb65a9866caae994858b 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 281634df8c3fb6be783cb977eb7b1c0e606a95aa..f4a32a29cb85fac24516980975be8dc0bf85192b 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 fb7f80e717daeae8c9b8aaba59b1d00e3afca07c..de3a916e93348d586e107f35b10ec82a1a77b98b 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 9bb2adb2d4209bde8cee4299d10521887f371428..423263f87c389747af97d502ec6f846dde4ab9ba 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 a2007886cbcc27309f04266d780b5515f62c48ed..6af2d0bf57cd8e51a07d80e103184a81edde2d21 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 0500bedf3ce94a4de175397bc14319f947698a9f..1500dbc60ffdb916889d8d6fad42a028c97776d6 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 28c71675e2b4157aa68aa899f935d7556360046f..3015f445bb108e3e67979b9bcd4aa27c6dfe0d9c 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 0003b5712c917f046f942e40a638dd1c95e3d62d..4bff2fc35c0ab71b1814346ce23619764df23007 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 e0b7c5be9c30e7d6fda7b9624c3a98b4b0755b4b..12a64456374e53d2aae089ca95091870c4f47f69 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 3f91df18c98cd182a99d11dd060d8f445bbbf51d..cbc10a7dd8fa0438af8bb5854c37f1ba8ed86021 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 c91c76e9f22a4abf3e2a6a2aa2996341574e6b06..262cf115ef5945b6edcb069b04e5df789e4c2c49 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 0000000000000000000000000000000000000000..80176b067850732aba3abe0282362cf4e5395695 --- /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 28ee662081c1aa2be9181e6ff373ad88d7a0a555..04d2fe98d2a7e181d787239338408e9ca378eab4 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 94f200bbb0606b7d10b77df641ac267352285b43..880c0525c82e82a7182af55c58f294aaad4fb782 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 5a700b57d916d403a867658753a8290aa57d126f..c4b0f2a7a0af3e45473bf3dac05dfb5163fcf1fc 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 b20c15e0dbb50ad9ad7113c6a0e15e82b7532381..d55c44105dc51ebddf3c83f27d18de7740de24b0 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 58f4bb6b143f3648fd91b47fdbfa3e63d9da5251..85aafb3a4af86e7705e69e9679625f0228277922 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 349c25e3626ae81b8864a5e40013e6510c9a2f8c..581024cd709f7c17319fefdf0722d20622aad066 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>