From 06087badfe9892aa7242442d472d8e90dce8b283 Mon Sep 17 00:00:00 2001 From: prasadsriramps Date: Mon, 10 Jul 2023 14:31:19 +0530 Subject: [PATCH 1/4] Static Portchannel commit --- .../cli/goldstone/north/cli/portchannel.py | 67 ++++++++++++++----- .../goldstone/south/sonic/portchannel.py | 56 ++++++++++++---- yang/goldstone-portchannel.yang | 12 +++- 3 files changed, 107 insertions(+), 28 deletions(-) diff --git a/src/north/cli/goldstone/north/cli/portchannel.py b/src/north/cli/goldstone/north/cli/portchannel.py index 5082cd06..e302243f 100644 --- a/src/north/cli/goldstone/north/cli/portchannel.py +++ b/src/north/cli/goldstone/north/cli/portchannel.py @@ -53,7 +53,9 @@ def get_list(session, ds, include_implicit_defaults=True): ) -def add_interfaces(session, id, ifnames): +def add_interfaces(session, id, ifnames, mode): + session.set(f"{pcxpath(id)}/config/mode", mode) + session.apply() prefix = "/goldstone-interfaces:interfaces" for ifname in ifnames: xpath = f"{prefix}/interface[name='{ifname}']" @@ -97,6 +99,7 @@ def remove_interfaces(session, ifnames): def run_conf(session): + n = 0 for data in get_list(session, "running", False): stdout.info("portchannel {}".format(data["config"]["portchannel-id"])) @@ -113,6 +116,7 @@ def run_conf(session): def show(session, id=None): + if id != None: items = session.get_operational(pcxpath(id)) else: @@ -120,19 +124,41 @@ def show(session, id=None): rows = [] for item in items: - rows.append( - [ - item["portchannel-id"], - item["state"]["oper-status"].lower(), - item["state"]["admin-status"].lower(), - ", ".join(natsorted(list(item["state"].get("interface", [])))), - ] - ) + if "config" in item and item["config"]["mode"] == "dynamic": + rows.append( + [ + item["portchannel-id"], + item["state"]["oper-status"].lower(), + item["state"]["admin-status"].lower(), + ", ".join(natsorted(list(item["state"].get("interface", [])))), + item["config"]["mode"], + ] + ) + elif "config" in item and item["config"]["mode"] == "static": + rows.append( + [ + item["portchannel-id"], + item["state"]["oper-status"].lower(), + item["state"]["admin-status"].lower(), + ", ".join(natsorted(list(item["config"].get("interface", [])))), + item["config"]["mode"], + ] + ) + elif "config" in item and item["config"]["mode"] == "none": + rows.append( + [ + item["portchannel-id"], + "-", + item["config"]["admin-status"].lower(), + ", ".join(natsorted(list(item["config"].get("interface", [])))), + item["config"]["mode"], + ] + ) stdout.info( tabulate( rows, - ["Portchannel ID", "oper-status", "admin-status", "Interfaces"], + ["Portchannel ID", "Oper-Status", "Admin-Status", "Interfaces", "Mode"], ) ) @@ -265,19 +291,30 @@ def get_portchannel(conn, ifname): return pc +class PortChannelModeOptions(ConfigCommand): + COMMAND_DICT = {"dynamic": Command, "static": Command} + +class PortChannelModeCommand(ConfigCommand): + def __init__( + self, context: Context = None, parent: Command = None, name=None, **options + ): + super().__init__(context, parent, name, **options) + if self.root.name != "no": + self.add_command("mode",PortChannelModeOptions) + class InterfacePortchannelCommand(ConfigCommand): def arguments(self): if self.root.name != "no": - return get_id(self.conn) - return [] + for id in get_id(self.conn): + self.add_command(str(id), PortChannelModeCommand) def exec(self, line): if self.root.name == "no": remove_interfaces(self.conn, self.context.ifnames) else: - if len(line) != 1: - raise InvalidInput(f"usage: {self.name_all()} ") - add_interfaces(self.conn, line[0], self.context.ifnames) + if len(line) != 3 and (line[2] != "dynamic" or line[2] != "static"): + raise InvalidInput(f"usage: {self.name_all()} mode [dynamic|static]") + add_interfaces(self.conn, line[0], self.context.ifnames, line[2]) @classmethod def to_command(cls, conn, data, **options): diff --git a/src/south/sonic/goldstone/south/sonic/portchannel.py b/src/south/sonic/goldstone/south/sonic/portchannel.py index 7db8dd91..2be42dbd 100644 --- a/src/south/sonic/goldstone/south/sonic/portchannel.py +++ b/src/south/sonic/goldstone/south/sonic/portchannel.py @@ -6,6 +6,10 @@ CallbackFailedError, ) +def _decode(string): + if hasattr(string, "decode"): + return string.decode("utf-8") + return str(string) class PortChannelChangeHandler(ChangeHandler): def __init__(self, server, change): @@ -26,24 +30,41 @@ def __init__(self, server, change): class PortChannelIDHandler(PortChannelChangeHandler): def apply(self, user): if self.type in ["created", "modified"]: - value = self.server.get_default("admin-status") - self.server.sonic.set_config_db( - self.pid, "admin-status", value, "PORTCHANNEL" - ) + self.mode = self.change.value + admin = self.server.get_default("admin-status") + mtu = value = self.server.get_default("mtu") + if self.mode == "dynamic": + self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") + self.server.sonic.set_config_db(self.pid, "admin-status", admin, "PORTCHANNEL") + self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") + elif self.mode == "static": + self.server.sonic.set_config_db( + self.pid, "static", "true", "PORTCHANNEL" + ) + self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") + self.server.sonic.set_config_db(self.pid, "admin-status", admin, "PORTCHANNEL") + self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") else: self.server.sonic.sonic_db.delete( - self.server.sonic.sonic_db.CONFIG_DB, f"PORTCHANNEL|{self.pid}" + self.server.sonic.sonic_db.CONFIG_DB, "PORTMODE|{}".format(self.pid) + ) + self.server.sonic.sonic_db.delete( + self.server.sonic.sonic_db.CONFIG_DB, "PORTCHANNEL|{}".format(self.pid) ) class AdminStatusHandler(PortChannelChangeHandler): def apply(self, user): + self.mode = _decode( + self.server.sonic.sonic_db.get(self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}", "mode") + ) if self.type in ["created", "modified"]: value = self.change.value else: value = self.server.get_default("admin-status") logger.debug(f"set {self.pid}'s admin-status to {value}") - self.server.sonic.set_config_db(self.pid, "admin-status", value, "PORTCHANNEL") + if self.type not in ["deleted"] and self.mode in ["dynamic","static"]: + self.server.sonic.set_config_db(self.pid, "admin-status", value, "PORTCHANNEL") def revert(self, user): # TODO @@ -52,12 +73,16 @@ def revert(self, user): class MTUHandler(PortChannelChangeHandler): def apply(self, user): + self.mode = _decode( + self.server.sonic.sonic_db.get(self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}", "mode") + ) if self.type in ["created", "modified"]: value = self.change.value else: value = self.server.get_default("mtu") logger.debug(f"set {self.pid}'s mtu to {value}") - self.server.sonic.set_config_db(self.pid, "mtu", value, "PORTCHANNEL") + if self.type not in ["deleted"] and self.mode in ["dynamic","static"]: + self.server.sonic.set_config_db(self.pid, "mtu", value, "PORTCHANNEL") class InterfaceHandler(PortChannelChangeHandler): @@ -71,6 +96,7 @@ def validate(self, user): def apply(self, user): if self.type in ["created", "modified"]: ifname = self.xpath[-1][2][0][1] + self.server.sonic.set_config_db(self.pid, "admin-status", "up", "PORTCHANNEL") self.server.sonic.sonic_db.set( self.server.sonic.sonic_db.CONFIG_DB, f"PORTCHANNEL_MEMBER|{self.pid}|{ifname}", @@ -94,7 +120,8 @@ def __init__(self, conn, sonic): "portchannel-group": { "portchannel-id": NoOp, "config": { - "portchannel-id": PortChannelIDHandler, + "portchannel-id": NoOp, + "mode": PortChannelIDHandler, "admin-status": AdminStatusHandler, "mtu": MTUHandler, "interface": InterfaceHandler, @@ -165,10 +192,15 @@ async def reconcile(self): ) for pc in pc_list: pid = pc["portchannel-id"] - for leaf in ["admin-status", "mtu"]: - default = self.get_default(leaf) - value = pc["config"].get(leaf, default) - self.sonic.set_config_db(pid, leaf, value, "PORTCHANNEL") + mode = pc["config"].get("mode",'') + if mode in ["dynamic","static"]: + for leaf in ["admin-status", "mtu"]: + default = self.get_default(leaf) + value = pc["config"].get(leaf, default) + self.sonic.set_config_db(pid, "mode", mode, "PORTMODE") + if mode == "static": + self.sonic.set_config_db(pid, "static", "true", "PORTCHANNEL") + self.sonic.set_config_db(pid, leaf, value, "PORTCHANNEL") for intf in pc["config"].get("interface", []): self.sonic.set_config_db( pid + "|" + intf, "NULL", "NULL", "PORTCHANNEL_MEMBER" diff --git a/yang/goldstone-portchannel.yang b/yang/goldstone-portchannel.yang index 63b395b5..66d1d6bf 100644 --- a/yang/goldstone-portchannel.yang +++ b/yang/goldstone-portchannel.yang @@ -19,7 +19,7 @@ module goldstone-portchannel { description "Goldstone portchannel"; - revision 2021-05-30 { + revision 2023-07-10 { description "Initial revision."; } @@ -49,6 +49,16 @@ module goldstone-portchannel { default 9100; } + leaf mode { + type enumeration{ + enum dynamic; + enum static; + enum none; + } + description "portchannel mode"; + default none; + } + uses gs-if:interface-common-config; leaf-list interface { From b3790f182d3a10a802d35c91ad65f289ee91f568 Mon Sep 17 00:00:00 2001 From: prasadsriramps Date: Tue, 11 Jul 2023 15:18:09 +0530 Subject: [PATCH 2/4] static portchannel commit fix --- .../cli/goldstone/north/cli/portchannel.py | 27 ++++++------- .../goldstone/south/sonic/portchannel.py | 38 +++++++++++++------ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/north/cli/goldstone/north/cli/portchannel.py b/src/north/cli/goldstone/north/cli/portchannel.py index e302243f..c0a705bc 100644 --- a/src/north/cli/goldstone/north/cli/portchannel.py +++ b/src/north/cli/goldstone/north/cli/portchannel.py @@ -55,7 +55,6 @@ def get_list(session, ds, include_implicit_defaults=True): def add_interfaces(session, id, ifnames, mode): session.set(f"{pcxpath(id)}/config/mode", mode) - session.apply() prefix = "/goldstone-interfaces:interfaces" for ifname in ifnames: xpath = f"{prefix}/interface[name='{ifname}']" @@ -99,7 +98,6 @@ def remove_interfaces(session, ifnames): def run_conf(session): - n = 0 for data in get_list(session, "running", False): stdout.info("portchannel {}".format(data["config"]["portchannel-id"])) @@ -116,7 +114,6 @@ def run_conf(session): def show(session, id=None): - if id != None: items = session.get_operational(pcxpath(id)) else: @@ -124,7 +121,11 @@ def show(session, id=None): rows = [] for item in items: - if "config" in item and item["config"]["mode"] == "dynamic": + if ( + "config" in item + and item["config"]["mode"] == "dynamic" + or item["config"]["mode"] == "static" + ): rows.append( [ item["portchannel-id"], @@ -134,16 +135,6 @@ def show(session, id=None): item["config"]["mode"], ] ) - elif "config" in item and item["config"]["mode"] == "static": - rows.append( - [ - item["portchannel-id"], - item["state"]["oper-status"].lower(), - item["state"]["admin-status"].lower(), - ", ".join(natsorted(list(item["config"].get("interface", [])))), - item["config"]["mode"], - ] - ) elif "config" in item and item["config"]["mode"] == "none": rows.append( [ @@ -294,13 +285,15 @@ def get_portchannel(conn, ifname): class PortChannelModeOptions(ConfigCommand): COMMAND_DICT = {"dynamic": Command, "static": Command} + class PortChannelModeCommand(ConfigCommand): def __init__( self, context: Context = None, parent: Command = None, name=None, **options ): super().__init__(context, parent, name, **options) if self.root.name != "no": - self.add_command("mode",PortChannelModeOptions) + self.add_command("mode", PortChannelModeOptions) + class InterfacePortchannelCommand(ConfigCommand): def arguments(self): @@ -313,7 +306,9 @@ def exec(self, line): remove_interfaces(self.conn, self.context.ifnames) else: if len(line) != 3 and (line[2] != "dynamic" or line[2] != "static"): - raise InvalidInput(f"usage: {self.name_all()} mode [dynamic|static]") + raise InvalidInput( + f"usage: {self.name_all()} mode [dynamic|static]" + ) add_interfaces(self.conn, line[0], self.context.ifnames, line[2]) @classmethod diff --git a/src/south/sonic/goldstone/south/sonic/portchannel.py b/src/south/sonic/goldstone/south/sonic/portchannel.py index 2be42dbd..2f51db52 100644 --- a/src/south/sonic/goldstone/south/sonic/portchannel.py +++ b/src/south/sonic/goldstone/south/sonic/portchannel.py @@ -6,11 +6,13 @@ CallbackFailedError, ) + def _decode(string): if hasattr(string, "decode"): return string.decode("utf-8") return str(string) + class PortChannelChangeHandler(ChangeHandler): def __init__(self, server, change): super().__init__(server, change) @@ -35,36 +37,44 @@ def apply(self, user): mtu = value = self.server.get_default("mtu") if self.mode == "dynamic": self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") - self.server.sonic.set_config_db(self.pid, "admin-status", admin, "PORTCHANNEL") + self.server.sonic.set_config_db( + self.pid, "admin-status", admin, "PORTCHANNEL" + ) self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") elif self.mode == "static": self.server.sonic.set_config_db( self.pid, "static", "true", "PORTCHANNEL" ) self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") - self.server.sonic.set_config_db(self.pid, "admin-status", admin, "PORTCHANNEL") + self.server.sonic.set_config_db( + self.pid, "admin-status", admin, "PORTCHANNEL" + ) self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") else: self.server.sonic.sonic_db.delete( - self.server.sonic.sonic_db.CONFIG_DB, "PORTMODE|{}".format(self.pid) + self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}" ) self.server.sonic.sonic_db.delete( - self.server.sonic.sonic_db.CONFIG_DB, "PORTCHANNEL|{}".format(self.pid) + self.server.sonic.sonic_db.CONFIG_DB, f"PORTCHANNEL|{self.pid}" ) class AdminStatusHandler(PortChannelChangeHandler): def apply(self, user): self.mode = _decode( - self.server.sonic.sonic_db.get(self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}", "mode") + self.server.sonic.sonic_db.get( + self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}", "mode" + ) ) if self.type in ["created", "modified"]: value = self.change.value else: value = self.server.get_default("admin-status") logger.debug(f"set {self.pid}'s admin-status to {value}") - if self.type not in ["deleted"] and self.mode in ["dynamic","static"]: - self.server.sonic.set_config_db(self.pid, "admin-status", value, "PORTCHANNEL") + if self.type not in ["deleted"] and self.mode in ["dynamic", "static"]: + self.server.sonic.set_config_db( + self.pid, "admin-status", value, "PORTCHANNEL" + ) def revert(self, user): # TODO @@ -74,14 +84,16 @@ def revert(self, user): class MTUHandler(PortChannelChangeHandler): def apply(self, user): self.mode = _decode( - self.server.sonic.sonic_db.get(self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}", "mode") + self.server.sonic.sonic_db.get( + self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}", "mode" + ) ) if self.type in ["created", "modified"]: value = self.change.value else: value = self.server.get_default("mtu") logger.debug(f"set {self.pid}'s mtu to {value}") - if self.type not in ["deleted"] and self.mode in ["dynamic","static"]: + if self.type not in ["deleted"] and self.mode in ["dynamic", "static"]: self.server.sonic.set_config_db(self.pid, "mtu", value, "PORTCHANNEL") @@ -96,7 +108,9 @@ def validate(self, user): def apply(self, user): if self.type in ["created", "modified"]: ifname = self.xpath[-1][2][0][1] - self.server.sonic.set_config_db(self.pid, "admin-status", "up", "PORTCHANNEL") + self.server.sonic.set_config_db( + self.pid, "admin-status", "up", "PORTCHANNEL" + ) self.server.sonic.sonic_db.set( self.server.sonic.sonic_db.CONFIG_DB, f"PORTCHANNEL_MEMBER|{self.pid}|{ifname}", @@ -192,8 +206,8 @@ async def reconcile(self): ) for pc in pc_list: pid = pc["portchannel-id"] - mode = pc["config"].get("mode",'') - if mode in ["dynamic","static"]: + mode = pc["config"].get("mode", "") + if mode in ["dynamic", "static"]: for leaf in ["admin-status", "mtu"]: default = self.get_default(leaf) value = pc["config"].get(leaf, default) From 101ee5173e8ec9449d49509f72931a253efd14af Mon Sep 17 00:00:00 2001 From: prasadsriramps Date: Tue, 18 Jul 2023 10:30:08 +0530 Subject: [PATCH 3/4] static portchannel model fix --- src/north/cli/goldstone/north/cli/portchannel.py | 12 ++++-------- src/south/sonic/goldstone/south/sonic/portchannel.py | 9 +++++++++ yang/goldstone-portchannel.yang | 2 -- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/north/cli/goldstone/north/cli/portchannel.py b/src/north/cli/goldstone/north/cli/portchannel.py index c0a705bc..64a21bb6 100644 --- a/src/north/cli/goldstone/north/cli/portchannel.py +++ b/src/north/cli/goldstone/north/cli/portchannel.py @@ -121,28 +121,24 @@ def show(session, id=None): rows = [] for item in items: - if ( - "config" in item - and item["config"]["mode"] == "dynamic" - or item["config"]["mode"] == "static" - ): + if "config" in item and "mode" in item["config"]: rows.append( [ item["portchannel-id"], item["state"]["oper-status"].lower(), item["state"]["admin-status"].lower(), ", ".join(natsorted(list(item["state"].get("interface", [])))), - item["config"]["mode"], + item["state"]["mode"], ] ) - elif "config" in item and item["config"]["mode"] == "none": + elif "config" in item: rows.append( [ item["portchannel-id"], "-", item["config"]["admin-status"].lower(), ", ".join(natsorted(list(item["config"].get("interface", [])))), - item["config"]["mode"], + "none", ] ) diff --git a/src/south/sonic/goldstone/south/sonic/portchannel.py b/src/south/sonic/goldstone/south/sonic/portchannel.py index 2f51db52..f83f2f5e 100644 --- a/src/south/sonic/goldstone/south/sonic/portchannel.py +++ b/src/south/sonic/goldstone/south/sonic/portchannel.py @@ -175,6 +175,15 @@ def oper_cb(self, xpath, priv): members = self.sonic.get_keys(f"LAG_MEMBER_TABLE:{name}:*", "APPL_DB") members = [m.split(":")[-1] for m in members] state["interface"] = members + state["interface"] = members + static = self.sonic.sonic_db.get( + self.sonic.sonic_db.CONFIG_DB, f"PORTCHANNEL|{name}", "static" + ) + if static is not None and static == "true": + state["mode"] = "static" + else: + state["mode"] = "dynamic" + r.append({"portchannel-id": name, "state": state}) logger.debug(f"portchannel: {r}") diff --git a/yang/goldstone-portchannel.yang b/yang/goldstone-portchannel.yang index 66d1d6bf..db235f3b 100644 --- a/yang/goldstone-portchannel.yang +++ b/yang/goldstone-portchannel.yang @@ -53,10 +53,8 @@ module goldstone-portchannel { type enumeration{ enum dynamic; enum static; - enum none; } description "portchannel mode"; - default none; } uses gs-if:interface-common-config; From 825f7d6002702f83973fc5b472f8fd756be5181e Mon Sep 17 00:00:00 2001 From: prasadsriramps Date: Thu, 20 Jul 2023 10:44:50 +0530 Subject: [PATCH 4/4] static portchannel comments fix --- .../cli/goldstone/north/cli/portchannel.py | 36 ++++++++----------- .../goldstone/south/sonic/portchannel.py | 20 ++++------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/north/cli/goldstone/north/cli/portchannel.py b/src/north/cli/goldstone/north/cli/portchannel.py index 64a21bb6..e0db5fbf 100644 --- a/src/north/cli/goldstone/north/cli/portchannel.py +++ b/src/north/cli/goldstone/north/cli/portchannel.py @@ -121,27 +121,21 @@ def show(session, id=None): rows = [] for item in items: - if "config" in item and "mode" in item["config"]: - rows.append( - [ - item["portchannel-id"], - item["state"]["oper-status"].lower(), - item["state"]["admin-status"].lower(), - ", ".join(natsorted(list(item["state"].get("interface", [])))), - item["state"]["mode"], - ] - ) - elif "config" in item: - rows.append( - [ - item["portchannel-id"], - "-", - item["config"]["admin-status"].lower(), - ", ".join(natsorted(list(item["config"].get("interface", [])))), - "none", - ] - ) - + rows.append( + [ + item["portchannel-id"], + item["state"]["oper-status"].lower() if "state" in item else "-", + item["state"]["admin-status"].lower() + if "state" in item + else item["config"]["admin-status"].lower(), + ", ".join(natsorted(list(item["state"].get("interface", [])))) + if "state" in item + else None, + item["state"]["mode"] + if "state" in item and "mode" in item["state"] + else "None", + ] + ) stdout.info( tabulate( rows, diff --git a/src/south/sonic/goldstone/south/sonic/portchannel.py b/src/south/sonic/goldstone/south/sonic/portchannel.py index f83f2f5e..7afbbb90 100644 --- a/src/south/sonic/goldstone/south/sonic/portchannel.py +++ b/src/south/sonic/goldstone/south/sonic/portchannel.py @@ -35,21 +35,15 @@ def apply(self, user): self.mode = self.change.value admin = self.server.get_default("admin-status") mtu = value = self.server.get_default("mtu") - if self.mode == "dynamic": - self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") - self.server.sonic.set_config_db( - self.pid, "admin-status", admin, "PORTCHANNEL" - ) - self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") - elif self.mode == "static": + if self.mode == "static": self.server.sonic.set_config_db( self.pid, "static", "true", "PORTCHANNEL" ) - self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") - self.server.sonic.set_config_db( - self.pid, "admin-status", admin, "PORTCHANNEL" - ) - self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") + self.server.sonic.set_config_db(self.pid, "mode", self.mode, "PORTMODE") + self.server.sonic.set_config_db( + self.pid, "admin-status", admin, "PORTCHANNEL" + ) + self.server.sonic.set_config_db(self.pid, "mtu", mtu, "PORTCHANNEL") else: self.server.sonic.sonic_db.delete( self.server.sonic.sonic_db.CONFIG_DB, f"PORTMODE|{self.pid}" @@ -179,7 +173,7 @@ def oper_cb(self, xpath, priv): static = self.sonic.sonic_db.get( self.sonic.sonic_db.CONFIG_DB, f"PORTCHANNEL|{name}", "static" ) - if static is not None and static == "true": + if static == "true": state["mode"] = "static" else: state["mode"] = "dynamic"