From cd89b87a82bf876fdf90786e087e1cdf8ac29a7d Mon Sep 17 00:00:00 2001 From: gbenhaim Date: Tue, 20 Mar 2018 17:52:37 +0200 Subject: [PATCH] brctl: Use "ip" to check if a bridge exists The interface of "brctl" was changed in fc27. When calling "brctl show X", if X doesn't exists, the return code is non-zero. In order to overcome this issue, check if the bridge exists using "ip" command. Signed-off-by: gbenhaim --- lago/brctl.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lago/brctl.py b/lago/brctl.py index 40e78042..abb22350 100644 --- a/lago/brctl.py +++ b/lago/brctl.py @@ -56,5 +56,14 @@ def destroy(name): def exists(name): - ret, out, err = _brctl('show', name) - return err == '' + ret, out, _ = utils.run_command( + ['ip', '-o', 'link', 'show', 'type', 'bridge'] + ) + if ret: + raise RuntimeError('Failed to check if bridge {} exists'.format(name)) + + for entry in out.splitlines(): + if name == entry.split(':')[1].strip(): + return True + + return False