Esempio n. 1
0
def report_init(dbfile = CLUES_DB):
	db = DataBase(dbfile)
	if DataBase.db_available:
		db.connect()
		if not db.table_exists("report_jobs"):
			# la tabla no existe y la vamos a crear
			sentence = '''create table "report_jobs" ('''
			sentence = sentence + ''' "date" FLOAT NOT NULL, '''
			sentence = sentence + ''' "Manager" VARCHAR(128) NOT NULL, '''
			sentence = sentence + ''' "NewJob" INTEGER NOT NULL, '''
			sentence = sentence + ''' "ReleasedJob" INTEGER NOT NULL '''
			sentence = sentence + ''' ) '''
			db.execute(sentence)
		if not db.table_exists("report_nodes"):
			# la tabla no existe y la vamos a crear
			sentence = '''create table "report_nodes" ('''
			sentence = sentence + ''' "date" FLOAT NOT NULL, '''
			sentence = sentence + ''' "Node" VARCHAR(256) NOT NULL, '''
			sentence = sentence + ''' "State" INTEGER NOT NULL, '''
			sentence = sentence + ''' "FreeSlots" REAL, '''
			sentence = sentence + ''' "TotalSlots" REAL'''
			sentence = sentence + ''' ) '''
			db.execute(sentence)
		if not db.table_exists("lrms_jobs"):
			# la tabla no existe y la vamos a crear
			sentence = '''create table "lrms_jobs" ('''
			sentence = sentence + ''' "Manager" VARCHAR(128) NOT NULL, '''
			sentence = sentence + ''' "JobID" INTEGER NOT NULL, '''
			sentence = sentence + ''' "Nodes" INTEGER NOT NULL, '''
			sentence = sentence + ''' "Specs" VARCHAR(256), '''
			sentence = sentence + ''' "WholeCluster" INTEGER NOT NULL, '''
			sentence = sentence + ''' "QueuedTime" FLOAT NOT NULL, '''
			sentence = sentence + ''' "StartTime" FLOAT, '''
			sentence = sentence + ''' "EndTime" FLOAT '''
			sentence = sentence + ''' ) '''
			db.execute(sentence)
		
		db.close()

	report_job_reset()
Esempio n. 2
0
	def excluded_nodes():
		exclusion_list = initly_excluded
		hosts = []
		db = DataBase(CLUES_DB)
		db.connect()
		try:
			if not db.table_exists("disabled_hosts"):
				# la tabla no existe y la vamos a crear
				db.execute('''create table "disabled_hosts" ("hostname" TEXT PRIMARY KEY)''')
				
			res = db.select('''select hostname from "disabled_hosts"''')
			hosts = [h[0] for h in res]

		except Exception, e:
			logging.error("failed trying to obtain persistent disabled node list")
Esempio n. 3
0
	def __init__(self, expiry_time, db_name = "users.db", create_table = False):
		# The database name where the users (and tokens) are stored
		self.__db_name = db_name
		# The expiry time is expressed in seconds and represents how long the authentication token is valid from the creation time
		self.__expiry_time = expiry_time
		# We are trying to validate the users database
		db = DataBase(self.__db_name)
		db.connect()
		if not db.table_exists("user"):
			if create_table:
				# if the table does not exist, we will create it
				sentence = '''create table "user" ('''
				sentence = sentence + ''' "user" TEXT PRIMARY KEY NOT NULL, '''
				sentence = sentence + ''' "password" TEXT NOT NULL, '''
				sentence = sentence + ''' "attributes" TEXT, '''
				sentence = sentence + ''' "token" TEXT, '''
				sentence = sentence + ''' "token_expire" INTEGER '''
				sentence = sentence + ''' ) '''
				db.execute(sentence)
			else:
				raise TableNotFound