Skip to content

Commit

Permalink
Send a reset REST API of a port after isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
vg12345 committed Sep 17, 2024
1 parent 612cb05 commit d2dd4e0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d2dd4e0

Please sign in to comment.