Commit e04c69a5 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

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

parents 6d45b88d 26e5b9d6
......@@ -23,7 +23,7 @@ use libdb;
sub usage() {
print STDOUT "Usage: inuse [-a | -t type] [-p pid [-e eid]] [-s|-r] " .
"[-f|-F] [-h] [-R]\n";
"[-f|-F] [-h] [-R] [-u feature | -U feature]\n";
print STDOUT " -h This message\n";
print STDOUT " -a Print all nodes (default: only PCs\n";
print STDOUT " -t type Limit to nodes of type (or class)\n";
......@@ -34,9 +34,11 @@ sub usage() {
print STDOUT " -f Include free nodes\n";
print STDOUT " -F Include ONLY free nodes\n";
print STDOUT " -R Only include pre-reserved nodes\n";
print STDOUT " -u feature Only include nodes with the given feature\n";
print STDOUT " -U feature Exclude nodes with the given feature\n";
exit (-1);
}
my $optlist = "t:p:e:srafFhR";
my $optlist = "t:p:e:srafFhRu:U:";
my @columns = ("n.node_id","n.type","pid","eid","reserved_pid");
......@@ -50,7 +52,8 @@ if (@ARGV != 0 || $opt{h}) {
# Check for mutually exclusive options or ones that must go together
if (($opt{s} && $opt{r}) || ($opt{e} && !$opt{p}) ||
($opt{a} && $opt{t}) || ($opt{f} && $opt{F})) {
($opt{a} && $opt{t}) || ($opt{f} && $opt{F}) ||
($opt{u} && $opt{U})) {
usage();
}
......@@ -92,6 +95,24 @@ if ($opt{p}) {
}
}
if ($opt{u} || $opt{U}) {
my $feature = defined($opt{u}) ? $opt{u} : $opt{U};
my $subquery = "(".
"EXISTS (SELECT * FROM node_features AS nf " .
" WHERE nf.node_id = n.node_id " .
" AND feature = '$feature') " .
" OR " .
"EXISTS (SELECT * FROM node_type_features AS ntf " .
" WHERE ntf.type = n.type " .
" AND feature = '$feature') " .
")";
if (defined($opt{u})) {
push @whereclauses, $subquery;
} else {
push @whereclauses, "NOT $subquery";
}
}
my $whereclause = "";
if (@whereclauses) {
$whereclause = "where " . join(" and ",map {"($_)"} @whereclauses);
......@@ -105,6 +126,7 @@ if ($opt{s}) {
$sortclause = "order by rsrv_time,priority";
}
my $columns = join(",",@columns);
my $result = DBQueryFatal("select $columns from nodes as n " .
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2003-2010 University of Utah and the Flux Group.
# Copyright (c) 2003-2011 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -510,6 +510,12 @@ Phase "ssh", "Allowing root ssh", sub {
AppendToFileFatal($SSHD_CONFIG,
"PermitRootLogin yes",
"Protocol 2,1");
# HUP the server so the changes take effect
if (-r "/var/run/sshd.pid") {
my $dpid = `cat /var/run/sshd.pid`;
chomp($dpid);
ExecQuiet("kill -HUP $dpid");
}
};
Phase "dotssh", "Making root's .ssh directory", sub {
DoneIfExists("/root/.ssh");
......
......@@ -1057,6 +1057,12 @@ Phase "ssh", "Allowing root ssh", sub {
AppendToFileFatal($SSHD_CONFIG,
"PermitRootLogin yes",
"Protocol 2,1");
# HUP the server so the changes take effect
if (-r "/var/run/sshd.pid") {
my $dpid = `cat /var/run/sshd.pid`;
chomp($dpid);
ExecQuiet("kill -HUP $dpid");
}
};
Phase "dotssh", "Making root's .ssh directory", sub {
DoneIfExists("/root/.ssh");
......
......@@ -401,6 +401,7 @@ main(int argc, char **argv)
ClientLogInit();
#ifdef MASTER_SERVER
if (imageid) {
struct in_addr pif;
GetReply reply;
int method = askonly ? MS_METHOD_ANY : xfermethods;
int timo = 5; /* XXX */
......@@ -418,7 +419,7 @@ main(int argc, char **argv)
if (!ClientNetFindServer(ntohl(serverip.s_addr),
portnum, host, imageid,
method, askonly, timo,
&reply, NULL))
&reply, &pif))
fatal("Could not get download info for '%s'",
imageid);
......@@ -442,6 +443,14 @@ main(int argc, char **argv)
mcastaddr.s_addr = htonl(reply.addr);
portnum = reply.port;
/*
* Unless the user explicitly specified the interface
* to use, default to the one on which we got a
* response from the server.
*/
if (mcastif.s_addr == 0)
mcastif = pif;
if (serverip.s_addr == mcastaddr.s_addr)
log("%s: address: %s:%d",
imageid, inet_ntoa(mcastaddr), portnum);
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2005, 2006 University of Utah and the Flux Group.
* Copyright (c) 2005-2011 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -126,7 +126,7 @@ dumphash(struct hashinfo *hinfo)
*/
static int
hash_and_cmp(int infd,
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *),
int hashlen, struct hashregion *hashreg, int num_reg)
{
......@@ -412,7 +412,7 @@ hashmap_compute_delta(struct range *curranges, char *hfile, int infd,
uint32_t gapstart, gapsize, lastdrangeend = 0;
unsigned int hashlen;
unsigned char *(*hashfunc)(const unsigned char *,
unsigned long, unsigned char *);
size_t, unsigned char *);
struct range dummy_head, *range_tail;
struct hashregion *hreg, *ereg;
char *hashstr;
......
......@@ -367,11 +367,8 @@ addhash(struct hashinfo **hinfop, int chunkno, uint32_t start, uint32_t size,
int nreg;
if (report) {
static int first = 1;
printf("%s\t%u\t%u\t%u\tU\t%s\n",
spewhash(hash, hashlen), start, size, chunkno,
first ? fileid : "-");
first = 0;
spewhash(hash, hashlen), start, size, chunkno, fileid);
return;
}
......@@ -523,7 +520,7 @@ checkhash(char *name, struct hashinfo *hinfo)
struct hashregion *reg;
int chunkno;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
char *hashstr;
readbuf_t *rbuf;
......@@ -863,7 +860,7 @@ hashchunk(int chunkno, char *chunkbufp, struct hashinfo **hinfop)
z_stream z;
int err, nreg;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
readbuf_t *rbuf;
int errors = 0;
......@@ -1101,7 +1098,7 @@ hashfilechunk(int chunkno, char *chunkbufp, int chunksize,
int resid;
uint32_t cursect = 0, nbytes;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
unsigned char *bufp = (unsigned char *)chunkbufp;
int errors = 0;
......
......@@ -36,6 +36,7 @@ use snmpit_remote;
# Protos
sub parseStatusString($);
sub filterList($$);
sub debug($);
sub doListVlans($);
sub doListPorts($);
......@@ -107,6 +108,8 @@ General:
given multiple times
-S <stack> Operate on the given stack, instead of the default of the
experimental network
--skip-supplied If the -S option was given, start with the default stacks,
but skip any switches in the stacks listed in -S.
--redirect-err Redirect STDERR to STDOUT, for easier capturing in logfiles
VLAN Control:
......@@ -187,7 +190,7 @@ GetOptions(\%opt,
'y=s','x=s','z=s','F','L=s','O', 'D', 'R', 'f', 'X', 'Z', 'vlan_tag=i',
'of-disable=s', 'of-enable=s', 'of-controller=s', 'of-listener=s',
'o=s@{1,1}', 'redirect-err', 'blockmode', 'syncvlans', 'impotent',
'shadow');
'shadow', 'skip-supplied');
if ($opt{h}) {
exit &usage;
......@@ -545,6 +548,13 @@ if (!@commands) {
#
# User-supplied switch lists
#
# See if we should we flip the behavior of -S and -i ?
my $skip_supplied = 0;
if ($opt{'skip-supplied'} && $opt{S}) {
$skip_supplied = 1;
}
my @supplied_switches = ();
my @supplied_stacks = ();
my $supplied_switches = 0; # Whether -i or -S was given
......@@ -687,17 +697,18 @@ COMMAND: foreach my $command (@commands) {
SWITCH: for ($operation) {
(/listvlans/ || /getstats/ || /vlannumber/ || /synchleader/ ||
/syncvlans/) && do {
@devicenames = $supplied_switches?
@devicenames = ($supplied_switches && !$skip_supplied)?
@supplied_switches : getTestSwitches();
last;
};
(/listports/) && do {
@devicenames = $supplied_switches? @supplied_switches :
(@ports? getDeviceNames(@ports) : getTestSwitches());
@devicenames = ($supplied_switches && !$skip_supplied)?
@supplied_switches :
(@ports? getDeviceNames(@ports) : getTestSwitches());
last;
};
( /make/ ) && do {
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
@devicenames = @supplied_switches;
} elsif (@ports) {
# Have to operate on whole stacks so that trunks work
......@@ -714,7 +725,7 @@ COMMAND: foreach my $command (@commands) {
# vlan from the db
# if others fail, default to experimental switches
my ($vlan_name) = @args;
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
debug("Remove: using supplied switches\n");
@devicenames = @supplied_switches;
}
......@@ -749,7 +760,7 @@ COMMAND: foreach my $command (@commands) {
if (!$quiet);
next COMMAND;
}
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
debug("Tables: using supplied switches\n");
@devicenames = @supplied_switches;
@vlans = filterVlansBySwitches(\@supplied_switches, @vlans);
......@@ -764,6 +775,17 @@ COMMAND: foreach my $command (@commands) {
debug("Tables: list from database: " . join(",",@devicenames) .
"\n");
}
if ($skip_supplied) {
debug("Tables: skipping supplied switches\n");
@devicenames = filterList(\@devicenames,\@supplied_switches);
@vlans = filterVlansBySwitches(\@devicenames, @vlans);
if (!@devicenames || !@vlans) {
print "snmpit: $pid/$eid has no VLANs to create ".
"on skip-filtered device list, skipping\n"
if (!$quiet);
next COMMAND;
}
}
if (scalar(@devicenames == 0)) {
debug("Tables: falling back to test swtiches\n");
@devicenames = getTestSwitches();
......@@ -795,7 +817,7 @@ COMMAND: foreach my $command (@commands) {
"created on switches\n ... skipping\n";
next COMMAND;
}
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
debug("Reset: using supplied switches\n");
@devicenames = @supplied_switches;
@vlans = filterVlansBySwitches(\@supplied_switches, @vlans);
......@@ -811,6 +833,18 @@ COMMAND: foreach my $command (@commands) {
"\n");
}
if ($skip_supplied) {
debug("Reset: skipping supplied switches\n");
@devicenames = filterList(\@devicenames,\@supplied_switches);
@vlans = filterVlansBySwitches(\@devicenames, @vlans);
if (!@devicenames || !@vlans) {
print "snmpit: $pid/$eid has no VLANs to reset ".
"on skip-filtered device list, skipping\n"
if (!$quiet);
next COMMAND;
}
}
# Fallthrough - if we haven't found any switches yet, operate
# on the whole experimetnal net
if (scalar(@devicenames) == 0) {
......@@ -826,7 +860,7 @@ COMMAND: foreach my $command (@commands) {
my @oldvlans;
VLan->StaleVlanList($experiment,\@oldvlans);
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
die("-X and -i cannot be used together\n");
}
else {
......@@ -835,6 +869,19 @@ COMMAND: foreach my $command (@commands) {
debug("Sync: list from database: " . join(",",@devicenames) .
"\n");
}
if ($skip_supplied) {
debug("Sync: skipping supplied switches (dangerous!)\n");
@devicenames = filterList(\@devicenames,\@supplied_switches);
@vlans = filterVlansBySwitches(\@devicenames, @vlans);
if (!@devicenames || !@vlans) {
print "snmpit: $pid/$eid has no VLANs to sync ".
"on skip-filtered device list, skipping\n"
if (!$quiet);
next COMMAND;
}
}
# Fallthrough - if we haven't found any switches yet, operate
# on the whole experimental net
if (scalar(@devicenames) == 0) {
......@@ -844,7 +891,7 @@ COMMAND: foreach my $command (@commands) {
last;
};
(/portcontrol/ || /trunkdisable/ || /portstatus/) && do {
@devicenames = $supplied_switches?
@devicenames = ($supplied_switches && !$skip_supplied)?
@supplied_switches : getDeviceNames(@ports);
last;
};
......@@ -857,14 +904,14 @@ COMMAND: foreach my $command (@commands) {
# Safety check - cannot be used with -i . We have to operate on
# all experimental switches
#
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
die "-c and -i or -S cannot be used together\n";
}
@devicenames = getTestSwitches();
last;
};
(/trunkenable/) && do {
@devicenames = $supplied_switches?
@devicenames = ($supplied_switches && !$skip_supplied)?
@supplied_switches : getDeviceNames(@ports);
@vlans = @optvlanids;
last;
......@@ -881,7 +928,7 @@ COMMAND: foreach my $command (@commands) {
if ($args{vlan}) {
@vlans = ($args{vlan});
}
@devicenames = $supplied_switches?
@devicenames = ($supplied_switches && !$skip_supplied)?
@supplied_switches : getDeviceNames(@ports);
@args = %args;
last;
......@@ -891,7 +938,7 @@ COMMAND: foreach my $command (@commands) {
# Same to 'remove', we find stacks by VLAN
my ($vlanobj, $stack);
if ($supplied_switches) {
if ($supplied_switches && !$skip_supplied) {
debug("Openflow operations: using supplied switches\n");
@devicenames = @supplied_switches;
} elsif (defined($experiment) &&
......@@ -907,6 +954,13 @@ COMMAND: foreach my $command (@commands) {
};
}
#
# No matter what operation we're doing, we're safe to filter the
# devicenames list now!
#
@devicenames = filterList(\@devicenames,\@supplied_switches)
if ($skip_supplied);
debug("Device names: " . join(",",@devicenames) . "\n");
debug("Ports: " . join(",", map($_->toIfaceString(), @ports)) . "\n");
......@@ -3386,7 +3440,28 @@ sub doTrunkDisable($$) {
if (!$errors);
return $errors;
}
#
# Simple little list filtering util function.
#
sub filterList($$) {
my ($srclist,$filterlist) = @_;
my @retval = ();
foreach my $item (@$srclist) {
my $found = 0;
foreach my $filter (@$filterlist) {
if ($item eq $filter) {
$found = 1;
last;
}
}
push @retval, $item
if (!$found);
}
return @retval;
}
#
# Openflow lock and functions
......
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