Skip to content
Snippets Groups Projects
Commit b3c0e922 authored by karamchandan's avatar karamchandan
Browse files

Cleanup of the DAD service implementation

parent 5967330e
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!141Pre-release fixes and code cleanup in L3 cybersecurity components
......@@ -81,9 +81,9 @@ class l3_distributedattackdetector:
with grpc.insecure_channel(CENTRALIZED_ATTACK_DETECTOR) as channel:
self.cad = L3CentralizedattackdetectorStub(channel)
LOGGER.info("Connected to the centralized attack detector")
LOGGER.info("Obtaining features...")
LOGGER.info("Connected to the Centralized Attack Detector")
LOGGER.info("Obtaining features Ids. from the Centralized Attack Detector...")
self.feature_ids = self.get_features_ids()
LOGGER.info("Features Ids.: {:s}".format(str(self.feature_ids)))
......@@ -118,10 +118,10 @@ class l3_distributedattackdetector:
# start an infinite loop
while True:
# read last line of file
# read last line of the file
line = file.readline()
# sleep if file hasn't been updated
# sleep if the file hasn't been updated
if not line:
time.sleep(time_sleep)
continue
......@@ -135,16 +135,19 @@ class l3_distributedattackdetector:
yield line
def load_file(self, dirname=TSTAT_DIR_NAME): # - Client side -
def load_file(self, dirname=TSTAT_DIR_NAME):
while True:
here = os.path.dirname(os.path.abspath(__file__))
tstat_piped = os.path.join(here, dirname)
tstat_dirs = os.listdir(tstat_piped)
if len(tstat_dirs) > 0:
tstat_dirs.sort()
new_dir = tstat_dirs[-1]
tstat_file = tstat_piped + new_dir + "/log_tcp_temp_complete"
LOGGER.info("Following: {:s}".format(str(tstat_file)))
return tstat_file
else:
LOGGER.info("No Tstat directory!")
......@@ -165,7 +168,7 @@ class l3_distributedattackdetector:
feature = feature_id - 1
values.append(float(line[feature]))
except IndexError:
print("IndexError: {0}".format(line))
LOGGER.error("IndexError: {0}".format(line))
return values
......
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