deleteimageid.php3 3.91 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include("imageid_defs.php");
26 27 28 29

#
# Only known and logged in users can end experiments.
#
30 31 32
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
33 34

#
35 36
# Verify page arguments.
#
37 38 39 40
$reqargs = RequiredPageArguments("image",     PAGEARG_IMAGE);
$optargs = OptionalPageArguments("canceled",  PAGEARG_BOOLEAN,
				 "confirmed", PAGEARG_BOOLEAN,
				 "purgefile", PAGEARG_BOOLEAN);
41

42 43 44 45
# Need these below
$imageid = $image->imageid();
$imagename = $image->imagename();
$pid = $image->pid();
46 47
$project = $image->Project();
$unix_pgid = $project->unix_gid();
48 49 50 51

#
# Verify permission.
#
52
if (! $image->AccessCheck($this_user, $TB_IMAGEID_DESTROY)) {
53 54 55
    USERERROR("You do not have permission to destroy ImageID $imageid!", 1);
}

56 57 58 59 60
#
# Standard Testbed Header
#
PAGEHEADER("Delete an Image Descriptor");

61 62 63
#
# Check to see if the imageid is being used in various places
#
64 65 66
if ($image->InUse()) {
    USERERROR("Image $imageid is still in use or busy!<br>".
	      "You must resolve these issues before is can be deleted!", 1);
67 68
}

69 70 71 72 73 74
#
# 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
# set. Or, the user can hit the cancel button, in which case we should
# probably redirect the browser back up a level.
#
75
if (isset($canceled) && $canceled) {
76
    echo "<center><h2><br>
Leigh Stoller's avatar
Leigh Stoller committed
77
          Image Descriptor removal canceled!
78 79 80 81 82 83
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

84
if (!isset($confirmed)) {
85
    echo "<center><h3><br>
86
          Are you <b>REALLY</b>
87
          sure you want to delete Image '$imagename' in project $pid?
88
          </h3>\n";
89 90

    $url = CreateURL("deleteimageid", $image);
91
    
92
    echo "<form action='$url' method=post>";
93 94
    echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
    echo "<b><input type=submit name=canceled value=Cancel></b>\n";
95 96 97 98
    echo "<br><br>\n";
    echo "<input type=checkbox checked name=purgefile value=yes><br>";
    echo "Uncheck this box if you want your image file preserved.<br> ";
    echo "Typically, you want to leave the box checked.";
99 100 101
    echo "</form>\n";
    echo "</center>\n";

102 103 104 105 106 107 108 109 110
    echo "<br>
          <ul>
           <li> Please note that if you have any experiments (swapped in
                <b>or</b> out) using an OS in this image, that experiment
                cannot be swapped in or out properly. You should terminate
                those experiments first, or cancel the deletion of this
                image by clicking on the cancel button above.
          </ul>\n";
    
111 112 113
    PAGEFOOTER();
    return;
}
114 115 116 117 118 119
if (isset($purgefile) && $purgefile) {
    $purgeopt = "-p";
}
else {
    $purgeopt = "";
}
120

121
#
122
# Invoke the backend script.
123
#
124
STARTBUSY("Deleting Image Descriptor ");
125

126
$retval = SUEXEC($uid, $unix_pgid,
127
		 "webdelete_image -F $purgeopt $imageid", SUEXEC_ACTION_DIE);
128

129 130
STOPBUSY();

131
echo "<center>
132
      <h3>
133 134
      Image '$imagename' in project $pid has been deleted!\n
      </h3>\n";
135 136

echo "<br>
137 138 139
      <a href='showimageid_list.php3'>Back to Image Descriptor list</a>
      </center>
      <br><br>\n";
140 141 142 143 144 145

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>