File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,11 +148,22 @@ def extract_ip_ver_addr(ip_prefix):
148148 return (ver , addr )
149149
150150
151+ def is_ip_prefix_in_key (key ):
152+ '''
153+ Function to check if IP address is present in the key. If it
154+ is present, then the key would be a tuple or else, it shall be
155+ be string
156+ '''
157+ return (isinstance (key , tuple ))
158+
159+
151160def get_loopback_addr (ip_ver ):
152161 loopback_intfs = config_db .get_table ('LOOPBACK_INTERFACE' )
153162 loopback_addr = ''
154163
155164 for intf in loopback_intfs .keys ():
165+ if not is_ip_prefix_in_key (intf ):
166+ continue
156167 if 'Loopback0' in intf :
157168 intf_ip_prefix = intf [1 ]
158169 (intf_ip_ver , intf_ip_addr ) = extract_ip_ver_addr (intf_ip_prefix )
@@ -208,6 +219,8 @@ def get_vlan_addr(vlan_intf_name, ip_ver):
208219 vlan_addr = []
209220
210221 for intf in vlan_intfs .keys ():
222+ if not is_ip_prefix_in_key (intf ):
223+ continue
211224 if vlan_intf_name in intf :
212225 intf_ip_prefix = intf [1 ]
213226 (intf_ip_ver , intf_ip_addr ) = extract_ip_ver_addr (intf_ip_prefix )
You can’t perform that action at this time.
0 commit comments