Skip to content

Commit

Permalink
Fixed for erasing LGTM alert and other minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozhenhong committed Aug 25, 2020
1 parent 2a5c58e commit e942575
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dockers/docker-fpm-frr/docker_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CFGGEN_PARAMS=" \
"
if [ -n "$TEMPL_CONFIG" ] && [ "$TEMPL_CONFIG" == "false" ]; then
CFGGEN_PARAMS+=" \
-t /usr/share/sonic/templates/bgdd/bfdd.conf.j2,/etc/frr/bfdd.conf \
-t /usr/share/sonic/templates/bfdd/bfdd.conf.j2,/etc/frr/bfdd.conf \
-t /usr/share/sonic/templates/ospfd/ospfd.conf.j2,/etc/frr/ospfd.conf \
"
fi
Expand Down
2 changes: 2 additions & 0 deletions dockers/docker-fpm-frr/frr/ospfd/ospfd.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% include "ospfd.conf.db.comm_list.j2" %}
{% include "ospfd.conf.db.interface.j2" %}
37 changes: 25 additions & 12 deletions src/sonic-bgpcfgd/bgpcfgd_no_template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import os
from swsssdk import ConfigDBConnector
import socket
import threading
import pty
import Queue
import signal
import re
Expand Down Expand Up @@ -82,7 +81,6 @@ class BgpdClientMgr(threading.Thread):
'BGP_GLOBALS': ['bgpd'],
'BGP_GLOBALS_AF': ['bgpd'],
'PREFIX_SET': ['bgpd'],
'PREFIX': ['bgpd'],
'COMMUNITY_SET': ['bgpd'],
'EXTENDED_COMMUNITY_SET': ['bgpd'],
'ROUTE_MAP': ['zebra', 'bgpd', 'ospfd'],
Expand Down Expand Up @@ -498,6 +496,10 @@ class BGPKeyMapInfo:
else:
self.hdl_func = hdlr
self.data = data
def __eq__(self, other):
return set(self.daemons) == set(other.daemons) and self.run_cmd == other.run_cmd
def __ne__(self, other):
return set(self.daemons) != set(other.daemons) or self.run_cmd != other.run_cmd
def get_command(self, daemon, op, st_idx, *vals):
return self.hdl_func(daemon, self.run_cmd, op, st_idx, vals, self.data)
def __str__(self):
Expand Down Expand Up @@ -544,6 +546,10 @@ class BGPKeyMapList(list):
except ValueError:
pass
super(BGPKeyMapList, self).append((db_field, BGPKeyMapInfo(cmd_str, hdl_func, hdl_data)))
def __eq__(self, other):
return super(BGPKeyMapList, self).__eq__(other) and self.table_name == other.table_name and self.table_key == self.table_key
def __ne__(self, other):
return super(BGPKeyMapList, self).__ne__(other) or self.table_name != other.table_name or self.table_key != self.table_key
@staticmethod
def get_map_field_key(field):
if type(field) is str:
Expand Down Expand Up @@ -1177,7 +1183,6 @@ def handle_ospf_if_mtu_ignore(daemon, cmd_str, op, st_idx, args, data):

def handle_ospf_if_nwtype(daemon, cmd_str, op, st_idx, args, data):
cmd_list = []
if_addr = "" if args[1] == '0.0.0.0' else args[1]
no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else ''

nwtype = ''
Expand Down Expand Up @@ -1234,7 +1239,6 @@ def handle_igmp_if_enable(daemon, cmd_str, op, st_idx, args, data):

def handle_ip_sla_common(daemon, cmd_str, op, st_idx, args, data):
cmd_list = []
param_value = args[0]

syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla cmd_str {} op {} st_idx {} args {} data {}'.format(
cmd_str, op, st_idx, args, data))
Expand All @@ -1248,7 +1252,6 @@ def handle_ip_sla_common(daemon, cmd_str, op, st_idx, args, data):

def handle_ip_sla_tcp_connect(daemon, cmd_str, op, st_idx, args, data):
cmd_list = []
param_value = args[0]

syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla_tcp_connect cmd_str {} op {} st_idx {} args {} data {}'.format(
cmd_str, op, st_idx, args, data))
Expand All @@ -1265,7 +1268,6 @@ def handle_ip_sla_tcp_connect(daemon, cmd_str, op, st_idx, args, data):

def handle_ip_sla_icmp_echo(daemon, cmd_str, op, st_idx, args, data):
cmd_list = []
param_value = args[0]

syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla_icmp_echo cmd_str {} op {} st_idx {} args {} data {}'.format(
cmd_str, op, st_idx, args, data))
Expand Down Expand Up @@ -1543,6 +1545,8 @@ class MatchPrefix:
else:
self.min_len = self.max_len = None
self.action = action
def __hash__(self):
return hash((self.ip_prefix, self.min_len, self.max_len))
def __str__(self):
ret_str = '%s %s' % (self.action.lower(), self.ip_prefix)
if self.min_len is not None:
Expand All @@ -1554,6 +1558,10 @@ class MatchPrefix:
return (self.ip_prefix == other.ip_prefix and
self.min_len == other.min_len and
self.max_len == other.max_len)
def __ne__(self, other):
return (self.ip_prefix != other.ip_prefix or
self.min_len != other.min_len or
self.max_len != other.max_len)

class MatchPrefixList(list):
def __init__(self, af_mode = None):
Expand All @@ -1562,6 +1570,10 @@ class MatchPrefixList(list):
self.af = None
else:
self.af = socket.AF_INET if af_mode == 'ipv4' else socket.AF_INET6
def __eq__(self, other):
return super(MatchPrefixList, self).__eq__(other) and self.af == other.af
def __ne__(self, other):
return super(MatchPrefixList, self).__ne__(other) or self.af != other.af
@staticmethod
def __get_ip_af(ip_pfx):
ip_pfx = ip_pfx.split('/')
Expand Down Expand Up @@ -1616,9 +1628,13 @@ class IpNextHop:
syslog.syslog(syslog.LOG_ERR, 'Mandatory attribute not found for nexthop')
raise ValueError
def __eq__(self, other):
return (self.af == other.af and self.blackhole == other.blackhole and
return (self.af == other.af and self.blackhole == other.blackhole and
self.ip == other.ip and self.track == other.track and self.interface == other.interface and
self.tag == other.tag and self.distance == other.distance and self.nh_vrf == other.nh_vrf)
def __ne__(self, other):
return (self.af != other.af or self.blackhole != other.blackhole or
self.ip != other.ip or self.track != other.track or self.interface != other.interface or
self.tag != other.tag or self.distance != other.distance or self.nh_vrf != other.nh_vrf)
def __hash__(self):
return hash((self.af, self.blackhole, self.ip, self.track, self.interface, self.tag, self.distance, self.nh_vrf))
def __str__(self):
Expand Down Expand Up @@ -3334,7 +3350,6 @@ class BGPConfigDaemon:
metriccmd = ""
metrictypecmd = ""
alwayscmd = ""
mapname = ""
acclistname = ""
rmapoper = ""
metricoper = ""
Expand All @@ -3345,7 +3360,6 @@ class BGPConfigDaemon:
if 'route-map' in data:
dval = data['route-map']
rmapoper = dval.op
mapname = dval.data
rmapcmd = " route-map {}".format(dval.data)

if 'access-list' in data:
Expand Down Expand Up @@ -3398,7 +3412,7 @@ class BGPConfigDaemon:
cmd_suffix = "no distribute-list {} out {}".format(acclistname, protocol.lower())

command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c '{}'".\
format(vrf, cmd_suffix)
format(vrf, cmd_suffix)

if not self.__run_command(table, command):
syslog.syslog(syslog.LOG_ERR, 'failed to create distribute-list {} {}'.format(protocol, direction))
Expand All @@ -3418,7 +3432,7 @@ class BGPConfigDaemon:
cmd_suffix = "no redistribute {}".format(protocol.lower()) + del_cmd_suffix

command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c '{}'".\
format(vrf, cmd_suffix)
format(vrf, cmd_suffix)

if not self.__run_command(table, command):
syslog.syslog(syslog.LOG_ERR, 'failed to create default-info/redistribute {} {}'.format(protocol, direction))
Expand All @@ -3429,7 +3443,6 @@ class BGPConfigDaemon:
if (direction == "IMPORT"):
command = ""
if (protocol == "DEFAULT_ROUTE"):
cmd_suffix = "no default-information originate" + cmd_suffix
command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no default-information originate'".\
format(vrf)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ log facility local4
! set static default route to mgmt gateway as a backup to learned default
ip route 0.0.0.0/0 10.0.0.1 200
!!
!

0 comments on commit e942575

Please sign in to comment.