Commit caef91e3 authored by Leigh Stoller's avatar Leigh Stoller

Add a couple of consistency checks before allowing osids and imageids

to be deleted.
parent 30e13688
......@@ -43,6 +43,35 @@ if (!TBImageInfo($imageid, $imagename, $pid)) {
USERERROR("ImageID '$imageid' is no longer a valid ImageID!", 1);
}
#
# Check to see if the imageid is being used in various places
#
$query_result1 =
DBQueryFatal("select * from current_reloads where image_id='$imageid'");
$query_result2 =
DBQueryFatal("select * from scheduled_reloads where image_id='$imageid'");
$query_result3 =
DBQueryFatal("select * from node_types where imageid='$imageid'");
if (mysql_num_rows($query_result1)) {
echo "$imageid is referenced in the current_reloads table!<br>";
$conflicts++;
}
if (mysql_num_rows($query_result2)) {
echo "$imageid is referenced in the scheduled_reloads table!<br>";
$conflicts++;
}
if (mysql_num_rows($query_result3)) {
echo "$imageid is referenced in the node_types table!<br>";
$conflicts++;
}
if ($conflicts) {
echo "<br>
You must resolve these issues before the imageid can be deleted!";
PAGEFOOTER();
return;
}
#
# We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be
......
......@@ -43,6 +43,8 @@ if (!TBOSInfo($osid, $osname, $pid)) {
USERERROR("OS Descriptor '$osid' is no longer valid!", 1);
}
$conflicts = 0;
#
# Check to see if the OSID is being used. Force whatever images are using
# it to be deleted or changed. This subsumes EZ created images/osids.
......@@ -77,7 +79,42 @@ if (mysql_num_rows($query_result)) {
</tr>\n";
}
echo "</table>\n";
$conflicts++;
}
# Ditto for node_types table.
$query_result =
DBQueryFatal("select class,type from node_types ".
"where osid='$osid' or delay_osid='$osid'");
if (mysql_num_rows($query_result)) {
echo "<br> <center>
The following node_types are using this OS Descriptor<br>
in the osid and/or delay_osid fields.<br>
They must be deleted first!
</center><br>\n";
echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";
echo "<tr>
<td align=center>Class</td>
<td align=center>Type</td>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$class = $row['class'];
$type = $row['type'];
echo "<tr>
<td>$class</td>
<td>$type</td>
</tr>\n";
}
echo "</table>\n";
$conflicts++;
}
if ($conflicts) {
PAGEFOOTER();
return;
}
......
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