Commit 78b4e4f5 authored by Mac Newbold's avatar Mac Newbold

Many changes and updates for handling new types. The db now has types like...

Many changes and updates for handling new types. The db now has types like 'pc600', 'pc850', and 'dnard', and each type has a class like 'pc' or 'shark'. This updates scripts that use types to use classes where appropriate, and to handle the new types where there were hardcoded things that couldn't be eliminated right now.
parent 922acc53
#!/usr/local/bin/perl -w
use Mysql;
my $d = 0; #debug mode
my $d = 1; #debug mode
if ($#ARGV >= 0 && $ARGV[0] =~ /^-?h/i ) {
die("Usage:\navail [help] [type[=<type>]] [OS[=<OS>]] [ver[=<OS_ver>]]\n".
" [deltas=<delta[,delta,...]>]".
#" [deltas=<delta[,delta,...]>]".
# " [fixes=<fix_name[,fix_name,...]>]".
"\n".
"type \t= pc | shark\n"."OS \t= Linux | FreeBSD | NetBSD | ...\n".
"ver \t= 6.2 | 3.4 | 4.0 | 5.2 | ...\n"."deltas \t= anetd | ...\n".
"ver \t= 6.2 | 3.4 | 4.0 | 5.2 | ...\n".#"deltas \t= anetd | ...\n".
# "fixes \t\t= cron_off | sendmail_off | ...\n"
"A field name alone will show that field in the display of available\n".
"nodes. A field name with '=' will match nodes that have that field\n".
......@@ -29,7 +29,7 @@ while ($#ARGV >= 0) {
@_ = split('=',$_);
my ($opt,$val) = @_ if ($#_ >= 0);
if (!defined($val)) { $val=""; }
$args{$opt}=$val if (defined($opt));
$args{"\L$opt"}=$val if (defined($opt));
}
}
if ( $d ) {
......@@ -41,12 +41,13 @@ if ( $d ) {
my $join= "nodes as a left join reserved as b on a.node_id=b.node_id";
my $cols= "a.node_id,a.type";
my $cond= "b.node_id is null and a.type!='cisco' and a.type!='APC'";
my $cond= "b.node_id is null and a.role='testnode'";
my $os = 0;
my $delta = 0;
if (defined($args{"type"})) {
$cond .= " and a.type='".$args{"type"}."'" if $args{"type"} ne '=';
if (defined($args{"type"})) {
# Make it a like, so if they type 'pc' they get pc850 and pc600...
$cond .= " and a.type like '%".$args{"type"}."%'" if $args{"type"} ne '=';
}
if (defined($args{"os"})) {
$os = 1;
......@@ -58,25 +59,25 @@ if (defined($args{"ver"})) {
$cols .= ",d.ver";
$cond .= " and d.ver='".$args{"ver"}."'" if $args{"ver"} ne '=';
}
if (defined($args{"deltas"})) {
$os = 1;
$delta=1;
$cols .= ",e.delta_id";
$cond .= " and e.delta_id='".$args{"deltas"}."'" if $args{"deltas"} ne '=';
}
# if (defined($args{"deltas"})) {
# $os = 1;
# $delta=1;
# $cols .= ",e.delta_id";
# $cond .= " and e.delta_id='".$args{"deltas"}."'" if $args{"deltas"} ne '=';
# }
if ($os) {
$join .= " left join partitions as c on a.node_id=c.node_id";
$join .= " left join disk_images as d on c.image_id=d.image_id";
$join .= " left join os_info as d on c.osid=d.osid";
}
if ($delta) {
$join .= " left join delta_inst as e on c.node_id=e.node_id ".
"and c.partition=e.partition";
}
# if ($delta) {
# $join .= " left join delta_inst as e on c.node_id=e.node_id ".
# "and c.partition=e.partition";
# }
my $cmd = "select $cols from $join where $cond order by node_id,type";
my $cmd = "select $cols from $join where $cond order by priority";
print "Sending cmd:\n$cmd\n" if $d;
......
......@@ -4,7 +4,7 @@ use Mysql;
my $dbh = Mysql->connect("localhost","@TBDBNAME@","script","none");
my $sth = $dbh->
query("select r.* from reserved as r left join nodes as n on r.node_id=n.node_id order by n.type,n.node_id");
query("select r.* from reserved as r left join nodes as n on r.node_id=n.node_id order by priority");
print $sth->as_string();
......@@ -14,7 +14,7 @@ include $(TESTBED_SRCDIR)/GNUmakerules
OBJS=get_ifi_info.o get_rtaddrs.o net_rt_iflist.o sock_ntop.o util.o
SOBJS=serv_listen.o recvfromflags.o if_indextoname.o reply.o serv.o forw_requests.o
COBJS=cli.o
COBJS=cli.o generate_namfile.o
LIBS = -lm
CFLAGS += -Wall -g
CC=gcc
......
......@@ -383,8 +383,7 @@ while (1) {
" nodes as a left join reserved as b" .
" on a.node_id=b.node_id" .
" where b.node_id is null" .
" and a.type != \"cisco\" and a.type != \"APC\"" .
" and a.type != \"shark\"");
" and a.role='testnode'");
if ($numnodes < $minimum_nodes) {
print STDERR "$0: *** Insufficient nodes available.\n";
......
......@@ -43,7 +43,7 @@ if ($@) {
# $delayos is the delay os, currently assumed to be os of PC's
# XXX - Should grab this from the DB eventually
$delayos = "FBSD40-STD";
$delaytype = "pc";
$delaytype = "pc600";
$raw = eval {&ir_get("/topology/nodes")};
if ($@) {
......
......@@ -26,7 +26,8 @@ Node instproc init {s} {
$self set iplist {}
# The type of the node.
$self set type "pc"
$self set type "pc600"
# XXX Temporary hack! to use ISPs, must change
# If osid remains blank when updatedb is called it is changed
# to the default OS based on it's type (taken from node_types
......
......@@ -219,7 +219,7 @@ for ($i = 0; $i < $db_result->numrows; $i++) {
# Set the canfail bit. Currently, sharks are always canfail=1.
# Will come from DB at some point.
#
if ($row{'type'} eq "shark") {
if ($row{'type'} eq "dnard") {
$canfail{$node} = 1;
}
else {
......
......@@ -7,7 +7,8 @@ $switch_speed = 100;
# Switch types - include all node types that are switches
%switch_types = (
'cisco', 1,
'cisco6509', 1,
'intel510t', 1
);
# Omit types - Include all types of node that will never be used.
......@@ -112,10 +113,10 @@ sub get_ifacebw {
}
};
$sth = $dbh->prepare("SELECT type,node_id1,card1,port1,node_id2,card2,port2" .
$sth = $dbh->prepare("SELECT node_id1,card1,port1,node_id2,card2,port2" .
" from wires where type=\"Node\"");
$sth->execute;
while (($type,$node1,$card1,$port1,$node2,$card2,$port2) =
while (($node1,$card1,$port1,$node2,$card2,$port2) =
$sth->fetchrow_array) {
if (defined($nodes{$node1}) && defined($nodes{$node2})) {
$iface1 = get_iface($node1,$card1,$port1);
......
......@@ -7,7 +7,7 @@ use Getopt::Std;
#
# usage: reload_daemon [-d]
#
# XXX - Hardwired to type "pc".
# XXX - Hardwired to type "pc600".
# Path to image and the partition are hardwired in.
#
# TODO: Use "logger" instead of writing a log file.
......@@ -27,7 +27,7 @@ my $TB = "@prefix@";
my $DBNAME = "@TBDBNAME@";
my $TBOPS = "@TBOPSEMAIL@";
my $TYPE = "pc";
my $TYPE = "pc600"; # XXX: Temporary hack! needs to change for ISPs
my $reloader = "$TB/sbin/sched_reload";
my $reboot = "$TB/bin/node_reboot";
my $logfile = "$TB/log/reloadlog";
......
......@@ -99,7 +99,7 @@ sub ReadTranslationTable {
print "FILLING %Devices\n" if $debug;
$sth = $dbh->query("select i.node_id,i.IP from interfaces as i ".
"left join nodes as n on n.node_id=i.node_id ".
"where n.type!='pc' and n.type!='shark'");
"where n.role!='testnode'");
while ( @_ = $sth->fetchrow_array()) {
$name = "$_[0]";
$ip = "$_[1]";
......
......@@ -7,9 +7,10 @@ include("defs.php3");
PAGEHEADER("Utah Testbed Machine Status");
$query_result = mysql_db_query($TBDBNAME,
"SELECT n.node_id, n.type, j.pid, j.eid, j.vname FROM nodes ".
"AS n LEFT JOIN reserved AS j ON n.node_id = j.node_id ".
"WHERE type='pc' OR type='shark' ORDER BY type,priority");
"SELECT n.node_id, n.type, nt.class, j.pid, j.eid, j.vname ".
"FROM nodes AS n LEFT JOIN reserved AS j ON n.node_id = j.node_id ".
"LEFT JOIN node_types AS nt ON n.type=nt.type ".
"WHERE role='testnode' ORDER BY type,priority");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting node reservation status: $err\n", 1);
......@@ -29,7 +30,7 @@ $freepcs = 0;
$freesharks= 0;
while ($r = mysql_fetch_array($query_result)) {
$type = $r["type"];
$type = $r["class"];
$eid = $r["eid"];
if ($type == "pc") {
......@@ -69,7 +70,7 @@ echo "</tr>\n";
mysql_data_seek($query_result, 0);
while ($r = mysql_fetch_array($query_result)) {
$id = $r["node_id"]; $type = $r["type"];
$id = $r["node_id"]; $type = $r["type"]; $class = $r["class"];
$res1 = $r["pid"];
$res2 = $r["eid"];
$res3 = $r["vname"];
......@@ -82,7 +83,7 @@ while ($r = mysql_fetch_array($query_result)) {
if (!$res3 || $res3 == "NULL") {
$res3 = "--";
}
echo "<tr><td>$id</td> <td>$type</td> ";
echo "<tr><td>$id</td> <td>$type ($class)</td> ";
# If I'm an admin, I can see pid/eid/vname, but if not, I only see eid
if ($isadmin) { echo "<td>$res1</td> "; }
echo "<td>$res2</td> ";
......
......@@ -63,6 +63,8 @@ if (mysql_num_rows($experiments_result)) {
<td width=70%>Name</td>
</tr>\n";
$total_pcs = 0;
$total_sharks = 0;
while ($row = mysql_fetch_array($experiments_result)) {
$pid = $row[pid];
$eid = $row[eid];
......@@ -70,9 +72,10 @@ if (mysql_num_rows($experiments_result)) {
$name = $row[expt_name];
$usage_query = mysql_db_query($TBDBNAME,
"select n.type, count(*) from reserved as r left join nodes as n ".
"on r.node_id=n.node_id where r.pid='$pid' and r.eid='$eid' ".
"group by n.type;");
"select nt.class, count(*) from reserved as r left join nodes as n ".
"on r.node_id=n.node_id left join node_types as nt ".
"on n.type=nt.type where r.pid='$pid' and r.eid='$eid' ".
"group by nt.class;");
$usage["pc"]="";
$usage["shark"]="";
......@@ -80,6 +83,9 @@ if (mysql_num_rows($experiments_result)) {
$usage[$n[0]] = $n[1];
}
$total_pcs += $usage["pc"];
$total_sharks += $usage["shark"];
echo "<tr>
<td><A href='showproject.php3?pid=$pid'>$pid</A></td>
<td><A href='showexp.php3?exp_pideid=$pid\$\$$eid'>
......@@ -95,6 +101,9 @@ if (mysql_num_rows($experiments_result)) {
</tr>\n";
}
echo "</table>\n";
echo "<center>\n<h2>Total PCs in use: $total_pcs<br>\n";#</h2>\n";
echo "Total Sharks in use: $total_sharks<br>\n";
echo "Total Nodes in use: ",$total_sharks+$total_pcs,"</h2>\n</center>\n";
}
if (mysql_num_rows($batch_result)) {
......
......@@ -139,8 +139,9 @@ tb-set-hardware $node4 shark
<p>Notes:
<ul>
<li>Currently only <code>pc</code> and <code>shark</code> are
supported types. <code>pc</code> is the default type.
<li>Currently only <code>pc</code>, <code>pc600</code>,
<code>pc850</code>, and <code>shark</code> are
supported types. <code>pc</code> is the default type.
<li>No current types have any additional arguments.
</dl>
......
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