diff --git a/tbsetup/GNUmakefile.in b/tbsetup/GNUmakefile.in index f4a8dc1235e738fcc5b6391924b39be1a0a08476..d4ee6d7b7f1440083301958179deb4396eb53d93 100644 --- a/tbsetup/GNUmakefile.in +++ b/tbsetup/GNUmakefile.in @@ -33,7 +33,7 @@ LIBEXEC_STUFF = rmproj rmacct-ctrl wanlinksolve wanlinkinfo \ webrmgroup webswapexp webnodecontrol \ webmkgroup webmkacct websetgroups webmkproj \ spewlogfile staticroutes routecalc wanassign \ - webidlecheck + webidlecheck webnodereboot LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \ snmpit_cisco.pm snmpit_lib.pm snmpit_apc.pm power_rpc27.pm \ diff --git a/www/boot.php3 b/www/boot.php3 new file mode 100644 index 0000000000000000000000000000000000000000..bcdb240977e12d15dcfad46926eb961cb05e31ef --- /dev/null +++ b/www/boot.php3 @@ -0,0 +1,148 @@ +<?php +include("defs.php3"); +include("showstuff.php3"); + +# +# No PAGEHEADER since we spit out a Location header later. See below. +# + +# +# Only known and logged in users can do this. +# +$uid = GETLOGIN(); +LOGGEDINORDIE($uid); + +# +# Check to make sure a valid nodeid, *or* a valid experiment. +# +if (isset($pid) && strcmp($pid, "") && + isset($eid) && strcmp($eid, "")) { + if (! TBValidExperiment($pid, $eid)) { + USERERROR("$pid/$eid is not a valid experiment!", 1); + } + + if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_MODIFY)) { + USERERROR("You do not have permission to reboot nodes in ". + "experiment $exp_eid!", 1); + } + $nodemode = 0; +} +elseif (isset($node_id) && strcmp($node_id, "")) { + if (! TBValidNodeName($node_id)) { + USERERROR("$node_id is not a valid node name!", 1); + } + + if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_REBOOT)) { + USERERROR("You do not have permission to reboot $node_id!", 1); + } + $nodemode = 1; +} +else { + USERERROR("Must specify a node or an experiment!", 1); +} + +# +# 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. +# +if ($canceled) { + PAGEHEADER("Reboot Nodes"); + + echo "<center><h3><br> + Operation canceled! + </h3></center>\n"; + + PAGEFOOTER(); + return; +} + +if (!$confirmed) { + PAGEHEADER("Reboot Nodes"); + + if ($nodemode) { + echo "<center><h2><br> + Are you <b>REALLY</b> + sure you want to reboot node '$node_id?' + </h2>\n"; + + SHOWNODE($node_id); + } + else { + echo "<center><h2><br> + Are you <b>REALLY</b> + sure you want to reboot all nodes in experiment $pid/$eid? + </h2>\n"; + + SHOWEXP($pid, $eid); + } + + + echo "<form action=boot.php3 target=_blank method=post>"; + if ($nodemode) { + echo "<input type=hidden name=node_id value=$node_id>\n"; + } + else { + echo "<input type=hidden name=pid value=$pid>\n"; + echo "<input type=hidden name=eid value=$eid>\n"; + } + echo "<b><input type=submit name=confirmed value=Confirm></b>\n"; + echo "<b><input type=submit name=canceled value=Cancel></b>\n"; + echo "</form>\n"; + echo "</center>\n"; + + PAGEFOOTER(); + return; +} + +# +# Pass it off to the script. +# +$retval = 0; +header("Content-Type: text/plain"); +ignore_user_abort(1); + +if ($nodemode) { + $result = system("$TBSUEXEC_PATH $uid nobody webnodereboot $node_id", + $retval); +} +else { + $result = system("$TBSUEXEC_PATH $uid nobody webnodereboot -e $pid,$eid", + $retval); +} + +if ($retval) { + USERERROR("Reboot failed!", 1); +} + +# +# And send an audit message. +# +TBUserInfo($uid, $uid_name, $uid_email); + +if ($nodemode) { + $message = "$node_id was rebooted via the web interface by $uid\n"; + $subject = "Node Reboot: $node_id"; +} +else { + $message = "Nodes in $pid/$eid were rebooted via the web interface ". + "by $uid\n"; + $subject = "Nodes Rebooted: $pid/eid"; +} + +TBMAIL($TBMAIL_AUDIT, + $subject, $message, + "From: $uid_name <$uid_email>\n". + "Errors-To: $TBMAIL_WWW"); + +# +# Spit out a redirect so that the history does not include a post +# in it. +# +#if ($nodemode) +# header("Location: shownode.php3?node_id=$node_id"); +#else +# header("Location: showexp.php3?exp_pid=$pid&exp_eid=$eid"); + +?> diff --git a/www/showexp.php3 b/www/showexp.php3 index 563fa8427a344b14b53c0471319b8dfd136cc553..d4a9217b35b731caea4ed9992fd568c6b3be3575 100644 --- a/www/showexp.php3 +++ b/www/showexp.php3 @@ -48,7 +48,7 @@ SUBPAGESTART(); SUBMENUSTART("Experiment Options"); if ($expstate) { - if (strcmp($expstate, $TB_EXPTSTATE_ACTIVATING)==0) { + if (TBExptLogFile($exp_pid, $exp_eid)) { WRITESUBMENUBUTTON("View Activation Logfile", "spewlogfile.php3?pid=$exp_pid&eid=$exp_eid"); } @@ -88,6 +88,12 @@ if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATEACCOUNTS)) { "updateaccounts.php3?pid=$exp_pid&eid=$exp_eid"); } +# Reboot option +if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) { + WRITESUBMENUBUTTON("Reboot all Nodes", + "boot.php3?pid=$exp_pid&eid=$exp_eid"); +} + # # Admin folks get a swap request link to send email. # @@ -109,17 +115,6 @@ SUBPAGEEND(); # SHOWNODES($exp_pid, $exp_eid); -if ($expstate && - (strcmp($expstate, $TB_EXPTSTATE_SWAPPING) == 0 || - strcmp($expstate, $TB_EXPTSTATE_ACTIVATING) == 0)) { - - echo "<script language=\"JavaScript\"> - <!-- - doLoad(30000); - //--> - </script>\n"; -} - # # Standard Testbed Footer # diff --git a/www/shownode.php3 b/www/shownode.php3 index d04dc37a65dd32c8b937d744b382ef6cda8a933c..a66f90648bf814b7df4771c6eeb61d443612abed 100644 --- a/www/shownode.php3 +++ b/www/shownode.php3 @@ -25,10 +25,8 @@ if (!isset($node_id) || # # Check to make sure that this is a valid nodeid # -$query_result = - DBQueryFatal("SELECT node_id FROM nodes WHERE node_id='$node_id'"); -if (mysql_num_rows($query_result) == 0) { - USERERROR("The node $node_id is not a valid nodeid!", 1); +if (! TBValidNodeName($node_id)) { + USERERROR("$node_id is not a valid node name!", 1); } # @@ -50,6 +48,11 @@ SUBMENUSTART("Node Options"); WRITESUBMENUBUTTON("Edit node info", "nodecontrol_form.php3?node_id=$node_id"); +if (TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_REBOOT)) { + WRITESUBMENUBUTTON("Reboot Node", + "boot.php3?node_id=$node_id"); +} + if ($isadmin) { WRITESUBMENUBUTTON("Access Node Log", "shownodelog.php3?node_id=$node_id");