Skip to content
Snippets Groups Projects
Commit 534ad49c authored by Javier Diaz's avatar Javier Diaz
Browse files

Code Cleanup

parent fe4af7af
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!259Resolve "(CTTC) Replace DLT Gateway functionality with an opensource and Hyper Ledger v2.4+ compliant version"
......@@ -51,11 +51,11 @@ spec:
env:
- name: LOG_LEVEL
value: "INFO"
## for debug purposes
#- name: DLT_GATEWAY_HOST
# value: "mock-blockchain.tfs-bchain.svc.cluster.local"
#- name: DLT_GATEWAY_PORT
# value: "50051"
## for debug purposes
#- name: DLT_GATEWAY_HOST
# value: "mock-blockchain.tfs-bchain.svc.cluster.local"
#- name: DLT_GATEWAY_PORT
# value: "50051"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:8080"]
......
......@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import grpc, asyncio, logging
import logging
from grpc.aio import ServicerContext
from typing import Optional
from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method_async
......
......@@ -13,7 +13,7 @@
# limitations under the License.
import logging, signal, sys, threading, asyncio
import logging, signal, threading, asyncio
from prometheus_client import start_http_server
from common.Constants import ServiceNameEnum
from common.Settings import (
......@@ -25,12 +25,12 @@ from .DltConnectorService import DltConnectorService
terminate = threading.Event()
LOGGER: logging.Logger = None
def signal_handler(signal, frame):
def signal_handler(signal, frame): # pylint: disable=redefined-outer-name
LOGGER.warning('Terminate signal received')
terminate.set()
async def main():
global LOGGER
global LOGGER # pylint: disable=global-statement
log_level = get_log_level()
logging.basicConfig(level=log_level, format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s")
......@@ -59,7 +59,7 @@ async def main():
await grpc_service.start()
# Wait for Ctrl+C or termination signal
while not terminate.wait(timeout=1.0):
while not terminate.is_set():
await asyncio.sleep(1.0)
LOGGER.info('Terminating...')
......
......@@ -20,5 +20,5 @@ def record_exists(record : DltRecord) -> bool:
exists = exists and (record.record_id.type != DLTRECORDTYPE_UNDEFINED)
exists = exists and (len(record.record_id.record_uuid.uuid) > 0)
#exists = exists and (record.operation != DLTRECORDOPERATION_UNDEFINED)
#exists = exists and (len(record.data_json) > 0)
#exists = exists and (len(record.data_json) > 0) #It conflicts as sometimes records do not have a data_json.
return exists
......@@ -50,7 +50,7 @@ def main():
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
LOGGER.info('Starting Interdomain Service...')
LOGGER.info('Starting...')
# Start metrics server
metrics_port = get_metrics_port()
......@@ -71,7 +71,7 @@ def main():
# topology_abstractor.start()
# Subscribe to Context Events
#dlt_enabled = is_dlt_enabled()
#dlt_enabled = is_dlt_enabled() #How to change the config?
dlt_enabled = True
if dlt_enabled:
LOGGER.info('Starting DLT functionality...')
......
......@@ -16,10 +16,9 @@ import logging
import asyncio
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Tuple
from common.proto.context_pb2 import Device, Link, Service, Slice, TopologyId
from common.proto.dlt_connector_pb2 import DltDeviceId, DltLinkId, DltServiceId, DltSliceId
from common.tools.grpc.Tools import grpc_message_to_json_string
from context.client.ContextClient import ContextClient
from dlt.connector.client.DltConnectorClientAsync import DltConnectorClientAsync
......
......@@ -12,21 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import threading
import asyncio
import time
import logging, threading, asyncio, time
from typing import Dict, Optional
from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, INTERDOMAIN_TOPOLOGY_NAME, ServiceNameEnum
from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, find_environment_variables, get_env_var_name
from common.proto.context_pb2 import ContextEvent, ContextId, Device, DeviceEvent, DeviceId, EndPointId, Link, LinkId, LinkEvent, TopologyId, TopologyEvent
from common.proto.context_pb2 import ContextEvent, ContextId, Device, DeviceEvent, DeviceId, LinkId, LinkEvent, TopologyId, TopologyEvent
from common.tools.context_queries.Context import create_context
from common.tools.context_queries.Device import get_uuids_of_devices_in_topology
from common.tools.context_queries.Topology import create_missing_topologies
from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Context import json_context_id
from common.tools.object_factory.Device import json_device_id
from common.tools.object_factory.Topology import json_topology_id
from context.client.ContextClient import ContextClient
from context.client.EventsCollector import EventsCollector
......
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