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 -*-
#
# Copyright (c) 2012-2015 University of Utah and the Flux Group.
# Copyright (c) 2012-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -329,6 +329,7 @@ Blockstore instproc finalize {} {
# XXX
set attributes(class) "SAN"
set attributes(protocol) "iSCSI"
set attributes(leasename) $leasename
}
# Make sure the blockstore has class...
......
......@@ -45,10 +45,11 @@ sub usage()
exit(-1);
}
my $optlist = "nqapc";
my $optlist = "nqapcr";
my $anonmode = 0;
my $passmode = 0;
my $impotent = 0;
my $rspecmode= 0;
my $debug = 0;
my $catout = 0;
......@@ -140,18 +141,19 @@ if (defined($options{"p"})) {
if (defined($options{"c"})) {
$catout = 1;
}
if (@ARGV != 4 && @ARGV != 1) {
usage();
if (defined($options{"r"})) {
$rspecmode = 1;
}
if (@ARGV == 1) {
$nsfile = $ARGV[0];
}
else {
$pid = $ARGV[0];
$gid = $ARGV[1];
$eid = $ARGV[2];
$nsfile= $ARGV[3];
$pid = shift(@ARGV);
$gid = shift(@ARGV);
if (@ARGV == 2) {
$eid = shift(@ARGV);
}
$nsfile= shift(@ARGV);
}
#
......@@ -171,12 +173,6 @@ if (defined($pid)) {
else {
die("Bad data in argument: $pid.");
}
if ($eid =~ /^([-\w]+)$/) {
$eid = $1;
}
else {
die("Bad data in argument: $eid.");
}
if ($gid =~ /^([-\w]+)$/) {
$gid = $1;
}
......@@ -184,12 +180,22 @@ if (defined($pid)) {
die("Bad data in argument: $gid.");
}
# Slowly convert to new libraries ...
$experiment = Experiment->Lookup($pid, $eid);
if (! defined($experiment)) {
tbdie("Cannot find the experiment object for $pid/$eid");
if (defined($eid)) {
if ($eid =~ /^([-\w]+)$/) {
$eid = $1;
}
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.
......@@ -245,6 +251,8 @@ $cmdargs .= " -q"
if (defined($options{"q"}));
$cmdargs .= " -p"
if ($passmode);
$cmdargs .= " -r"
if ($rspecmode);
$cmdargs .= " $pid $gid $eid"
if (!$anonmode);
......
......@@ -39,7 +39,8 @@
# -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.
# spit out the parse results.
# -r rspecmode.
######################################################################
proc usage {} {
......@@ -137,6 +138,7 @@ variable verbose 1
variable impotent 0
variable anonymous 0
variable passmode 0
variable rspecmode 0
variable vtype_list {}
}
......@@ -155,6 +157,9 @@ while {$argv != {}} {
} elseif {$arg == "-p"} {
lpop argv
set GLOBALS::passmode 1
} elseif {$arg == "-r"} {
lpop argv
set GLOBALS::rspecmode 1
} else {
break
}
......
......@@ -496,6 +496,7 @@ Simulator instproc run {} {
var_import ::GLOBALS::irfile
var_import ::GLOBALS::ran
var_import ::GLOBALS::impotent
var_import ::GLOBALS::rspecmode
var_import ::GLOBALS::passmode
var_import ::GLOBALS::vtypes
var_import ::GLOBALS::uselatestwadata
......@@ -663,7 +664,7 @@ Simulator instproc run {} {
}
# 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
......
......@@ -710,6 +710,7 @@ proc tb-set-node-os {node os {parentos 0}} {
if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode} &&
([regexp {^(ftp|http|https):} $os] == 0) } {
var_import ::TBCOMPAT::osids
var_import ::GLOBALS::pid
# Look for :version in the name.
set osid $os
......@@ -720,6 +721,22 @@ proc tb-set-node-os {node os {parentos 0}} {
perror "\[tb-set-node-os] Invalid osid $os."
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} {
# Look for :version in the name.
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