Commit 8c415489 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

operating system database table removed

parent 4d8077ce
...@@ -173,44 +173,6 @@ CREATE TABLE `tbl_serv_observer` ( ...@@ -173,44 +173,6 @@ CREATE TABLE `tbl_serv_observer` (
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_observer_slot_calibration`
--
DROP TABLE IF EXISTS `tbl_serv_observer_slot_calibration`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tbl_serv_observer_slot_calibration` (
`serv_observer_slot_calibration_key` int(10) unsigned NOT NULL AUTO_INCREMENT,
`observer_fk` int(10) unsigned NOT NULL,
`slot` enum('1','2','3','4') COLLATE utf8_bin NOT NULL,
`offset` double NOT NULL,
`factor` double NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`comment` text COLLATE utf8_bin,
PRIMARY KEY (`serv_observer_slot_calibration_key`),
UNIQUE KEY `obs_and_slot_unq` (`observer_fk`,`slot`),
KEY `observer_key` (`observer_fk`),
CONSTRAINT `observer_key` FOREIGN KEY (`observer_fk`) REFERENCES `tbl_serv_observer` (`serv_observer_key`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=162 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tbl_serv_operatingsystems`
--
DROP TABLE IF EXISTS `tbl_serv_operatingsystems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tbl_serv_operatingsystems` (
`serv_operatingsystems_key` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) COLLATE utf8_bin NOT NULL,
`description` text COLLATE utf8_bin,
`last_changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`serv_operatingsystems_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_pinmappings` -- Table structure for table `tbl_serv_pinmappings`
-- --
...@@ -316,7 +278,6 @@ CREATE TABLE `tbl_serv_targetimages` ( ...@@ -316,7 +278,6 @@ CREATE TABLE `tbl_serv_targetimages` (
`name` varchar(45) COLLATE utf8_bin NOT NULL, `name` varchar(45) COLLATE utf8_bin NOT NULL,
`description` text COLLATE utf8_bin, `description` text COLLATE utf8_bin,
`owner_fk` int(10) unsigned NOT NULL, `owner_fk` int(10) unsigned NOT NULL,
`operatingsystems_fk` int(10) unsigned NOT NULL,
`platforms_fk` int(10) unsigned NOT NULL, `platforms_fk` int(10) unsigned NOT NULL,
`core` int(8) unsigned DEFAULT '0', `core` int(8) unsigned DEFAULT '0',
`binary` longblob, `binary` longblob,
...@@ -324,10 +285,8 @@ CREATE TABLE `tbl_serv_targetimages` ( ...@@ -324,10 +285,8 @@ CREATE TABLE `tbl_serv_targetimages` (
`last_changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`serv_targetimages_key`), PRIMARY KEY (`serv_targetimages_key`),
KEY `fk_tbl_serv_targetimages_users` (`owner_fk`), KEY `fk_tbl_serv_targetimages_users` (`owner_fk`),
KEY `fk_tbl_serv_targetimages_os` (`operatingsystems_fk`),
KEY `fk_tbl_serv_targetimages_platform` (`platforms_fk`), KEY `fk_tbl_serv_targetimages_platform` (`platforms_fk`),
KEY `index_tbl_serv_targetimages_binary_hash_sha1` (`binary_hash_sha1`), KEY `index_tbl_serv_targetimages_binary_hash_sha1` (`binary_hash_sha1`),
CONSTRAINT `fk_tbl_serv_targetimages_os` FOREIGN KEY (`operatingsystems_fk`) REFERENCES `tbl_serv_operatingsystems` (`serv_operatingsystems_key`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_tbl_serv_targetimages_platform` FOREIGN KEY (`platforms_fk`) REFERENCES `tbl_serv_platforms` (`serv_platforms_key`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_tbl_serv_targetimages_platform` FOREIGN KEY (`platforms_fk`) REFERENCES `tbl_serv_platforms` (`serv_platforms_key`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_tbl_serv_targetimages_users` FOREIGN KEY (`owner_fk`) REFERENCES `tbl_serv_users` (`serv_users_key`) ON DELETE NO ACTION ON UPDATE NO ACTION CONSTRAINT `fk_tbl_serv_targetimages_users` FOREIGN KEY (`owner_fk`) REFERENCES `tbl_serv_users` (`serv_users_key`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=33510 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=33510 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
......
Dump structure of database using following command:
mysqldump -d -h <db_server> -u <username> -p --databases 'flocklab' --lock-tables=false > flocklab_server_db.sql
mysqldump -t -h <db_server> -u <username> -p flocklab tbl_serv_architectures tbl_serv_observer tbl_serv_observer_slot_calibration tbl_serv_operatingsystems tbl_serv_pinmappings tbl_serv_platforms tbl_serv_services tbl_serv_tg_adapt_list tbl_serv_tg_adapt_types >> flocklab_server_db.sql
...@@ -269,8 +269,6 @@ def start_test(testid, cur, cn, obsdict_key, obsdict_id): ...@@ -269,8 +269,6 @@ def start_test(testid, cur, cn, obsdict_key, obsdict_id):
ON `t`.`serv_targetimages_key` = `m`.`targetimage_fk` ON `t`.`serv_targetimages_key` = `m`.`targetimage_fk`
LEFT JOIN `tbl_serv_platforms` AS `p` LEFT JOIN `tbl_serv_platforms` AS `p`
ON `t`.`platforms_fk` = `p`.`serv_platforms_key` ON `t`.`platforms_fk` = `p`.`serv_platforms_key`
LEFT JOIN `tbl_serv_operatingsystems` AS `o`
ON `t`.`operatingsystems_fk` = `o`.`serv_operatingsystems_key`
LEFT JOIN `tbl_serv_architectures` AS `a` LEFT JOIN `tbl_serv_architectures` AS `a`
ON `t`.`core` = `a`.`core` AND `p`.`serv_platforms_key` = `a`.`platforms_fk` ON `t`.`core` = `a`.`core` AND `p`.`serv_platforms_key` = `a`.`platforms_fk`
WHERE `m`.`test_fk` = %d WHERE `m`.`test_fk` = %d
...@@ -295,7 +293,6 @@ def start_test(testid, cur, cn, obsdict_key, obsdict_id): ...@@ -295,7 +293,6 @@ def start_test(testid, cur, cn, obsdict_key, obsdict_id):
imagefile.close() imagefile.close()
logger.debug("Got target image ID %s for observer ID %s with node ID %s from database and wrote it to temp file %s (hash %s)" % (str(tgimage_key), str(obs_id), str(node_id), imagepath, hashlib.sha1(binary).hexdigest())) logger.debug("Got target image ID %s for observer ID %s with node ID %s from database and wrote it to temp file %s (hash %s)" % (str(tgimage_key), str(obs_id), str(node_id), imagepath, hashlib.sha1(binary).hexdigest()))
# Convert image to binary format and, depending on operating system and platform architecture, write the node ID (if specified) to the image:
logger.debug("Found %s target architecture on platform %s for observer ID %s (node ID to be used: %s)." % (arch, platname, str(obs_id), str(node_id))) logger.debug("Found %s target architecture on platform %s for observer ID %s (node ID to be used: %s)." % (arch, platname, str(obs_id), str(node_id)))
# binary patching # binary patching
......
...@@ -137,7 +137,7 @@ def main(argv): ...@@ -137,7 +137,7 @@ def main(argv):
now = time.strftime(flocklab.config.get("database", "timeformat"), time.gmtime()) now = time.strftime(flocklab.config.get("database", "timeformat"), time.gmtime())
# schedule link measurement if needed # schedule link measurement if needed
flocklab.schedule_linktest(cur, cn, debug) #flocklab.schedule_linktest(cur, cn, debug)
# Check for work --- # Check for work ---
# Check if a new test is to be started --- # Check if a new test is to be started ---
......
...@@ -335,15 +335,14 @@ def main(argv): ...@@ -335,15 +335,14 @@ def main(argv):
# If DB image IDs are present, check if they are in the database and belong to the user (if he is not an admin) and get values for later use: # If DB image IDs are present, check if they are in the database and belong to the user (if he is not an admin) and get values for later use:
if dbimageid: if dbimageid:
for dbimg, line in zip(dbimageid, dbimageid_line): for dbimg, line in zip(dbimageid, dbimageid_line):
sql = """ SELECT b.name, c.name, a.core sql = """SELECT b.name, a.core
FROM `tbl_serv_targetimages` AS a FROM `tbl_serv_targetimages` AS a
LEFT JOIN `tbl_serv_operatingsystems` AS b LEFT JOIN `tbl_serv_platforms` AS b
ON a.operatingsystems_fk = b.serv_operatingsystems_key ON a.platforms_fk = b.serv_platforms_key
LEFT JOIN `tbl_serv_platforms` AS c WHERE (a.`serv_targetimages_key` = %s AND a.`binary` IS NOT NULL)
ON a.platforms_fk = c.serv_platforms_key """ % (dbimg)
WHERE (a.`serv_targetimages_key` = %s AND a.`binary` IS NOT NULL)""" %(dbimg)
if "admin" not in userrole: if "admin" not in userrole:
sql += " AND (a.`owner_fk` = %s)"%(userid) sql += " AND (a.`owner_fk` = %s)" % (userid)
cur.execute(sql) cur.execute(sql)
ret = cur.fetchone() ret = cur.fetchone()
if not ret: if not ret:
...@@ -352,16 +351,16 @@ def main(argv): ...@@ -352,16 +351,16 @@ def main(argv):
errcnt = errcnt + 1 errcnt = errcnt + 1
else: else:
# Put data into dictionary for later use: # Put data into dictionary for later use:
core = int(ret[2]) core = int(ret[1])
for obsid in obsids: for obsid in obsids:
if obsid not in obsiddict: if obsid not in obsiddict:
obsiddict[obsid] = {} obsiddict[obsid] = {}
if core in obsiddict[obsid]: if core in obsiddict[obsid]:
if not quiet: if not quiet:
print(("Line %d: element dbImageId: There is already an image for core %d (image with ID %s)." %(line, core, str(dbimg)))) print(("Line %d: element dbImageId: There is already an image for core %d (image with ID %s)." % (line, core, str(dbimg))))
errcnt = errcnt + 1 errcnt = errcnt + 1
else: else:
obsiddict[obsid][core]=ret[:2] obsiddict[obsid][core] = ret[0]
# If embedded image IDs are present, check if they have a corresponding <imageConf> which is valid: # If embedded image IDs are present, check if they have a corresponding <imageConf> which is valid:
if embimageid: if embimageid:
...@@ -373,10 +372,6 @@ def main(argv): ...@@ -373,10 +372,6 @@ def main(argv):
errcnt = errcnt + 1 errcnt = errcnt + 1
else: else:
# Get os and platform and put it into dictionary for later use: # Get os and platform and put it into dictionary for later use:
if imageconf[0].xpath('d:os', namespaces=ns):
opersys = imageconf[0].xpath('d:os', namespaces=ns)[0].text
else:
opersys = 'other'
platform = imageconf[0].xpath('d:platform', namespaces=ns)[0].text platform = imageconf[0].xpath('d:platform', namespaces=ns)[0].text
try: try:
core = int(imageconf[0].xpath('d:core', namespaces=ns)[0].text) core = int(imageconf[0].xpath('d:core', namespaces=ns)[0].text)
...@@ -391,7 +386,7 @@ def main(argv): ...@@ -391,7 +386,7 @@ def main(argv):
if not quiet: if not quiet:
print(("Line %d: element dbImageId: There is already an image for core %d (image with ID %s)." %(line, core, str(embimg)))) print(("Line %d: element dbImageId: There is already an image for core %d (image with ID %s)." %(line, core, str(embimg))))
errcnt = errcnt + 1 errcnt = errcnt + 1
obsiddict[obsid][core]=(opersys, platform) obsiddict[obsid][core] = platform
# Get the image and save it to a temporary file: # Get the image and save it to a temporary file:
image = imageconf[0].xpath('d:data', namespaces=ns)[0].text image = imageconf[0].xpath('d:data', namespaces=ns)[0].text
if "dpp2lora" in platform.lower(): if "dpp2lora" in platform.lower():
...@@ -462,19 +457,13 @@ def main(argv): ...@@ -462,19 +457,13 @@ def main(argv):
""" """
for obsid in usedObsidsList: for obsid in usedObsidsList:
if obsid in obsiddict: if obsid in obsiddict:
platf = next(iter(obsiddict[obsid].values()))[1].lower() platf = next(iter(obsiddict[obsid].values()))[0].lower()
opersys = next(iter(obsiddict[obsid].values()))[0].lower()
for p in obsiddict[obsid].values(): for p in obsiddict[obsid].values():
if platf!=p[1].lower(): if platf!=p[1].lower():
if not quiet: if not quiet:
print(("Element targetConf: Observer ID %s has images of several platform types assigned." %(obsid))) print(("Element targetConf: Observer ID %s has images of several platform types assigned." %(obsid)))
errcnt = errcnt + 1 errcnt = errcnt + 1
break break
#if opersys!=p[0].lower():
# if not quiet:
# print(("Element targetConf: Observer ID %s has images of several operating system types assigned." %(obsid)))
# errcnt = errcnt + 1
# break
else: else:
platf = None platf = None
# Get tg_adapt_types_fk of installed target adaptors on observer: # Get tg_adapt_types_fk of installed target adaptors on observer:
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
DEST=${3:-/tmp/flocklab} # destination directory (if not specified, the default is used: /tmp/flocklab) DEST=${3:-/tmp/flocklab} # destination directory (if not specified, the default is used: /tmp/flocklab)
EXTRACT=1 # extract results? EXTRACT=1 # extract results?
TESTCONFIG=0 # also download XML test config? TESTCONFIG=0 # also download XML test config?
SERVER_URL=https://flocklab.ethz.ch SERVER_URL=https://flocklab.ethz.ch/user
CURL_PARAMS='-sS -4 --insecure' CURL_PARAMS='-sS -4 --insecure'
FLAUTH_FILE=.flocklabauth FLAUTH_FILE=.flocklabauth
NETRC_FILE=$HOME/.netrc NETRC_FILE=$HOME/.netrc
DAV_URL=https://flocklab-dev-server.ethz.ch/webdav DAV_URL=https://flocklab.ethz.ch/user/webdav
DAV_CLIENT=cadaver DAV_CLIENT=cadaver
if [ -f $FLAUTH_FILE ] if [ -f $FLAUTH_FILE ]
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
USER="flocklab" USER="flocklab"
HOST="flocklab-dev-server" HOST="flocklab-dev-server"
RSYNCPARAMS="-a -z -c -K --exclude=.git" RSYNCPARAMS="-a -z -c -K --exclude=.git --no-perms --no-owner --no-group"
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
HOST=$1 HOST=$1
...@@ -23,7 +23,6 @@ else ...@@ -23,7 +23,6 @@ else
rsync ${RSYNCPARAMS} -e 'ssh -q' testmanagementserver/ ${USER}@${HOST}:testmanagementserver rsync ${RSYNCPARAMS} -e 'ssh -q' testmanagementserver/ ${USER}@${HOST}:testmanagementserver
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "Failed to copy files!\n" printf "Failed to copy files!\n"
continue
else else
printf "done.\n" printf "done.\n"
fi fi
...@@ -33,12 +32,10 @@ RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' webserver/ ${USER}@${HOST}:w ...@@ -33,12 +32,10 @@ RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' webserver/ ${USER}@${HOST}:w
if [ -z "$RES" ]; then if [ -z "$RES" ]; then
echo "Webserver files are up to date." echo "Webserver files are up to date."
else else
echo $RES
printf "Updating webserver files..." printf "Updating webserver files..."
rsync ${RSYNCPARAMS} -e 'ssh -q' webserver/ ${USER}@${HOST}:webserver rsync ${RSYNCPARAMS} -e 'ssh -q' webserver/ ${USER}@${HOST}:webserver
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "failed to copy repository files!\n" printf "failed to copy repository files!\n"
continue
else else
printf "done.\n" printf "done.\n"
fi fi
...@@ -48,12 +45,10 @@ RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' tools/ ${USER}@${HOST}:tools ...@@ -48,12 +45,10 @@ RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' tools/ ${USER}@${HOST}:tools
if [ -z "$RES" ]; then if [ -z "$RES" ]; then
echo "Tools are up to date." echo "Tools are up to date."
else else
echo $RES
printf "Updating tools... " printf "Updating tools... "
rsync ${RSYNCPARAMS} -e 'ssh -q' tools/ ${USER}@${HOST}:tools rsync ${RSYNCPARAMS} -e 'ssh -q' tools/ ${USER}@${HOST}:tools
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "Failed to copy files!\n" printf "Failed to copy files!\n"
continue
else else
printf "done.\n" printf "done.\n"
fi fi
......
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
<h1>Manage Images</h1>'; <h1>Manage Images</h1>';
$db = db_connect(); $db = db_connect();
$sql = 'SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_operatingsystems`.`name` as `os_name`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed` $sql = 'SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed`
FROM `tbl_serv_targetimages` FROM `tbl_serv_targetimages`
LEFT JOIN (`tbl_serv_platforms`, `tbl_serv_operatingsystems`) ON (`operatingsystems_fk`=`tbl_serv_operatingsystems`.`serv_operatingsystems_key` AND `platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key`) LEFT JOIN `tbl_serv_platforms` ON `platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key`
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_targetimages_key` = ' .mysqli_real_escape_string($db, $_POST['imageid']); WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_targetimages_key` = ' .mysqli_real_escape_string($db, $_POST['imageid']);
$res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch image information: ' . mysqli_error($db)); $res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch image information: ' . mysqli_error($db));
$row = mysqli_fetch_assoc($res); $row = mysqli_fetch_assoc($res);
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
<tr><td>Name</td><td>'.$row['name'].'</td></tr> <tr><td>Name</td><td>'.$row['name'].'</td></tr>
<tr><td>Description</td><td>'.$row['description'].'</td></tr> <tr><td>Description</td><td>'.$row['description'].'</td></tr>
<tr><td>Platform</td><td>'.$row['platform_name'].'</td></tr> <tr><td>Platform</td><td>'.$row['platform_name'].'</td></tr>
<tr><td>Os</td><td>'.$row['os_name'].'</td></tr>
<tr><td>Date</td><td>'.$row['last_changed'].'</td></tr> <tr><td>Date</td><td>'.$row['last_changed'].'</td></tr>
</table></p> </table></p>
</div><p></p> </div><p></p>
...@@ -76,4 +75,4 @@ ...@@ -76,4 +75,4 @@
<!-- END content --> <!-- END content -->
<?php <?php
do_layout('Manage Images','Manage Images'); do_layout('Manage Images','Manage Images');
?> ?>
\ No newline at end of file
...@@ -13,17 +13,16 @@ ...@@ -13,17 +13,16 @@
<?php <?php
if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($_POST['imageid'],$_SESSION['serv_users_key'])) { if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($_POST['imageid'],$_SESSION['serv_users_key'])) {
$db = db_connect(); $db = db_connect();
$sql = "SELECT `binary`, p.`name` `platform`, o.`name` `operatingsystem` $sql = "SELECT `binary`, p.`name` `platform`
FROM tbl_serv_targetimages i FROM tbl_serv_targetimages i
left join tbl_serv_platforms p on (i.platforms_fk = p.serv_platforms_key) left join tbl_serv_platforms p on (i.platforms_fk = p.serv_platforms_key)
left join tbl_serv_operatingsystems o on (i.operatingsystems_fk = o.serv_operatingsystems_key)
WHERE ".($_SESSION['is_admin']?"":("owner_fk = " . $_SESSION['serv_users_key'] . " AND "))."`serv_targetimages_key`=".mysqli_real_escape_string($db, $_POST['imageid']); WHERE ".($_SESSION['is_admin']?"":("owner_fk = " . $_SESSION['serv_users_key'] . " AND "))."`serv_targetimages_key`=".mysqli_real_escape_string($db, $_POST['imageid']);
$res = mysqli_query($db, $sql); $res = mysqli_query($db, $sql);
if ($res !== false) { if ($res !== false) {
$row = mysqli_fetch_assoc($res); $row = mysqli_fetch_assoc($res);
// Send the file to the user's browser: // Send the file to the user's browser:
header("Content-Type: binary/octet-stream"); header("Content-Type: binary/octet-stream");
header("Content-Disposition: attachment; filename=\"". $_POST['imageid'] .".".$row['platform'].".".$row['operatingsystem'].".exe\""); header("Content-Disposition: attachment; filename=\"". $_POST['imageid'] .".".$row['platform'].".exe\"");
echo $row['binary']; echo $row['binary'];
} }
else { else {
...@@ -32,4 +31,4 @@ if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($ ...@@ -32,4 +31,4 @@ if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($
} }
else else
header("HTTP/1.0 400 Bad Request"); header("HTTP/1.0 400 Bad Request");
?> ?>
\ No newline at end of file
...@@ -50,10 +50,9 @@ ...@@ -50,10 +50,9 @@
while ($row = mysqli_fetch_assoc($rs)) while ($row = mysqli_fetch_assoc($rs))
array_push($multicore, $row['name']); array_push($multicore, $row['name']);
/* Get all test images of the current user from the database and display them in the table. */ /* Get all test images of the current user from the database and display them in the table. */
$sql = "SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_architectures`.`description` as `core_desc`, `tbl_serv_operatingsystems`.`name` as `os_name`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed`, `test_fk`, `tbl_serv_tests`.`test_status` $sql = "SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_architectures`.`description` as `core_desc`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed`, `test_fk`, `tbl_serv_tests`.`test_status`
FROM `tbl_serv_targetimages` FROM `tbl_serv_targetimages`
LEFT JOIN (`tbl_serv_platforms`, `tbl_serv_operatingsystems`) LEFT JOIN `tbl_serv_platforms` ON `platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key`
ON (`operatingsystems_fk`=`tbl_serv_operatingsystems`.`serv_operatingsystems_key` AND `platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key`)
LEFT JOIN `tbl_serv_architectures` LEFT JOIN `tbl_serv_architectures`
ON (`tbl_serv_architectures`.`platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key` AND `tbl_serv_architectures`.`core` = `tbl_serv_targetimages`.`core`) ON (`tbl_serv_architectures`.`platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key` AND `tbl_serv_architectures`.`core` = `tbl_serv_targetimages`.`core`)
LEFT JOIN `tbl_serv_map_test_observer_targetimages` LEFT JOIN `tbl_serv_map_test_observer_targetimages`
......
...@@ -29,7 +29,6 @@ function db_connect() ...@@ -29,7 +29,6 @@ function db_connect()
mysqli_query($dbh, $sql) or flocklab_die('Cannot init timezone for database connection because: ' . mysqli_error($dbh)); mysqli_query($dbh, $sql) or flocklab_die('Cannot init timezone for database connection because: ' . mysqli_error($dbh));
$sql='SET sql_mode=""'; $sql='SET sql_mode=""';
mysqli_query($dbh, $sql) or flocklab_die('Cannot set sql mode for database connection because: ' . mysqli_error($dbh)); mysqli_query($dbh, $sql) or flocklab_die('Cannot set sql mode for database connection because: ' . mysqli_error($dbh));
mysqli_set_charset($dbh, "utf8");
return($dbh); return($dbh);
} }
...@@ -280,31 +279,6 @@ function get_available_platforms() { ...@@ -280,31 +279,6 @@ function get_available_platforms() {
return $available_platforms; return $available_platforms;
} }
/*
##############################################################################
#
# get_available_os
#
# from the database
#
##############################################################################
*/
function get_available_os() {
$db = db_connect();
$sql = 'SELECT `serv_operatingsystems_key`, `name`
FROM `tbl_serv_operatingsystems`
ORDER BY `name` ASC';
$res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch available os because: ' . mysqli_error($db));
$num = mysqli_num_rows($res);
$available_os = Array();
while ($num-- > 0) {
$row = mysqli_fetch_assoc($res);
$available_os[$row['serv_operatingsystems_key']]=$row['name'];
}
mysqli_close($db);
return $available_os;
}
function get_testconfig($testid) { function get_testconfig($testid) {
$db = db_connect(); $db = db_connect();
$sql = "SELECT `testconfig_xml` $sql = "SELECT `testconfig_xml`
...@@ -432,16 +406,12 @@ function check_image_duplicate($image) { ...@@ -432,16 +406,12 @@ function check_image_duplicate($image) {
function store_image($image) { function store_image($image) {
$id = null; $id = null;
$hash = hash('sha1', $image['data']); $hash = hash('sha1', $image['data']);
if (!array_key_exists('os', $image) || $image['os'] == "") {
$image['os'] = 1; # 1 = 'other'
}
$db = db_connect(); $db = db_connect();
$sql = 'INSERT INTO `tbl_serv_targetimages` (`name`,`description`,`owner_fk`,`operatingsystems_fk`,`platforms_fk`,`core`,`binary`,`binary_hash_sha1`) $sql = 'INSERT INTO `tbl_serv_targetimages` (`name`,`description`,`owner_fk`,`platforms_fk`,`core`,`binary`,`binary_hash_sha1`)
VALUES ( VALUES (
"'.mysqli_real_escape_string($db, trim($image['name'])).'", "'.mysqli_real_escape_string($db, trim($image['name'])).'",
"'.mysqli_real_escape_string($db, trim($image['description'])).'", "'.mysqli_real_escape_string($db, trim($image['description'])).'",
'.$_SESSION['serv_users_key'].', '.$_SESSION['serv_users_key'].',
'.mysqli_real_escape_string($db, $image['os']).',
'.mysqli_real_escape_string($db, $image['platform']).', '.mysqli_real_escape_string($db, $image['platform']).',
'.mysqli_real_escape_string($db, $image['core']).', '.mysqli_real_escape_string($db, $image['core']).',
"'.mysqli_real_escape_string($db, $image['data']).'", "'.mysqli_real_escape_string($db, $image['data']).'",
...@@ -1085,7 +1055,6 @@ function update_add_test($xml_config, &$errors, $existing_test_id = NULL, $abort ...@@ -1085,7 +1055,6 @@ function update_add_test($xml_config, &$errors, $existing_test_id = NULL, $abort
$used_dbImages = Array(); $used_dbImages = Array();
$embeddedImages = Array(); $embeddedImages = Array();
$dbImages = Array(); $dbImages = Array();
$available_os = get_available_os();
$available_platforms = get_available_platforms(); $available_platforms = get_available_platforms();
$targetnodes = Array(); $targetnodes = Array();
foreach($testconfig->targetConf as $tc) { foreach($testconfig->targetConf as $tc) {
...@@ -1123,15 +1092,6 @@ function update_add_test($xml_config, &$errors, $existing_test_id = NULL, $abort ...@@ -1123,15 +1092,6 @@ function update_add_test($xml_config, &$errors, $existing_test_id = NULL, $abort
foreach($available_platforms as $key => $platform) foreach($available_platforms as $key => $platform)
if (strcasecmp($platform[0]['name'], trim($im->platform)) == 0) if (strcasecmp($platform[0]['name'], trim($im->platform)) == 0)
$im_cpy['platform'] = $key; $im_cpy['platform'] = $key;
if(!isset($im->os) || !in_array($im->os, $available_os)) {
$im_os = 'other';
}
foreach($available_os as $key => $os) {
if (strcasecmp($os, $im_os) == 0) {
$im_cpy['os'] = $key;
break;
}
}
$im_cpy['core'] = isset($im->core) ? $im->core : 0; $im_cpy['core'] = isset($im->core) ? $im->core : 0;
$embeddedImages[$eId] = $im_cpy; $embeddedImages[$eId] = $im_cpy;
} }
......
<?php
echo "
<html>
<body style='font-family: arial,helvetica'>
<center>
<br />
<br />
<br />
<img src='pics/flocklab_eth_logo.png' border='0px' /><br />
<br />
<br />
<h3>FlockLab is temporarily unavailable. We are currently updating our testbed to a new version, FlockLab 2!</h3>
The current FlockLab observers will be removed and replaced by new FlockLab 2 observers!<br />
<!--The new observers come with a built-in <a href='http://rocketlogger.ethz.ch/' target='new' style='color:#28549f'>RocketLogger</a> and <a href='https://www.segger.com/products/debug-probes/j-link/' target='new' style='color:#28549f'>J-Link debugger</a>.<br />-->
Initially, the new testbed will consist of 10 observers, but we plan to increase the numbers in the near future.<br />
FlockLab 2 is expected to be online in a few days (with limited functionality).<br />
<br />
If you have any questions or concerns, feel free to <a href='mailto:flocklab@tik.ee.ethz.ch' style='color:#28549f'>contact us</a>.<br />
<br />
</center>
</body>
</html>
";
?>
...@@ -242,12 +242,11 @@ class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server ...@@ -242,12 +242,11 @@ class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server
$db = db_connect(); $db = db_connect();
$sql = "SELECT serv_tests_key, `targetimage_fk`, UNIX_TIMESTAMP(tbl_serv_targetimages.last_changed) as image_last_changed, $sql = "SELECT serv_tests_key, `targetimage_fk`, UNIX_TIMESTAMP(tbl_serv_targetimages.last_changed) as image_last_changed,
UNIX_TIMESTAMP(tbl_serv_tests.last_changed) as last_changed, UNIX_TIMESTAMP(tbl_serv_tests.last_changed) as last_changed,
length(`binary`) as imagesize, tbl_serv_operatingsystems.name as os, tbl_serv_platforms.name as platform length(`binary`) as imagesize, tbl_serv_platforms.name as platform
FROM tbl_serv_tests FROM tbl_serv_tests
LEFT JOIN tbl_serv_map_test_observer_targetimages ON (serv_tests_key = test_fk) LEFT JOIN tbl_serv_map_test_observer_targetimages ON (serv_tests_key = test_fk)
LEFT JOIN tbl_serv_targetimages ON (serv_targetimages_key = `targetimage_fk`) LEFT JOIN tbl_serv_targetimages ON (serv_targetimages_key = `targetimage_fk`)
LEFT JOIN tbl_serv_platforms ON (serv_platforms_key = `platforms_fk`) LEFT JOIN tbl_serv_platforms ON (serv_platforms_key = `platforms_fk`)
LEFT JOIN tbl_serv_operatingsystems ON (serv_operatingsystems_key= `operatingsystems_fk`)
WHERE tbl_serv_tests.".$owner_query."serv_tests_key = ".mysqli_real_escape_string($db, $matches[1])." AND test_status <> 'deleted' AND test_status <> 'todelete' WHERE tbl_serv_tests.".$owner_query."serv_tests_key = ".mysqli_real_escape_string($db, $matches[1])." AND test_status <> 'deleted' AND test_status <> 'todelete'
GROUP BY `targetimage_fk`"; GROUP BY `targetimage_fk`";
$rs = mysqli_query($db, $sql) or flog('Cannot get tests from database because: ' . mysqli_error($db)); $rs = mysqli_query($db, $sql) or flog('Cannot get tests from database because: ' . mysqli_error($db));
...@@ -261,7 +260,7 @@ class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server ...@@ -261,7 +260,7 @@ class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server
mysqli_data_seek($rs,0); mysqli_data_seek($rs,0);