Skip to content
Snippets Groups Projects
Commit 6655cdbe authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Integral optical link with optical controller

parent ca8d23f9
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!284Resolve: "(CNIT) Multi-Granular Optical Nodes and Optical Transpoders management"
Showing
with 1560 additions and 52 deletions
No preview for this file type
...@@ -102,7 +102,7 @@ export CRDB_DEPLOY_MODE="single" ...@@ -102,7 +102,7 @@ export CRDB_DEPLOY_MODE="single"
export CRDB_DROP_DATABASE_IF_EXISTS="" export CRDB_DROP_DATABASE_IF_EXISTS=""
# Disable flag for re-deploying CockroachDB from scratch. # Disable flag for re-deploying CockroachDB from scratch.
export CRDB_REDEPLOY="YES" export CRDB_REDEPLOY=""
# ----- NATS ------------------------------------------------------------------- # ----- NATS -------------------------------------------------------------------
......
...@@ -638,6 +638,7 @@ message OpticalConfigId { ...@@ -638,6 +638,7 @@ message OpticalConfigId {
message OpticalConfig { message OpticalConfig {
OpticalConfigId opticalconfig_id = 1; OpticalConfigId opticalconfig_id = 1;
string config = 2; string config = 2;
DeviceId device_id = 3;
} }
message OpticalConfigList { message OpticalConfigList {
......
...@@ -44,13 +44,22 @@ def channel_get_uuid( ...@@ -44,13 +44,22 @@ def channel_get_uuid(
('channel uuid', channel_name), ('channel uuid', channel_name),
], extra_details=['Channel name is required to produce a channel UUID']) ], 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( def opticalconfig_get_uuid(
device_name : str = '', allow_random : bool = False device_name : str = '', allow_random : bool = False
) -> str: ) -> str:
if len(device_name) > 0: 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() if allow_random: return get_uuid_random()
raise InvalidArgumentsException([ raise InvalidArgumentsException([
......
...@@ -317,8 +317,10 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer ...@@ -317,8 +317,10 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer
def SelectOpticalConfig(self, request : OpticalConfigId, context : grpc.ServicerContext) -> OpticalConfig: def SelectOpticalConfig(self, request : OpticalConfigId, context : grpc.ServicerContext) -> OpticalConfig:
result = select_opticalconfig(self.db_engine, request) result = select_opticalconfig(self.db_engine, request)
optical_config_id = OpticalConfigId() optical_config_id = OpticalConfigId()
device_id = DeviceId()
optical_config_id.CopyFrom(result.opticalconfig_id) 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) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def DeleteOpticalConfig (self, request : OpticalConfigId, context : grpc.ServicerContext) -> Empty: def DeleteOpticalConfig (self, request : OpticalConfigId, context : grpc.ServicerContext) -> Empty:
......
...@@ -107,7 +107,7 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi ...@@ -107,7 +107,7 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
topology_uuids.add(topology_uuid) topology_uuids.add(topology_uuid)
is_oc_driver = DeviceDriverEnum.DEVICEDRIVER_OC in set(request.device_drivers) 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}") LOGGER.info(f"is_oc_driver {is_oc_driver}")
endpoints_data : List[Dict] = list() endpoints_data : List[Dict] = list()
for i, endpoint in enumerate(request.device_endpoints): for i, endpoint in enumerate(request.device_endpoints):
...@@ -138,18 +138,18 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi ...@@ -138,18 +138,18 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
'created_at' : now, 'created_at' : now,
'updated_at' : now, 'updated_at' : now,
}) })
# ------------------- Experimental ----------------------- # # ------------------- Experimental -----------------------
if is_oc_driver: # if is_oc_driver:
optical_endpoints_data.append({ # optical_endpoints_data.append({
'endpoint_uuid' : endpoint_uuid, # 'endpoint_uuid' : endpoint_uuid,
'device_uuid' : endpoint_device_uuid, # 'device_uuid' : endpoint_device_uuid,
'name' : endpoint_name, # 'name' : endpoint_name,
'endpoint_type' : endpoint.endpoint_type, # 'endpoint_type' : endpoint.endpoint_type,
'created_at' : now, # 'created_at' : now,
'updated_at' : now, # 'updated_at' : now,
}) # })
...@@ -211,20 +211,20 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi ...@@ -211,20 +211,20 @@ def device_set(db_engine : Engine, messagebroker : MessageBroker, request : Devi
#---------------------- Experimental --------------------------------- #---------------------- Experimental ---------------------------------
if len(optical_endpoints_data) > 0: # if len(optical_endpoints_data) > 0:
LOGGER.info(f"Optical endpoint data_ device_model {optical_endpoints_data}") # LOGGER.info(f"Optical endpoint data_ device_model {optical_endpoints_data}")
stmt = insert(OpticalEndPointModel).values(optical_endpoints_data) # stmt = insert(OpticalEndPointModel).values(optical_endpoints_data)
stmt = stmt.on_conflict_do_update( # stmt = stmt.on_conflict_do_update(
index_elements=[OpticalEndPointModel.endpoint_uuid], # index_elements=[OpticalEndPointModel.endpoint_uuid],
set_=dict( # set_=dict(
name = stmt.excluded.name, # name = stmt.excluded.name,
endpoint_type = stmt.excluded.endpoint_type, # endpoint_type = stmt.excluded.endpoint_type,
updated_at = stmt.excluded.updated_at, # updated_at = stmt.excluded.updated_at,
) # )
) # )
stmt = stmt.returning(OpticalEndPointModel.created_at, OpticalEndPointModel.updated_at) # stmt = stmt.returning(OpticalEndPointModel.created_at, OpticalEndPointModel.updated_at)
optical_endpoint_updates = session.execute(stmt).fetchall() # optical_endpoint_updates = session.execute(stmt).fetchall()
updated_optical_endpoints = any([(updated_at > created_at) for created_at,updated_at in endpoint_updates]) # updated_optical_endpoints = any([(updated_at > created_at) for created_at,updated_at in endpoint_updates])
device_topology_ids = [] device_topology_ids = []
if not updated or len(related_topologies) > 1: if not updated or len(related_topologies) > 1:
...@@ -323,6 +323,7 @@ def device_delete(db_engine : Engine, messagebroker : MessageBroker, request : D ...@@ -323,6 +323,7 @@ def device_delete(db_engine : Engine, messagebroker : MessageBroker, request : D
return Empty() return Empty()
def device_select(db_engine : Engine, request : DeviceFilter) -> DeviceList: def device_select(db_engine : Engine, request : DeviceFilter) -> DeviceList:
device_uuids = [ device_uuids = [
device_get_uuid(device_id, allow_random=False) device_get_uuid(device_id, allow_random=False)
for device_id in request.device_ids.device_ids for device_id in request.device_ids.device_ids
......
...@@ -20,7 +20,7 @@ from sqlalchemy.orm import Session, sessionmaker ...@@ -20,7 +20,7 @@ from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy_cockroachdb import run_transaction from sqlalchemy_cockroachdb import run_transaction
from common.proto.context_pb2 import OpticalConfig, OpticalConfigId , Empty , EventTypeEnum from common.proto.context_pb2 import OpticalConfig, OpticalConfigId , Empty , EventTypeEnum
from .models.OpticalConfigModel import OpticalConfigModel , OpticalChannelModel 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 from .Events import notify_event_opticalconfig
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
...@@ -35,32 +35,37 @@ def get_opticalconfig(db_engine : Engine): ...@@ -35,32 +35,37 @@ def get_opticalconfig(db_engine : Engine):
optical_config = OpticalConfig() optical_config = OpticalConfig()
optical_config.config = json.dumps(obj.dump()) 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) optical_configs.append(optical_config)
return optical_configs return optical_configs
obj = run_transaction(sessionmaker(bind=db_engine), callback) obj = run_transaction(sessionmaker(bind=db_engine), callback)
return obj return obj
def set_opticalconfig(db_engine : Engine, request : OpticalConfig): def set_opticalconfig(db_engine : Engine, request : OpticalConfig):
opticalconfig_id = OpticalConfigId() 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 = [] OpticalConfig_data = []
if request.config: if request.config:
channels = [] channels = []
transceivers = [] transceivers = []
config = json.loads(request.config) config = json.loads(request.config)
opticalconfig_uuid =opticalconfig_get_uuid(device_id)
if 'transceivers' in config and len(config['transceivers']['transceiver']) > 0: if 'transceivers' in config and len(config['transceivers']['transceiver']) > 0:
transceivers = [transceiver for transceiver in config['transceivers']['transceiver']] transceivers = [transceiver for transceiver in config['transceivers']['transceiver']]
if 'channels' in config and len(config['channels']) > 0: if 'channels' in config and len(config['channels']) > 0:
#channels = [channel['name']['index'] for channel in config['channels']] #channels = [channel['name']['index'] for channel in config['channels']]
for channel_params in config['channels']: for channel_params in config['channels']:
channels.append( channels.append(
{ {
"opticalconfig_uuid":opticalconfig_uuid,
"channel_uuid":channel_get_uuid(channel_params['name']['index']), "channel_uuid":channel_get_uuid(channel_params['name']['index']),
"opticalconfig_uuid": request.opticalconfig_id.opticalconfig_uuid,
"channel_name" : channel_params['name']['index'], "channel_name" : channel_params['name']['index'],
"frequency" : int(channel_params["frequency"]) if "frequency" in channel_params else 0, "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, "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): ...@@ -70,12 +75,12 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig):
OpticalConfig_data.append( OpticalConfig_data.append(
{ {
"opticalconfig_uuid": request.opticalconfig_id.opticalconfig_uuid, "opticalconfig_uuid":opticalconfig_uuid,
"transcievers" : transceivers, "transcievers" : transceivers,
"interfaces" :"", "interfaces" :"",
"channel_namespace" : config.get("channel_namespace",None), "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): ...@@ -120,7 +125,11 @@ def select_opticalconfig(db_engine:Engine,request:OpticalConfigId):
obj = stmt.first() obj = stmt.first()
if obj is not None: if obj is not None:
result.config = json.dumps(obj.dump()) 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 result
return run_transaction(sessionmaker(bind=db_engine, expire_on_commit=False), callback) return run_transaction(sessionmaker(bind=db_engine, expire_on_commit=False), callback)
......
...@@ -40,7 +40,7 @@ class DeviceModel(_Base): ...@@ -40,7 +40,7 @@ class DeviceModel(_Base):
controller = relationship('DeviceModel', remote_side=[device_uuid], passive_deletes=True) # lazy='joined', back_populates='device' controller = relationship('DeviceModel', remote_side=[device_uuid], passive_deletes=True) # lazy='joined', back_populates='device'
# ------------------- Experimental ----------------------------------- # ------------------- Experimental -----------------------------------
optical_endpoints= relationship('OpticalEndPointModel',passive_deletes=True) optical_config= relationship('OpticalConfigModel',passive_deletes=True)
def dump_id(self) -> Dict: def dump_id(self) -> Dict:
return {'device_uuid': {'uuid': self.device_uuid}} return {'device_uuid': {'uuid': self.device_uuid}}
......
...@@ -35,6 +35,7 @@ class EndPointModel(_Base): ...@@ -35,6 +35,7 @@ class EndPointModel(_Base):
device = relationship('DeviceModel', back_populates='endpoints') # lazy='selectin' device = relationship('DeviceModel', back_populates='endpoints') # lazy='selectin'
topology = relationship('TopologyModel', lazy='selectin') topology = relationship('TopologyModel', lazy='selectin')
optical_link_endpoints = relationship('OpticalLinkEndPointModel', back_populates='endpoint' )
#link_endpoints = relationship('LinkEndPointModel', back_populates='endpoint' ) #link_endpoints = relationship('LinkEndPointModel', back_populates='endpoint' )
#service_endpoints = relationship('ServiceEndPointModel', back_populates='endpoint' ) #service_endpoints = relationship('ServiceEndPointModel', back_populates='endpoint' )
......
...@@ -27,11 +27,16 @@ class OpticalConfigModel(_Base): ...@@ -27,11 +27,16 @@ class OpticalConfigModel(_Base):
channel_namespace = Column(String, nullable=True) channel_namespace = Column(String, nullable=True)
endpoints = Column(ARRAY(String), nullable=True) endpoints = Column(ARRAY(String), nullable=True)
channels = relationship("OpticalChannelModel") 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 ): def dump_id (self ):
return { return {
"opticalconfig_uuid":self.opticalconfig_uuid "opticalconfig_uuid":self.opticalconfig_uuid,
"device_uuid" :self.device_uuid
} }
def dump(self): def dump(self):
...@@ -41,7 +46,7 @@ class OpticalConfigModel(_Base): ...@@ -41,7 +46,7 @@ class OpticalConfigModel(_Base):
"interfaces" : {"interface":json.loads(self.interfaces) if self.interfaces else ''}, "interfaces" : {"interface":json.loads(self.interfaces) if self.interfaces else ''},
"channel_namespace" : self.channel_namespace, "channel_namespace" : self.channel_namespace,
"endpoints" : [json.loads(endpoint) for endpoint in self.endpoints if endpoint], "endpoints" : [json.loads(endpoint) for endpoint in self.endpoints if endpoint],
"device_name": self.device.device_name
} }
......
...@@ -39,7 +39,7 @@ class OpticalEndPointModel(_Base): ...@@ -39,7 +39,7 @@ class OpticalEndPointModel(_Base):
created_at = Column(DateTime, nullable=False) created_at = Column(DateTime, nullable=False)
updated_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' ) #link_endpoints = relationship('LinkEndPointModel', back_populates='endpoint' )
#service_endpoints = relationship('ServiceEndPointModel', back_populates='endpoint' ) #service_endpoints = relationship('ServiceEndPointModel', back_populates='endpoint' )
......
...@@ -107,11 +107,11 @@ class OpticalLinkEndPointModel(_Base): ...@@ -107,11 +107,11 @@ class OpticalLinkEndPointModel(_Base):
__tablename__ = 'opticallink_endpoint' __tablename__ = 'opticallink_endpoint'
link_uuid = Column(ForeignKey('opticallink.opticallink_uuid', ondelete='CASCADE' ), primary_key=True) 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' optical_link = relationship('OpticalLinkModel', back_populates='opticallink_endpoints')
endpoint = relationship('OpticalEndPointModel', lazy='selectin') # back_populates='link_endpoints' endpoint = relationship('EndPointModel', lazy='selectin')
from common.method_wrappers.ServiceExceptions import InvalidArgumentsException from common.method_wrappers.ServiceExceptions import InvalidArgumentsException
from ._Builder import get_uuid_from_string, get_uuid_random from ._Builder import get_uuid_from_string, get_uuid_random
from common.proto.context_pb2 import DeviceId
def channel_get_uuid( def channel_get_uuid(
channel_name :str , allow_random : bool = False channel_name :str , allow_random : bool = False
) -> str: ) -> str:
...@@ -15,3 +15,13 @@ def channel_get_uuid( ...@@ -15,3 +15,13 @@ def channel_get_uuid(
('channel uuid', channel_name), ('channel uuid', channel_name),
], extra_details=['Channel name is required to produce a channel UUID']) ], 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
...@@ -75,7 +75,7 @@ class OpenConfigServicer(DeviceServiceServicer): ...@@ -75,7 +75,7 @@ class OpenConfigServicer(DeviceServiceServicer):
@safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def ConfigureOpticalDevice (self, request : OpticalConfig, context : grpc.ServicerContext) -> Empty: 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=[] resources=[]
is_all_good=True is_all_good=True
config =json.loads(request.config) config =json.loads(request.config)
......
...@@ -295,7 +295,9 @@ class OCDriver(_Driver): ...@@ -295,7 +295,9 @@ class OCDriver(_Driver):
logging.info(f"parameters {oc_values}") logging.info(f"parameters {oc_values}")
opticalConfig.config=json.dumps(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) config_id=context_client.SetOpticalConfig(opticalConfig)
context_client.close() context_client.close()
......
...@@ -235,4 +235,4 @@ if __name__ == '__main__': ...@@ -235,4 +235,4 @@ if __name__ == '__main__':
rsa = RSA(nodes_dict, links_dict) rsa = RSA(nodes_dict, links_dict)
#print(rsa.init_link_slots2(testing)) #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)
This diff is collapsed.
...@@ -10,7 +10,7 @@ Nc = 320 ...@@ -10,7 +10,7 @@ Nc = 320
Ns = 720 Ns = 720
nodes_json = 'json_files/nodes.json' 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_TFSworking.json' #LAST
#topology_json = 'json_files/optical_topoTFS.json' #topology_json = 'json_files/optical_topoTFS.json'
#topology_json = 'json_files/topo_2_links.json' #topology_json = 'json_files/topo_2_links.json'
......
...@@ -254,6 +254,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): ...@@ -254,6 +254,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
DEFAULT_TOPOLOGY_NAME, context_id_x) DEFAULT_TOPOLOGY_NAME, context_id_x)
topology_details = context_client.GetTopologyDetails( topology_details = context_client.GetTopologyDetails(
TopologyId(**topology_id_x)) TopologyId(**topology_id_x))
#refresh_opticalcontroller(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 = get_devices_in_topology(context_client, TopologyId(**topology_id_x), ContextId(**context_id_x))
devices = topology_details.devices devices = topology_details.devices
......
...@@ -16,7 +16,7 @@ import logging, signal, sys, threading , os ...@@ -16,7 +16,7 @@ import logging, signal, sys, threading , os
from prometheus_client import start_http_server from prometheus_client import start_http_server
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import ( 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 wait_for_environment_variables
) )
from .ServiceService import ServiceService from .ServiceService import ServiceService
...@@ -48,7 +48,16 @@ def main(): ...@@ -48,7 +48,16 @@ def main():
get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_HOST ), 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.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGTERM, signal_handler)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment