shownode.php3 3.95 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
7
include("defs.php3");
8
include_once("node_defs.php");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
9 10 11 12

#
# Only known and logged in users can do this.
#
13 14 15
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
16 17

#
18
# Verify page arguments.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
19
#
20 21 22 23
$reqargs = RequiredPageArguments("node", PAGEARG_NODE);

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

25 26 27 28
#
# Standard Testbed Header
#
PAGEHEADER("Node $node_id");
29

Leigh B. Stoller's avatar
Leigh B. Stoller committed
30 31 32 33
#
# Admin users can look at any node, but normal users can only control
# nodes in their own experiments.
#
34
if (! $isadmin &&
35
    ! $node->AccessCheck($this_user, $TB_NODEACCESS_MODIFYINFO)) {
36

37 38 39 40 41
    $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);
42
	$power_id = $row["power_id"];
43 44
    }
    if (STUDLY() && ($power_id == "mail")) {
45 46 47 48 49
	    SUBPAGESTART();
	    SUBMENUSTART("Node Options");
	    WRITESUBMENUBUTTON("Update Power State",
			       "powertime.php3?node_id=$node_id");
	    SUBMENUEND();
50
	    $node->Show(SHOWNODE_NOPERM);
51 52 53
	    SUBPAGEEND();
    }
    else {
54
	    $node->Show(SHOWNODE_NOPERM);
55
    }
56 57
    PAGEFOOTER();
    return;
Leigh B. Stoller's avatar
Leigh B. Stoller committed
58 59
}

60 61 62 63 64
# If reserved, more menu options.
if (($experiment = $node->Reservation())) {
    $pid   = $experiment->pid();
    $eid   = $experiment->eid();
    $vname = $node->VirtName();
65
}
66

67 68
SUBPAGESTART();
SUBMENUSTART("Node Options");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
69

Chad Barb's avatar
Chad Barb committed
70 71 72
#
# Tip to node option
#
73
if ($node->HasSerialConsole()) {
Chad Barb's avatar
Chad Barb committed
74
    WRITESUBMENUBUTTON("Connect to Serial Line</a> " . 
75
	"<a href=\"faq.php3#tiptunnel\">(howto)",
Chad Barb's avatar
Chad Barb committed
76
	"nodetipacl.php3?node_id=$node_id");
77 78

    WRITESUBMENUBUTTON("Show Console Log",
79
		       "showconlog.php3?node_id=$node_id&linecount=500");
Chad Barb's avatar
Chad Barb committed
80 81
}

82 83 84
#
# SSH to option.
# 
85
if ($experiment) {
86
    WRITESUBMENUBUTTON("SSH to node</a> ".
87
		       "<a href='$WIKIDOCURL/ssh_mine'>".
88 89 90
		       "(howto)", "nodessh.php3?node_id=$node_id");
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
91 92 93
#
# Edit option
#
Chad Barb's avatar
Chad Barb committed
94
WRITESUBMENUBUTTON("Edit Node Info",
95
		   "nodecontrol_form.php3?node_id=$node_id");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
96

97 98 99
if ($isadmin ||
    $node->AccessCheck($this_user, $TB_NODEACCESS_REBOOT)) {
    if ($experiment) {
100 101 102 103
	WRITESUBMENUBUTTON("Update Node",
			   "updateaccounts.php3?pid=$pid&eid=$eid".
			   "&nodeid=$node_id");
    }
104 105
    WRITESUBMENUBUTTON("Reboot Node",
		       "boot.php3?node_id=$node_id");
106 107 108

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

111
if ($node->AccessCheck($this_user, $TB_NODEACCESS_LOADIMAGE)) {
112
    WRITESUBMENUBUTTON("Create a Disk Image",
113
		       "newimageid_ez.php3?formfields[node_id]=$node_id");
114 115
}

116 117 118
if (($isadmin ||
     $node->AccessCheck($this_user, $TB_NODEACCESS_READINFO)) &&
    ($node->TypeClass() == "robot")) {
119
    WRITESUBMENUBUTTON("Show Telemetry",
120
		       "telemetry.php3?node_id=$node_id",
121 122 123
		       "telemetry");
}

124
if ($isadmin || OPSGUY()) {
125
    WRITESUBMENUBUTTON("Show Node Log",
126
		       "shownodelog.php3?node_id=$node_id");
127 128
    WRITESUBMENUBUTTON("Show Node History",
		       "shownodehistory.php3?node_id=$node_id");
129
}
130
if ($experiment && ($isadmin || (OPSGUY()) && $pid == $TBOPSPID)) {
131 132
    WRITESUBMENUBUTTON("Free Node",
		       "freenode.php3?node_id=$node_id");
133 134
}

135
if ($isadmin || STUDLY() || OPSGUY()) {
136 137
    WRITESUBMENUBUTTON("Set Node Location",
		       "setnodeloc.php3?node_id=$node_id");
138 139
    WRITESUBMENUBUTTON("Update Power State",
		       "powertime.php3?node_id=$node_id");
140
}
141 142

if ($isadmin || STUDLY() || OPSGUY()) {
Kirk Webb's avatar
Kirk Webb committed
143
    WRITESUBMENUBUTTON("Modify Node Attributes",
144 145 146
                       "modnodeattributes_form.php3?node_id=$node_id");
}

147
if ($isadmin) {
148
    if (!$node->reserved_pid()) {
149
	WRITESUBMENUBUTTON("Pre-Reserve Node",
Russ Fish's avatar
Russ Fish committed
150
			   "prereserve_node.php3?node_id=$node_id");
151 152 153
    }
    else {
	WRITESUBMENUBUTTON("Clear Pre-Reserve",
Russ Fish's avatar
Russ Fish committed
154
			   "prereserve_node.php3?node_id=$node_id&clear=1");
155 156
    }
}
157 158 159 160 161
SUBMENUEND();

#
# Dump record.
# 
162
$node->Show(SHOWNODE_NOFLAGS);
163 164

SUBPAGEEND();
165

Leigh B. Stoller's avatar
Leigh B. Stoller committed
166 167 168 169 170
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>
Chad Barb's avatar
Chad Barb committed
171 172 173 174