def GET(self): if not base.logged(): raise web.seeother('/') if not web.input(): raise web.seeother('/main') action = web.input().action hid = web.input().hid if not hid.isdigit(): return base.code("<script language='javascript'>alert('参数错误');window.history.back(-1);</script>") host = models.getOneHost(hid) if action == 'mh': if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() return render.modify_host(city,project,idc,status,host[0]) elif action == 'vh': city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() return render.view_host(city,project,idc,status,host[0]) elif action == 'dh': if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") models.delHost(hid) raise web.seeother('/main') else: return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>")
def GET(self): if not base.logged(): raise web.seeother('/') if not web.input(): raise web.seeother('/main') action = web.input().action hid = web.input().hid if not hid.isdigit(): return base.code("<script language='javascript'>alert('参数错误');window.history.back(-1);</script>") host = models.getOneHost(hid) if action == 'mh': if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() return render.modify_host(city,project,idc,status,host[0]) elif action == 'vh': city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() host_list = list(host) t = host_list[0]['modifytime'] ltime = time.localtime(int(t)) modifytime = time.strftime("%Y-%m-%d %H:%M:%S",ltime) host_list[0]['modifytime'] = modifytime return render.view_host(city,project,idc,status,host_list[0]) elif action == 'dh': if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") # Save to history h = models.getOneHost(hid)[0] content = "INSERT INTO hosts VALUES (%s,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (h['hid'],h['hostname'],h['city'],h['project'],h['idc'],h['port'],h['addr1_ip'],h['addr1_netmask'],h['addr1_gateway'],h['addr1_line'],h['addr2_ip'],h['addr2_netmask'],h['addr2_gateway'],h['addr2_line'],h['addr3_ip'],h['addr3_netmask'],h['addr3_gateway'],h['addr3_gateway'],h['memory'],h['cpu'],h['disk'],h['buytime'],h['servicetime'],h['hardwareinfo'],h['bandwidth'],h['uses'],h['status'],h['company'],h['os'],h['other'],h['jointime'],h['modifytime'],h['modifyman']) description = u"<b>主机标识:</b>%s<br><b>地址:</b>%s/%s/%s<br><b>用途:</b>%s" % (h['hostname'],h['addr1_ip'],h['addr2_ip'],h['addr3_ip'],h['uses']) delman = web.ctx.session.username deltime = int(time.time()) models.addHistory(content,description,delman,deltime) models.delHost(hid) raise web.seeother('/main') else: return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>")
def GET(self): if not base.logged(): raise web.seeother('/') if not web.input(): raise web.seeother('/main') action = web.input().action hid = web.input().hid if not hid.isdigit(): return base.code("<script language='javascript'>alert('参数错误');window.history.back(-1);</script>") host = models.getOneHost(hid) if action == 'mh': if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() return render.modify_host(city,project,idc,status,host[0]) elif action == 'vh': city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() host_list = list(host) t = host_list[0]['modifytime'] ltime = time.localtime(int(t)) modifytime = time.strftime("%Y-%m-%d %H:%M:%S",ltime) host_list[0]['modifytime'] = modifytime return render.view_host(city,project,idc,status,host_list[0]) elif action == 'dh': if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") # Save to history h = models.getOneHost(hid)[0] content = "INSERT INTO hosts VALUES (%s,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (h['hid'],h['hostname'],h['city'],h['project'],h['idc'],h['port'],h['addr1_ip'],h['addr1_netmask'],h['addr1_gateway'],h['addr1_line'],h['addr2_ip'],h['addr2_netmask'],h['addr2_gateway'],h['addr2_line'],h['addr3_ip'],h['addr3_netmask'],h['addr3_gateway'],h['addr3_gateway'],h['memory'],h['cpu'],h['disk'],h['buytime'],h['servicetime'],h['hardwareinfo'],h['bandwidth'],h['uses'],h['status'],h['company'],h['os'],h['other'],h['jointime'],h['modifytime'],h['modifyman']) description = u"<b>主机标识:</b>%s<br><b>地址:</b>%s/%s/%s<br><b>用途:</b>%s" % (h['hostname'],h['addr1_ip'],h['addr2_ip'],h['addr3_ip'],h['uses']) delman = web.ctx.session.username deltime = int(time.time()) models.addHistory(content,description,delman,deltime) models.delHost(hid) return base.code("<script language='javascript'>location.replace(document.referrer)</script>") else: return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>")
def GET(self): if not base.logged(): raise web.seeother('/') idc_info_list = [] all_idc_list = models.getIDCInfo() cid_to_city = base.cidToCity() #[iid,city,idcname,hostcountbyidc,hztime,contact,fun], one_count = [] for i in all_idc_list: city = base.getCity(i.city) host_count = models.getHostCountByIDC(i.iid) one_count.append(i.iid) one_count.append(city) one_count.append(i.idcname) one_count.append(host_count) one_count.append(i.hztime) one_count.append(i.contact) idc_info_list.append(one_count) one_count = [] if web.ctx.session.privilege == 0: return render.idc_list(idc_info_list) else: return render.idc_list_admin(idc_info_list)
def GET(self): if not base.logged(): raise web.seeother('/') city = models.getCityInfo() project = models.getProjectInfo() idc = models.getIDCInfo() status = models.getStatusInfo() if web.ctx.session.privilege == 0: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问!');window.history.back(-1);</script>") else: return render.add_host(city,project, idc, status)
def iidToIDCName(): all_idc = getIDCInfo() all_idc_dict = {} for i in all_idc: all_idc_dict[i.iid] = i.idcname return all_idc_dict