def start(self): with self.lock: if self.idl is not None: return try: helper = idlutils.get_schema_helper(self.connection, self.schema_name) except Exception: # We may have failed do to set-manager not being called helpers.enable_connection_uri(self.connection) # There is a small window for a race, so retry up to a second @retrying.retry(wait_exponential_multiplier=10, stop_max_delay=1000) def do_get_schema_helper(): return idlutils.get_schema_helper(self.connection, self.schema_name) helper = do_get_schema_helper() helper.register_all() self.idl = idl.Idl(self.connection, helper) idlutils.wait_for_change(self.idl, self.timeout) self.poller = poller.Poller() self.thread = threading.Thread(target=self.run) self.thread.setDaemon(True) self.thread.start()
def start(self, table_name_list=None): """ :param table_name_list: A list of table names for schema_helper to register. When this parameter is given, schema_helper will only register tables which name are in list. Otherwise, schema_helper will register all tables for given schema_name as default. """ with self.lock: if self.idl is not None: return try: helper = get_schema_helper(self.connection, self.schema_name) except Exception: # We may have failed do to set-manager not being called enable_connection_uri() # There is a small window for a race, so retry up to a second @retrying.retry(wait_exponential_multiplier=10, stop_max_delay=1000) def do_get_schema_helper(): return get_schema_helper(self.connection, self.schema_name) helper = do_get_schema_helper() if table_name_list is None: helper.register_all() else: for table_name in table_name_list: helper.register_table(table_name) self.idl = idl.Idl(self.connection, helper) wait_for_change(self.idl, self.timeout)
def get_ovsdb_connection(connection_string, schema, timeout, tables=None): helper = idlutils.get_schema_helper(connection_string, schema) if tables: for table in tables: helper.register_table(table) else: helper.register_all() return connection.Connection(idl.Idl(connection_string, helper), timeout)
def conn(): log.info('Connecting to OpenSwitch...') helper = utils.get_schema_helper(self.ovsdb, self.schema_name) helper.register_all() self.idl = idl.Idl(self.ovsdb, helper) utils.wait_for_change(self.idl, self.timeout) self.poller = poller.Poller() self.hdr = handle.OpsHandler(self.idl, self)
def start(self): connection_string = config.cfg.CONF.ovs.ovsdb_connection helper = idlutils.get_schema_helper(connection_string, 'Open_vSwitch') tables = ('Open_vSwitch', 'Bridge', 'Port', 'Interface') for table in tables: helper.register_table(table) ovs_idl = idl.Idl(connection_string, helper) conn = connection.Connection( ovs_idl, timeout=config.cfg.CONF.ovs.ovsdb_connection_timeout) return idl_ovs.OvsdbIdl(conn)
def start(self, connection_string): helper = idlutils.get_schema_helper(connection_string, 'Open_vSwitch') tables = ('Open_vSwitch', 'Bridge', 'Port', 'Interface') for table in tables: helper.register_table(table) ovs_idl = idl.Idl(connection_string, helper) ovs_idl._session.reconnect.set_probe_interval(60000) conn = connection.Connection( ovs_idl, timeout=180) self.idl_ovs = idl_ovs.OvsdbIdl(conn)
def start(self): with self.lock: if self.idl is not None: return self.idl = idl.Idl(self.connection, self._schema_helper) idlutils.wait_for_change(self.idl, self.timeout) self.poller = poller.Poller() self.thread = threading.Thread(target=self.run) self.thread.setDaemon(True) self.thread.start()
def idl_factory(): conn = cfg.CONF.OVS.ovsdb_connection schema_name = 'Open_vSwitch' try: helper = idlutils.get_schema_helper(conn, schema_name) except Exception: helpers.enable_connection_uri(conn) @tenacity.retry(wait=tenacity.wait_exponential(multiplier=0.01), stop=tenacity.stop_after_delay(1), reraise=True) def do_get_schema_helper(): return idlutils.get_schema_helper(conn, schema_name) helper = do_get_schema_helper() # TODO(twilson) We should still select only the tables/columns we use helper.register_all() return idl.Idl(conn, helper)
def _idl_factory(): connection = cfg.CONF.OVS.ovsdb_connection helper = idlutils.get_schema_helper(connection, 'Open_vSwitch') for table in tables: helper.register_table(table) return idl.Idl(connection, helper)
def idl_factory(conn, schema): helper = idlutils.get_schema_helper(conn, schema) helper.register_all() return idl.Idl(conn, helper)
def idl_factory(config): conn = config.connection schema_name = 'Open_vSwitch' helper = idlutils.get_schema_helper(conn, schema_name) helper.register_all() return idl.Idl(conn, helper)
def __init__(self, connection, timeout, schema_name): idl_ = idl.Idl(connection, get_schema_helper_for_vtep()) super(Connection, self).__init__(idl_, timeout)