]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
allow OVSDB connection schema to be configurable
authorGal Sagie <gal.sagie@huawei.com>
Mon, 6 Apr 2015 13:11:23 +0000 (16:11 +0300)
committerGal Sagie <gal.sagie@huawei.com>
Mon, 13 Apr 2015 06:31:52 +0000 (09:31 +0300)
Add the schema name as a parameter to the OVSDB IDL connection.
That way other users can use this with other schemas

Change-Id: I55ab5ae4f3f937d236eee773f9717b5090c18557
Closes-Bug: #1441180

neutron/agent/ovsdb/impl_idl.py
neutron/agent/ovsdb/native/connection.py
neutron/agent/ovsdb/native/idlutils.py

index dfea54ba23ca2bce0a1a84e1db90a7b9b2728e4a..011db3a91d60fd98e01aaeff2caa0a94da9c96a0 100644 (file)
@@ -120,7 +120,8 @@ class Transaction(api.Transaction):
 class OvsdbIdl(api.API):
 
     ovsdb_connection = connection.Connection(cfg.CONF.OVS.ovsdb_connection,
-                                             cfg.CONF.ovs_vsctl_timeout)
+                                             cfg.CONF.ovs_vsctl_timeout,
+                                             'Open_vSwitch')
 
     def __init__(self, context):
         super(OvsdbIdl, self).__init__(context)
index 22b42ff3864bd27da0d1662b0c256cd6d72e2010..ce0d21691e53e772bc4b1bd7d260994f29903981 100644 (file)
@@ -49,19 +49,21 @@ class TransactionQueue(Queue.Queue, object):
 
 
 class Connection(object):
-    def __init__(self, connection, timeout):
+    def __init__(self, connection, timeout, schema_name):
         self.idl = None
         self.connection = connection
         self.timeout = timeout
         self.txns = TransactionQueue(1)
         self.lock = threading.Lock()
+        self.schema_name = schema_name
 
     def start(self):
         with self.lock:
             if self.idl is not None:
                 return
 
-            helper = idlutils.get_schema_helper(self.connection)
+            helper = idlutils.get_schema_helper(self.connection,
+                                                self.schema_name)
             helper.register_all()
             self.idl = idl.Idl(self.connection, helper)
             idlutils.wait_for_change(self.idl, self.timeout)
index bcb237cf10f4e696acea604f0bffc3d3f2c8b388..ba0508eaf56f2f2692e497874201e69ae483dcd2 100644 (file)
@@ -93,14 +93,14 @@ class ExceptionResult(object):
         self.tb = tb
 
 
-def get_schema_helper(connection):
+def get_schema_helper(connection, schema_name):
     err, strm = stream.Stream.open_block(
         stream.Stream.open(connection))
     if err:
         raise Exception("Could not connect to %s" % (
             connection,))
     rpc = jsonrpc.Connection(strm)
-    req = jsonrpc.Message.create_request('get_schema', ['Open_vSwitch'])
+    req = jsonrpc.Message.create_request('get_schema', [schema_name])
     err, resp = rpc.transact_block(req)
     rpc.close()
     if err: