Exemplo n.º 1
0
 def verify(self):
     """Run fuel verification"""
     try:
         utils.wait_for_true(
             self.check_if_all_services_ready,
             timeout=self.config.checker['timeout'],
             interval=self.config.checker['interval'])
     except errors.TimeoutError:
         raise errors.UpgradeVerificationError(
             'Failed to run services {0}'.format(
                 self._get_non_running_services()))
Exemplo n.º 2
0
 def verify(self):
     """Run fuel verification
     """
     try:
         utils.wait_for_true(self.check_if_all_services_ready,
                             timeout=self.config.checker['timeout'],
                             interval=self.config.checker['interval'])
     except errors.TimeoutError:
         raise errors.UpgradeVerificationError(
             'Failed to run services {0}'.format(
                 self._get_non_running_services()))
Exemplo n.º 3
0
    def restart_and_wait(self):
        """Restart supervisor and wait untill it will be available"""
        logger.info('Restart supervisor')
        self.supervisor.restart()

        all_processes = utils.wait_for_true(
            lambda: self.get_all_processes_safely() is not None,
            timeout=self.config.supervisor['restart_timeout'])

        logger.debug('List of supervisor processes %s', all_processes)
Exemplo n.º 4
0
    def restart_and_wait(self):
        """Restart supervisor and wait untill it will be available
        """
        logger.info(u'Restart supervisor')
        self.supervisor.restart()

        all_processes = utils.wait_for_true(
            lambda: self.get_all_processes_safely() is not None,
            timeout=self.config.supervisor['restart_timeout'])

        logger.debug(u'List of supervisor processes %s', all_processes)
Exemplo n.º 5
0
    def restart_and_wait(self):
        """Restart supervisor and wait untill it will be available
        """
        logger.info(u'Restart supervisor')
        self.supervisor.restart()

        all_processes = utils.wait_for_true(
            self.get_all_processes_safely,
            timeout=self.config.supervisor['restart_timeout'])

        logger.debug(u'List of supervisor processes {0}'.format(
            all_processes))
Exemplo n.º 6
0
    def save_db(self):
        """Saves postgresql database into the file
        """
        logger.debug(u'Backup database')
        pg_dump_path = os.path.join(self.working_directory, 'pg_dump_all.sql')
        pg_dump_files = utils.VersionedFile(pg_dump_path)
        pg_dump_tmp_path = pg_dump_files.next_file_name()

        utils.wait_for_true(
            lambda: self.make_pg_dump(pg_dump_tmp_path, pg_dump_path),
            timeout=self.config.db_backup_timeout,
            interval=self.config.db_backup_interval)

        valid_dumps = filter(utils.verify_postgres_dump,
                             pg_dump_files.sorted_files())
        if valid_dumps:
            utils.hardlink(valid_dumps[0], pg_dump_path, overwrite=True)
            map(utils.remove_if_exists,
                valid_dumps[self.config.keep_db_backups_count:])
        else:
            raise errors.DatabaseDumpError(
                u'Failed to make database dump, there '
                'are no valid database backup '
                'files, {0}'.format(pg_dump_path))
Exemplo n.º 7
0
    def save_db(self):
        """Saves postgresql database into the file
        """
        logger.debug(u'Backup database')
        pg_dump_path = os.path.join(self.working_directory, 'pg_dump_all.sql')
        pg_dump_files = utils.VersionedFile(pg_dump_path)
        pg_dump_tmp_path = pg_dump_files.next_file_name()

        utils.wait_for_true(
            lambda: self.make_pg_dump(pg_dump_tmp_path, pg_dump_path),
            timeout=self.config.db_backup_timeout,
            interval=self.config.db_backup_interval)

        valid_dumps = filter(utils.verify_postgres_dump,
                             pg_dump_files.sorted_files())
        if valid_dumps:
            utils.hardlink(valid_dumps[0], pg_dump_path, overwrite=True)
            map(utils.remove_if_exists,
                valid_dumps[self.config.keep_db_backups_count:])
        else:
            raise errors.DatabaseDumpError(
                u'Failed to make database dump, there '
                'are no valid database backup '
                'files, {0}'.format(pg_dump_path))
Exemplo n.º 8
0
    def restart_and_wait(self):
        """Restart supervisor and wait untill it will be available
        """
        logger.info(u'Restart supervisor')
        self.supervisor.restart()

        def get_all_processes():
            try:
                return self.supervisor.getAllProcessInfo()
            except (IOError, Fault):
                return False

        all_processes = utils.wait_for_true(
            get_all_processes,
            timeout=self.config.supervisor['restart_timeout'])

        logger.debug(u'List of supervisor processes {0}'.format(all_processes))
Exemplo n.º 9
0
    def restart_and_wait(self):
        """Restart supervisor and wait untill it will be available
        """
        logger.info(u'Restart supervisor')
        self.supervisor.restart()

        def get_all_processes():
            try:
                return self.supervisor.getAllProcessInfo()
            except (IOError, Fault):
                return False

        all_processes = utils.wait_for_true(
            get_all_processes,
            timeout=self.config.supervisor['restart_timeout'])

        logger.debug(u'List of supervisor processes {0}'.format(
            all_processes))
    def request(self):
        """Creates authentification session if required

        :returns: :class:`requests.Session` object
        """
        session = requests.Session()

        # NOTE(ikalnitsky):
        #   After starting a new Keystone container, the first attempt to
        #   get a token fails. Unfortunately, the logs keep silent and say
        #   nothing. As a workaround, we can just increase retries number.
        #
        # See https://bugs.launchpad.net/fuel/+bug/1399144 for details.
        try:
            token = utils.wait_for_true(self.get_token, timeout=10)
            session.headers.update({'X-Auth-Token': token})
        except errors.TimeoutError:
            logger.exception(
                'Cannot retrieve an auth token - an unauthenticated '
                'request will be performed.')

        return session
Exemplo n.º 11
0
 def test_wait_for_true_does_not_raise_errors(self):
     self.assertEqual(wait_for_true(lambda: True, timeout=0), True)
Exemplo n.º 12
0
 def test_wait_for_true_does_not_raise_errors(self):
     self.assertEqual(wait_for_true(lambda: True, timeout=0), True)