Support noderange of form: f[1-2]n[1-10]

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7796 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
bp-sawyers 2010-10-09 01:32:07 +00:00
parent 4a8e507141
commit 87f3d02381
2 changed files with 24 additions and 7 deletions

View File

@ -277,20 +277,28 @@ sub expandatom { #TODO: implement table selection as an atom (nodetype.os==rhels
return(@nodes);
}
if ($atom =~ m/(.*)\[(.*)\](.*)/) { # square bracket range
#for the time being, we are only going to consider one [] per atom
#xcat 1.2 does no better
if ($atom =~ m/(.+?)\[(.+?)\](.*)/) { # square bracket range
# if there are more than 1 [], we picked off just the 1st. if there is another, we will process it later
my @subelems = split(/([\,\-\:])/,$2);
my $subrange="";
my $subelem;
my $start = $1;
my $ending = $3;
my $morebrackets = $ending =~ /\[.+?\]/; # if there are more brackets, we have to expand just the 1st part, then add the 2nd part later
while (scalar @subelems) {
my $subelem = shift @subelems;
my $subop=shift @subelems;
$subrange=$subrange."$1$subelem$3$subop";
$subrange=$subrange."$start$subelem" . ($morebrackets?'':$ending) . "$subop";
}
foreach (split /,/,$subrange) {
my @newnodes=expandatom($_,$verify);
@nodes=(@nodes,@newnodes);
my @newnodes=expandatom($_, ($morebrackets?0:$verify));
if (!$morebrackets) { push @nodes,@newnodes; }
else {
# for each of the new nodes, add the 2nd brackets and then expand
foreach my $n (@newnodes) {
push @nodes, expandatom("$n$ending", $verify);
}
}
}
return @nodes;
}
@ -398,8 +406,8 @@ sub expandatom { #TODO: implement table selection as an atom (nodetype.os==rhels
}
}
push @$missingnodes,$atom;
if ($verify) {
push @$missingnodes,$atom;
return ();
} else {
return ($atom);

View File

@ -14,6 +14,8 @@ I<Examples:>
node[14-56]
f[1-3]n[1-20]
all,-node129-node256,-frame01-frame03
/node.*
@ -48,6 +50,7 @@ A range of nodes or groups:
node[01-10] (same as above)
node01:node10 (same as above)
node[01:10] (same as above)
f[1-2]n[1-3] (equivalent to: f1n1,f1n2,f1n3,f2n1,f2n2,f2n3)
group1-group3 (equivalent to: group1,group2,group3)
(all the permutations supported above for nodes are also supported for groups)
@ -224,6 +227,12 @@ attribute.
nodehm.cons=~hmc
=item 9.
Generate a list of nodes in the 1st two frames:
f[1-2]n[1-42]
=back