]> xenbits.xensource.com Git - people/iwj/colo-for-testing.git/commitdiff
convert-cabinet-layout: --only, etc.
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 9 Mar 2015 17:53:33 +0000 (17:53 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 9 Mar 2015 17:53:33 +0000 (17:53 +0000)
convert-cabinet-layout

index ea2e8a754a7a422946d126a59be18b3c1d7df2d5..6ec5b1d2d942f416083c19b1771e514b01898f65 100755 (executable)
@@ -5,6 +5,15 @@
 #
 # * Run
 #      ./convert-cabinet-layout "COLO Cabinet Layout.csv";
+#
+# * Paste the output in appropriate places
+#
+# Options:
+#   --only TEXT       TEXT should be a piece of text containing,
+#                     perhaps amongst other things, machine names
+#                     to output.  TEXT will be subjected to
+#                     =~ m/\b$hostname\b/ for each host $hostname
+#                     and output for that host ignored if no match.
 
 use strict;
 use Text::CSV;
@@ -12,10 +21,15 @@ use Text::CSV;
 use Data::Dumper;
 
 open DEBUG, ">/dev/null";
+our $only;
 
 while (@ARGV && $ARGV[0] =~ m/^-/) {
     $_ = shift @ARGV;
     last if m/^\-\-?$/;
+    if (s/^--only=//) {
+        $only = $_;
+        next;
+    }
     for (;;) {
         last unless m/^-./;
         if (s/^-D/-/) {
@@ -52,10 +66,11 @@ sub reportno ($) {
 
 our %dests;
 our %outfor;
+our $ndests=0;
 
 sub outfor ($$) {
     my ($dest,$s) = @_;
-    $dests{$dest} //= %dests;
+    $dests{$dest} //= $ndests++;
     $outfor{$dest} .= $s;
 }
 
@@ -72,6 +87,10 @@ while (my $row = $csv->getline_hr($fh)) {
     next unless $machine =~ m/^([a-z]+) ([0-1])$/;
     $machine = $1.$2;
 
+    if (defined $only) {
+        next unless $only =~ m/\b$machine\b/;
+    }
+
     print "# $machine\n";
 
     eval {