Commit f8de754a authored by Leigh Stoller's avatar Leigh Stoller

Add web interface to template delete operation. Must be reddot, and it

appears as a box on the show template page, with a mandatory confirm
checkbox right next to it.
parent 5e1a0a3d
......@@ -59,7 +59,8 @@ LIBEXEC_STUFF = rmproj wanlinksolve wanlinkinfo \
webtemplate_swapin webtemplate_swapout webtemplate_exprun \
webtemplate_graph webtemplate_metadata webtemplate_export \
webtemplate_control webtemplate_commit webtemplate_analyze \
webtemplate_linkgraph webtemplate_instantiate
webtemplate_linkgraph webtemplate_instantiate \
webtemplate_delete
LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_cisco.pm snmpit_lib.pm snmpit_apc.pm power_rpc27.pm \
......
......@@ -76,6 +76,7 @@ use libdb;
use libtestbed;
use libtblog;
use Template;
use libaudit;
# Be careful not to exit on transient error
$libdb::DBQUERY_MAXTRIES = 0;
......@@ -186,6 +187,9 @@ foreach my $template (@templates) {
exit(1)
if ($active);
# Use the logonly option to audit so that we get a record mailed.
LogStart(0);
#
# Okay, do the deletions.
#
......@@ -212,6 +216,8 @@ foreach my $template (@templates) {
}
# And finally the template record.
print "Deleting template $template ...\n";
$template->Delete() == 0
or tbdie("Could not delete template $template");
}
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# This gets invoked from the Web interface. Simply a wrapper ...
#
#
# Configure variables
#
my $TB = "@prefix@";
#
# Run the real thing, and never return.
#
exec "$TB/bin/template_delete", @ARGV;
die("webtemplate_delete: Could not exec template_delete: $!");
......@@ -76,7 +76,7 @@ CheckArguments($guid, $version);
function Show($which, $zoom, $detail)
{
global $pid, $eid, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
global $template;
global $template, $isadmin;
$html = "";
if ($which == "vis") {
......@@ -155,6 +155,16 @@ function Show($which, $zoom, $detail)
$html .= " onclick=\"GraphChange('zoomout');\">Zoom Out</button>\n";
$html .= "<button name=zoomin type=button value=in";
$html .= " onclick=\"GraphChange('zoomin');\">Zoom In</button>\n";
# A delete button with a confirm box right there.
if ($isadmin) {
$html .= "<br><br>\n";
$html .= "<button name=deletetemplate type=button value=Delete";
$html .= " onclick=\"DeleteTemplate();\">";
$html .= "<font color=red>Delete</font></button>&nbsp";
$html .= "<input id=confirm_delete type=checkbox value=Yep> ";
$html .= "Confirm";
}
}
elseif ($which == "nsfile") {
$nsdata = "";
......@@ -261,6 +271,49 @@ if (isset($action) && ($action == "activate" || $action == "inactivate")) {
GraphChange($action, 0, 1);
}
# Delete is just plain special!
if (isset($action) && $action == "deletetemplate" &&
isset($confirmed) && $confirmed == "yep") {
# Need this for scripts.
TBGroupUnixInfo($pid, $gid, $unix_gid, $unix_name);
PAGEHEADER("Delete Template: $guid/$version");
STARTBUSY("Deleting template $guid/$version recurively");
# Pass recursive option all the time.
$retval = SUEXEC($uid, "$pid,$unix_gid",
"webtemplate_delete -r $guid/$version",
SUEXEC_ACTION_IGNORE);
CLEARBUSY();
#
# Fatal Error. Report to the user, even though there is not much he can
# do with the error. Also reports to tbops.
#
if ($retval < 0) {
SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
# User error. Tell user and exit.
if ($retval) {
SUEXECERROR(SUEXEC_ACTION_USERERROR);
PAGEFOOTER();
return;
}
#
# Okay, lets zap back to the root, unless this was the root.
#
if ($template->IsRoot()) {
PAGEREPLACE("showuser.php3?target_uid=$uid");
}
else {
PAGEREPLACE("template_show.php?guid=$guid&version=1");
}
return;
}
#
# Standard Testbed Header after argument checking.
#
......@@ -358,6 +411,20 @@ echo "<script type='text/javascript' language='javascript'>
x_Show('vis', zoom, detail, Show_cb);
return false;
}
function DeleteTemplate() {
confirm_flag = 0;
confirm_box = getObjbyName('confirm_delete');
if (confirm_box) {
confirm_flag = ((confirm_box.checked == true) ? 1 : 0);
}
if (confirm_flag == 0) {
return false;
}
window.location.replace('template_show.php?guid=$guid" .
"&version=$version&action=deletetemplate&confirmed=yep');
return false;
}
function GraphChange(action) {
recursive_flag = 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