shownode.php3 5 KB
Newer Older
Leigh Stoller's avatar
Leigh Stoller committed
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2017 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
#
Leigh Stoller's avatar
Leigh Stoller committed
24
include("defs.php3");
25
include_once("node_defs.php");
26
include_once("imageid_defs.php");
Leigh Stoller's avatar
Leigh Stoller committed
27 28 29 30

#
# Only known and logged in users can do this.
#
31 32 33
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
Leigh Stoller's avatar
Leigh Stoller committed
34 35

#
36
# Verify page arguments.
Leigh Stoller's avatar
Leigh Stoller committed
37
#
38 39 40 41
$reqargs = RequiredPageArguments("node", PAGEARG_NODE);

# Need these below
$node_id = $node->node_id();
Leigh Stoller's avatar
Leigh Stoller committed
42

43 44 45 46
#
# Standard Testbed Header
#
PAGEHEADER("Node $node_id");
47

Leigh Stoller's avatar
Leigh Stoller committed
48 49 50 51
#
# Admin users can look at any node, but normal users can only control
# nodes in their own experiments.
#
52
if (! $isadmin &&
53
    ! $node->AccessCheck($this_user, $TB_NODEACCESS_MODIFYINFO)) {
54

55 56 57 58 59
    $power_id = "";
    $query_result = DBQueryFatal("select power_id from outlets ".
				 "where node_id='$node_id'");
    if (mysql_num_rows($query_result) > 0) {
	$row = mysql_fetch_array($query_result);
60
	$power_id = $row["power_id"];
61 62
    }
    if (STUDLY() && ($power_id == "mail")) {
63 64 65 66 67
	    SUBPAGESTART();
	    SUBMENUSTART("Node Options");
	    WRITESUBMENUBUTTON("Update Power State",
			       "powertime.php3?node_id=$node_id");
	    SUBMENUEND();
68
	    $node->Show(SHOWNODE_NOPERM);
69 70 71
	    SUBPAGEEND();
    }
    else {
72
	    $node->Show(SHOWNODE_NOPERM);
73
    }
74 75
    PAGEFOOTER();
    return;
Leigh Stoller's avatar
Leigh Stoller committed
76 77
}

78 79 80 81 82
# If reserved, more menu options.
if (($experiment = $node->Reservation())) {
    $pid   = $experiment->pid();
    $eid   = $experiment->eid();
    $vname = $node->VirtName();
83
}
84

85 86
SUBPAGESTART();
SUBMENUSTART("Node Options");
Leigh Stoller's avatar
Leigh Stoller committed
87

Chad Barb's avatar
Chad Barb committed
88 89 90
#
# Tip to node option
#
91
if ($node->HasSerialConsole()) {
Chad Barb's avatar
Chad Barb committed
92
    WRITESUBMENUBUTTON("Connect to Serial Line</a> " . 
93
	"<a href=\"faq.php3#tiptunnel\">(howto)",
Chad Barb's avatar
Chad Barb committed
94
	"nodetipacl.php3?node_id=$node_id");
95

96
    WRITESUBMENUBUTTON("Report a Problem" ,
97 98
		       "reportnode.php3?node_id=$node_id");

99
    WRITESUBMENUBUTTON("Show Console Log",
100
		       "showconlog.php3?node_id=$node_id&linecount=500");
Chad Barb's avatar
Chad Barb committed
101 102
}

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
if ($node->AccessCheck($this_user, $TB_NODEACCESS_LOADIMAGE)) {
    $baseimage = $node->def_boot_image();

    if ($baseimage &&
	$baseimage->AccessCheck($this_user, $TB_IMAGEID_DESTROY)) {
	WRITESUBMENUBUTTON("Create a Disk Image",
			   "loadimage.php3?target=$node_id" .
			   "&imageid=" . $baseimage->imageid() .
			   "&version=" . $baseimage->version());
    }
    else {
	#
	# This can happen for virtual nodes which are running the
	# defaut osid. User must create a new descriptor.
	#
	WRITESUBMENUBUTTON("Create a Disk Image",
			   "newimageid_ez.php3?node_id=$node_id");
    }
}

123 124 125
#
# SSH to option.
# 
126
if ($experiment) {
Leigh Stoller's avatar
Leigh Stoller committed
127 128 129
    $sshurl = $node->sshurl($uid);
    WRITESUBMENUBUTTON("SSH URL", $sshurl);
    
130
    WRITESUBMENUBUTTON("SSH to node</a> ".
131
		       "<a href='$WIKIDOCURL/ssh_mine'>".
132 133 134
		       "(howto)", "nodessh.php3?node_id=$node_id");
}

Leigh Stoller's avatar
Leigh Stoller committed
135 136 137
#
# Edit option
#
Chad Barb's avatar
Chad Barb committed
138
WRITESUBMENUBUTTON("Edit Node Info",
139
		   "nodecontrol_form.php3?node_id=$node_id");
Leigh Stoller's avatar
Leigh Stoller committed
140

141 142 143
if ($isadmin ||
    $node->AccessCheck($this_user, $TB_NODEACCESS_REBOOT)) {
    if ($experiment) {
144 145 146 147
	WRITESUBMENUBUTTON("Update Node",
			   "updateaccounts.php3?pid=$pid&eid=$eid".
			   "&nodeid=$node_id");
    }
148 149
    WRITESUBMENUBUTTON("Reboot Node",
		       "boot.php3?node_id=$node_id");
150 151 152

    WRITESUBMENUBUTTON("Show Boot Log",
		       "bootlog.php3?node_id=$node_id");
153 154
}

155 156 157
if (($isadmin ||
     $node->AccessCheck($this_user, $TB_NODEACCESS_READINFO)) &&
    ($node->TypeClass() == "robot")) {
158
    WRITESUBMENUBUTTON("Show Telemetry",
159
		       "telemetry.php3?node_id=$node_id",
160 161 162
		       "telemetry");
}

163
if ($isadmin || OPSGUY()) {
164
    WRITESUBMENUBUTTON("Show Node Log",
165
		       "shownodelog.php3?node_id=$node_id");
166 167
    WRITESUBMENUBUTTON("Show Node History",
		       "shownodehistory.php3?node_id=$node_id");
168
}
169
if ($experiment && ($isadmin || (OPSGUY()) && $pid == $TBOPSPID)) {
170 171
    WRITESUBMENUBUTTON("Free Node",
		       "freenode.php3?node_id=$node_id");
172 173
}

174
if ($isadmin || STUDLY() || OPSGUY()) {
175 176
    WRITESUBMENUBUTTON("Set Node Location",
		       "setnodeloc.php3?node_id=$node_id");
177 178
    WRITESUBMENUBUTTON("Update Power State",
		       "powertime.php3?node_id=$node_id");
179
}
180 181

if ($isadmin || STUDLY() || OPSGUY()) {
Kirk Webb's avatar
Kirk Webb committed
182
    WRITESUBMENUBUTTON("Modify Node Attributes",
183 184 185
                       "modnodeattributes_form.php3?node_id=$node_id");
}

186 187 188 189 190
SUBMENUEND();

#
# Dump record.
# 
191
$node->Show(SHOWNODE_NOFLAGS);
192 193

SUBPAGEEND();
194

Leigh Stoller's avatar
Leigh Stoller committed
195 196 197 198 199
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>
Chad Barb's avatar
Chad Barb committed
200 201 202 203