net-misc/exabgp-4.2.11-r2: Revbump, supervision, misc bugfixes

Copyright: Sony Interactive Entertainment Inc.
Package-Manager: Portage-3.0.15, Repoman-3.0.2
Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
This commit is contained in:
Patrick McLean
2021-02-25 09:31:21 -08:00
committed by Patrick McLean
parent 88ebc2b6b9
commit 6e73d50d48
5 changed files with 202 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
PYTHON_COMPAT=( python3_{7..9} )
DISTUTILS_USE_SETUPTOOLS=rdepend
inherit tmpfiles systemd distutils-r1
DESCRIPTION="The BGP swiss army knife of networking"
HOMEPAGE="https://github.com/Exa-Networks/exabgp"
SRC_URI="https://github.com/Exa-Networks/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64"
IUSE="test"
RESTRICT="!test? ( test )"
RDEPEND="
acct-group/exabgp
acct-user/exabgp
"
BDEPEND="
test? (
dev-python/psutil[${PYTHON_USEDEP}]
dev-python/nose[${PYTHON_USEDEP}]
dev-python/six[${PYTHON_USEDEP}]
)
"
PATCHES=(
"${FILESDIR}/exabgp-4.2.7-paths.patch"
"${FILESDIR}/exabgp-4.2.10-ip-path.patch"
"${FILESDIR}/exabgp-4.2.11-healthcheck-allow-disable-metric.patch"
"${FILESDIR}/exabgp-4.2.11-healthcheck-fix-log-crash.patch"
"${FILESDIR}/exabgp-4.2.11-less-verbose-logging.patch"
)
python_test() {
./qa/bin/parsing || die "tests fail with ${EPYTHON}"
nosetests -v ./qa/tests/*_test.py || die "tests fail with ${EPYTHON}"
}
python_install_all() {
distutils-r1_python_install_all
newinitd "${FILESDIR}/${PN}.initd-r1" ${PN}
newconfd "${FILESDIR}/${PN}.confd" ${PN}
newtmpfiles "${FILESDIR}/exabgp.tmpfiles" ${PN}.conf
systemd_dounit etc/systemd/*
insinto /etc/logrotate.d
newins "${FILESDIR}/${PN}.logrotate" ${PN}
keepdir /etc/exabgp
doman doc/man/*.?
}

View File

@@ -0,0 +1,22 @@
diff --git a/lib/exabgp/application/healthcheck.py b/lib/exabgp/application/healthcheck.py
index a4f6b8d1..805cf8af 100644
--- a/lib/exabgp/application/healthcheck.py
+++ b/lib/exabgp/application/healthcheck.py
@@ -168,6 +168,7 @@
g.add_argument(
"--start-ip", metavar='N', type=int, default=0, help="index of the first IP in the list of IP addresses"
)
+ g.add_argument("--no-metric", action="store_true", default=False, help="don't send metrics when updating announcements")
g.add_argument(
"--up-metric", metavar='M', type=int, default=100, help="first IP get the metric M when the service is up"
)
@@ -494,7 +495,8 @@
announce = "route {0} next-hop {1}".format(str(ip), options.next_hop or "self")
if command == "announce":
- announce = "{0} med {1}".format(announce, metric)
+ if not options.no_metric:
+ announce = "{0} med {1}".format(announce, metric)
if options.local_preference >= 0:
announce = "{0} local-preference {1}".format(announce, options.local_preference)
if options.community or options.disabled_community:

View File

@@ -0,0 +1,13 @@
diff --git a/lib/exabgp/logger.py b/lib/exabgp/logger.py
index 41a1cf28..f87785a2 100644
--- a/lib/exabgp/logger.py
+++ b/lib/exabgp/logger.py
@@ -339,7 +339,7 @@ class Logger(object):
else:
src = source
- log = self._option.get(src, True) and getattr(syslog, 'LOG_%s' % level) <= self.level
+ log = self._option.get(src, True) and getattr(syslog, 'LOG_%s' % level, logging.handlers.SysLogHandler.LOG_DAEMON) <= self.level
if not log:
return

View File

@@ -0,0 +1,44 @@
diff --git a/lib/exabgp/application/healthcheck.py b/lib/exabgp/application/healthcheck.py
index a4f6b8d1..d8195074 100644
--- a/lib/exabgp/application/healthcheck.py
+++ b/lib/exabgp/application/healthcheck.py
@@ -159,7 +159,16 @@ def setup_logging(debug, silent, name, syslog_facility, syslog):
enable_syslog = syslog and not debug
# To syslog
if enable_syslog:
- facility = getattr(logging.handlers.SysLogHandler, "LOG_{0}".format(syslog_facility.upper()))
+ if isinstance(syslog_facility, int) or syslog_facility.isdigit():
+ for log_facility, value in sorted(logging.handlers.SysLogHandler.facility_names.items(), key=lambda x: x[1]):
+ if value >= int(syslog_facility):
+ facility = log_facility
+ break
+ elif hasattr(logging.handlers.SysLogHandler, "LOG_{0}".format(syslog_facility.upper())):
+ facility = getattr(logging.handlers.SysLogHandler, "LOG_{0}".format(syslog_facility.upper()))
+ else:
+ facility = logging.handlers.SysLogHandler.LOG_DAEMON
+
sh = logging.handlers.SysLogHandler(address=str(syslog_address()), facility=facility)
if name:
healthcheck_name = "healthcheck-{0}".format(name)
diff --git a/lib/exabgp/reactor/api/command/announce.py b/lib/exabgp/reactor/api/command/announce.py
index 3c9091d2..e21cbe95 100644
--- a/lib/exabgp/reactor/api/command/announce.py
+++ b/lib/exabgp/reactor/api/command/announce.py
@@ -6,6 +6,7 @@ Created by Thomas Mangin on 2017-07-01.
Copyright (c) 2009-2017 Exa Networks. All rights reserved.
License: 3-clause BSD. (See the COPYRIGHT file)
"""
+import logging
from exabgp.reactor.api.command.command import Command
from exabgp.reactor.api.command.limit import match_neighbors
@@ -50,7 +51,8 @@ def announce_route(self, reactor, service, line):
change.nlri.action = OUT.ANNOUNCE
reactor.configuration.inject_change(peers, change)
self.log_message(
- 'route added to %s : %s' % (', '.join(peers) if peers else 'all peers', change.extensive())
+ 'route added to %s : %s' % (', '.join(peers) if peers else 'all peers', change.extensive()),
+ level=logging.WARNING
)
yield False

View File

@@ -0,0 +1,64 @@
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# default arguments
: "${EXABGP_ARGS:=--env=/etc/${RC_SVCNAME}/exabgp.env /etc/${RC_SVCNAME}/exabgp.conf}"
command="capsh"
command_args="
--uid=${EXABGP_USER:=exabgp}
--gid=${EXABGP_GROUP:=exabgp}
--caps='cap_net_admin+epi cap_setuid+ep-i cap_setgid+ep-i'
-- -c \"/usr/bin/exabgp ${EXABGP_ARGS}\""
supervisor=supervise-daemon
: "${pidfile:=/run/exabgp/${RC_SVCNAME}-supervisor.pid}"
: "${output_log:=/var/log/${RC_SVCNAME}/exabgp.log}"
: "${error_log:=/var/log/${RC_SVCNAME}/exabgp.log}"
extra_started_commands="routes sessions"
extra_commands="checkconfig"
depend() {
need net
}
start_pre() {
checkpath -q -d -m 0755 -o "${EXABGP_USER}:${EXABGP_GROUP}" \
/run/exabgp || return
checkpath -q -p -m 0600 -o "${EXABGP_USER}:${EXABGP_GROUP}" \
/run/exabgp/${RC_SVCNAME}.{in,out} || return
checkpath -q -d -m 0755 -o "${EXABGP_USER}:${EXABGP_GROUP}" \
"/var/log/${RC_SVCNAME}" || return
checkconfig || return
}
stop_pre() {
# don't restart if the configuration is bad
if [ "${RC_CMD}" = restart ]; then
checkconfig || return
fi
}
checkconfig() {
ebegin "Checking configuration for ${RC_SVCNAME}"
exabgp -t ${EXABGP_ARGS}
eend ${?} "Invalid configuration"
}
sessions() {
ebegin "Querying sessions"
exabgpcli --env /etc/${RC_SVCNAME}/exabgp.env show neighbor summary
eend ${?} "exabgpcli failed"
}
routes() {
ebegin "Querying routes"
exabgpcli --env /etc/${RC_SVCNAME}/exabgp.env show adj-rib out
eend ${?} "exabgpcli failed"
}