def handle(self, request, context): try: if context['action_id'] == '': freezer_api.Action(request).create(context) else: freezer_api.Action(request).update(context, context['action_id']) return shortcuts.redirect('horizon:disaster_recovery:' 'actions:index') except Exception: exceptions.handle(request) return False
def get(self, request, job_id=None): actions = freezer_api.Action(request).list(json=True) actions_in_job = freezer_api.Job(request).actions(job_id, api=True) action_ids = [a['action_id'] for a in actions] actions_in_job_ids = [a['action_id'] for a in actions_in_job] available = set.difference(set(action_ids), set(actions_in_job_ids)) selected = set.intersection(set(action_ids), set(actions_in_job_ids)) available_actions = [] for action in actions: if action['action_id'] in available: available_actions.append(action) selected_actions = [] for action in actions_in_job: if action['action_id'] in selected: selected_actions.append(action) actions = {'available': available_actions, 'selected': selected_actions} actions = json.dumps(actions) return http.HttpResponse(actions, content_type="application/json")
def get_initial(self): initial = super(ActionWorkflowView, self).get_initial() if self.is_update(): initial.update({'action_id': None}) action = freezer_api.Action(self.request).get( self.kwargs['action_id'], json=True) initial.update(**action['freezer_action']) initial.update({ "mandatory": action.get('mandatory', None), "max_retries": action.get('max_retries', None), "max_retries_interval": action.get('max_retries_interval', None) }) initial.update({'action_id': action['action_id']}) return initial
def delete(self, request, action_id): freezer_api.Action(request).delete(action_id) # TODO(m3m0): this shouldnt redirect here when an action is deleted # from jobs views return shortcuts.redirect('horizon:disaster_recovery:actions:index')
def get_context_data(self, **kwargs): action = freezer_api.Action(self.request).get(kwargs['action_id'], json=True) return {'data': pprint.pformat(action)}
def get_data(self): filters = self.table.get_filter_string() or None return freezer_api.Action(self.request).list(search=filters)
def get(self, request): """Get all registered freezer actions""" actions = freezer_api.Action(request).list(json=True) actions = json.dumps(actions) return http.HttpResponse(actions, content_type="application/json")