Exemplo n.º 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)
Exemplo n.º 2
0
 def _lock_task(self, context):
     session = context.session
     with db_api.autonested_transaction(session):
         return db.lock_periodic_task(session, self.task)
Exemplo n.º 3
0
 def _lock_task(self, context):
     return db.lock_periodic_task(context, self.task)
Exemplo n.º 4
0
 def _lock_task(self, context):
     return db.lock_periodic_task(context, self.task)