diff --git a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py index 20804fb0..3b9ffb46 100644 --- a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py +++ b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py @@ -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 @@ -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) @@ -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 {} diff --git a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/ufm_communication_mgr.py b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/ufm_communication_mgr.py index 3f2cfe33..bcb303df 100644 --- a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/ufm_communication_mgr.py +++ b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/ufm_communication_mgr.py @@ -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,