def GET(self): web.header("Content-Type", "text/html; charset=utf-8") form = forms.node_add_form() return render("baseform.html", form=form, title="新增节点", action="/node/add")
def POST(self): web.header("Content-Type", "text/html; charset=utf-8") form = forms.node_add_form() if not form.validates(source=web.input(nas_bind=[])): return render("baseform.html", form=form, title="新增节点", action="/node/add") else: db = get_db() if db.query(models.RadNode).filter( models.RadNode.id == form.d.node_id).count() > 0: return errorpage("节点编号重复") try: radnode = models.RadNode() radnode.id = form.d.node_id radnode.name = form.d.node_name radnode.desc = form.d.node_desc radopr = models.RadOpr() radopr.node_id = radnode.id radopr.id = nextid() radopr.type = 1 radopr.name = form.d.opr_name radopr.ip_addr = form.d.opr_ip radopr.password = encrypt(form.d.opr_passwd) radopr.status = 0 db.add(radnode) db.add(radopr) #新增nas绑定 for ip in form.d.nas_bind: radnasnode = models.RadNasNode() radnasnode.node_id = radnode.id radnasnode.ip_addr = ip db.add(radnasnode) db.commit() db.flush() except Exception, e: db.rollback() log.error("add node error: %s" % str(e)) return errorpage("节点新增失败 %s" % str(e)) raise web.seeother("/node", absolute=True)
def node_add_post(db): form=forms.node_add_form() if not form.validates(source=request.forms): return render("base_form", form=form) node = models.SlcNode() node.node_name = form.d.node_name node.node_desc = form.d.node_desc db.add(node) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)新增区域信息:%s'%(get_cookie("username"),serial_json(node)) db.add(ops_log) db.commit() redirect("/node")
def POST(self): web.header("Content-Type","text/html; charset=utf-8") form = forms.node_add_form() if not form.validates(source=web.input(nas_bind=[])): return render("baseform.html",form=form,title="新增节点",action="/node/add") else: db = get_db() if db.query(models.RadNode).filter(models.RadNode.id == form.d.node_id).count()>0: return errorpage("节点编号重复") try: radnode = models.RadNode() radnode.id = form.d.node_id radnode.name = form.d.node_name radnode.desc = form.d.node_desc radopr = models.RadOpr() radopr.node_id = radnode.id radopr.id = nextid() radopr.type = 1 radopr.name = form.d.opr_name radopr.ip_addr = form.d.opr_ip radopr.password = encrypt(form.d.opr_passwd) radopr.status = 0 db.add(radnode) db.add(radopr) #新增nas绑定 for ip in form.d.nas_bind: radnasnode = models.RadNasNode() radnasnode.node_id = radnode.id radnasnode.ip_addr = ip db.add(radnasnode) db.commit() db.flush() except Exception,e: db.rollback() log.error("add node error: %s"%str(e)) return errorpage("节点新增失败 %s"%str(e)) raise web.seeother("/node",absolute=True)
def node_add_post(db): form = forms.node_add_form() if not form.validates(source=request.forms): return render("base_form", form=form) node = models.SlcNode() node.node_name = form.d.node_name node.node_desc = form.d.node_desc db.add(node) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)新增区域信息:%s' % (get_cookie("username"), serial_json(node)) db.add(ops_log) db.commit() redirect("/node")
def node_add(db): return render("base_form", form=forms.node_add_form())
def GET(self): web.header("Content-Type","text/html; charset=utf-8") form = forms.node_add_form() return render("baseform.html",form=form,title="新增节点",action="/node/add")
def node_add(db): return render("base_form",form=forms.node_add_form())