From f0f9907b9da1c7f6dcccf14f06c25a542c059aa6 Mon Sep 17 00:00:00 2001 From: Bob Lantz <rlantz@cs.stanford.edu> Date: Wed, 19 Nov 2014 09:32:56 -0800 Subject: [PATCH] Add setup() and dpctl() methods for LinuxBridge Also adds docstrings. Fixes #422 --- mininet/nodelib.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mininet/nodelib.py b/mininet/nodelib.py index 1760c7b3..dc126bed 100644 --- a/mininet/nodelib.py +++ b/mininet/nodelib.py @@ -6,6 +6,8 @@ from mininet.node import Node, Switch from mininet.log import setLogLevel, info +from mininet.moduledeps import pathCheck + class LinuxBridge( Switch ): "Linux Bridge (with optional spanning tree)" @@ -31,6 +33,7 @@ def connected( self ): return True def start( self, controllers ): + "Start Linux bridge" self.cmd( 'ifconfig', self, 'down' ) self.cmd( 'brctl delbr', self ) self.cmd( 'brctl addbr', self ) @@ -43,9 +46,20 @@ def start( self, controllers ): self.cmd( 'ifconfig', self, 'up' ) def stop( self ): + "Stop Linux bridge" self.cmd( 'ifconfig', self, 'down' ) self.cmd( 'brctl delbr', self ) + def dpctl( self, *args ): + "Run brctl command" + return self.cmd( 'brctl', *args ) + + @classmethod + def setup( cls ): + "Make sure our class dependencies are available" + pathCheck( 'brctl', moduleName='bridge-utils' ) + + class NAT( Node ): """NAT: Provides connectivity to external network""" -- GitLab