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)
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)
def _clear_and_unlock_task(self, context): db.update_periodic_task(context, task=self.task, operation=None) db.unlock_periodic_task(context, self.task)