From: Ian Jackson Date: Mon, 9 Mar 2015 17:53:33 +0000 (+0000) Subject: convert-cabinet-layout: --only, etc. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=50b5ee103771dfdffbcae8278867ceed98f04b6a;p=people%2Fiwj%2Fcolo-for-testing.git convert-cabinet-layout: --only, etc. --- diff --git a/convert-cabinet-layout b/convert-cabinet-layout index ea2e8a7..6ec5b1d 100755 --- a/convert-cabinet-layout +++ b/convert-cabinet-layout @@ -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 {