def _register_schedule(self, schedule, date=None): date = date or timeutils.utcnow() sched = self._deserialize_schedule(schedule) expires = sched.get("expiration_date") if expires and expires <= date: LOG.info("Not registering expired schedule: %s" % sched["id"]) return trust_ctxt = context.get_admin_context(trust_id=schedule["trust_id"]) description = "Scheduled job for %s" % sched["id"] job = cron.CronJob(sched["id"], description, sched["schedule"], sched["enabled"], sched["expiration_date"], None, None, _trigger_replica, trust_ctxt, self._rpc_client, schedule["replica_id"], schedule["shutdown_instance"]) self._cron.register(job)
def __init__(self): self._rpc_client = rpc_client.ConductorClient() # Setup cron loop self._cron = cron.Cron() self._admin_ctx = context.get_admin_context() self._init_cron()
def _cleanup_schedule_resources(self, ctxt, schedule): self._replica_cron_client.unregister(ctxt, schedule) if schedule.trust_id: tmp_trust = context.get_admin_context(trust_id=schedule.trust_id) keystone.delete_trust(tmp_trust)