Skip to content

Commit

Permalink
put telemetry collection in it own class
Browse files Browse the repository at this point in the history
Signed-off-by: Elad Gershon <egershon@nvidia.com>
  • Loading branch information
egershonNvidia committed Aug 19, 2024
1 parent dad6b6b commit f28263f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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 @@ -193,6 +194,7 @@ 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 @@ -528,7 +530,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.ufm_client.get_telemetry(self.test_mode)
ports_counters = self.telemetry_collector.get_telemetry()
if ports_counters is None:
self.logger.error("Couldn't retrieve telemetry data")
return {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,6 @@ 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 f28263f

Please sign in to comment.