Skip to content

Commit

Permalink
UFD feature enhancement (#78)
Browse files Browse the repository at this point in the history
* UFD feature enhancement

* UFD fix code cleanup

---------

Co-authored-by: prasadsriramps <[email protected]>
  • Loading branch information
prasadsriramps and rsubhamr authored Jul 7, 2023
1 parent b777922 commit a9b09af
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/south/sonic/goldstone/south/sonic/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,35 @@ async def event_handler(self):
"if-name": ifname,
"oper-status": self.get_oper_status(ifname),
}
self.ufd_handler(ifname, oper_status)
self.send_notification(eventname, notif)
self.sonic.notif_if[ifname] = oper_status

def ufd_handler(self, ifname, oper_status):
downlinks = self.get_downlinks(ifname)

if not downlinks:
return

if oper_status == "down":
for port in downlinks:
self.sonic.set_config_db(port, "admin_status", "down")
elif oper_status == "up":
for port in downlinks:
downlink_admin_status = self.get_running_data(
f"/goldstone-interfaces:interfaces/interface[name='{port}']/config/admin-status",
None,
)
if downlink_admin_status == "UP":
self.sonic.set_config_db(port, "admin_status", "up")

def get_downlinks(self, ifname):
ufd_list = self.get_ufd()
for data in ufd_list:
uplinks = data.get("config", {}).get("uplink", [])
if ifname in uplinks:
return list(data.get("config", {}).get("downlink", []))

def clear_counters(self, xpath, input_params, event, priv):
logger.debug(
f"clear_counters: xpath: {xpath}, input: {input}, event: {event}, priv: {priv}"
Expand Down

0 comments on commit a9b09af

Please sign in to comment.