Commit 70246c91 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Client side of the event system changes.

* Download the eventkey with new tmcd call.

* Pass -k option to various agents so that they can verify the HMACs
  in the incoming notifications.

* Change program agent; The list of agents from tmcd now includes the
  command, which is written to a config file for the program-agent to
  read in. The command string in the event is now ignored.

* Build the local proxy for linux, and add the goo to start the local
  elvind and use the proxy. It has been this way on FreeBSD for a
  while, but I never got it installed for Linux before now.
parent 54bc15c4
......@@ -44,7 +44,7 @@ use libtmcc;
#
# BE SURE TO BUMP THIS AS INCOMPATIBILE CHANGES TO TMCD ARE MADE!
#
sub TMCD_VERSION() { 12; };
sub TMCD_VERSION() { 13; };
libtmcc::configtmcc("version", TMCD_VERSION());
# Control tmcc timeout.
......@@ -363,14 +363,22 @@ sub cleanup_node ($) {
#
sub check_status ()
{
my $status;
my @tmccresults;
if (tmcc(TMCCCMD_STATUS, undef, \@tmccresults) < 0) {
warn("*** WARNING: Could not get status from server!\n");
return -1;
}
$status = $tmccresults[0];
#
# This is possible if the boss node does not now about us yet.
# We want to appear free. Specifically, it could happen on the
# MFS when trying to bring in brand new nodes. tmcd will not know
# anything about us, and return no info.
#
return 0
if (! @tmccresults);
my $status = $tmccresults[0];
if ($status =~ /^FREE/) {
unlink TMNICKNAME;
......@@ -1843,17 +1851,10 @@ sub dotrafficconfig()
}
my ($pid, $eid, $vname) = check_nickname();
my $cmdline = "$BINDIR/trafgen -s ";
# Inside a jail, we connect to the local elvind and talk to the
# master via the proxy.
if (JAILED()) {
$cmdline .= "localhost"
}
else {
$cmdline .= "$boss"
}
# We connect to the local elvind and talk to the master via the proxy.
my $cmdline = "$BINDIR/trafgen -s localhost ";
if ($pid) {
$cmdline .= " -E $pid/$eid";
$cmdline .= " -E $pid/$eid -k " . TMEVENTKEY();
}
#
......
......@@ -97,6 +97,10 @@ sub tmcccopycache($$)
warn("*** WARNING: No such directory $root!\n");
return -1;
}
if (-d $todir) {
system("rm -rf $todir") == 0 ||
warn("*** WARNING: Could not remove old cache $todir!\n");
}
return system("cp -rp $fromdir $todir");
}
......
......@@ -63,38 +63,11 @@ if (! -s TMPROGAGENTS) {
}
#
# The progagent always talks to the local elvind on FreeBSD, which
# talks to boss. Otherwise, it talks to boss directly.
# The progagent always talks to the local elvind, which talks to boss.
#
my $bossname;
if ($OSNAME eq "freebsd") {
$bossname = "localhost";
}
else {
$bossname = tmccbossname();
}
#
# Open up the command file, which tells us what to do.
#
open(CMD, TMPROGAGENTS) or
fatal("Could not open " . TMPROGAGENTS . ": $!");
my @agents;
my $login;
while (<CMD>) {
if ($_ =~ /^UID=([-\w]+)$/) {
$login = $1;
}
elsif ($_ =~ /^AGENT=([-\w]+)$/) {
push (@agents, $1);
}
}
if (! @agents || !defined($login)) {
fatal(TMPROGAGENTS . " not in proper format!");
}
my $elvind = "localhost";
my $config = TMPROGAGENTS();
my $keyfile = TMEVENTKEY();
#
# Need the pid/eid.
......@@ -105,12 +78,10 @@ my ($pid, $eid, $vname) = check_nickname();
# Start the program agent. It will become the user. It must be started
# as root of course to do this.
#
my $agentlist = join(" -a ", @agents);
print "Starting Program Agent ($login, @agents) ...\n";
print "Starting Program Agent ...\n";
system("program-agent -e $pid/$eid -s $bossname -u $login -l $logfile ".
"-a $agentlist -i $pidfile &");
system("program-agent -e $pid/$eid -s $elvind -l $logfile ".
"-i $pidfile -k $keyfile -c $config &");
exit($? >> 0);
sub fatal($)
......
......@@ -25,4 +25,4 @@
* NB: See ron/libsetup.pm. That is version 4! I'll merge that in.
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 12
#define CURRENT_VERSION 13
......@@ -46,6 +46,7 @@ if (@ARGV) {
}
# Must do this *after* setting vnode id.
my $MAPFILE = TMDELMAP();
my $KEYFILE = TMEVENTKEY();
my $logfile;
my $pidfile;
......@@ -85,16 +86,10 @@ print "Starting Delay Agent ...\n";
my ($pid, $eid, $vname) = check_nickname();
#
# We use the tmcc to figure out where the Testbed Event Daemon is running.
# Don't worry about the port for now. When for a jail, we use localhost
# to talk to the local elvind and the evproxy. Maybe just do this all the
# time and not worry about the extra 1ms of transit delay?
# The agent always talks to the local elvind, which talks to boss.
#
my $bossname = "localhost";
if (! defined($vnodeid)) {
$bossname = tmccbossname();
}
my $elvind = "localhost";
system("delay-agent -s $bossname -E $pid/$eid ".
"-f $MAPFILE -l $logfile -i $pidfile &");
system("delay-agent -s $elvind -E $pid/$eid ".
"-f $MAPFILE -l $logfile -i $pidfile -k $KEYFILE &");
exit($? >> 0);
......@@ -44,7 +44,7 @@ use libtmcc;
#
# BE SURE TO BUMP THIS AS INCOMPATIBILE CHANGES TO TMCD ARE MADE!
#
sub TMCD_VERSION() { 12; };
sub TMCD_VERSION() { 13; };
libtmcc::configtmcc("version", TMCD_VERSION());
# Control tmcc timeout.
......@@ -363,14 +363,22 @@ sub cleanup_node ($) {
#
sub check_status ()
{
my $status;
my @tmccresults;
if (tmcc(TMCCCMD_STATUS, undef, \@tmccresults) < 0) {
warn("*** WARNING: Could not get status from server!\n");
return -1;
}
$status = $tmccresults[0];
#
# This is possible if the boss node does not now about us yet.
# We want to appear free. Specifically, it could happen on the
# MFS when trying to bring in brand new nodes. tmcd will not know
# anything about us, and return no info.
#
return 0
if (! @tmccresults);
my $status = $tmccresults[0];
if ($status =~ /^FREE/) {
unlink TMNICKNAME;
......@@ -1843,17 +1851,10 @@ sub dotrafficconfig()
}
my ($pid, $eid, $vname) = check_nickname();
my $cmdline = "$BINDIR/trafgen -s ";
# Inside a jail, we connect to the local elvind and talk to the
# master via the proxy.
if (JAILED()) {
$cmdline .= "localhost"
}
else {
$cmdline .= "$boss"
}
# We connect to the local elvind and talk to the master via the proxy.
my $cmdline = "$BINDIR/trafgen -s localhost ";
if ($pid) {
$cmdline .= " -E $pid/$eid";
$cmdline .= " -E $pid/$eid -k " . TMEVENTKEY();
}
#
......
......@@ -98,6 +98,10 @@ sysetc-install: dir-install
mv -f $(SYSETCDIR)/cron.daily/makewhatis.cron \
$(SYSETCDIR)/cron.pend; \
fi
$(INSTALL) -m 755 $(SRCDIR)/elvin.sh $(RCDIR)/init.d/elvin
-ln -s $(RCDIR)/init.d/elvin $(RCDIR)/rc3.d/S96elvin
-ln -s $(RCDIR)/init.d/elvin $(RCDIR)/rc1.d/K12elvin
-ln -s $(RCDIR)/init.d/elvin $(RCDIR)/rc6.d/K12elvin
sysetc-remove:
-rm -f $(RCDIR)/*/S95anacron $(RCDIR)/*/K05anacron
......
#!/bin/sh
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
if [ ! -f /etc/sysconfig/network ]; then
exit 0
fi
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
case "$1" in
start)
if [ -x /usr/local/sbin/elvind ]; then
/usr/local/sbin/elvind && echo -n ' elvind'
fi
touch /var/lock/subsys/elvin
;;
stop)
killproc elvind
rm -f /var/lock/subsys/elvin
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac
exit 0
#!/bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
. /etc/emulab/paths.sh
......@@ -43,6 +43,7 @@ case "$1" in
killproc slothd
killproc healthd
killproc watchdog
killproc evproxy
echo "Informing the testbed we're rebooting ..."
$BINDIR/tmcc state SHUTDOWN
RETVAL=$?
......
......@@ -4879,12 +4879,9 @@ COMMAND_PROTOTYPE(doprogagents)
return 1;
}
res = mydb_query("select v.vname from virt_agents as v "
"left join event_objecttypes as e on "
" e.idx=v.objecttype "
"where e.type='PROGRAM' and "
" v.vnode='%s' and v.pid='%s' and v.eid='%s'",
1, reqp->nickname, reqp->pid, reqp->eid);
res = mydb_query("select vname,command from virt_programs "
"where vnode='%s' and pid='%s' and eid='%s'",
2, reqp->nickname, reqp->pid, reqp->eid);
if (!res) {
error("PROGRAM: %s: DB Error getting virt_agents\n",
......@@ -4906,7 +4903,10 @@ COMMAND_PROTOTYPE(doprogagents)
while (nrows) {
row = mysql_fetch_row(res);
sprintf(buf, "AGENT=%s\n", row[0]);
sprintf(buf, "AGENT=%s", row[0]);
if (vers >= 13)
sprintf(&buf[strlen(buf)], " COMMAND='%s'", row[1]);
strcat(buf, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
nrows--;
......
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