Beispiel #1
0
def modifyHost(hid,hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,modifytime,modifyman):
		# Check the ip address exists?
	if addr1_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr1_ip, addr1_ip, addr1_ip))
		if result:
			return 'addr'
	if addr2_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr2_ip, addr2_ip, addr2_ip))
		if result:
			return 'addr'
	if addr3_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr3_ip, addr3_ip, addr3_ip))
		if result:
			return 'addr'
	# Check hostname exists?
	if hostname != '':
		result = db.query("SELECT hid FROM hosts WHERE hostname = '%s'" % (hostname))
		if result:
			return 'hostname'
	
	#result = db.query("SELECT hid FROM hosts WHERE hostname = '%s' AND hid != '%s'" % (hostname, hid))
	#if result:
	#	return False
	#else:
	db.update("hosts", where='hid=$hid', vars={'hid':hid}, hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,modifytime=modifytime,modifyman=modifyman)
	return True
Beispiel #2
0
def restoreHistory(hid):
    content = db.query("SELECT content FROM history WHERE hid = %s" % hid)
    try:
        sql = content[0]['content']
        result = db.query("%s" % sql)
    except:
        return False

    if result:
        return True
    else:
        return False
Beispiel #3
0
def restoreHistory(hid):
	content = db.query("SELECT content FROM history WHERE hid = %s" % hid)
	try:
		sql = content[0]['content']
		result = db.query("%s" % sql)
	except:
		return False

	if result:
		return True
	else:
		return False
Beispiel #4
0
def insert_idc(idcname,city, contact,hztime, other):
	result = db.query("SELECT iid FROM `idc` WHERE idcname='%s'" % (idcname))
	if result:
		return False
	else:
		db.insert('idc', idcname=idcname, city=city, contact=contact,hztime=hztime, other=other)
		return True
Beispiel #5
0
def modifyProject(pid,project,other):
	result = db.query("SELECT pid FROM project WHERE project = '%s' AND pid != '%s'" % (project,pid))
	if result:
		return False
	else:
		db.update("project", where='pid=$pid', vars={'pid': pid}, project=project ,other=other)
		return True
Beispiel #6
0
def modifyIDC(iid,idcname,city,contact,hztime,other):
	result = db.query("SELECT iid FROM idc WHERE idcname = '%s' AND iid != '%s'" % (idcname, iid))
	if result:
		return False
	else:
		db.update("idc", where='iid=$iid', vars={'iid': iid}, idcname=idcname, city=city, contact=contact, hztime=hztime,other=other)
		return True
Beispiel #7
0
def modifyCity(cid, city, other):
	result = db.query("SELECT cid FROM city WHERE city = '%s' AND cid != '%s'" % (city, cid))
	if result:
		return False	
	else:
		db.update("city", where='cid=$cid', vars={'cid': cid}, city=city, other=other)
		return True
Beispiel #8
0
def insert_project(project, other):
	result = db.query("SELECT pid FROM `project` WHERE project='%s'" % (project))
	if result:
		return False
	else:	
		db.insert('project', project=project, other=other)
		return True
Beispiel #9
0
def insert_city(city, other):
	result = db.query("SELECT cid FROM `city` WHERE city='%s'" % (city))	
	if result:
		return False
	else:
		db.insert('city', city=city, other=other)
		return True
Beispiel #10
0
def insert_idc(idcname,city, contact,hztime, other):
	result = db.query("SELECT iid FROM `idc` WHERE idcname='%s'" % (idcname))
	if result:
		return False
	else:
		db.insert('idc', idcname=idcname, city=city, contact=contact,hztime=hztime, other=other)
		return True
Beispiel #11
0
def insert_project(project, other):
	result = db.query("SELECT pid FROM `project` WHERE project='%s'" % (project))
	if result:
		return False
	else:	
		db.insert('project', project=project, other=other)
		return True
Beispiel #12
0
def modifyCity(cid, city, other):
	result = db.query("SELECT cid FROM city WHERE city = '%s' AND cid != '%s'" % (city, cid))
	if result:
		return False	
	else:
		db.update("city", where='cid=$cid', vars={'cid': cid}, city=city, other=other)
		return True
Beispiel #13
0
def insert_city(city, other):
    result = db.query("SELECT cid FROM `city` WHERE city='%s'" % (city))
    if result:
        return False
    else:
        db.insert('city', city=city, other=other)
        return True
Beispiel #14
0
def modifyProject(pid,project,other):
	result = db.query("SELECT pid FROM project WHERE project = '%s' AND pid != '%s'" % (project,pid))
	if result:
		return False
	else:
		db.update("project", where='pid=$pid', vars={'pid': pid}, project=project ,other=other)
		return True
Beispiel #15
0
def modifyIDC(iid,idcname,city,contact,hztime,other):
	result = db.query("SELECT iid FROM idc WHERE idcname = '%s' AND iid != '%s'" % (idcname, iid))
	if result:
		return False
	else:
		db.update("idc", where='iid=$iid', vars={'iid': iid}, idcname=idcname, city=city, contact=contact, hztime=hztime,other=other)
		return True
Beispiel #16
0
def getUserInfo(username):
	try:
		#results = db.select('users', where="username=$username")
		results = db.query("SELECT * FROM `users` WHERE username='******'" % (username))
		return results[0]
	except IndexError:
		return 0
Beispiel #17
0
def getUserInfo():
	try:
		#results = db.select('users', where="username=$username")
		results = db.query("SELECT * FROM `users`")
		return results
	except IndexError:
		return 0
Beispiel #18
0
 def GET(self):
     try:
         comment = db.select(msg,limit="0,10",order="date DESC")
         count = int(db.query("select count(*) from "+msg)[0]["count(*)"])
         return render.about(isadmin(),comment,count>10)
     except:
         return render.error()
Beispiel #19
0
def modifyHost(hid,hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,modifytime,modifyman):
	result = db.query("SELECT hid FROM hosts WHERE hostname = '%s' AND hid != '%s'" % (hostname, hid))
	if result:
		return False
	else:
		db.update("hosts", where='hid=$hid', vars={'hid':hid}, hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,modifytime=modifytime,modifyman=modifyman)
		return True
Beispiel #20
0
def modifyApply(aid,sitename,idc,project,addr_ip,sofeware,datadir,startscrite,port,mysql_conf,mysql_ip,mysql_stype,mysql_name,mysql_use,mysql_pw,dev_name,other,modifytime,modifyman):
	if addr_ip != '':
		result = db.query("SELECT aid FROM applications WHERE sitename = '%s' AND addr_ip = '%s'" % (sitename,addr_ip))
		if result:
			return False
	db.update("applications", where='aid=$aid', vars={'aid':aid}, sitename=sitename,idc=idc,project=project,addr_ip=addr_ip,sofeware=sofeware,datadir=datadir,startscrite=startscrite,port=port,mysql_conf=mysql_conf,mysql_ip=mysql_ip,mysql_stype=mysql_stype,mysql_name=mysql_name,mysql_use=mysql_use,mysql_pw=mysql_pw,dev_name=dev_name,other=other,modifytime=modifytime,modifyman=modifyman)
	return True
Beispiel #21
0
def getUserInfo(username):
	try:
		#results = db.select('users', where="username=$username")
		results = db.query("SELECT * FROM `users` WHERE username='******'" % (username))
		return results[0]
	except IndexError:
		return 0
Beispiel #22
0
def hasUser(username):
	try:
		results = db.query("SELECT uid FROM `users` WHERE username='******'" % (username))
		#return results[0]
		if results:
			return 1
	except IndexError:
		return 0
Beispiel #23
0
def hasUser(username):
	try:
		results = db.query("SELECT uid FROM `users` WHERE username='******'" % (username))
		#return results[0]
		if results:
			return 1
	except IndexError:
		return 0
Beispiel #24
0
def insert_host(hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr1_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr1_ip, addr1_ip, addr1_ip))
		if result:
			return False
	if addr2_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr2_ip, addr2_ip, addr2_ip))
		if result:
			return False
	if addr3_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr3_ip, addr3_ip, addr3_ip))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('hosts',hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
Beispiel #25
0
def insert_host(hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr1_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr1_ip, addr1_ip, addr1_ip))
		if result:
			return False
	if addr2_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr2_ip, addr2_ip, addr2_ip))
		if result:
			return False
	if addr3_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr3_ip, addr3_ip, addr3_ip))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('hosts',hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
Beispiel #26
0
def insert_apply(sitename,idc,project,addr_ip,sofeware,datadir,startscrite,port,mysql_conf,mysql_ip,mysql_stype,mysql_name,mysql_use,mysql_pw,dev_name,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr_ip != '':
		result = db.query("SELECT aid FROM `applications` WHERE addr_ip='%s' AND sitename='%s'"  % (addr_ip,sitename))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('applications',sitename=sitename,idc=idc,project=project,addr_ip=addr_ip,sofeware=sofeware,datadir=datadir,startscrite=startscrite,port=port,mysql_conf=mysql_conf,mysql_ip=mysql_ip,mysql_stype=mysql_stype,mysql_name=mysql_name,mysql_use=mysql_use,mysql_pw=mysql_pw,dev_name=dev_name,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
Beispiel #27
0
 def POST(self):
 	i=web.input()
 	name=i['name']
     pwd=i['pwd']
     ident = db.query("select * from user where name='%s'" %(name))
     if not ident :
         return "<html><body><p>用户不存在!</p><a href='/login'>返回登录页</a></body></html>"
     else:
         if ident[0]['pwd']==pwd :
             web.setcookie('have_user',name,3600)
             return web.seeother('/ok')
         else:
             return "<html><body><p>用户名或密码错误!</p><a href='/login'>返回登录页</a></body></html>"
Beispiel #28
0
 def POST(self):
     i=web.input()
     name=i['name']
     pwd1=i['pwd1']
     pwd2=i['pwd2']
     ident = db.query("select * from user where name='%s'" %(name))
     if ident :
         return "<html><body><p>用用户已存在!</p><a href='/login'>返回登录页面</a></body></html>"
     else :
         if pwd1==pwd2 :
             db.insert('user',name=name,pwd=pwd1,post_time=datetime.now())
             return "<html><body><p>注册成功!</p><a href='/login'>返回登录页面</a></body></html>"
         else :
             return "<html><body><p>注册失败!两次密码输入不一致!</p><a href='/register'>返回注册页面</a></body></html>"
Beispiel #29
0
 def POST(self):
     #you can add user only on the first time
     if int(db.query("select count(*) from "+usert)[0]["count(*)"])!=0:
         return render.error()
     postdata = web.input()
     usrid    = postdata.get("usrname","")
     pw       = postdata.get("password","")
     pw+=salt
     pwmd5 = md5.new(pw).hexdigest()
     db.insert(usert,id=1,user=usrid,password=pwmd5);
     seed = random.randint(0,100000)
     session.hash = md5.new((usrid+pwmd5+str(seed))).hexdigest()
     session.id   = 1
     session.seed = seed
     raise web.seeother('/')
Beispiel #30
0
 def GET(self):
     try:
         page = int(web.input(p='1').p)-1
         query = db.select(artt,limit="%d,5"%(page*5),order="date DESC")
         
         if len(query)==0 and page!=0:
             return render.error()
         count = int(db.query("select count(*) from "+artt)[0]["count(*)"])
         ne=pre=0
         maxpage = count/5
         if maxpage%5 !=0:
             maxpage+=1
         if page>0:
             pre = page
         if page+1<maxpage:
             ne = page+2
         return render.index(query,pre,ne,isadmin())
     except:
         return render.error()
Beispiel #31
0
def getStatusOverView():
	result = db.query("select distinct hosts.status as sid,status.status,count(hosts.status) as total from hosts,status where hosts.status = status.sid group by hosts.status")
	return result
Beispiel #32
0
def getSysOverView():
	result = db.query("SELECT COUNT(hid) AS host,COUNT(distinct city) AS city,COUNT(distinct idc) AS idc,COUNT(distinct project) AS project FROM hosts")
	return result[0]
Beispiel #33
0
def updateServerInfo(hostname,ip1,ip2,project,hostconfig,idc,id):
	db.query("UPDATE `servers` SET `hostname` = '%s', `ip1` = '%s' , `ip2` = '%s' , `project` = '%s' , `hostconfig` = '%s' , `idc` = '%s' WHERE `id` = %s;" %  (hostname,ip1,ip2,project,hostconfig,idc,id))
Beispiel #34
0
def getSysOverView():
    result = db.query(
        "SELECT COUNT(hid) AS host,COUNT(distinct city) AS city,COUNT(distinct idc) AS idc,COUNT(distinct project) AS project FROM hosts"
    )
    return result[0]
Beispiel #35
0
def ChangeUserPWD(user,pwd):
	db.query("UPDATE `users` SET `password` = '%s' WHERE `username` = '%s'" %  (pwd,user))
Beispiel #36
0
def updateUserLogin(uid, lastlogin, loginip):
	db.query("UPDATE `users` SET `lastlogin` = '%s', `loginip` = '%s' WHERE `uid` = %s;" %  (lastlogin, loginip, uid))
Beispiel #37
0
def getHostCountByPidAndIid(pid, iid):
    result = db.query(
        "SELECT count(hid) as count FROM `hosts` WHERE project = '%s' AND idc = '%s'"
        % (pid, iid))
    return result[0].count
Beispiel #38
0
def getIDCInfoByProject(pid):
    result = db.query("SELECT DISTINCT idc FROM `hosts` WHERE project = '%s'" %
                      (pid))
    return result
Beispiel #39
0
def ChangeUserPWD(user, pwd):
    db.query("UPDATE `users` SET `password` = '%s' WHERE `username` = '%s'" %
             (pwd, user))
Beispiel #40
0
def getPageByPidAndIid(pid, iid, offset, pagesize):
    result = db.query(
        "SELECT * FROM `hosts` WHERE project = '%s' AND idc = '%s' order by hid desc limit %s,%s"
        % (pid, iid, offset, pagesize))
    return result
Beispiel #41
0
def getIDCInfoByCity(cid):
    result = db.query("SELECT * FROM `idc` WHERE city = '%s'" % (cid))
    return result
Beispiel #42
0
def getHistory():
    result = db.query("SELECT * FROM history ORDER BY deltime desc")
    return result
Beispiel #43
0
def getStatusOverView():
    result = db.query(
        "select distinct hosts.status as sid,status.status,count(hosts.status) as total from hosts,status where hosts.status = status.sid group by hosts.status"
    )
    return result
Beispiel #44
0
def getHistory():
	result = db.query("SELECT * FROM history ORDER BY deltime desc")
	return result
Beispiel #45
0
def getPageByProject(pid, offset, pagesize):
    result = db.query(
        "SELECT * FROM `hosts` WHERE project = %s order by hid desc limit %s,%s"
        % (pid, offset, pagesize))
    return result
Beispiel #46
0
def getPageByIDC(iid, offset, pagesize):
    result = db.query(
        "SELECT * FROM `hosts` WHERE idc = %s order by hid desc limit %s,%s" %
        (iid, offset, pagesize))
    return result
Beispiel #47
0
def getHostCountByCidAndIid(cid, iid):
    result = db.query(
        "SELECT count(hid) as count FROM `hosts` WHERE city = '%s' AND idc = '%s'"
        % (cid, iid))
    #result = db.query("select count(hid) as count from hosts,idc where hosts.idc = idc.iid and idc=%s and city=%s" % (iid, cid))
    return result[0].count
Beispiel #48
0
def getUserInfoByUID(uid):
	try:
		results = db.query("SELECT * FROM `users` WHERE uid=%s" % (uid))
		return results[0]
	except IndexError:
		return 0
Beispiel #49
0
def getPageBySearch(field, keyword, offset, pagesize):
    result = db.query("SELECT * FROM `hosts` WHERE " + field + " LIKE '%" +
                      keyword + "%' limit " + offset + "," + pagesize + "")
    return result
Beispiel #50
0
def UpdateUserInfo(username,password,phone,email):
	db.query("UPDATE `users` SET `username` = '%s', `password` = '%s' , `phone` = '%s', `email` = '%s';" %  (username,password,phone,email))
Beispiel #51
0
def getHostCountBySearchIp(ip):
    result = db.query(
        "SELECT COUNT(hid) as count FROM `hosts` WHERE addr1_ip LIKE '%" + ip +
        "%' OR addr2_ip LIKE '%" + ip + "%' OR addr3_ip LIKE '%" + ip + "%'")
    return result[0].count
Beispiel #52
0
def getPageBySearch(field,keyword,offset,pagesize):
	result = db.query("SELECT * FROM `hosts` WHERE "+ field +" LIKE '%"+ keyword +"%' limit "+offset+","+pagesize+"")
	return result
Beispiel #53
0
def updateConfig(name, page):
    return db.query("UPDATE config SET name='%s',page='%s' LIMIT 1;" %
                    (name, page))
Beispiel #54
0
def getPageBySearchIp(ip,offset,pagesize):
	result = db.query("SELECT * FROM `hosts` WHERE addr1_ip LIKE '%"+ip+"%' OR addr2_ip LIKE '%"+ip+"%' OR addr3_ip LIKE '%"+ip+"%' limit "+offset+","+pagesize+"")
	return result
Beispiel #55
0
def updateConfig(name,page):
	return db.query("UPDATE config SET name='%s',page='%s' LIMIT 1;" % (name, page))
Beispiel #56
0
def getPageBySearchIp(ip, offset, pagesize):
    result = db.query("SELECT * FROM `hosts` WHERE addr1_ip LIKE '%" + ip +
                      "%' OR addr2_ip LIKE '%" + ip +
                      "%' OR addr3_ip LIKE '%" + ip + "%' limit " + offset +
                      "," + pagesize + "")
    return result
Beispiel #57
0
def getHostCountBySearch(field, keyword):
    result = db.query("SELECT count(hid) as count FROM `hosts` WHERE " +
                      field + " LIKE '%" + keyword + "%'")
    return result[0].count