Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue:4091669 PDR plugin is not isolate based on LinkDownedCounter measurements #262

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PortData:
"""
Represents the port data.
"""
#pylint: disable=too-many-arguments
#pylint: disable=too-many-positional-arguments,too-many-arguments
def __init__(self, port_name=None, port_num=None, peer=None, node_type=None, active_speed=None, port_width=None, port_guid=None):
"""
Initialize a new instance of the PortData class.
Expand Down Expand Up @@ -470,7 +470,7 @@ def check_deisolation_conditions(self, isolated_port):

return True

#pylint: disable=too-many-arguments,too-many-locals
#pylint: disable=too-many-positional-arguments,too-many-arguments,too-many-locals
def calc_symbol_ber_rate(self, port_name, port_speed, port_width, col_name, time_delta):
"""
calculate the symbol BER rate for a given port given the time delta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,48 @@ def get_telemetry(self):
get the telemetry from secondary telemetry, if it in test mode it get from the simulation
return DataFrame of the telemetry
"""
# get telemetry data
if self.test_mode:
url = "http://127.0.0.1:9090/csv/xcset/simulated_telemetry"
else:
url = f"http://127.0.0.1:{self.SECONDARY_TELEMETRY_PORT}/csv/xcset/{self.SECONDARY_INSTANCE}"
try:
self.logger.info(f"collecting telemetry from {url}.")
self.logger.info(f"Collecting telemetry from {url}.")
telemetry_data = pd.read_csv(url)
except (pd.errors.ParserError, pd.errors.EmptyDataError, urllib.error.URLError) as connection_error:
self.logger.error("failed to get telemetry data from UFM, fetched url=%s. Error: %s",url,connection_error)
self.logger.error("Failed to get telemetry data from UFM, fetched url=%s. Error: %s",url,connection_error)
telemetry_data = None
if self.previous_telemetry_data is not None and telemetry_data is not None:
delta = self._get_delta(self.previous_telemetry_data,telemetry_data)
# when we want to keep only delta
if len(delta) > 0:
self.data_store.save(delta,self.data_store.get_filename_delta())
elif telemetry_data is not None:
# when we want to keep the abs

# store telemetry data
vg12345 marked this conversation as resolved.
Show resolved Hide resolved
try:
if self.previous_telemetry_data is not None and telemetry_data is not None:
delta = self._get_delta(self.previous_telemetry_data,telemetry_data)
# when we want to keep only delta
if len(delta) > 0:
self.data_store.save(delta,self.data_store.get_filename_delta())
elif telemetry_data is not None:
# when we want to keep the abs
self.data_store.save(telemetry_data,self.data_store.get_filename_abs())
except Exception as exception_error: # pylint: disable=broad-exception-caught
self.logger.error(f"Failed to store telemetry data with error {exception_error}")

# update previous telemetry data
if telemetry_data is not None:
self.previous_telemetry_data = telemetry_data
self.data_store.save(telemetry_data,self.data_store.get_filename_abs())
return telemetry_data

def _get_delta(self, first_df: pd.DataFrame, second_df:pd.DataFrame):
merged_df = pd.merge(second_df, first_df, on=self.BASED_COLUMNS, how='inner', suffixes=('', '_x'))
delta_dataframe = pd.DataFrame()
for index,col in enumerate(second_df.columns):
if col not in self.KEY and not isinstance(merged_df.iat[0,index],str):
col_x = col + "_x"
delta_dataframe[col] = merged_df[col] - merged_df[col_x]
for _,col in enumerate(second_df.columns):
col_x = col + "_x"
if col not in self.KEY \
and merged_df[col].dtype != 'object' \
and merged_df[col_x].dtype != 'object':
try:
delta_dataframe[col] = merged_df[col] - merged_df[col_x]
except TypeError:
delta_dataframe[col] = second_df[col]
else:
delta_dataframe[col] = second_df[col]
return delta_dataframe