Ejemplo n.º 1
0
    def _get_schema_helper(self, tables='all'):
        db_connection = ('%s:%s:%s' % (self.protocol, self.ip, self.port))
        try:
            helper = idlutils.get_schema_helper(db_connection,
                                                self.db_name)
        except Exception:
            # We may have failed do to set-manager not being called
            helpers.enable_connection_uri(db_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(db_connection,
                                                  self.db_name)
            helper = do_get_schema_helper()
        if tables == 'all':
            helper.register_all()
        elif isinstance(tables, dict):
            for table_name, columns in six.iteritems(tables):
                if columns == 'all':
                    helper.register_table(table_name)
                else:
                    helper.register_columns(table_name, columns)
        return helper
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    def start(self, plugin):
        # The implementation of this function is same as the base class start()
        # except that OvnIdl object is created instead of idl.Idl
        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 = OvnIdl(plugin, self.connection, helper)
            self.idl.set_lock(self.idl.event_lock_name)
            idlutils.wait_for_change(self.idl, self.timeout)
            # We would have received the initial dump of all the logical
            # ports as events by now. Unwatch the create events for
            # logical ports as it is no longer necessary.
            self.idl.unwatch_logical_port_create_events()
            self.poller = poller.Poller()
            self.thread = threading.Thread(target=self.run)
            self.thread.setDaemon(True)
            self.thread.start()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
    def start(self, driver):
        # The implementation of this function is same as the base class start()
        # except that OvnIdl object is created instead of idl.Idl
        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 = OvnIdl(driver, self.connection, helper)
            self.idl.set_lock(self.idl.event_lock_name)
            idlutils.wait_for_change(self.idl, self.timeout)
            # We would have received the initial dump of all the logical
            # ports as events by now. Unwatch the create events for
            # logical ports as it is no longer necessary.
            self.idl.unwatch_logical_port_create_events()
            self.poller = poller.Poller()
            self.thread = threading.Thread(target=self.run)
            self.thread.setDaemon(True)
            self.thread.start()
Ejemplo n.º 6
0
    def start(self):
        with self.lock:
            if self.idl is not None:
                return

            helper = idlutils.get_schema_helper(self.connection)
            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()
Ejemplo n.º 7
0
    def get_schema_helper(self):
        """Retrieve the schema helper object from OVSDB"""
        # The implementation of this function is same as the base class method
        # without the enable_connection_uri() called (since ovs-vsctl won't
        # exist on the controller node when using the reference architecture).
        try:
            helper = idlutils.get_schema_helper(self.connection,
                                                self.schema_name)
        except Exception:
            # There is a small window for a race, so retry up to a second
            @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(self.connection,
                                                  self.schema_name)
            helper = do_get_schema_helper()

        return helper
Ejemplo n.º 8
0
    def get_schema_helper(self):
        """Retrieve the schema helper object from OVSDB"""
        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
            @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(self.connection,
                                                  self.schema_name)
            helper = do_get_schema_helper()

        return helper
Ejemplo n.º 9
0
    def get_schema_helper(self):
        """Retrieve the schema helper object from OVSDB"""
        # The implementation of this function is same as the base class method
        # without the enable_connection_uri() called (since ovs-vsctl won't
        # exist on the controller node when using the reference architecture).
        try:
            helper = idlutils.get_schema_helper(self.connection,
                                                self.schema_name)
        except Exception:
            # There is a small window for a race, so retry up to a second
            @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(self.connection,
                                                  self.schema_name)
            helper = do_get_schema_helper()

        return helper
Ejemplo n.º 10
0
    def get_schema_helper(self):
        """Retrieve the schema helper object from OVSDB"""
        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
            @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(self.connection,
                                                  self.schema_name)
            helper = do_get_schema_helper()

        return helper
Ejemplo n.º 11
0
    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 = 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,
                                              set_timeout=True)

                # 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()

            if table_name_list is None:
                helper.register_all()
            else:
                for table_name in table_name_list:
                    helper.register_table(table_name)
            self.idl = self.idl_class(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()
Ejemplo n.º 12
0
    def start(self, driver, table_name_list=None):
        # The implementation of this function is same as the base class start()
        # except that OvnIdl object is created instead of idl.Idl and the
        # enable_connection_uri() helper isn't called (since ovs-vsctl won't
        # exist on the controller node when using the reference architecture).
        with self.lock:
            if self.idl is not None:
                return

            try:
                helper = idlutils.get_schema_helper(self.connection,
                                                    self.schema_name)
            except Exception:
                # There is a small window for a race, so retry up to a second
                @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(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)

            idl_cls = self.get_ovn_idl_cls()
            self.idl = idl_cls(driver, self.connection, helper)
            self.idl.set_lock(self.idl.event_lock_name)
            idlutils.wait_for_change(self.idl, self.timeout)
            self.idl.post_initialize(driver)
            self.poller = poller.Poller()
            self.thread = threading.Thread(target=self.run)
            self.thread.setDaemon(True)
            self.thread.start()
Ejemplo n.º 13
0
def get_schema_helper(connection_string, db_name='Open_vSwitch', tables='all'):
    try:
        helper = idlutils.get_schema_helper(connection_string, db_name)
    except Exception:
        # We may have failed do to set-manager not being called
        helpers.enable_connection_uri(connection_string)

        # 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(connection_string, db_name)

        helper = do_get_schema_helper()
    if tables == 'all':
        helper.register_all()
    elif isinstance(tables, dict):
        for table_name, columns in six.iteritems(tables):
            if columns == 'all':
                helper.register_table(table_name)
            else:
                helper.register_columns(table_name, columns)
    return helper
Ejemplo n.º 14
0
    def start(self, driver, table_name_list=None):
        # The implementation of this function is same as the base class start()
        # except that OvnIdl object is created instead of idl.Idl
        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()

            if table_name_list is None:
                helper.register_all()
            else:
                for table_name in table_name_list:
                    helper.register_table(table_name)

            idl_cls = self.get_ovn_idl_cls()
            self.idl = idl_cls(driver, self.connection, helper)
            self.idl.set_lock(self.idl.event_lock_name)
            idlutils.wait_for_change(self.idl, self.timeout)
            self.idl.post_initialize(driver)
            self.poller = poller.Poller()
            self.thread = threading.Thread(target=self.run)
            self.thread.setDaemon(True)
            self.thread.start()
Ejemplo n.º 15
0
    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 = 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()

            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)
            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()
Ejemplo n.º 16
0
    def start(self, driver, table_name_list=None):
        # The implementation of this function is same as the base class start()
        # except that OvnIdl object is created instead of idl.Idl
        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()

            if table_name_list is None:
                helper.register_all()
            else:
                for table_name in table_name_list:
                    helper.register_table(table_name)

            idl_cls = self.get_ovn_idl_cls()
            self.idl = idl_cls(driver, self.connection, helper)
            self.idl.set_lock(self.idl.event_lock_name)
            idlutils.wait_for_change(self.idl, self.timeout)
            self.idl.post_initialize(driver)
            self.poller = poller.Poller()
            self.thread = threading.Thread(target=self.run)
            self.thread.setDaemon(True)
            self.thread.start()
Ejemplo n.º 17
0
def get_schema_helper(connection_string, db_name='Open_vSwitch', tables='all'):
    try:
        helper = idlutils.get_schema_helper(connection_string,
                                            db_name)
    except Exception:
        # We may have failed do to set-manager not being called
        helpers.enable_connection_uri(connection_string)

        # 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(connection_string,
                                              db_name)
        helper = do_get_schema_helper()
    if tables == 'all':
        helper.register_all()
    elif isinstance(tables, dict):
        for table_name, columns in six.iteritems(tables):
            if columns == 'all':
                helper.register_table(table_name)
            else:
                helper.register_columns(table_name, columns)
    return helper
Ejemplo n.º 18
0
 def do_get_schema_helper():
     return idlutils.get_schema_helper(db_connection,
                                       self.db_name)
Ejemplo n.º 19
0
 def do_get_schema_helper():
     return idlutils.get_schema_helper(self.connection,
                                       self.schema_name)
Ejemplo n.º 20
0
 def do_get_schema_helper():
     return idlutils.get_schema_helper(connection_string, db_name)
Ejemplo n.º 21
0
 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)
Ejemplo n.º 22
0
 def get_schema_helper(self):
     """Retrieve the schema helper object from OVSDB"""
     return idlutils.get_schema_helper(self.connection,
                                       self.schema_name,
                                       retry=True)
Ejemplo n.º 23
0
 def get_schema_helper(self):
     """Retrieve the schema helper object from OVSDB"""
     return idlutils.get_schema_helper(self.connection, self.schema_name, retry=True)
Ejemplo n.º 24
0
 def do_get_schema_helper():
     return idlutils.get_schema_helper(connection_string,
                                       db_name)
Ejemplo n.º 25
0
 def do_get_schema_helper():
     return idlutils.get_schema_helper(self.connection,
                                       self.schema_name)
Ejemplo n.º 26
0
 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)