def _build(self, job): action_ids = utils.get_action_ids(job.pop('actions')) job = utils.create_dict(**job) clients = job.pop('clients', []) scheduling = {} new_job = {} utils.assign_and_remove(job, scheduling, 'schedule_start_date') utils.assign_and_remove(job, scheduling, 'schedule_interval') utils.assign_and_remove(job, scheduling, 'schedule_end_date') actions = self._get_actions_in_job(action_ids) new_job['description'] = job.get('description') new_job['job_actions'] = actions new_job['job_schedule'] = scheduling for client_id in clients: search = client_id client = Client(self.request).list(search=search) new_job['client_id'] = client[0].id job_id = self.client.jobs.create(new_job) self.stop(job_id) return True
def get_schedule_info(context): """Get schedule info from context """ scheduling = {} try: if context['schedule_end_date'] != '': utils.assign_and_remove(context, scheduling, 'schedule_end_date') else: context.pop('schedule_end_date') except KeyError: pass try: if context['schedule_interval'] != '': utils.assign_and_remove(context, scheduling, 'schedule_interval') else: context.pop('schedule_interval') except KeyError: pass try: if context['schedule_start_date'] != '': utils.assign_and_remove(context, scheduling, 'schedule_start_date') else: context.pop('schedule_start_date') except KeyError: pass return scheduling
def update(self, job_id, job): scheduling = {} try: if job['schedule_end_date'] != '': utils.assign_and_remove(job, scheduling, 'schedule_end_date') else: job.pop('schedule_end_date') except KeyError: pass try: if job['schedule_interval'] != '': utils.assign_and_remove(job, scheduling, 'schedule_interval') else: job.pop('schedule_interval') except KeyError: pass try: if job['schedule_start_date'] != '': utils.assign_and_remove(job, scheduling, 'schedule_start_date') else: job.pop('schedule_start_date') except KeyError: pass job.pop('job_actions', []) job.pop('clients', None) job.pop('actions', None) job.pop('job_id') job['job_schedule'] = scheduling return self.client.jobs.update(job_id, job)
def _build(self, session): session = utils.create_dict(**session) scheduling = {} utils.assign_and_remove(session, scheduling, 'schedule_start_date') utils.assign_and_remove(session, scheduling, 'schedule_interval') utils.assign_and_remove(session, scheduling, 'schedule_end_date') session['jobs'] = {} session['schedule'] = scheduling return self.client.sessions.create(session)
def _build(self, action): """Get a flat action dict and convert it to a freezer action format """ action_rules = {} utils.assign_and_remove(action, action_rules, 'max_retries') utils.assign_and_remove(action, action_rules, 'max_retries_interval') utils.assign_and_remove(action, action_rules, 'mandatory') action = utils.create_dict(**action) action.pop('action_id', None) # if the backup name has spaces the tar metadata file cannot be found # so we replace " " for "_" backup_name = action.pop('backup_name', None) action['backup_name'] = backup_name.replace(' ', '_') action = {'freezer_action': action} return self.client.actions.create(action)
def _build(self, action): """Get a flat action dict and convert it to a freezer action format """ action_rules = {} utils.assign_and_remove(action, action_rules, 'max_retries') utils.assign_and_remove(action, action_rules, 'max_retries_interval') utils.assign_and_remove(action, action_rules, 'mandatory') action = utils.create_dict(**action) action.pop('action_id', None) # if the backup name has spaces the tar metadata file cannot be found # so we replace " " for "_" backup_name = action.pop('backup_name', None) action['backup_name'] = backup_name.replace(' ', '_') action = {'freezer_action': action} action.update(action_rules) return self.client.actions.create(action)