mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-31 13:03:02 +02:00
statd: silence bogus log warnings
With a basic bridge setup, which has multicast snooping disabled by default, `show interfaces` cause the following bogus log messages: Sep 13 07:08:35 yanger: Command '['mctl', 'show', 'igmp', 'json']' returned non-zero exit status 1 Sep 13 07:08:35 yanger: Command '['mctl', 'show', 'igmp', 'json']' returned non-zero exit status 1 Sep 13 07:08:35 yanger: Command '['mctl', '-p', 'show', 'igmp', 'json']' returned non-zero exit status 1 Add a quiet flag to the run methods and set quiet=True for all mctl commands to silence these log messages. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -102,14 +102,16 @@ def insert(obj, *path_and_value):
|
|||||||
curr[path[-1]] = value
|
curr[path[-1]] = value
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(cmd, testfile, default=None):
|
def run_cmd(cmd, testfile, default=None, check=True):
|
||||||
"""Run a command (array of args) and return an array of lines"""
|
"""Run a command (array of args) and return an array of lines"""
|
||||||
|
|
||||||
if TESTPATH and testfile:
|
if TESTPATH and testfile:
|
||||||
cmd = ['cat', os.path.join(TESTPATH, testfile)]
|
cmd = ['cat', os.path.join(TESTPATH, testfile)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(cmd, stderr=subprocess.DEVNULL, text=True)
|
result = subprocess.run(cmd, check=check, stderr=subprocess.DEVNULL,
|
||||||
|
stdout=subprocess.PIPE, text=True)
|
||||||
|
output = result.stdout
|
||||||
return output.splitlines()
|
return output.splitlines()
|
||||||
except subprocess.CalledProcessError as err:
|
except subprocess.CalledProcessError as err:
|
||||||
logger.error(f"{err}")
|
logger.error(f"{err}")
|
||||||
@@ -118,14 +120,14 @@ def run_cmd(cmd, testfile, default=None):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def run_json_cmd(cmd, testfile, default=None):
|
def run_json_cmd(cmd, testfile, default=None, check=True):
|
||||||
"""Run a command (array of args) with JSON output and return the JSON"""
|
"""Run a command (array of args) with JSON output and return the JSON"""
|
||||||
|
|
||||||
if TESTPATH and testfile:
|
if TESTPATH and testfile:
|
||||||
cmd = ['cat', os.path.join(TESTPATH, testfile)]
|
cmd = ['cat', os.path.join(TESTPATH, testfile)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(cmd, check=True, stdout=subprocess.PIPE,
|
result = subprocess.run(cmd, check=check, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE, text=True)
|
stderr=subprocess.PIPE, text=True)
|
||||||
output = result.stdout
|
output = result.stdout
|
||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
@@ -528,9 +530,9 @@ def add_container(containers):
|
|||||||
|
|
||||||
|
|
||||||
def get_brport_multicast(ifname):
|
def get_brport_multicast(ifname):
|
||||||
data = run_json_cmd(['mctl', 'show', 'igmp', 'json'],
|
"""Check if multicast snooping is enabled on bridge, default: nope"""
|
||||||
"igmp-status.json",
|
data = run_json_cmd(['mctl', 'show', 'igmp', 'json'], "igmp-status.json",
|
||||||
default={})
|
default={}, check=False)
|
||||||
multicast = {}
|
multicast = {}
|
||||||
|
|
||||||
if ifname in data.get('fast-leave-ports', []):
|
if ifname in data.get('fast-leave-ports', []):
|
||||||
@@ -890,9 +892,10 @@ def main():
|
|||||||
add_ethtool_std(ifname, iface_out)
|
add_ethtool_std(ifname, iface_out)
|
||||||
|
|
||||||
if 'type' in iface_out and iface_out['type'] == "infix-if-type:bridge":
|
if 'type' in iface_out and iface_out['type'] == "infix-if-type:bridge":
|
||||||
|
# Fail silent, multicast snooping may not be enabled on bridge
|
||||||
mc_status = run_json_cmd(['mctl', '-p', 'show', 'igmp', 'json'],
|
mc_status = run_json_cmd(['mctl', '-p', 'show', 'igmp', 'json'],
|
||||||
"igmp-status.json",
|
"igmp-status.json", default={},
|
||||||
default={})
|
check=False)
|
||||||
|
|
||||||
add_vlans_to_bridge(ifname, iface_out, mc_status)
|
add_vlans_to_bridge(ifname, iface_out, mc_status)
|
||||||
add_mdb_to_bridge(ifname, iface_out, mc_status)
|
add_mdb_to_bridge(ifname, iface_out, mc_status)
|
||||||
|
|||||||
Reference in New Issue
Block a user