def handle(self, request, context): try: if context['session_id'] != '': freezer_api.Session(request).update(context, context['session_id']) else: freezer_api.Session(request).create(context) return reverse("horizon:disaster_recovery:sessions:index") except Exception: exceptions.handle(request) return False
def get_initial(self): initial = super(CreateSessionWorkflow, self).get_initial() if self.is_update(): initial.update({'job_id': None}) session = freezer_api.Session(self.request).get( self.kwargs['session_id'], json=True) initial.update(**session) initial.update(**session['schedule']) return initial
def handle(self, request, context): try: freezer_api.Session(request).add_job(context['session_id'], context['job_id']) return reverse("horizon:disaster_recovery:jobs:index") except Exception: exceptions.handle(request) return False
def populate_session_id_choices(self, request, context): sessions = [] try: sessions = freezer_api.Session(request).list() except Exception: exceptions.handle(request, _('Error getting session list')) sessions = [(s.session_id, s.description) for s in sessions] sessions.insert(0, ('', _('Select A Session'))) return sessions
def get_object(self, *args, **kwargs): return freezer_api.Session(self.request).get(self.kwargs['session_id'])
def get_jobs_data(self): if self.kwargs['session_id']: return freezer_api.Session(self.request).jobs( self.kwargs['session_id']) return []
def get_sessions_data(self): return freezer_api.Session(self.request).list(limit=100)
def delete(self, request, session_id): return freezer_api.Session(request).delete(session_id)
def delete(self, request, session): job_id, session_id = session.split('===') return freezer_api.Session(request).remove_job(session_id, job_id)