configurable port option for l2gw agent

whenever l2gw agent IP:PORT is configured in manager table
of ovsdb server, it has to be configured in l2gateway_agent.ini
so that l2gw agent can listen for the connection request from ovsdb
server for the configured port.

Change-Id: Iac81c41cbac7daf43e72c12f094d6fefe33ce749
Closes-Bug: 1580869
stable/ocata
vikas 7 years ago
parent 9360989a30
commit 4cb660909f
  1. 15
      etc/l2gateway_agent.ini
  2. 7
      networking_l2gw/services/l2gateway/agent/ovsdb/base_connection.py
  3. 6
      networking_l2gw/services/l2gateway/common/config.py
  4. 2
      networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_base_connection.py

@ -11,10 +11,17 @@
# ovsdb_hosts =
# Example: ovsdb_hosts = 'ovsdb1:16.95.16.1:6632,ovsdb2:16.95.16.2:6632'
#enable_manager = False
#connection can be initiated by the ovsdb server.
#By default 'enable_manager' value is False, turn on the variable to True
#to initiate the connection from ovsdb server to l2gw agent.
# enable_manager = False
# (BoolOpt) connection can be initiated by the ovsdb server.
# By default 'enable_manager' value is False, turn on the variable to True
# to initiate the connection from ovsdb server to l2gw agent.
# manager_table_listening_port = 6632
# (PortOpt) set port number for l2gateway agent, so that it can listen
# for ovsdb server,whenever its IP is entered in manager table of ovsdb server.
# by default it is set to port 6632.
# you can use vtep-ctl utility to populate manager table of ovsdb.
# For Example: sudo vtep-ctl set-manager tcp:x.x.x.x:6640,
# where x.x.x.x is IP of l2gateway agent and 6640 is a port.
# (StrOpt) Base path to private key file(s).
# Agent will find key file named

@ -44,6 +44,8 @@ class BaseConnection(object):
self.mgr = mgr
self.enable_manager = cfg.CONF.ovsdb.enable_manager
if self.enable_manager:
self.manager_table_listening_port = (
cfg.CONF.ovsdb.manager_table_listening_port)
self.s = None
self.check_c_sock = None
self.check_sock_rcv = False
@ -90,8 +92,9 @@ class BaseConnection(object):
def _rcv_socket(self):
# Create a socket object.
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = '' # Get local machine name
port = 6632 # Reserve a port for your service.
host = '' # Get local machine name
port = self.manager_table_listening_port
# configured port for your service.
self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.s.bind((host, port)) # Bind to the port
self.s.listen(5) # Now wait for client connection.

@ -36,6 +36,12 @@ OVSDB_OPTS = [
cfg.BoolOpt('enable_manager',
default=False,
help=_('Set to True if ovsdb Manager manages the client')),
cfg.PortOpt('manager_table_listening_port',
default=6632,
help=_('Set port number for l2gw agent, so that it can '
'listen to whenever its IP is entered in manager '
'table of ovsdb server, For Ex: tcp:x.x.x.x:6640, '
'where x.x.x.x is IP of l2gw agent')),
cfg.IntOpt('max_connection_retries',
default=10,
help=_('Maximum number of retries to open a socket '

@ -204,6 +204,8 @@ class TestBaseConnection_with_enable_manager(base.BaseTestCase):
self.assertIsNone(self.l2gw_ovsdb_conn.check_c_sock)
self.assertEqual(self.l2gw_ovsdb_conn.ovsdb_dicts, fake_dict)
self.assertEqual(self.l2gw_ovsdb_conn.ovsdb_fd_states, fake_dict)
self.assertEqual(self.l2gw_ovsdb_conn.manager_table_listening_port,
6632)
self.assertTrue(mock_thread.called)
def test_send_monitor_msg_to_ovsdb_connection(self):

Loading…
Cancel
Save