Commit 7d0f59e6 authored by Leigh Stoller's avatar Leigh Stoller

Two sets of minor changes.

* In the parser, make -n (impotent) and -a (anonymous) more
  independent. Used to be that -n required -a, but that makes the
  preparse less useful, since it cannot catch project related errors
  (like bad osids, or node type permissions), and so the user does not
  get that until the email message later. Thats so annoying, even Mike
  whined about it.

  Note that impotent mode is sorta misnamed now, since the parse never
  operates on the DB. Rather, impotent mode now skips doing the XML
  output phase (still aptly named updateDB!).

* Add -p (pass) option. I added this for my script that was parsing
  all the old NS files to get renderings. In this case, I do not want
  -n or -a; I want to upload the results into the DB, but the project
  related checks are obviously going to fail since I was doing it
  inside the testbed project. So, -p turns on some of the anon checks,
  and later might be used to turn certain features that are no longer
  supported, since all we really care about is the toplology (some NS
  files failed on old features and syntax).

Upon reflection I think these three options could probably be rolled
into just two, by cleaning up the current impotent and anonymous
flags.
parent eec36584
......@@ -20,7 +20,7 @@ sub usage()
die("Usage: batchexp [-i [-f]] [-x expires] [-E description] [-g gid] ".
"[-s] [-n low|high] -p <pid> -e <eid> [<nsfile>]\n");
}
my $optlist = "iE:d:g:x:e:p:sn:f";
my $optlist = "iE:d:g:x:e:p:sn:fgq";
#
# Configure variables
......@@ -42,6 +42,7 @@ my $startexp = "$TB/bin/startexp";
my $tbdata = "tbdata";
my $immediate= 0;
my $frontend = 0;
my $quiet = 0;
my $dbuid;
my @row;
......@@ -233,7 +234,7 @@ chmod(0664, "$nsfile");
# Run parse in impotent mode on the NS file. This has no effect but
# will display any errors.
#
if (system("$parser -n -a $nsfile") != 0) {
if (system("$parser -n $pid $gid $eid $nsfile") != 0) {
fatal("NS Parse failed!");
}
......@@ -263,9 +264,13 @@ if ($nsfile_string) {
# so that the batch daemon will see it and act.
#
if ($immediate) {
my $farg = ($frontend ? "-f" : "");
my $optargs = "";
$optargs .= " -f"
if ($frontend);
$optargs .= " -b"
if ($quiet);
if (system("$startexp $farg -g $gid $pid $eid $nsfile")) {
if (system("$startexp $optargs -g $gid $pid $eid $nsfile")) {
fatal("Failed to start experiment $pid/$eid!");
}
}
......@@ -392,6 +397,9 @@ sub ParseArgs()
if (defined($options{"s"})) {
$swappable = 1;
}
if (defined($options{"q"})) {
$quiet = 1;
}
if (defined($options{"n"})) {
if ($options{"n"} eq "low") {
$priority = TB_EXPTPRIORITY_LOW;
......
......@@ -25,8 +25,9 @@ sub usage()
exit(-1);
}
my $optlist = "nqa";
my $optlist = "nqap";
my $anonmode = 0;
my $passmode = 0;
my $impotent = 0;
my $debug = 0;
......@@ -97,6 +98,9 @@ if (defined($options{"a"})) {
if (defined($options{"n"})) {
$impotent = 1;
}
if (defined($options{"p"})) {
$passmode = 1;
}
if (@ARGV != 4 && @ARGV != 1) {
usage();
}
......@@ -172,15 +176,17 @@ system("cat $nsfile >> $infile") == 0
# result back to a file if not in anonmode. Remember to tack on the
# user ID to flip to, when not in testmode.
#
my $cmdargs = "$TB/libexec/ns2ir/parse.proxy";
my $cmdargs = "$TB/libexec/ns2ir/parse.proxy ";
$cmdargs .= " -u $dbuid"
if (defined($dbuid));
$cmdargs .= " -a"
if (defined($options{"a"}));
if ($anonmode);
$cmdargs .= " -n"
if (defined($options{"n"}));
$cmdargs .= " -q"
if (defined($options{"q"}));
$cmdargs .= " -p"
if ($passmode);
$cmdargs .= " $pid $gid $eid"
if (!$anonmode);
......
......@@ -16,11 +16,21 @@
# See README for extensive discussion of the structure and
# implementation.
#
# -q will supress all the unsupported messages.
# -n will cause the parser to output error/warning messages and exit
# without updating the database.
# -q quiet mode: supress all the unsupported messages.
# -n impotent mode: parser will output error/warning messages and exit
# without spitting out the actual parse results.
# -a anonymous mode: do not do project related checks. Turns on impotent
# mode (-n).
# -p pass mode: Similar to anonymous mode, except that the parser *will*
# spit out the parse results.
######################################################################
proc usage {} {
puts stderr "Syntax: $argv0 \[-q\] -a ns_file"
puts stderr " $argv0 \[-q\] \[-p\] \[-n\] pid gid eid ns_file"
exit 1
}
# Initial Procedures
###
......@@ -109,6 +119,7 @@ namespace eval GLOBALS {
variable verbose 1
variable impotent 0
variable anonymous 0
variable passmode 0
variable vtype_list {}
}
......@@ -123,22 +134,19 @@ while {$argv != {}} {
} elseif {$arg == "-a"} {
lpop argv
set GLOBALS::anonymous 1
set GLOBALS::impotent 1
} elseif {$arg == "-p"} {
lpop argv
set GLOBALS::passmode 1
} else {
break
}
}
if {${GLOBALS::anonymous} && ! ${GLOBALS::impotent}} {
puts stderr "-a can only be used with -n."
exit 1
}
if {${GLOBALS::anonymous} && ([llength $argv] != 1)} {
puts stderr "Syntax: $argv0 \[-q\] -n -a ns_file"
exit 1
usage();
} elseif {(! ${GLOBALS::anonymous}) && ([llength $argv] != 4)} {
puts stderr "Syntax: $argv0 \[-q\] \[-n \[-a\]\] pid gid eid ns_file"
exit 1
usage();
}
# Now we can set up the rest of our global variables.
......
......@@ -127,7 +127,7 @@ proc tb-set-hardware {node type args} {
perror "\[tb-set-hardware] Invalid hardware type $type."
return
}
if {! ${GLOBALS::anonymous}} {
if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode}} {
var_import ::TBCOMPAT::nodetypeXpid_permissions
var_import ::GLOBALS::pid
set allowed 1
......@@ -157,7 +157,7 @@ proc tb-set-hardware {node type args} {
}
proc tb-set-node-os {node os} {
if {! ${GLOBALS::anonymous}} {
if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode}} {
var_import ::TBCOMPAT::osids
if {! [info exists osids($os)]} {
perror "\[tb-set-node-os] Invalid osid $os."
......
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