Skip to content

Commit

Permalink
brctl: Use "ip" to check if a bridge exists
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gbenhaim committed Mar 20, 2018
1 parent 802e6d1 commit cd89b87
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lago/brctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cd89b87

Please sign in to comment.