diff options
Diffstat (limited to 'src/ovs/ofctl.py')
-rw-r--r-- | src/ovs/ofctl.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/ovs/ofctl.py b/src/ovs/ofctl.py index 93894889..d7a2b320 100644 --- a/src/ovs/ofctl.py +++ b/src/ovs/ofctl.py @@ -57,12 +57,18 @@ class OFBase(object): def run_vsctl(self, args, check_error=False): """Run ``ovs-vsctl`` with supplied arguments. + In case that timeout is set to -1, then ovs-vsctl + will be called with --no-wait option. + :param args: Arguments to pass to ``ovs-vsctl`` :param check_error: Throw exception on error :return: None """ - cmd = ['sudo', _OVS_VSCTL_BIN, '--timeout', str(self.timeout)] + args + if self.timeout == -1: + cmd = ['sudo', _OVS_VSCTL_BIN, '--no-wait'] + args + else: + cmd = ['sudo', _OVS_VSCTL_BIN, '--timeout', str(self.timeout)] + args return tasks.run_task( cmd, self.logger, 'Running ovs-vsctl...', check_error) @@ -343,6 +349,37 @@ class OFBridge(OFBase): self.logger.debug('dump flows') self.run_ofctl(['dump-flows', self.br_name], timeout=120) + def set_stp(self, enable=True): + """ + Set stp status + :param enable: Boolean to enable or disable stp + :return: None + """ + self.logger.debug( + 'Setting stp on bridge to %s', 'on' if enable else 'off') + self.run_vsctl( + ['set', 'Bridge', self.br_name, 'stp_enable={}'.format( + 'true' if enable else 'false')]) + + def set_rstp(self, enable=True): + """ + Set rstp status + :param enable: Boolean to enable or disable rstp + :return: None + """ + self.logger.debug( + 'Setting rstp on bridge to %s', 'on' if enable else 'off') + self.run_vsctl( + ['set', 'Bridge', self.br_name, 'rstp_enable={}'.format( + 'true' if enable else 'false')]) + + def bridge_info(self): + """ + Get bridge info + :return: Returns bridge info from list bridge command + """ + return self.run_vsctl(['list', 'bridge', self.br_name]) + # # helper functions # |