Пример #1
0
	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>")
Пример #2
0
	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>")
Пример #3
0
	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>")
Пример #4
0
	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>")
Пример #5
0
	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)
Пример #6
0
	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)
Пример #7
0
	def GET(self):
		if not base.logged():
			raise web.seeother('/')
		project_info_list = []
		all_project_list = models.getProjectInfo();
		one_count = []
	
		#[pid,project,idc,hostcount]
		for p in all_project_list:
			host_count = models.getHostCountByProject(p.pid)
			idc_count = models.getIDCCountByProject(p.pid)
			one_count.append(p.pid)
			one_count.append(p.project)
			one_count.append(idc_count)
			one_count.append(host_count)
			project_info_list.append(one_count)
			one_count = []
		
		if web.ctx.session.privilege == 0:
			return render.project_list(project_info_list)
		else:
			return render.project_list_admin(project_info_list)
Пример #8
0
	def GET(self):
		if not base.logged():
			raise web.seeother('/')
		project_info_list = []
		all_project_list = models.getProjectInfo();
		one_count = []
	
		#[pid,project,idc,hostcount]
		for p in all_project_list:
			host_count = models.getHostCountByProject(p.pid)
			idc_count = models.getIDCCountByProject(p.pid)
			one_count.append(p.pid)
			one_count.append(p.project)
			one_count.append(idc_count)
			one_count.append(host_count)
			project_info_list.append(one_count)
			one_count = []
		
		if web.ctx.session.privilege == 0:
			return render.project_list(project_info_list)
		else:
			return render.project_list_admin(project_info_list)
Пример #9
0
def pidToProject():
    projects = getProjectInfo()
    projects_dict = {}
    for p in projects:
        projects_dict[p.pid] = p.project
    return projects_dict
Пример #10
0
def pidToProject():
	projects = getProjectInfo()
	projects_dict = {}
	for p in projects:
		projects_dict[p.pid] = p.project
	return projects_dict