Commit 2a8a8f74 authored by Robert Ricci's avatar Robert Ricci

Make it possible to have ops check in with newnode.

This starts with a new option to newnode, -o, that tells it it's
running on ops. This reports some slightly different information
to the checkin page.

The checkin page and the backend newnode script then take this extra
information into account, and deal with ops nodes slightly
differently.
parent 71d95c31
......@@ -29,7 +29,7 @@ else {
my $FETCH = "/usr/bin/fetch";
my $FORMURL = "newnodecheckin.php";
my $FORMURL = "dev/ricci/newnodecheckin.php";
my $IFCONFIG = "/sbin/ifconfig";
my $DMESG = "/var/run/dmesg.boot";
......@@ -72,6 +72,13 @@ my $BEEP_SLEEP = 3; # In seconds
my $FLOPPY_REMOVED = 0;
my $FLOPPY_INSERTED = 1;
#
# What type of client this node is. Possible values:
# testnode - The default, a regular testbed node
# ops - The node checking in is actually ops
#
my $client_type = "testnode";
#
# Handle command-line arguments - we do them ourselves unstead of using getopt,
# because we want to be able to run this on minimalist environments where that
......@@ -82,6 +89,7 @@ my $writefloppy = 0;
my $testing = 0;
my $bossnode = "";
my $uniquifier;
foreach my $arg (@ARGV) {
if ($arg =~ s/^-//) {
......@@ -90,6 +98,7 @@ foreach my $arg (@ARGV) {
/h/ && do { $headless = 1; last; };
/w/ && do { $writefloppy = 1; last; };
/t/ && do { $testing = 1; last; };
/o/ && do { $client_type = "ops"; last; };
};
}
} else {
......@@ -102,10 +111,11 @@ foreach my $arg (@ARGV) {
}
sub usage {
print "Usage: $0 [-h] [-w] [-t] [identifer]\n";
print "Usage: $0 [-h] [-w] [-t] [-o] [identifer]\n";
print " -h - Run headless (beep codes for errors)\n";
print " -w - Write an the node's unique identifier to a floppy\n";
print " -t - Test mode\n";
print " -o - 'ops' mode\n";
print " identifier - supply the given identifier to boss\n";
1;
}
......@@ -131,11 +141,44 @@ my @ifaces = find_interfaces();
my ($diskdev, $disksize) = get_disksize();
my $speed = get_cpuspeed();
#
# For some node types, we may already know the node_id we're supposed to use
#
my $node_id;
if ($client_type eq "ops") {
$node_id = "ops";
}
#
# For some node types, we know we're supposed to use our 'temporary' IP as the
# permanent one - take care of those now
#
my $use_temp_IP = 0;
if ($client_type eq "ops") {
$use_temp_IP = 1;
}
#
# Also, keep track of the role this node will have in the testbed
#
my $role = "testnode";
if ($client_type eq "ops") {
$role = "ctrlnode";
}
#
# In some cases, we may know the node's type in advance
#
my $type;
if ($client_type eq "ops") {
$type = "ops";
}
#
# Start the program that will annouce us to the switch, so that it learns
# MAC addresses, etc.
#
if (!$testing) {
if (!$testing && ($client_type ne "ops")) {
teachswitch();
}
......@@ -186,9 +229,19 @@ sub buildURL {
$URL .= "cpuspeed=" . urlencode($speed);
$URL .= "&diskdev=" . urlencode($diskdev);
$URL .= "&disksize=" . urlencode($disksize);
$URL .= "&role=" . urlencode($role);
if ($node_id) {
$URL .= "&node_id=" . urlencode($node_id);
}
if ($uniquifier) {
$URL .= "&identifier=". urlencode($uniquifier);
}
if ($use_temp_IP) {
$URL .= "&use_temp_IP=1";
}
if ($type) {
$URL .= "&type=" . urlencode($type);
}
my $ifaceindex = 0;
foreach my $aref (@ifaces) {
......
......@@ -39,12 +39,14 @@ my $sudo = "/usr/local/bin/sudo -S";
#
# MFS to boot the nodes into initially
#
my $INITIAL_MFS = TB_OSID_FREEBSD_MFS();
my $MFS_INITIAL = TB_OSID_FREEBSD_MFS();
my $OS_OPSNODE = "OPSNODE-BSD";
#
# Initial event system state to put the nodes into
#
my $INITIAL_STATE = TBDB_NODESTATE_SHUTDOWN;
my $STATE_INITIAL = TBDB_NODESTATE_SHUTDOWN;
my $STATE_OPSNODE = TBDB_NODESTATE_ISUP;
#
# Number of vnodes to create for each physical node
......@@ -56,6 +58,14 @@ my $NUM_VNODES = 50;
#
my $DEFAULT_PCVM_COUNT = 20;
#
# Experiments we might put nodes into
#
my $PID_HWDOWN = NODEDEAD_PID();
my $EID_HWDOWN = NODEDEAD_EID();
my $PID_OPSNODE = TBOPSPID();
my $EID_OPSNODE = "opsnodes";
# Turn off line buffering on output
$| = 1;
......@@ -108,16 +118,6 @@ if (!-w $dhcpd_conf) {
die "In order to use this script, you must be able to write $dhcpd_conf\n";
}
#
# Find out what op_mode the $INITIAL_MFS runs in
#
my $result = DBQueryFatal("select op_mode from os_info where " .
" osid='$INITIAL_MFS'");
if ($result->numrows() != 1) {
die "Unable to find OS information for $INITIAL_MFS\n";
}
my ($INITIAL_OPMODE) = $result->fetchrow();
#
# For vnodes - figure out the jail IP base
#
......@@ -151,14 +151,14 @@ NODE: foreach my $node_id (@node_ids) {
# Grab information about the node from the new_nodes table
#
$query_result = DBQueryFatal("SELECT new_node_id, type, IP, temporary_IP, ".
"floor, building, loc_x, loc_y, contact, phone, room " .
"floor, building, loc_x, loc_y, contact, phone, room, role " .
"FROM new_nodes WHERE node_id='$node_id'");
if (!$query_result->num_rows()) {
warn "Node $node_id failed: No pending node with that name exists!\n";
next NODE;
}
my ($new_node_id, $type, $IP, $tempIP, $floor, $building, $loc_x, $loc_y,
$contact, $phone, $room) = $query_result->fetchrow();
$contact, $phone, $room, $role) = $query_result->fetchrow();
#
# Make sure they've given it an IP address that looks valid
......@@ -224,7 +224,7 @@ NODE: foreach my $node_id (@node_ids) {
# Do a sanity check - make sure that we have a switch recorded for all
# experimental interfaces
#
unless ($force_unconnected_interfaces) {
unless ($force_unconnected_interfaces || ($role eq "ctrlnode")) {
my $iface = "eth$card";
if (($iface ne $control_iface) && ($connector !~ /wireless/i)
&& !$switch_id) {
......@@ -254,14 +254,56 @@ NODE: foreach my $node_id (@node_ids) {
$priority = 1;
}
#
# Figure out which project and experiment this node needs to go into
#
my ($pid, $eid);
if ($role eq "ctrlnode") {
$pid = $PID_OPSNODE;
$eid = $EID_OPSNODE;
} else {
$pid = $PID_HWDOWN;
$eid = $EID_HWDOWN;
}
#
# Figure out what OS this node should run
#
my $osid;
if ($role eq "ctrlnode") {
$osid = $OS_OPSNODE;
} else {
$osid = $MFS_INITIAL;
}
#
# Figure out which opmode the OS runs in
#
my $result = DBQueryFatal("select op_mode from os_info where " .
" osid='$osid'");
if ($result->numrows() != 1) {
die "Unable to find OS information for $osid\n";
}
my ($opmode) = $result->fetchrow();
#
# Figure out what state to start the node in
#
my $state;
if ($role eq "ctrlnode") {
$state = $STATE_OPSNODE;
} else {
$state = $STATE_INITIAL;
}
#
# Okay, time to actually add the node!
#
DBQueryFatal("INSERT INTO nodes SET node_id='$node_id', type='$type', " .
"phys_nodeid='$node_id', role='testnode', priority=$priority, " .
"eventstate='$INITIAL_STATE', op_mode='$INITIAL_OPMODE', " .
"def_boot_osid='$INITIAL_MFS', " .
"phys_nodeid='$node_id', role='$role', priority=$priority, " .
"eventstate='$state', op_mode='$opmode', " .
"def_boot_osid='$MFS_INITIAL', " .
"state_timestamp=unix_timestamp(NOW()), " .
"op_mode_timestamp=unix_timestamp(NOW())");
......@@ -306,7 +348,7 @@ NODE: foreach my $node_id (@node_ids) {
#
# Add some vnodes
#
if (defined $nodenum) {
if (defined $nodenum && ($role eq "testnode")) {
my $vtype = $type;
if (!($vtype =~ s/pc/pcvm/)) {
$vtype = "$vtype-vm";
......@@ -360,7 +402,7 @@ NODE: foreach my $node_id (@node_ids) {
# Put it into hwdown for now - I would put them in reloading, but I'm
# afriad the reload_daemon might do the wrong thing to them
#
system "$nalloc emulab-ops hwdown $node_id";
system "$nalloc $pid $eid $node_id";
#
# Remove the node from the new_ tables
......
<?php
e<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2003 University of Utah and the Flux Group.
......@@ -97,18 +97,37 @@ if (count($interfaces)) {
#
# Attempt to come up with a node_id and an IP address for it
# Attempt to come up with a node_id and an IP address for it - unless one was
# provided by the client.
#
$name_info = find_free_id("pc");
$node_prefix = $name_info[0];
$node_num = $name_info[1];
$hostname = $node_prefix . $node_num;
$IP = guess_IP($node_prefix,$node_num);
if (!$node_id) {
$name_info = find_free_id("pc");
$node_prefix = $name_info[0];
$node_num = $name_info[1];
$hostname = $node_prefix . $node_num;
} else {
$hostname = $node_id;
}
if ($use_temp_IP) {
$IP = $tmpIP;
} else {
$IP = guess_IP($node_prefix,$node_num);
}
#
# Make an educated guess as to what type it belongs to
#
$type = guess_node_type($cpuspeed,$disksize);
if (!$type) {
$type = guess_node_type($cpuspeed,$disksize);
}
#
# Default the role to 'testnode' if the node didn't supply a role
#
if (!$role) {
$role = "testnode";
}
#
# Stash this information in the database
......@@ -120,7 +139,7 @@ if ($identifier) {
}
DBQueryFatal("insert into new_nodes set node_id='$hostname', type='$type', " .
"IP='$IP', temporary_IP='$tmpIP', dmesg='$messages', created=now(), " .
"identifier=$identifier");
"identifier=$identifier, role='$role'");
$query_result = DBQueryFatal("select last_insert_id()");
$row = mysql_fetch_array($query_result);
......
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