diff --git a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/constants.py b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/constants.py index fc53971c..48a99a89 100644 --- a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/constants.py +++ b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/constants.py @@ -54,6 +54,7 @@ class PDRConstants(): GET_ISOLATED_PORTS = "/resources/isolated_ports" GET_PORTS_REST = "/resources/ports" GET_ACTIVE_PORTS_REST = "/resources/ports?active=true" + POST_ACTIONS_REST = "/actions" API_HEALTHY_PORTS = "healthy_ports" API_ISOLATED_PORTS = "isolated_ports" SECONDARY_INSTANCE = "low_freq_debug" 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 232e39eb..184dfbbe 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 @@ -80,10 +80,16 @@ def eval_isolation(self, port_name, cause): return if not self.dry_run: + # Isolate port ret = self.ufm_client.isolate_port(port_name) if not ret or ret.status_code != http.HTTPStatus.OK: self.logger.warning("Failed isolating port: %s with cause: %s... status_code= %s", port_name, cause, ret.status_code) return + # Reset port + ret = self.ufm_client.reset_port(port_name, port_obj.port_guid) + if not ret or ret.status_code != http.HTTPStatus.OK: + self.logger.warning("Failed resetting port: %s... status_code= %s", port_name, ret.status_code) + return isolated_port = self.isolated_ports.get(port_name) if not isolated_port: self.isolated_ports[port_name] = IsolatedPort(port_name) 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 1abe370d..8bfc4217 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 @@ -123,3 +123,18 @@ def get_ports_metadata(self): def get_port_metadata(self, port_name): return self.get_request(f"{Constants.GET_PORTS_REST}/ {port_name}") + + def reset_port(self, port_name, port_guid): + """ + Reset port + """ + # using isolation UFM REST API - POST /ufmRestV2/actions + data = { + "params": { "port_id": port_name }, + "action": "reset", + "object_ids": [ port_guid ], + "object_type": "System", + "description": "", + "identifier": "id" + } + return self.send_request(Constants.POST_ACTIONS_REST, data, method=Constants.POST_METHOD)