diff options
author | Jason Kölker <jason@koelker.net> | 2016-03-15 20:50:25 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-17 06:11:11 +0900 |
commit | 2b047bd7d7a09db2506ac1e2d6345bcc1e7db3c5 (patch) | |
tree | 4c3ff5170c446d0c14fa160283ca3c590b7aed0a | |
parent | a3c8c591d9e6fe1353f7ba54f56a40f09d301f79 (diff) |
protocols/ovsdb: Allow setting backoff settings
Signed-off-by: Jason Kölker <jason@koelker.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/ovsdb/client.py | 12 | ||||
-rw-r--r-- | ryu/services/protocols/ovsdb/manager.py | 12 |
2 files changed, 22 insertions, 2 deletions
diff --git a/ryu/services/protocols/ovsdb/client.py b/ryu/services/protocols/ovsdb/client.py index ef532b38..5d4b21ff 100644 --- a/ryu/services/protocols/ovsdb/client.py +++ b/ryu/services/protocols/ovsdb/client.py @@ -192,7 +192,8 @@ class RemoteOvsdb(app_manager.RyuApp): event.EventPortUpdated] @classmethod - def factory(cls, sock, address, probe_interval=None, *args, **kwargs): + def factory(cls, sock, address, probe_interval=None, min_backoff=None, + max_backoff=None, *args, **kwargs): ovs_stream = stream.Stream(sock, None, None) connection = jsonrpc.Connection(ovs_stream) schemas = discover_schemas(connection) @@ -209,6 +210,15 @@ class RemoteOvsdb(app_manager.RyuApp): if probe_interval is not None: fsm.set_probe_interval(probe_interval) + if min_backoff is None: + min_backoff = fsm.get_min_backoff() + + if max_backoff is None: + max_backoff = fsm.get_max_backoff() + + if min_backoff and max_backoff: + fsm.set_backoff(min_backoff, max_backoff) + fsm.connected(now()) session = jsonrpc.Session(fsm, connection) diff --git a/ryu/services/protocols/ovsdb/manager.py b/ryu/services/protocols/ovsdb/manager.py index 631f28bd..b828eb73 100644 --- a/ryu/services/protocols/ovsdb/manager.py +++ b/ryu/services/protocols/ovsdb/manager.py @@ -27,6 +27,12 @@ from ryu.controller import handler opts = (cfg.StrOpt('address', default='0.0.0.0', help='OVSDB address'), cfg.IntOpt('port', default=6640, help='OVSDB port'), cfg.IntOpt('probe-interval', help='OVSDB reconnect probe interval'), + cfg.IntOpt('min-backoff', + help=('OVSDB reconnect minimum milliseconds between ' + 'connection attemps')), + cfg.IntOpt('max-backoff', + help=('OVSDB reconnect maximum milliseconds between ' + 'connection attemps')), cfg.StrOpt('mngr-privkey', default=None, help='manager private key'), cfg.StrOpt('mngr-cert', default=None, help='manager certificate'), cfg.ListOpt('whitelist', default=[], @@ -45,6 +51,8 @@ class OVSDB(app_manager.RyuApp): self._address = self.CONF.ovsdb.address self._port = self.CONF.ovsdb.port self._probe_interval = self.CONF.ovsdb.probe_interval + self._min_backoff = self.CONF.ovsdb._min_backoff + self._max_backoff = self.CONF.ovsdb._max_backoff self._clients = {} def _accept(self, server): @@ -92,7 +100,9 @@ class OVSDB(app_manager.RyuApp): def _start_remote(self, sock, client_address): app = client.RemoteOvsdb.factory(sock, client_address, - probe_interval=self._probe_interval) + probe_interval=self._probe_interval, + min_backoff=self._min_backoff, + max_backoff=self._max_min_backoff) if app: self._clients[app.name] = app |