def delete(cls, id): tgt = RasTarget.get(RasTarget.id == id) with database.database.atomic(): for act in tgt.actions: RasActionForm.delete(act.id) tgt.delete_instance() tgt.teardown()
def rastgt_delete(grpid, typ, tgtid): tgt = RasTarget.get(RasTarget.id == tgtid) fclass = _TARGET_FORMS[typ] form = fclass(data=fclass.obj2dict(tgt)) return render_template( 'ras/target_delete.html', form=form, grpid=grpid, typ=typ, tgtid=tgtid, group_name=tgt.group.name)
def rasact_create(grpid, tgtid, atype): form = _ACTION_FORMS[atype]() tgt = RasTarget.get(RasTarget.id == tgtid) return render_template('ras/action_create.html', form=form, grpid=grpid, target=tgt, atype=atype)
def _save(self, action, tgtid, script_data=None): tgt = RasTarget.get(RasTarget.id == tgtid) action.target = tgtid action.name = self.name.data action.mode = 1 << 1 action.type = 'restart' action.data = json.dumps( {'type': tgt.type, 'retry': int(self.retry.data), 'interval': int(self.interval.data)}) action.save()
def rastgt_delete(grpid, typ, tgtid): tgt = RasTarget.get(RasTarget.id == tgtid) fclass = _TARGET_FORMS[typ] form = fclass(data=fclass.obj2dict(tgt)) return render_template('ras/target_delete.html', form=form, grpid=grpid, typ=typ, tgtid=tgtid, group_name=tgt.group.name)
def _save(self, action, tgtid, script_data=None): tgt = RasTarget.get(RasTarget.id == tgtid) action.target = tgtid action.name = self.name.data action.mode = 1 << 1 action.type = 'restart' action.data = json.dumps({ 'type': tgt.type, 'retry': int(self.retry.data), 'interval': int(self.interval.data) }) action.save()
def rasact_list(grpid, tgtid): atype = request.form['type'] form = _ACTION_FORMS[atype](request.form) if not form.validate(): tgt = RasTarget.get(RasTarget.id == tgtid) return render_template( 'ras/action_create.html', form=form, grpid=grpid, target=tgt, atype=atype) script = request.files['script'] if 'script' in request.files else None form.create(tgtid, script) return redirect(url_for( 'rastgt_detail', grpid=grpid, tgtid=tgtid))
def rasact_list(grpid, tgtid): atype = request.form['type'] form = _ACTION_FORMS[atype](request.form) if not form.validate(): tgt = RasTarget.get(RasTarget.id == tgtid) return render_template('ras/action_create.html', form=form, grpid=grpid, target=tgt, atype=atype) script = request.files['script'] if 'script' in request.files else None form.create(tgtid, script) return redirect(url_for('rastgt_detail', grpid=grpid, tgtid=tgtid))
def rastgt_detail(grpid, tgtid): tgt = RasTarget.get(RasTarget.id == tgtid) return render_template('ras/target_show.html', target=tgt)
def rasact_create(grpid, tgtid, atype): form = _ACTION_FORMS[atype]() tgt = RasTarget.get(RasTarget.id == tgtid) return render_template( 'ras/action_create.html', form=form, grpid=grpid, target=tgt, atype=atype)