Merge "allow OVSDB connection schema to be configurable"
This commit is contained in:
commit
e270fb41ae
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue