コード例 #1
0
    def execute_ops(self):
        LOG.info("Starting %s periodic task.", self.task)
        context = neutron_context.get_admin_context()

        # Lock make sure that periodic task is executed only after
        # specified interval. It makes sure that maintenance tasks
        # are not executed back to back.
        if self.task_already_executed_recently(context):
            LOG.info(
                "Periodic %s task executed after periodic interval "
                "Skipping execution.", self.task)
            return

        if not db.lock_periodic_task(context.session, self.task):
            LOG.info("Periodic %s task already running task", self.task)
            return

        try:
            for phase in self.phases:
                self._execute_op(phase, context)
        finally:
            db.update_periodic_task(context.session,
                                    task=self.task,
                                    operation=None)
            db.unlock_periodic_task(context.session, self.task)

        LOG.info("%s task has been finished", self.task)
コード例 #2
0
 def _clear_and_unlock_task(self, context):
     session = context.session
     with db_api.autonested_transaction(session):
         db.update_periodic_task(session, task=self.task, operation=None)
         db.unlock_periodic_task(session, self.task)
コード例 #3
0
 def _clear_and_unlock_task(self, context):
     db.update_periodic_task(context, task=self.task,
                             operation=None)
     db.unlock_periodic_task(context, self.task)
コード例 #4
0
 def _clear_and_unlock_task(self, context):
     db.update_periodic_task(context, task=self.task, operation=None)
     db.unlock_periodic_task(context, self.task)