Commit 8e188686 authored by Leigh Stoller's avatar Leigh Stoller

A little script to remove a node from being used by protogeni and

the resource mapper. To add a node restriction:

boss> node_exclude pcXXX

To remove the restriction:

boss> node_exclude -r pcXXX
parent f609481c
......@@ -52,7 +52,8 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
addvpubaddr imageinfo ctrladdr image_import \
prereserve_check tcppd addexternalnetwork \
update_sitevars delete_image sitecheckin sitecheckin_client \
mktestbedtest fixrootcert addservers poolmonitor
mktestbedtest fixrootcert addservers poolmonitor \
node_exclude
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
webwanodecheckin webspewimage webdumpdescriptor \
......
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use English;
use Getopt::Std;
use strict;
#
# Exclude a node form protogeni.
#
sub usage()
{
print "Usage: node_exclude [-r] ...\n";
print "Options:\n";
print " -r Remove restriction\n";
exit(-1);
}
my $optlist = "r";
my $debug = 0;
my $undo = 0;
#
# Configure variables
#
my $TB = "@prefix@";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libtestbed;
use emdb;
use EmulabConstants;
use Node;
my $TBOPSPID = EmulabConstants::TBOPSPID();
#
# Function prototypes
#
sub fatal($);
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"r"})) {
$undo = 1;
}
usage()
if (@ARGV != 1);
my $node = Node->Lookup($ARGV[0]);
if (!defined($node)) {
fatal("No such node!");
}
my $node_id = $node->node_id();
if ($undo) {
DBQueryFatal("delete from node_attributes ".
"where node_id='$node_id' and ".
" (attrkey='protogeni_exclude' or ".
" attrkey='allowed_projects')");
}
else {
DBQueryFatal("replace into node_attributes set ".
" node_id='$node_id', ".
" attrkey='protogeni_exclude', attrvalue='Yep'");
DBQueryFatal("replace into node_attributes set ".
" node_id='$node_id', ".
" attrkey='allowed_projects', attrvalue='$TBOPSPID'");
}
exit(0);
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