Commit fc2811bd authored by Leigh Stoller's avatar Leigh Stoller

Merge branch 'master' of git-public.flux.utah.edu:/flux/git/emulab-devel

parents 98064cb5 98b30d5e
......@@ -3,7 +3,7 @@
# Start the network....
#
udhcpc_opts="-q"
udhcpc_opts="-q -O staticroutes"
if [ -f /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
......@@ -22,6 +22,7 @@ parse_cached_pxe_lease() {
local routers=""
local nameservers=""
local hostname=""
local classless_routes=""
local mac=""
local iface=""
local ifcfg_opts=""
......@@ -35,6 +36,8 @@ parse_cached_pxe_lease() {
case $key in
OPT_BROADCAST_ADDRESS)
broadcast="$value"; ;;
OPT_CLASSLESS_ROUTES)
classless_routes="$value"; ;;
OPT_SUBNET_MASK)
netmask="$value"; ;;
OPT_HOST_NAME)
......@@ -89,6 +92,16 @@ parse_cached_pxe_lease() {
echo "adding default route via $gw"
/sbin/route add default gw $gw dev $iface
done
if [ -n "$classless_routes" ]; then
echo "creating static routes"
for route in $classless_routes; do
dest=${route%%:*}
gw=${route##*:}
/sbin/route add -net $dest gw $gw
done
fi
echo -n > /etc/resolv.conf
if [ -n "$domain" ]; then
......
......@@ -47,6 +47,14 @@ case "$1" in
done
fi
if [ -n "$staticroutes" ] ; then
echo "creating static routes"
echo $staticroutes | while read dest router; do
route add -net $dest gw $router
done
fi
echo -n > $RESOLV_CONF
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
for i in $dns ; do
......
......@@ -165,7 +165,7 @@ my $infodir = $experiment->InfoDir();
# Sanity check.
if (! (-e $workdir && -e $userdir)) {
die("*** $0:\n".
" Missing a critical directory!\n");
" $pid/$eid is missing a critical directory!\n");
}
if (! -e $infodir) {
if (! -e "$TB/expinfo/$pid") {
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005, 2006, 2007 University of Utah and the Flux Group.
# Copyright (c) 2005-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -69,6 +69,8 @@ use libaudit;
use libdb;
use libtestbed;
use User;
use Group;
use Project;
# Protos
sub fatal($);
......
......@@ -9,6 +9,7 @@
use English;
use Getopt::Std;
use Math::BigInt;
use List::Util 'shuffle';
use lib "@prefix@/lib";
use libdb qw(TBGetSiteVar);
......@@ -34,7 +35,7 @@ sub usage()
{
print("Usage: ptopgen [-v] [-s switch] [-p pid [-e eid]] [-m factor] " .
"[-n c/e] [-x] [-g (0.1 | 2)] [-c component-name]".
"[-l type-limit-file]\n" .
"[-l type-limit-file] [-z]\n" .
" -p include nodes the project has permission to use\n".
" -e include given experiments resources\n" .
" in the ptopfile (as if they were free)\n" .
......@@ -50,11 +51,12 @@ sub usage()
" -x Output into the new xml ptop format\n".
" -g version With -x, geni version. Must be '0', '0.1' or '2'\n".
" -l specifies the location of the type limit file\n" .
" -1 Print an rspec containing only the node component-name");
" -1 Print an rspec containing only the node component-name" .
" -z Randomize node output order");
exit(-1);
}
my $optlist = "s:e:m:vp:rSan:c:uxg:h1:l:";
my $optlist = "s:e:m:vp:rSan:c:uxg:h1:l:z";
my $mfactor;
my $virtstuff = 0;
my $widearea = 0;
......@@ -67,6 +69,7 @@ my $do_xml = 0;
my $genimode = $NO_GENI;
my $useshared = 0;
my $component_name = undef;
my $randomize = 0;
my $OURDOMAIN = "@OURDOMAIN@";
my $MAINSITE = @TBMAINSITE@;
......@@ -217,6 +220,9 @@ if (defined($options{"l"})) {
if (defined($options{"1"})) {
$component_name = $options{"1"};
}
if (defined($options{"z"})) {
$randomize = 1;
}
usage()
if ($prune && !defined($exempt_eid)
......@@ -726,10 +732,16 @@ while (my ($node_id1, $node_id2) = $result->fetchrow()) {
}
}
@nodenames = keys(%nodes);
if ($randomize)
{
@nodenames = shuffle(@nodenames);
}
#
# Loop through and print out all nodes
#
foreach $node (keys(%nodes)) {
foreach $node (@nodenames) {
my $current = $top->nodes()->{$node};
# Wide area nodes are handled below
......
......@@ -46,6 +46,7 @@ struct dhcp_option_info {
int parse_ip_address(struct option *option, char **out);
int parse_ip_address_pair(struct option *option, char **out);
int parse_classless_route(struct option *option, char **out);
int parse_string(struct option *option, char **out);
int parse_data(struct option *option, char **out);
int parse_int8(struct option *option, char **out);
......@@ -123,8 +124,8 @@ struct dhcp_option_info rfc2132_option_info[] = {
{STR(OPT_REBINDING_TIME_VALUE), parse_int32, 0},
{STR(OPT_VENDOR_CLASS_ID), parse_data, 0},
{STR(OPT_CLIENT_ID), parse_data, 0},
{"", NULL, 0},
{"", NULL, 0},
{"", /*62*/ NULL, 0},
{"", /*63*/ NULL, 0},
{STR(OPT_NISPLUS_DOMAIN), parse_string, 0},
{STR(OPT_NISPLUS_SERVER), parse_ip_address, 1},
{STR(OPT_TFTP_SERVER), parse_string, 0},
......@@ -145,6 +146,7 @@ struct dhcp_option_info rfc2132_option_info[] = {
{STR(OPT_CLIENT_FQDN), parse_data, 0},
{STR(OPT_RELAY_AGENT_INFO), parse_data, /* encap */ 0},
{STR(OPT_ISNS), parse_data, 0},
{"", /*84*/ NULL, 0},
{STR(OPT_NDS_SERVERS), parse_ip_address, 1},
{STR(OPT_NDS_TREE_NAME), parse_string, 0},
{STR(OPT_NDS_CONTEXT), parse_string, 0},
......@@ -167,7 +169,7 @@ struct dhcp_option_info rfc2132_option_info[] = {
{"", /*104*/ NULL, 0},
{"", /*105*/ NULL, 0},
{"", /*106*/ NULL, 0},
{"", /*106*/ NULL, 0},
{"", /*107*/ NULL, 0},
{"", /*108*/ NULL, 0},
{"", /*109*/ NULL, 0},
{"", /*110*/ NULL, 0},
......@@ -181,7 +183,7 @@ struct dhcp_option_info rfc2132_option_info[] = {
{STR(OPT_SUBNET_SELECTION), parse_ip_address, 0},
{STR(OPT_DOMAIN_SEARCH), parse_data, /* XXX */ 0},
{STR(OPT_SIP_SERVER), parse_data, /* XXX */ 0},
{STR(OPT_CLASSLESS_ROUTE), parse_data, 0},
{STR(OPT_CLASSLESS_ROUTE), parse_classless_route, 1},
{STR(OPT_CABLELABS_CLIENT_CONFIG), parse_data, /* encap */ 0},
{STR(OPT_LOCATION_CONFIG_INFO), parse_data, 0},
{STR(OPT_VENDOR_IDENT_CLASS), parse_data, 0},
......@@ -666,6 +668,101 @@ int _parse_ip_address(uint8_t *data, size_t len, int pair, char **out)
return ERROR_NONE;
}
int parse_classless_route(struct option *option, char **out)
{
size_t buffer_len, len;
char *buffer, *b;
uint8_t *data, *p;
data = option->data;
len = option->length;
/*
* The buffer must be long enough to hold all routes with a
* space between each one, a '/' separating the mask size from
* the address, a ':' separating the destination from the
* router, and two bytes for the mask size (and a terminating
* null at the end).
*
* Note that the minimum length for a route description is 5
* bytes, so the option value can describe at most length / 5
* routes.
*/
buffer_len = (len / 5) * (INET_ADDRSTRLEN * 2 + 5);
buffer = malloc(buffer_len);
if (!buffer)
return ERROR_MEM;
p = data;
b = buffer;
while (len > 0) {
const char *addr_str;
uint8_t mask_bits;
uint32_t dest_addr;
struct in_addr dest;
struct in_addr router;
mask_bits = *p++;
if (mask_bits > 32) {
free(buffer);
return ERROR_INVALID_VALUE;
}
if ((mask_bits > 24 && len < 9) ||
(mask_bits > 16 && len < 7) ||
(mask_bits > 8 && len < 6) ||
(mask_bits > 0 && len < 5)) {
free(buffer);
return ERROR_INVALID_LENGTH;
}
dest_addr = 0;
if (mask_bits > 0)
dest_addr |= (uint32_t)(*p++) << 24;
if (mask_bits > 8)
dest_addr |= (uint32_t)(*p++) << 16;
if (mask_bits > 16)
dest_addr |= (uint32_t)(*p++) << 8;
if (mask_bits > 24)
dest_addr |= (uint32_t)(*p++);
dest.s_addr = (in_addr_t)htonl(dest_addr);
router.s_addr = *(in_addr_t *)p;
addr_str = inet_ntop(AF_INET, &dest, b,
INET_ADDRSTRLEN);
if (addr_str == NULL) {
perror("parse_classless_route");
free(buffer);
return ERROR_INVALID_VALUE;
}
b += strlen(b);
b += sprintf(b, "/%d:", mask_bits);
addr_str = inet_ntop(AF_INET, &router, b,
INET_ADDRSTRLEN);
if (addr_str == NULL) {
perror("parse_classless_route");
free(buffer);
return ERROR_INVALID_VALUE;
}
b += strlen(b);
p += 4;
len -= 1 + 4 + (mask_bits / 8 + (mask_bits % 8 ? 1 : 0));
if (len > 0)
*b++ = ' ';
}
*out = buffer;
return ERROR_NONE;
}
int parse_ip_address(struct option *option, char **out) {
return _parse_ip_address(option->data, option->length, 0, out);
}
......
......@@ -25,7 +25,8 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
spewconlog opsdb_control newnode suchown archive_list \
wanodecheckin wanodecreate spewimage \
anonsendmail epmodeset fixexpinfo node_traffic \
dumpdescriptor subboss_tftpboot_sync testbed-control
dumpdescriptor subboss_tftpboot_sync testbed-control \
archive-expinfo
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
webwanodecheckin webspewimage
......
#!/bin/sh
THRESHOLD=1000
if [ "$1" = "-t" ] && [ $# -eq 2 ] && [ "$2" -gt 0 ]; then
THRESHOLD="$2"
elif [ $# -ne 0 ]; then
cat >&2 <<-EOF
Usage:
$0 [-t threshold]
EOF
exit 1
fi
find @prefix@/expinfo -depth 4 -name activity.log -mtime +"$THRESHOLD" \
-print | sed 's/.activity.log$//' | \
( while read DIRNAME; do
echo -n "Compressing $DIRNAME... "
tar cy -C "$DIRNAME/.." -f "${DIRNAME}.tar.bz2" \
`basename "$DIRNAME"` && \
chown `stat -f %u "$DIRNAME"` "${DIRNAME}.tar.bz2" && \
rm -rf "$DIRNAME"
echo done
done )
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