Skip to content

Commit

Permalink
Remove config parsing for variables in birdc output
Browse files Browse the repository at this point in the history
  • Loading branch information
jplitza committed Sep 12, 2019
1 parent 2444dd8 commit 10053ce
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions birdagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ def __init__(self, cfgfile, birdcli, sscmd):
_re_config_include = re.compile("^include\s*\"(/[^\"]*)\".*$")
_re_config_bgp_proto_begin = re.compile(
"^protocol bgp ([a-zA-Z0-9_]+).*\{$")
_re_config_local_as = re.compile(
"local ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) as ([0-9]+);")
_re_config_bgp_holdtime = re.compile("hold time ([0-9]+);")
_re_config_bgp_keepalive = re.compile("keepalive time ([0-9]+);")
_re_config_remote_peer = re.compile(
"neighbor ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) as ([0-9]+);")
_re_config_timeformat = re.compile(
"\s*timeformat\s+protocol\s+iso\s+long\s+;")
_re_config_proto_end = re.compile("^\}$")
Expand Down Expand Up @@ -193,25 +189,6 @@ def getBGPState(self):
proto = match.group(1)
cfg["bgp-peers"][proto] = {}
if proto:
match = self._re_config_local_as.search(line)
if match:
cfg["bgp-peers"][proto]["bgpPeerLocalAddr"] = SnmpIpAddress(
match.group(1))
cfg["bgp-peers"][proto]["bgpPeerLocalAs"] = int(
match.group(2))
if "bgpLocalAs" not in cfg:
cfg["bgpLocalAs"] = int(match.group(2))
elif cfg["bgpLocalAs"] != int(match.group(2)):
print("WARNING: multiple local AS: %i/%i" %
(cfg["bgpLocalAs"], int(match.group(2))))

match = self._re_config_remote_peer.search(line)
if match:
cfg["bgp-peers"][proto]["bgpPeerRemoteAddr"] = SnmpIpAddress(
match.group(1))
cfg["bgp-peers"][proto]["bgpPeerRemoteAs"] = int(
match.group(2))

match = self._re_config_bgp_holdtime.search(line)
if match:
cfg["bgp-peers"][proto]["bgpPeerHoldTimeConfigured"] = int(
Expand All @@ -229,19 +206,6 @@ def getBGPState(self):
print("ERROR: timeformat not configured for this agent's use, terminating...")
sys.exit(1)

# Validate protocol's config
for proto in cfg["bgp-peers"]:
if not cfg["bgp-peers"][proto]: continue
if "bgpPeerLocalAddr" not in cfg["bgp-peers"][proto] and \
"bgpPeerLocalAs" not in cfg["bgp-peers"][proto]:
print(
"WARNING: Protocol \"%s\" does not have a properly formated 'local <ip> as <asn>;' line in the config" % proto)

if "bgpPeerRemoteAddr" not in cfg["bgp-peers"][proto] and \
"bgpPeerRemoteAs" not in cfg["bgp-peers"][proto]:
print(
"WARNING: Protocol \"%s\" does not have a properly formated 'neighbor <ip> as <asn>;' line in the config" % proto)

state = cfg.copy()
bgp_proto = None
# "with"-context-manager for Popen not available in python < 3.2
Expand Down

0 comments on commit 10053ce

Please sign in to comment.