def saveuserrights(self, **kwargs):
		sess = db.getsession()
		try:
			s = sess.query(usergroup).filter(usergroup.GROUPID == kwargs["GROUPID"]).one()
		except Exception, e:
			s = usergroup(GROUPID = kwargs["GROUPID"])
			sess.add(s)
	def edituserrights(self, id, time=None, dashboard=0):
		sess = db.getsession()
		try:
			s = sess.query(usergroup).filter(usergroup.GROUPID == id).one()
		except:
			s = usergroup(GROUPID = id)
		return self.lookup.get_template(USERSINGROUP + "edituserrights.html").render(usergroup = s, table = db.usergroup_table, dashboard=dashboard)
	def saveservergroup(self, **kwargs):
		sess = db.getsession()
		try:
			s = sess.query(servergroup).filter(servergroup.GROUPID == kwargs["GROUPID"]).one()
		except Exception, e:
			s = actions.action(GROUPID = kwargs["GROUPID"])
			sess.add(s)
Beispiel #4
0
	def editjob(self, id, actionid=None, scheduleid=None, time=None, dashboard=0):
		sess = db.getsession()
		try:
			j = sess.query(job).filter(job.JOBID == int(id)).one()
		except:
			try:
				u = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()
			except:
				return "Could not get user."

			j = job(STATUS = 4)
			if actionid == None:
				a = sess.query(action).first()
				j.ACTIONID = a.ACTIONID

			else:
				j.ACTIONID = actionid
				a = sess.query(action).filter(action.ACTIONID == actionid).one()
				if u.jobs(db.EDIT_MINE) and not u.jobs(db.EDIT):
					if a.USERID != cherrypy.session.get('hquserid'):
						return "Cannot schedule an action that is not yours."
			j.COMMENTS = ""
			j.STDIN = ""
			j.BATCH = ""
			j.SERVERID = ""
			j.USERID = cherrypy.session.get('hquserid')
			sess.add(j)
			sess.flush()
			sess.refresh(j)

		return self.lookup.get_template(JOBS + "editjob.html").render(job = j, table = db.job_table, dashboard=dashboard)
Beispiel #5
0
	def deleteall(self, **elements):
		elements = elements["elements[]"]
		try:
			len(elements)
		except:
			e = []
			e.append(elements)
			elements = e
		sess = db.getsession()
		deleted = ""

		onfile = False

		for i in elements:
			try:
				d = sess.query(schedule).filter(schedule.SCHEDID == i).one()
				onfile = True
			except:
				onFile = False

			if onfile:
				if d.SCHEDID != 'ONCE' and d.SCHEDID != 'IMMEDIATE':
					sess.delete(d)
					deleted = deleted + "Schedule " + d.SCHEDID + " deleted.\n"

					try:
						sess.flush()
					except:
						deleted = deleted + "Could not delete schedule " + d.SCHEDID + ".\n"

		return deleted
Beispiel #6
0
	def rerun(self, id, batch="", time=None):
		sess = db.getsession()

		u = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()


		try:
			a = sess.query(action).filter(action.ACTIONID == id).one()
		except:
			return "Action " + id + " is not on file."

		if a.USERID != u.USERID and not u.jobs(db.EDIT):
			if a.USERID != cherrypy.session.get('hquserid'):
				return "Cannot schedule an action that is not yours."


		try:
			j = job(ACTIONID = id, BATCH=batch)
			j.USERID = u.USERID
			sess.add(j)
			sess.flush()
			quick_create_event(14, event_job = j, event_action = a, event_user = u)

			return "Reran " + id + "."
		except:
			return "Failed to rerun.  Action not on file."
Beispiel #7
0
	def loglist(self, currentview='', dashboard = 0, time=0, detach=0, makedef=0, ACTIONID=''):
		sess = db.getsession()
	
		try:
			usr_obj = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()
		except Exception, e:
			return "Cannot locate user "
Beispiel #8
0
	def editview(self, viewid, time=None, dashboard = 0):	
		sess = db.getsession()

		usr_obj = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()


		try:
			v = sess.query(logview).filter(and_(logview.VIEWID == viewid, logview.USERID == usr_obj.USERID)).one()	
		except:
			v = logview(USERID = usr_obj.USERID, VIEWID = viewid)	
			v.ORDERBY = "EXECEND"
			v.COUNT = 1000
			v.REFRESH = 0
			v.PLUSDELTA = -1
			v.FILTERJOBID = "%"
			v.FILTERACTIONID = "%"
			v.FILTERBATCH = "%"
			v.FILTERSCHEDID = "%"
			v.FILTERUSERID = "%"
			v.FILTERSERVERID = "%"
			v.FILTERCMDLINE = "%"
			v.FILTERGTPID = 999999
			v.FILTERLTPID = 0
			v.FILTERGTRETCODE = 999999
			v.FILTERLTRETCODE = 0
			v.FILTERGTRESULT = 10
			v.FILTERLTRESULT = 0
		return self.lookup.get_template(LOGS + "editview.html").render(view=v, table=db.logview_table, dashboard = dashboard) 
Beispiel #9
0
	def deletejob(self, id):
		sess = db.getsession()

		j = sess.query(job).filter(job.JOBID == id).one()

		try:
			a = sess.query(action).filter(action.ACTIONID == j.ACTIONID).one()
		except:
			sess.delete(j)
			sess.flush()
			return "Action not on file, deleted job."

		u = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()

		if u.jobs(db.EDIT_MINE) and not u.jobs(db.EDIT):
			if a.USERID != cherrypy.session.get('hquserid'):
				return "Cannot delete job that action is not yours."

		try:
			j = sess.query(job).filter(job.JOBID == id).one()
			sess.delete(j)
			sess.flush()
		except:
			return "Unknown Job"
		return "Deleted Job " + str(id) + "."
Beispiel #10
0
	def unscheduleall(self, **elements):
		elements = elements["elements[]"]
		try:
			len(elements)
		except:
			e = []
			e.append(elements)
			elements = e
		sess = db.getsession()
		sched = ""

		onfile = True

		for i in elements:
			try:
				j = sess.query(job).filter(job.JOBID == int(i)).one()
				u = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()	
				onfile = True
			except Exception, e:
				onfile = False

			if onfile:
				try:
					if j.USERID != u.USERID and not u.jobs(db.EDIT):
						sched = sched + "Could not unschedule job " + i + ", job is not yours.\n"
					else:
						j.STATUS = 4
						sched = sched + "Unscheduled job " + i + ".\n"
				except Exception, e:
					sched = sched + str(e) + ".\n"

				try:
					sess.flush()
				except Exception, e:
					return "Error unscheduling " + str(e) + "."
Beispiel #11
0
	def deleteall(self, elements):
		try:
			len(elements)
		except:
			e = []
			e.append(elements)
			elements = e
		sess = db.getsession()
		deleted = ""

		onfile = False

		for i in elements:
			try:
				d = sess.query(useringroup).filter(useringroup.GROUPID == i).all()
				onfile = True
				if len(d) < 1:
					onfile = False
			except:
				onfile = False

			if onfile:
				for x in d:
					sess.delete(x)
				deleted = deleted + "Group " + i + " deleted.\n"

				try:
					sess.flush()
				except:
					deleted = deleted + "Error deleting group " + i + ".\n"

		return deleted
Beispiel #12
0
	def savejob(self, **kwargs):	
		sess = db.getsession()

		try:
			a = sess.query(job).filter(job.JOBID == int(kwargs["JOBID"])).one()
		except:
			return "Job " + kwargs["JOBID"] + " is not on file."

		try:
			a = sess.query(action).filter(action.ACTIONID == kwargs["ACTIONID"]).one()
		except:
			return "Action " + kwargs["ACTIONID"] + " is not on file."

		try:
			u = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()
		except:
			return "Could not get user."

		if u.jobs(db.EDIT_MINE) and not u.jobs(db.EDIT):
			if a.USERID != cherrypy.session.get('hquserid'):
				return "Cannot save job that is not yours."

		try:
			j = sess.query(job).filter(job.JOBID == (kwargs["JOBID"])).one()
		except Exception, e:
			j = job(STATUS = 4)
			sess.add(j)
			sess.flush()
			sess.refresh(j)
Beispiel #13
0
	def editschedule(self, id, time=None, dashboard=0):
		sess = db.getsession()
		try:
			s = sess.query(schedule).filter(schedule.SCHEDID == id).one()
		except:
			s = schedule(SCHEDID = id)
		return self.lookup.get_template(SCHEDULES + "editschedule.html").render(schedule = s, table = db.schedule_table, dashboard = dashboard)
	def deleteall(self, elements):
		try:
			len(elements)
		except:
			e = []
			e.append(elements)
			elements = e
		sess = db.getsession()
		deleted = ""

		onfile = False

		for i in elements:
			try:
				d = sess.query(servergroup).filter(servergroup.GROUPID == i).one()
				onfile = True
			except:
				onfile = False

			if onfile:
				sess.delete(d)
				deleted = deleted + "Server group " + i + " deleted.\n"

				try:
					sess.flush()
				except:
					deleted = deleted + "Could not delete server group " + i + "\n"

		return deleted
Beispiel #15
0
	def saveactionretcode(self, **kwargs):
		sess = db.getsession()

		try:
			sess.query(validreturncode).filter(and_(validreturncode.ACTIONID == kwargs["ACTIONID"], validreturncode.VALUE == int(kwargs["VALUE"]))).one()
			return "Error: Value exists for this Action."
		except:
			pass

		v = validreturncode(ACTIONID = kwargs["ACTIONID"])
		sess.add(v)

		try:
			try:
				fillobj(v, db.validreturncode_table, kwargs)
			except:
				return "Error: Invalid value"

			u = sess.query(user).filter(user.USERID == cherrypy.session.get('hquserid')).one()
			if u.actions(db.EDIT_MINE) and not u.actions(db.EDIT):
				if sess.query(actions.action).filter(actions.action.ACTIONID == kwargs["ACTIONID"]).one().USERID != u.USERID:
					return "Error: Unable to save action return code, you do not have rights to do so."

			sess.flush()
		except Exception, e:
			return "Error: " + str(e)
Beispiel #16
0
	def saveeventdef(self, **kwargs):
		sess = db.getsession()
		try:
			a = sess.query(eventdef).filter(eventdef.EVENTNUM == kwargs["EVENTNUM"]).one()
		except Exception, e:
			a = eventdef(EVENTNUM = kwargs["EVENTNUM"])
			sess.add(a)
Beispiel #17
0
	def deleteall(self, **elements):
		elements = elements["elements[]"]
		try:
			len(elements)
		except:
			e = []
			e.append(elements)
			elements = e
		sess = db.getsession()
		deleted = ""

		onfile = False

		for i in elements:
			try:
				d = sess.query(eventdef).filter(eventdef.EVENTNUM == i).one()
				onfile = True
			except:
				onfile = False

			if onfile:
				sess.delete(d)
				deleted = deleted + "Event definition " + str(d.EVENTNUM) + " deleted.\n"

				try:
					sess.flush()
				except:
					deleted = deleted + "error deleting event definition " + str(d.EVENTNUM) + ".\n"

		return deleted
Beispiel #18
0
	def saveschedule(self, **kwargs):
		sess = db.getsession()
		try:
			s = sess.query(schedule).filter(schedule.SCHEDID == kwargs["SCHEDID"]).one()
		except Exception, e:
			s = schedule(SCHEDID = kwargs["SCHEDID"])
			sess.add(s)
Beispiel #19
0
	def editeventdef(self, id, time=None, dashboard=0):
		sess = db.getsession()
		try:
			j = sess.query(eventdef).filter(eventdef.EVENTNUM==id).one()
		except:
			j = eventdef(EVENTNUM = id)
		return self.lookup.get_template(EVENTDEFS + "editeventdef.html").render(eventdef=j, table=db.eventdef_table, dashboard=dashboard)
Beispiel #20
0
	def editnotifygroup(self, id, time=None):
		sess = db.getsession()

		n = sess.query(notifygroup).filter(notifygroup.EVENTNUM==int(id)).all()

		b = notifygroup()
		b.EVENTNUM = int(id)

		return self.lookup.get_template(EVENTDEFS + "editnotifygroup.html").render(notifygrouplist=n, blank=b, table=db.notifygroup_table, id=int(id))
	def deleteserveringroup(self, id, time=None):
		sess = db.getsession()
		try:
			s = sess.query(serveringroup).filter(serveringroup.SIGID == int(id)).one()
			sess.delete(s)
			sess.flush()
			return "Deleted."
		except Exception, e:
			return "Failed to Delete ", e
	def deleteservergroup(self, id):
		sess = db.getsession()
		try:
			s = sess.query(servergroup).filter(servergroup.GROUPID == id).one()
			sess.delete(s)
			sess.flush()
			return "Deleted." 
		except Exception, e:
			return "Failed to Delete ", e
Beispiel #23
0
	def editactivateaction(self, id, time=None):
		sess = db.getsession()

		a = sess.query(activateaction).filter(activateaction.EVENTNUM ==int(id)).all()

		b = activateaction()
		b.EVENTNUM = int(id)

		return self.lookup.get_template(EVENTDEFS + "editactivateaction.html").render(activateactionlist=a, blank=b, table=db.activateaction_table, id=int(id))
Beispiel #24
0
	def editvalidtimes(self, id, time=None):
		sess = db.getsession()

		v = sess.query(validtime).filter(validtime.SCHEDID==id).all()

		b = validtime()
		b.SCHEDID = id

		return self.lookup.get_template(SCHEDULES + "editvalidtimes.html").render(validtimelist = v, blank=b, table=db.validtime_table, id=id)
Beispiel #25
0
	def deleteuig(self, id, time=None):
		sess = db.getsession()
		try:
			sc = sess.query(useringroup).filter(useringroup.UIGID == id).one()
			sess.delete(sc)
			sess.flush()
			return "Deleted."
		except:
			return "Failed to Delete."
Beispiel #26
0
	def editactiondeps(self, id, time=None):
		sess = db.getsession()

		j = sess.query(actiondeps.actiondep).filter(actiondeps.actiondep.ACTIONID==id).all()
	
		b = actiondeps.actiondep()
		b.ACTIONID = id

		return self.lookup.get_template(ACTIONS + "editactiondeps.html").render(actiondeplist=j, blankdep=b, table=db.actiondep_table, id=id)
Beispiel #27
0
	def deleteuserrights(self, id):
		sess = db.getsession()
		try:
			sc = sess.query(usergroup).filter(usergroup.GROUPID == id).one()
			sess.delete(sc)
			sess.flush()
			return "Deleted."
		except:
			return "Failed to Delete."
Beispiel #28
0
	def editactionservers(self, id, time=None):
		sess = db.getsession()

		s = sess.query(actionservers.actionserver).filter(actionservers.actionserver.ACTIONID==id).all()

		b = actionservers.actionserver()
		b.ACTIONID = id

		return self.lookup.get_template(ACTIONS + "editactionservers.html").render(actionserverlist=s, blankserver=b, table=db.actionserver_table, id=id)
Beispiel #29
0
	def editactionretcodes(self, id, time=None):
		sess = db.getsession()

		v = sess.query(validreturncode).filter(validreturncode.ACTIONID==id).all()
	
		b = validreturncode()
		b.ACTIONID = id

		return self.lookup.get_template(ACTIONS + "editactionretcodes.html").render(retcodelist=v, blankretcode=b, table=db.validreturncode_table, id=id)
Beispiel #30
0
	def editaction(self, id, time=None, dashboard=0):
		sess = db.getsession()
		try:
			j = sess.query(actions.action).filter(actions.action.ACTIONID==id).one()
		except:
			j = actions.action(ACTIONID = id, STDIN = "", COMMENTS = "", CMDLINE = "")

			j.USERID = cherrypy.session.get('hquserid')

		return self.lookup.get_template(ACTIONS + "editaction.html").render(action=j, table=db.action_table, dashboard=dashboard)