Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
caef91e3
Commit
caef91e3
authored
Dec 20, 2002
by
Leigh B. Stoller
Browse files
Add a couple of consistency checks before allowing osids and imageids
to be deleted.
parent
30e13688
Changes
2
Hide whitespace changes
Inline
Side-by-side
www/deleteimageid.php3
View file @
caef91e3
...
...
@@ -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
...
...
www/deleteosid.php3
View file @
caef91e3
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment