Commit ee5a497d authored by Reto Da Forno's avatar Reto Da Forno
Browse files

unused database tables removed

parent 34deb1c5
......@@ -66,32 +66,6 @@ CREATE TABLE `tbl_serv_dispatcher_activity` (
) ENGINE=InnoDB AUTO_INCREMENT=1181 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_errorlog`
--
DROP TABLE IF EXISTS `tbl_serv_errorlog`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tbl_serv_errorlog` (
`serv_errorlog_key` int(10) unsigned NOT NULL AUTO_INCREMENT,
`test_fk` int(10) unsigned DEFAULT NULL,
`observer_fk` int(10) unsigned DEFAULT NULL,
`obs_db_timestamp` datetime DEFAULT NULL,
`obs_db_seq_nr` int(10) unsigned DEFAULT NULL,
`service_fk` int(10) unsigned DEFAULT NULL,
`errormessage` text COLLATE utf8_bin NOT NULL,
`timestamp` decimal(16,6) NOT NULL,
PRIMARY KEY (`serv_errorlog_key`),
UNIQUE KEY `uc_errolog_entry` (`test_fk`,`observer_fk`,`obs_db_timestamp`,`obs_db_seq_nr`),
KEY `fk_tbl_serv_errorlog_tests` (`test_fk`),
KEY `fk_tbl_serv_errorlog_observer` (`observer_fk`),
KEY `fk_tbl_serv_errorlog_services` (`service_fk`),
CONSTRAINT `fk_tbl_serv_errorlog_observer` FOREIGN KEY (`observer_fk`) REFERENCES `tbl_serv_observer` (`serv_observer_key`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_tbl_serv_errorlog_tests` FOREIGN KEY (`test_fk`) REFERENCES `tbl_serv_tests` (`serv_tests_key`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=38621 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_groups`
--
......@@ -173,24 +147,6 @@ CREATE TABLE `tbl_serv_observer` (
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_pinmappings`
--
DROP TABLE IF EXISTS `tbl_serv_pinmappings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tbl_serv_pinmappings` (
`serv_pinmappings_key` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pin_number` tinyint(3) NOT NULL,
`pin_name` varchar(10) COLLATE utf8_bin NOT NULL,
`services_fk` int(11) DEFAULT NULL,
PRIMARY KEY (`serv_pinmappings_key`),
KEY `fk_tbl_serv_pinmappings_1_idx` (`services_fk`),
CONSTRAINT `fk_tbl_serv_pinmappings_1` FOREIGN KEY (`services_fk`) REFERENCES `tbl_serv_services` (`serv_services_key`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_platforms`
--
......@@ -250,22 +206,6 @@ CREATE TABLE `tbl_serv_resource_allocation` (
) ENGINE=InnoDB AUTO_INCREMENT=2289 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_services`
--
DROP TABLE IF EXISTS `tbl_serv_services`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tbl_serv_services` (
`serv_services_key` int(11) NOT NULL AUTO_INCREMENT,
`service` varchar(45) COLLATE utf8_bin NOT NULL,
`abbreviation` varchar(2) COLLATE utf8_bin NOT NULL,
`last_changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`serv_services_key`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_targetimages`
--
......
......@@ -98,7 +98,7 @@ def main(argv):
else:
delete_all = False
# Clean through all relevant tables ---
relevant_tables = ['tbl_serv_errorlog']
relevant_tables = []
if delete_all:
relevant_tables.append('tbl_serv_map_test_observer_targetimages')
for table in relevant_tables:
......
......@@ -1229,11 +1229,6 @@ def main(argv):
# Test start failed. Make it abort:
logger.warn("Going to abort test because of errors when trying to start it.")
abort = True
# Write errors and warnings to DB:
for warn in warnings:
flocklab.write_errorlog(cursor=cur, conn=cn, testid=testid, message=warn)
for err in errors:
flocklab.write_errorlog(cursor=cur, conn=cn, testid=testid, message=err)
# Inform user:
ret = inform_user(testid, cur, action, errors, warnings)
......@@ -1278,12 +1273,6 @@ def main(argv):
cur.execute(sql%(int(time_needed), testid))
cn.commit()
# Write errors and warnings to DB:
for warn in warnings:
flocklab.write_errorlog(cursor=cur, conn=cn, testid=testid, message=warn)
for err in errors:
flocklab.write_errorlog(cursor=cur, conn=cn, testid=testid, message=err)
# Inform user:
ret = inform_user(testid, cur, action, errors, warnings)
# Wait until test has status synced or no more fetcher is running:
......
......@@ -20,9 +20,7 @@ testresultsdir = None
testresultsfile_dict = {}
mainloop_stop = False
owner_fk = None
pindict = None
obsdict_byid = None
servicedict = None
serialdict = None
ITEM_TO_PROCESS = 0
......@@ -753,9 +751,7 @@ def main(argv):
global testresultsdir
global testresultsfile_dict
global owner_fk
global pindict
global obsdict_byid
global servicedict
global serialdict
stop = False
......@@ -851,11 +847,6 @@ def main(argv):
owner_fk = rs[0]
else:
owner_fk = None
rs = flocklab.get_pinmappings(cur)
if isinstance(rs, dict):
pindict = rs
else:
pindict = None
rs = flocklab.get_test_obs(cur, testid)
if isinstance(rs, tuple):
obsdict_byid = rs[1]
......@@ -863,11 +854,6 @@ def main(argv):
obsdict_byid = None
# Dict for serial service: 'r' means reader (data read from the target), 'w' means writer (data written to the target):
serialdict = {0: 'r', 1: 'w'}
rs = flocklab.get_servicemappings(cur)
if isinstance(rs, dict):
servicedict = rs
else:
servicedict = None
#find out the start and stoptime of the test
cur.execute("SELECT `time_start_wish`, `time_end_wish` FROM `tbl_serv_tests` WHERE `serv_tests_key` = %d" %testid)
......@@ -914,9 +900,9 @@ def main(argv):
cur.close()
cn.close()
if ((owner_fk==None) or (pindict==None) or (obsdict_byid==None) or (servicedict==None)):
if ((owner_fk==None) or (obsdict_byid==None)):
msg = "Error when getting metadata.\n"
msg += "owner_fk: %s\npindict: %s\nobsdict_byid: %s\nservicedict: %s\n" % (str(owner_fk), str(pindict), str(obsdict_byid), str(servicedict))
msg += "owner_fk: %s\nobsdict_byid: %s\n" % (str(owner_fk), str(obsdict_byid))
msg += "Exiting..."
logger.debug(msg)
os.kill(os.getpid(), signal.SIGTERM)
......
......@@ -491,78 +491,6 @@ def get_test_owner(cursor=None, testid=0):
### END get_test_owner()
##############################################################################
#
# get_pinmappings - Get all pin mappings from the database
#
##############################################################################
def get_pinmappings(cursor=None):
"""Arguments:
cursor: cursor of the database connection to be used for the query
Return value:
Dictionary with pin number, pin_name
1 if there is an error in the arguments passed to the function
2 if there was an error in processing the request
"""
if ((type(cursor) != MySQLdb.cursors.Cursor)):
return 1
try:
cursor.execute("SELECT `a`.`pin_number`, `a`.`pin_name` , `b`.`service` \
FROM `tbl_serv_pinmappings` AS `a` \
LEFT JOIN `tbl_serv_services` AS `b` \
ON `a`.`services_fk` = `b`.`serv_services_key` \
")
rs = cursor.fetchall()
pindict = {}
for row in rs:
pindict[row[0]] = (row[1], row[2])
if len(pindict) == 0:
raise
return pindict
except:
logger = get_logger()
logger.error("%s: %s" %(str(sys.exc_info()[0]), str(sys.exc_info()[1])))
return 2
### END get_pinmappings()
##############################################################################
#
# get_servicemappings - Get all service mappings from the database
#
##############################################################################
def get_servicemappings(cursor=None):
"""Arguments:
cursor: cursor of the database connection to be used for the query
Return value:
Dictionary with mappings
1 if there is an error in the arguments passed to the function
2 if there was an error in processing the request
"""
if ((type(cursor) != MySQLdb.cursors.Cursor)):
return 1
try:
cursor.execute("SELECT `serv_services_key`, `service`, `abbreviation` FROM `tbl_serv_services`")
rs = cursor.fetchall()
servicedict = {}
for row in rs:
servicedict[row[0]] = (row[1], row[2])
return servicedict
except:
logger = get_logger()
logger.error("%s: %s" %(str(sys.exc_info()[0]), str(sys.exc_info()[1])))
return 2
### END get_servicemappings()
##############################################################################
#
# get_slot - Get slot for specific observer and platform from the database
......@@ -904,49 +832,6 @@ def release_db_lock(cursor, conn, key, expiry_time=10):
### END release_db_lock()
##############################################################################
#
# write_errorlog - Writes a message to the errorlog table tbl_serv_errorlog.
#
##############################################################################
def write_errorlog(cursor=None, conn=None, testid=0, obsid=0, message="", timestamp=0.0):
# Check the arguments:
if ((type(cursor) != MySQLdb.cursors.Cursor) or (type(conn) != MySQLdb.connections.Connection) or (type(testid) != int) or (type(obsid) != int) or (type(message) != str) or (len(message) <= 0) or (type(timestamp) != float) or (timestamp < 0.0)):
return FAILED
if ((testid != 0) and (check_test_id(cursor, testid) != 0)):
return FAILED
if ((obsid != 0) and (check_observer_id(cursor, obsid) <= 0)):
return FAILED
else:
obskey = check_observer_id(cursor, obsid)
# Prepare timestamp:
if (timestamp <= 0.0):
timestamp = time.time()
# Set the status in the database
sql = "INSERT INTO `tbl_serv_errorlog` (`errormessage`, `timestamp`, `test_fk`, `observer_fk`) VALUES ('%s', %f" %(re.escape(message), timestamp)
if testid != 0:
sql += ", %d"%testid
else:
sql += ", NULL"
if obsid != 0:
sql += ", %d"%obskey
else:
sql += ", NULL"
sql += ");"
try:
cursor.execute(sql)
conn.commit()
except:
# There was an error in the database connection:
logger = get_logger()
logger.error("Error when executing %s: %s: %s" %(sql, str(sys.exc_info()[0]), str(sys.exc_info()[1])))
return FAILED
return(0)
### END write_errorlog()
##############################################################################
#
# error_logandexit - Logs an error (to log and email to admins) and exits the script
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment