Commit 793e28c8 authored by Leigh Stoller's avatar Leigh Stoller

Several small tweaks to the parser to make it easier to convert to

geni-lib in the ns2rspec path.
parent 2c6e7053
# -*- tcl -*- # -*- tcl -*-
# #
# Copyright (c) 2012-2015 University of Utah and the Flux Group. # Copyright (c) 2012-2016 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -329,6 +329,7 @@ Blockstore instproc finalize {} { ...@@ -329,6 +329,7 @@ Blockstore instproc finalize {} {
# XXX # XXX
set attributes(class) "SAN" set attributes(class) "SAN"
set attributes(protocol) "iSCSI" set attributes(protocol) "iSCSI"
set attributes(leasename) $leasename
} }
# Make sure the blockstore has class... # Make sure the blockstore has class...
......
...@@ -45,10 +45,11 @@ sub usage() ...@@ -45,10 +45,11 @@ sub usage()
exit(-1); exit(-1);
} }
my $optlist = "nqapc"; my $optlist = "nqapcr";
my $anonmode = 0; my $anonmode = 0;
my $passmode = 0; my $passmode = 0;
my $impotent = 0; my $impotent = 0;
my $rspecmode= 0;
my $debug = 0; my $debug = 0;
my $catout = 0; my $catout = 0;
...@@ -140,18 +141,19 @@ if (defined($options{"p"})) { ...@@ -140,18 +141,19 @@ if (defined($options{"p"})) {
if (defined($options{"c"})) { if (defined($options{"c"})) {
$catout = 1; $catout = 1;
} }
if (@ARGV != 4 && @ARGV != 1) { if (defined($options{"r"})) {
usage(); $rspecmode = 1;
} }
if (@ARGV == 1) { if (@ARGV == 1) {
$nsfile = $ARGV[0]; $nsfile = $ARGV[0];
} }
else { else {
$pid = $ARGV[0]; $pid = shift(@ARGV);
$gid = $ARGV[1]; $gid = shift(@ARGV);
$eid = $ARGV[2]; if (@ARGV == 2) {
$nsfile= $ARGV[3]; $eid = shift(@ARGV);
}
$nsfile= shift(@ARGV);
} }
# #
...@@ -171,12 +173,6 @@ if (defined($pid)) { ...@@ -171,12 +173,6 @@ if (defined($pid)) {
else { else {
die("Bad data in argument: $pid."); die("Bad data in argument: $pid.");
} }
if ($eid =~ /^([-\w]+)$/) {
$eid = $1;
}
else {
die("Bad data in argument: $eid.");
}
if ($gid =~ /^([-\w]+)$/) { if ($gid =~ /^([-\w]+)$/) {
$gid = $1; $gid = $1;
} }
...@@ -184,12 +180,22 @@ if (defined($pid)) { ...@@ -184,12 +180,22 @@ if (defined($pid)) {
die("Bad data in argument: $gid."); die("Bad data in argument: $gid.");
} }
# Slowly convert to new libraries ... if (defined($eid)) {
$experiment = Experiment->Lookup($pid, $eid); if ($eid =~ /^([-\w]+)$/) {
if (! defined($experiment)) { $eid = $1;
tbdie("Cannot find the experiment object for $pid/$eid"); }
else {
die("Bad data in argument: $eid.");
}
$experiment = Experiment->Lookup($pid, $eid);
if (! defined($experiment)) {
tbdie("Cannot find the experiment object for $pid/$eid");
}
$exptidx = $experiment->idx();
}
else {
$eid = "ignore";
} }
$exptidx = $experiment->idx();
} }
# Remove temps cause of swapin by alternates. # Remove temps cause of swapin by alternates.
...@@ -245,6 +251,8 @@ $cmdargs .= " -q" ...@@ -245,6 +251,8 @@ $cmdargs .= " -q"
if (defined($options{"q"})); if (defined($options{"q"}));
$cmdargs .= " -p" $cmdargs .= " -p"
if ($passmode); if ($passmode);
$cmdargs .= " -r"
if ($rspecmode);
$cmdargs .= " $pid $gid $eid" $cmdargs .= " $pid $gid $eid"
if (!$anonmode); if (!$anonmode);
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
# -a anonymous mode: do not do project related checks. Turns on impotent # -a anonymous mode: do not do project related checks. Turns on impotent
# mode (-n). # mode (-n).
# -p pass mode: Similar to anonymous mode, except that the parser *will* # -p pass mode: Similar to anonymous mode, except that the parser *will*
# spit out the parse results. # spit out the parse results.
# -r rspecmode.
###################################################################### ######################################################################
proc usage {} { proc usage {} {
...@@ -137,6 +138,7 @@ variable verbose 1 ...@@ -137,6 +138,7 @@ variable verbose 1
variable impotent 0 variable impotent 0
variable anonymous 0 variable anonymous 0
variable passmode 0 variable passmode 0
variable rspecmode 0
variable vtype_list {} variable vtype_list {}
} }
...@@ -155,6 +157,9 @@ while {$argv != {}} { ...@@ -155,6 +157,9 @@ while {$argv != {}} {
} elseif {$arg == "-p"} { } elseif {$arg == "-p"} {
lpop argv lpop argv
set GLOBALS::passmode 1 set GLOBALS::passmode 1
} elseif {$arg == "-r"} {
lpop argv
set GLOBALS::rspecmode 1
} else { } else {
break break
} }
......
...@@ -496,6 +496,7 @@ Simulator instproc run {} { ...@@ -496,6 +496,7 @@ Simulator instproc run {} {
var_import ::GLOBALS::irfile var_import ::GLOBALS::irfile
var_import ::GLOBALS::ran var_import ::GLOBALS::ran
var_import ::GLOBALS::impotent var_import ::GLOBALS::impotent
var_import ::GLOBALS::rspecmode
var_import ::GLOBALS::passmode var_import ::GLOBALS::passmode
var_import ::GLOBALS::vtypes var_import ::GLOBALS::vtypes
var_import ::GLOBALS::uselatestwadata var_import ::GLOBALS::uselatestwadata
...@@ -663,7 +664,7 @@ Simulator instproc run {} { ...@@ -663,7 +664,7 @@ Simulator instproc run {} {
} }
# If we are running in impotent mode we stop here # If we are running in impotent mode we stop here
if {$impotent == 1 && $passmode == 0} {return} if {$impotent == 1 && $passmode == 0 && $rspecmode == 0} {return}
$self spitxml_init $self spitxml_init
......
...@@ -710,6 +710,7 @@ proc tb-set-node-os {node os {parentos 0}} { ...@@ -710,6 +710,7 @@ proc tb-set-node-os {node os {parentos 0}} {
if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode} && if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode} &&
([regexp {^(ftp|http|https):} $os] == 0) } { ([regexp {^(ftp|http|https):} $os] == 0) } {
var_import ::TBCOMPAT::osids var_import ::TBCOMPAT::osids
var_import ::GLOBALS::pid
# Look for :version in the name. # Look for :version in the name.
set osid $os set osid $os
...@@ -720,6 +721,22 @@ proc tb-set-node-os {node os {parentos 0}} { ...@@ -720,6 +721,22 @@ proc tb-set-node-os {node os {parentos 0}} {
perror "\[tb-set-node-os] Invalid osid $os." perror "\[tb-set-node-os] Invalid osid $os."
return return
} }
#
# Always qualify the name if there is one in the current project.
#
if { ${GLOBALS::rspecmode} } {
if { ! [regexp {/} $os] } {
set pos = "$pid/$osid"
if { [info exists osids($pos)]} {
$osid = $pos
} else {
set pos = "emulab-ops/$osid"
if { [info exists osids($pos)]} {
$osid = $pos
}
}
}
}
if {$parentos != {} && $parentos != 0} { if {$parentos != {} && $parentos != 0} {
# Look for :version in the name. # Look for :version in the name.
set posid $parentos set posid $parentos
......
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