To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 69e7b068 authored by Reto Da Forno's avatar Reto Da Forno

shell tool updated

parent cab21cf4
......@@ -19,16 +19,16 @@
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_types` AS slot4 ON d.tg_adapt_types_fk = slot4.serv_tg_adapt_types_key
WHERE obs.status='online'
ORDER BY obs.observer_id;";
$res = mysql_query($sql);
$res = mysqli_query($db, $sql);
if (!$res) {
echo json_encode(array('status' => 'error', 'output' => mysql_error()));
echo json_encode(array('status' => 'error', 'output' => mysqli_error($db)));
}
else {
if (isset($_POST['platform'])) {
$platform = mysql_real_escape_string($_POST['platform']);
$platform = mysqli_real_escape_string($db, $_POST['platform']);
}
$output = "";
while ($row = mysql_fetch_assoc($res)) {
while ($row = mysqli_fetch_assoc($res)) {
if ($platform == "" || !strcasecmp($platform, $row['name1']) || !strcasecmp($platform, $row['name2']) || !strcasecmp($platform, $row['name3']) || !strcasecmp($platform, $row['name4'])) {
$output .= $row['observer_id']." ";
}
......@@ -36,6 +36,38 @@
echo json_encode(array('status' => 'ok', 'output' => trim($output)));
}
}
else if ($_POST['q'] == 'platform') {
$db = db_connect();
$sql = "SELECT obs.observer_id, slot1.name AS name1, slot1.description AS desc1,
slot2.name AS name2, slot2.description AS desc2,
slot3.name AS name3, slot3.description AS desc3,
slot4.name AS name4, slot4.description AS desc4
FROM `flocklab`.`tbl_serv_observer` AS obs
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_list` AS a ON obs.slot_1_tg_adapt_list_fk = a.serv_tg_adapt_list_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_types` AS slot1 ON a.tg_adapt_types_fk = slot1.serv_tg_adapt_types_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_list` AS b ON obs.slot_2_tg_adapt_list_fk = b.serv_tg_adapt_list_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_types` AS slot2 ON b.tg_adapt_types_fk = slot2.serv_tg_adapt_types_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_list` AS c ON obs.slot_3_tg_adapt_list_fk = c.serv_tg_adapt_list_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_types` AS slot3 ON c.tg_adapt_types_fk = slot3.serv_tg_adapt_types_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_list` AS d ON obs.slot_4_tg_adapt_list_fk = d.serv_tg_adapt_list_key
LEFT JOIN `flocklab`.`tbl_serv_tg_adapt_types` AS slot4 ON d.tg_adapt_types_fk = slot4.serv_tg_adapt_types_key
WHERE obs.status='online'
ORDER BY obs.observer_id;";
$res = mysqli_query($db, $sql);
if (!$res) {
echo json_encode(array('status' => 'error', 'output' => mysqli_error($db)));
}
else {
$output = [];
while ($row = mysqli_fetch_assoc($res)) {
$output[] = $row['name1'];
$output[] = $row['name2'];
$output[] = $row['name3'];
$output[] = $row['name4'];
}
echo json_encode(array('status' => 'ok', 'output' => join(" ", array_unique(array_filter($output)))));
}
}
else {
echo json_encode(array('status' => 'error', 'output' => 'unknown query'));
}
......
......@@ -13,6 +13,7 @@
# -g <testid>: get via https
# -f <testid>: fetch via webdav
# -o <platform>: get a list of the currently available (online) observers
# -p: get a list of the available platforms
# -h: display help
#
# Your FlockLab login credentials need to be stored in .flocklabauth in your home directory as follows:
......@@ -66,7 +67,8 @@ OPTIONS:
-d <testid>: delete test
-g <testid>: get test results (via https)
-f <testid>: fetch test results (via webdav)
-o <platform>: get the list of currently available observers
-o <platform>: get a list of currently available observers
-p: get a list of available platforms
EOF
}
......@@ -136,7 +138,7 @@ then
exit 1
fi
while getopts “v:c:a:d:f:g:o:h” OPTION
while getopts “v:c:a:d:f:g:o:ph” OPTION
do
case $OPTION in
v)
......@@ -280,6 +282,13 @@ do
echo $RESPONSE
fi
;;
p)
RESPONSE=`curl $CURL_PARAMS -o - -F username="$USER" -F password="$PASSWORD" -F q="platform" $SERVER_URL/api.php`
if [ $? -eq 0 ]
then
echo $RESPONSE
fi
;;
h)
usage
exit 0
......
Markdown is supported
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