Skip to content

Commit

Permalink
Revert "move get telemetry to it's own file"
Browse files Browse the repository at this point in the history
This reverts commit 03dd1a5.
  • Loading branch information
TalLerner committed Aug 26, 2024
1 parent ee23eb0 commit 1263cc7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from exclude_list import ExcludeList

from constants import PDRConstants as Constants
from telemetry_collector import TelemetryCollector
from ufm_communication_mgr import UFMCommunicator
# should actually be persistent and thread safe dictionary pf PortStates

Expand Down Expand Up @@ -194,7 +193,6 @@ def __init__(self, ufm_client: UFMCommunicator, logger):
self.test_iteration = 0
# Take from Conf
self.logger = logger
self.telemetry_collector = TelemetryCollector(self.test_mode)
self.ber_intervals = Constants.BER_THRESHOLDS_INTERVALS if not self.test_mode else [[0.5 * 60, 3]]
intervals = [x[0] for x in self.ber_intervals]
self.min_ber_wait_time = min(intervals)
Expand Down Expand Up @@ -530,7 +528,7 @@ def read_next_set_of_high_ber_or_pdr_ports(self):
Read the next set of ports and check if they have high BER, PDR, temperature or link downed issues
"""
issues = {}
ports_counters = self.telemetry_collector.get_telemetry()
ports_counters = self.ufm_client.get_telemetry(self.test_mode)
if ports_counters is None:
self.logger.error("Couldn't retrieve telemetry data")
return {}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ def send_request(self, uri, data, method=Constants.POST_METHOD, headers=None):
logging.info("UFM API Request Status: {}, URL: {}".format(response.status_code, request))
return response

def get_telemetry(self,test_mode):
"""
get the telemetry from secondary telemetry, if it in test mode it get from the simulation
return DataFrame of the telemetry
"""
if test_mode:
url = f"http://127.0.0.1:9090/csv/xcset/simulated_telemetry"
else:
url = f"http://127.0.0.1:{Constants.SECONDARY_TELEMETRY_PORT}/csv/xcset/{Constants.SECONDARY_INSTANCE}"
try:
telemetry_data = pd.read_csv(url)
except (pd.errors.ParserError, pd.errors.EmptyDataError, urllib.error.URLError) as e:
logging.error(f"Failed to get telemetry data from UFM, fetched url={url}. Error: {e}")
telemetry_data = None
return telemetry_data


def send_event(self, message, event_id=Constants.EXTERNAL_EVENT_NOTICE, external_event_name="PDR Plugin Event", external_event_type="PDR Plugin Event"):
data = {
"event_id": event_id,
Expand Down

0 comments on commit 1263cc7

Please sign in to comment.