Commit 72aa7bec authored by Robert Ricci's avatar Robert Ricci
Browse files

Merge remote-tracking branch 'origin/master' into current

parents 103e0385 2ed3cc0b
......@@ -85,7 +85,7 @@ endif
#
# For installation on boss node
#
boss-install: install-checks install-branchcheck \
boss-install: install-checks \
install-subdirs install-mkdirs \
install-setbuildinfo
@echo "Boss node installed!"
......@@ -95,19 +95,19 @@ boss-install-force: install-subdirs install-mkdirs install-setbuildinfo
@echo "Boss node installed!"
# Skip only the schema checks, but do the other checks.
boss-install-noschemacheck: install-updatecheck install-branchcheck \
boss-install-noschemacheck: install-updatecheck \
install-sitevarscheck install-dbfillcheck \
install-genischemacheck install-subdirs install-mkdirs \
install-setbuildinfo
# Skip the update check.
boss-install-noupdatecheck: install-schemacheck install-branchcheck \
boss-install-noupdatecheck: install-schemacheck \
install-sitevarscheck install-dbfillcheck \
install-genischemacheck install-subdirs install-mkdirs \
install-setbuildinfo
# Only the checks:
install-checks: install-branchcheck \
install-checks: \
install-updatecheck \
install-schemacheck \
install-sitevarscheck \
......
......@@ -109,7 +109,7 @@ default-clean:
rm -f GNUmakefile
# This is to avoid warnings about duplicate targets.
default-install:
default-install-notusing:
ifeq ($(ISMAINSITE),1)
ifeq ($(TBROOT),/usr/testbed/devel/stoller)
(cd $(SRCDIR) ; \
......@@ -121,7 +121,7 @@ else
/usr/bin/true
endif
install: default-install
#install: default-install
#
# Where to find source files.
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -42,15 +42,16 @@ use Getopt::Std;
#
sub usage()
{
print("Usage: tbacct [-f] [-b] [-u] ".
print("Usage: tbacct [-f] [-b] [-u] [-v] ".
"<add|del|mod|passwd|wpasswd|email|freeze|thaw|verify|revoke|dots> ".
"<user> [args]\n");
exit(-1);
}
my $optlist = "fbu";
my $optlist = "fbuv";
my $force = 0;
my $batch = 0;
my $update = 0;
my $verified= 0;
#
# Configure variables
......@@ -203,6 +204,9 @@ if (defined($options{"b"})) {
if (defined($options{"u"})) {
$update = 1;
}
if (defined($options{"v"})) {
$verified = 1;
}
if (@ARGV < 2) {
usage();
}
......@@ -926,7 +930,7 @@ sub UpdateEmail()
#
# Only admin people can do this.
#
if (! TBAdmin($UID)) {
if (!TBAdmin($UID) && !$verified) {
fatal("You do not have permission to update email for user $user.");
}
......
......@@ -316,6 +316,13 @@ my $tmp = APT_Profile::SetSites(\$rspecstr, $sitemap, $default_aggregate_urn,
if ($tmp) {
($tmp < 0 ? fatal($errmsg) : UserError($errmsg));
}
#
# Yep, this can happen when users do not put any nodes in their rspec.
#
if (!@aggregate_urns) {
UserError("There are no nodes in your experiment, syntax error?");
}
# but do not override command line force.
$usestitcher = 1 if ($needstitcher);
......
......@@ -1788,6 +1788,12 @@ sub StartMonitorInternal(;$)
sub DoLockdownInternal($$)
{
my ($setclr,$which) = @_;
# The web interface (and in the future the xmlrpc interface) sets this.
my $this_user = User->ImpliedUser();
if (! defined($this_user)) {
$this_user = User->ThisUser();
}
my $slice = $instance->GetGeniSlice();
if (!defined($slice)) {
......@@ -1820,6 +1826,24 @@ sub DoLockdownInternal($$)
my $coderef = sub {
my ($sliver) = @_;
#
# We cannot do lockdown at AL2S. More generally, it only works at
# Emulab based aggregates, but we do not talk to other aggregates.
#
if ($sliver->ISAL2S()) {
return 0
if ($clear);
my $project = $instance->GetProject();
$project->SendEmail($this_user->email(),
"Failed to completely lock down APT Instance",
"Failed to completely lock down $instance,\n".
"cause it crosses AL2S.\n\n".
$instance->webURL() . "\n",
$project->OpsEmailAddress(),
"CC: " . $project->OpsEmailAddress());
return 0;
}
my $response = $sliver->Lockdown($clear);
if (!defined($response)) {
print STDERR "RPC Error calling Lockdown\n";
......
/*
* Copyright (c) 2000-2014 University of Utah and the Flux Group.
* Copyright (c) 2000-2016 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -476,9 +476,10 @@ event_main(event_handle_t handle)
if (handle->mainloop(handle->server, &handle->do_loop, &handle->status)) {
ERROR("Event mainloop failed: ");
pubsub_error_fprintf(stderr, &handle->status);
handle->do_loop = 0;
return 0;
}
handle->do_loop = 0;
return 1;
}
......
#!/usr/bin/perl -w
#
# Copyright (c) 2004-2013 University of Utah and the Flux Group.
# Copyright (c) 2004-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -233,5 +233,5 @@ sub doreconfig()
#
sub docleanup()
{
doaction("reset", @bootscripts);
doaction("reset", reverse(@bootscripts));
}
#!/usr/bin/perl -w
#
# Copyright (c) 2004-2015 University of Utah and the Flux Group.
# Copyright (c) 2004-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -118,27 +118,7 @@ SWITCH: for ($action) {
last SWITCH;
};
/^reset$/i && do {
#
# XXX this should be docleanup(3), but we have not implemented
# the nasty temporary removal of LVM/ZFS/etc state from the
# imageable filesystems for local blockstores.
#
# So for now we just do a shutdown. This will do the right thing
# for SAN-based blockstores which only use traditional filesystem
# mounts (i.e., no volume manager) and thus have no local disk
# state (as SAN mounts do not appear in /etc/fstab).
#
# It is also the right thing for the local SYSVOL case in which
# you want the blockstore to be included in the image.
#
# It is not correct for other blockstores, where you will get
# partial state in the image (e.g., in /etc/lvm or /etc/zfs).
#
# The moral is: if you are going to do a custom image, you should
# only use persistent SAN-based blockstores or create a SYSVOL local
# blockstore and take a whole-disk image!
#
docleanup(0);
docleanup(3);
last SWITCH;
};
# XXX non-standard, for debugging
......@@ -524,7 +504,21 @@ sub docleanup($)
fatal("Could not retrieve stashed storage config!");
}
if ($doteardown) {
#
# XXX the $dolocal is a quick hack to ensure that when we are
# doing a reconfig/reset ala:
# rc.storageremote reset
# rc.storagelocal reset
# that we don't remove the OLDCONFIG until the end. Otherwise
# we would not reconfig/reset the local blockstores because there
# would be no config when we reached rc.storagelocal! This relies
# heavily on the ordering of the two scripts in rc.config and the
# fact that we reverse that list of scripts when we shutdown.
# We use this hack below as well where we remove STORAGEMAP and
# DISKINFO. Note that the storage state will be inconsistent between
# removing the remote and local storage, but we can live with that.
#
if ($doteardown && $dolocal) {
unlink($OLDCONFIG);
}
}
......@@ -540,8 +534,16 @@ sub docleanup($)
}
}
if ($doteardown == 2) {
print "Forcing teardown of storage, ignore errors...\n";
my $msg = "";
if ($dolocal && !$doremote) {
$msg = "local ";
} elsif (!$dolocal && $doremote) {
$msg = "remote ";
}
if ($doteardown == 1 || $doteardown == 2) {
print "Forcing teardown of ${msg}storage, volatile blockstores WILL BE DESTROYED...\n";
} elsif ($doteardown == 3) {
print "Clearing ${msg}storage config from root filesystem, volatile blockstores will be preserved...\n";
}
my @cmds = ();
......@@ -578,7 +580,10 @@ sub docleanup($)
system("/bin/kill `cat $bsapidfile`");
}
unlink($STORAGEMAP, $DISKINFO);
# XXX see XXX comment above.
if ($dolocal) {
unlink($STORAGEMAP, $DISKINFO);
}
}
#
......@@ -755,7 +760,9 @@ sub process($$$$)
print "unmounted " . $href->{'MOUNTPOINT'} .
($doteardown ? " and " : " ");
}
if ($doteardown) {
if ($doteardown == 3) {
print "deactivated $dev";
} elsif ($doteardown) {
print "destroyed $dev";
}
print "\n";
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2013-2015 University of Utah and the Flux Group.
# Copyright (c) 2013-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -453,6 +453,27 @@ sub get_zpool_datasets($)
return @dsets;
}
#
# Return a list of names of active (mounted) datasets in the given pool.
# Returns an empty list if there is not such pool or no datasets.
#
sub get_zpool_active_datasets($)
{
my ($pool) = @_;
my @dsets = ();
if (open(FD, "$ZFS get -Hr -o name,value mounted $pool 2>/dev/null|")) {
while (<FD>) {
if (/^($pool\/\S+)\s+yes/) {
push(@dsets, $1);
}
}
close(FD);
}
return @dsets;
}
#
# Returns 1 if the volume manager has been initialized.
# For ZFS this means that the "emulab" zpool exists.
......@@ -466,6 +487,15 @@ sub is_lvm_initialized($)
if (mysystem("$ZPOOL list emulab >/dev/null 2>&1") == 0) {
return 1;
}
#
# zpool may not exist if we are rebooting after a "reset";
# in that case the pool will have been exported.
# Try an import to bring it back.
#
if (mysystem("$ZPOOL import emulab >/dev/null 2>&1") == 0) {
return 1;
}
} else {
if (get_vinum_drives() > 0) {
return 1;
......@@ -625,6 +655,7 @@ sub get_diskinfo($)
#
if ($usezfs) {
my @vdevs = get_zpool_vdevs("emulab");
foreach my $dev (@vdevs) {
if (exists($geominfo{$dev}) && $geominfo{$dev}{'type'} eq "DISK") {
$geominfo{$dev}{'inuse'} = 1;
......@@ -692,9 +723,9 @@ sub get_diskinfo($)
# See if this is a filesystem type we can deal with.
# If so, return the type suitable for use by fsck and mount.
#
sub get_fstype($$;$)
sub get_fstype($$;$$)
{
my ($href,$dev,$rwref) = @_;
my ($href,$dev,$rwref,$silent) = @_;
my $type = "";
#
......@@ -767,18 +798,70 @@ sub get_fstype($$;$)
if ($rwref) {
$$rwref = 0;
}
if ($FBSD_VERSION < 10) {
return undef;
if ($FBSD_VERSION >= 10) {
return "ext2fs";
}
return "ext2fs";
}
if (!$silent) {
my $lv = $href->{'VOLNAME'};
if ($type) {
warn("*** $lv: unsupported FS ($type) on $dev\n");
} else {
warn("*** $lv: unknown or no FS on $dev\n");
}
}
if ($rwref) {
$$rwref = 0;
}
return undef;
}
#
# Check that the device for a blockstore has a valid filesystem by
# fscking it. If $fixit is zero, run the fsck RO just to report if
# the filesystem is there and consistent, otherwise attempt to fix it.
# $redir is a redirect string for output of the fsck command.
#
# Returns 1 if all is well, 0 otherwise.
#
sub checkfs($$$)
{
my ($href,$fixit,$redir) = @_;
my $lv = $href->{'VOLNAME'};
my $mdev = $href->{'LVDEV'};
# determine the filesystem type
my $fstype = get_fstype($href, $mdev);
if (!$fstype) {
return 0;
}
my $fopt = "-p";
if (!$fixit || $href->{'PERMS'} eq "RO") {
$fopt = "-n";
}
#
# Note that we invoke EXT fsck directly as the FBSD 10.x
# era port does not install everything correctly for use
# by "fsck -t ext2fs".
#
my $FSCK = $BSD_FSCK;
if ($fstype eq "ext2fs" && -x "$EXT_FSCK") {
$FSCK = $EXT_FSCK;
} else {
$fopt .= " -t $fstype";
}
if (mysystem("$FSCK $fopt $mdev $redir")) {
warn("*** $lv: fsck of $mdev failed\n");
return 0;
}
return 1;
}
#
# Handle one-time operations.
# Return a cookie (object) with current state of storage subsystem.
......@@ -1132,34 +1215,26 @@ sub os_check_storage_element($$)
#
my $mpoint = $href->{'MOUNTPOINT'};
if ($mpoint) {
my $line = `$MOUNT | grep '^/dev/$dev on '`;
if (!$line) {
my $mopt = "";
my $fopt = "-p";
my $mdev = $href->{'LVDEV'};
my $mopt = "";
my $line = `$MOUNT | grep '^$mdev on '`;
if (!$line) {
# determine the filesystem type
my $rw = 0;
my $fstype = get_fstype($href, "/dev/$dev", \$rw);
my $fstype = get_fstype($href, $mdev, \$rw);
if (!$fstype) {
if (exists($href->{'FSTYPE'})) {
warn("*** $bsid: unsupported FS (".
$href->{'FSTYPE'}.
") on /dev/$dev\n");
} else {
warn("*** $bsid: unknown FS on /dev/$dev\n");
}
return -1;
}
# check for RO export and adjust options accordingly
if ($href->{'PERMS'} eq "RO") {
$mopt = "-o ro";
$fopt = "-n";
}
# OS only supports RO mounting, right now we just fail
elsif ($rw == 0) {
warn("*** $bsid: OS only supports RO mounting of ".
$href->{'FSTYPE'}. " FSes\n");
"$fstype FSes\n");
return -1;
}
......@@ -1169,35 +1244,28 @@ sub os_check_storage_element($$)
return -1;
}
#
# fsck it in case of an abrupt shutdown.
#
# Note that we invoke EXT fsck directly as the FBSD 10.x
# era port does not install everything correctly for use
# by "fsck -t ext2fs".
#
my $FSCK = $BSD_FSCK;
if ($fstype eq "ext2fs" && -x "$EXT_FSCK") {
$FSCK = $EXT_FSCK;
} else {
$fopt .= " -t $fstype";
}
if (mysystem("$FSCK $fopt /dev/$dev $redir")) {
warn("*** $bsid: fsck of /dev/$dev failed\n");
# fsck the filesystem in case of an abrupt shutdown.
if (!checkfs($href, 1, $redir)) {
return -1;
}
if (mysystem("$MOUNT $mopt -t $fstype /dev/$dev $mpoint $redir")) {
warn("*** $bsid: could not mount /dev/$dev on $mpoint\n");
# and mount it
if (mysystem("$MOUNT $mopt -t $fstype $mdev $mpoint $redir")) {
warn("*** $bsid: could not mount $mdev on $mpoint\n");
return -1;
}
}
elsif ($line !~ /^\/dev\/$dev on (\S+) / || $1 ne $mpoint) {
elsif ($line !~ /^${mdev} on (\S+) / || $1 ne $mpoint) {
warn("*** $bsid: mounted on $1, should be on $mpoint\n");
return -1;
}
}
# XXX set the fstype for reporting
if (!exists($href->{'FSTYPE'})) {
get_fstype($href, "/dev/$dev");
}
return 1;
}
......@@ -1329,24 +1397,65 @@ sub os_check_storage_slice($$)
return -1;
}
$href->{'FSTYPE'} = "zfs";
} else {
my $line = `$MOUNT | grep '^/dev/$mdev on '`;
if (!$line && mysystem("$MOUNT $mpoint")) {
goto done;
}
my $line = `$MOUNT | grep '^/dev/$mdev on '`;
if (!$line) {
#
# See if the mount exists in /etc/fstab.
#
# XXX Right now if it does not, it might be because we
# removed it prior to creating an image. So we make some
# additional sanity checks (right now fsck'ing the alleged FS)
# and if it passes, re-add the mount line.
#
$line = `grep '^/dev/$mdev\[\[:space:\]\]' /etc/fstab`;
if (!$line) {
warn("*** $lv: mount of /dev/$mdev missing from fstab; sanity checking and re-adding\n");
my $fstype = get_fstype($href, "/dev/$mdev");
if (!$fstype) {
return -1;
}
# XXX sanity check, is there a recognized FS on the dev?
# XXX checkfs needs LVDEV set
$href->{'LVDEV'} = "/dev/$mdev";
if (!checkfs($href, 0, "")) {
undef $href->{'LVDEV'};
return -1;
}
undef $href->{'LVDEV'};
if (!open(FD, ">>/etc/fstab")) {
warn("*** $lv: could not add mount to /etc/fstab\n");
return -1;
}
print FD "# /dev/$mdev added by $BINDIR/rc/rc.storage\n";
print FD "/dev/$mdev\t$mpoint\t$fstype\trw\t2\t2\n";
close(FD);
}
if (mysystem("$MOUNT $mpoint")) {
warn("*** $lv: is not mounted, should be on $mpoint\n");
return -1;
}
if ($line && ($line !~ /^\/dev\/$mdev on (\S+) / || $1 ne $mpoint)) {
} else {
if ($line !~ /^\/dev\/$mdev on (\S+) / || $1 ne $mpoint) {
warn("*** $lv: mounted on $1, should be on $mpoint\n");
return -1;
}
$href->{'FSTYPE'} = "ufs";
}
$href->{'FSTYPE'} = "ufs";
}
if ($devtype ne "ZFS") {
$mdev = "/dev/$mdev";
}
$href->{'LVDEV'} = "$mdev";
done:
# XXX set the fstype for reporting
if (!exists($href->{'FSTYPE'})) {
get_fstype($href, $mdev);
}
$href->{'LVDEV'} = $mdev;
return 1;
}
......@@ -1403,46 +1512,27 @@ sub os_create_storage($$)
#
if ($href->{'CLASS'} eq "SAN" && $href->{'PROTO'} eq "iSCSI" &&
$href->{'PERSIST'} != 0) {
# determine the filesystem type
# check for the easy errors first, before time consuming fsck
my $rw = 0;
$fstype = get_fstype($href, $mdev, \$rw);
if (!$fstype) {
if (exists($href->{'FSTYPE'})) {
warn("*** $lv: unsupported FS (".
$href->{'FSTYPE'}.
") on $mdev\n");
} else {
warn("*** $lv: unknown FS on $mdev\n");
}
return 0;
}
# check for RO export and adjust options accordingly
# check for RO export and adjust mount options accordingly
if ($href->{'PERMS'} eq "RO") {
$mopt = "-o ro";
$fopt = "-n";
}
# OS only supports RO mounting, right now we just fail
elsif ($rw == 0) {
warn("*** $lv: OS only supports RO mounting of ".
$href->{'FSTYPE'}. " FSes\n");
"$fstype FSes\n");
return 0;
}