]> xenbits.xensource.com Git - people/iwj/colo-for-testing.git/commitdiff
convert-cabinet-layout: Refactor flags
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 12 Mar 2015 14:01:28 +0000 (14:01 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 12 Mar 2015 14:01:28 +0000 (14:01 +0000)
convert-cabinet-layout

index 89187273c681c8bfc872e76d17d004347683ba2a..82246d02fec7b7474ef2f5870062376cbb94c045 100755 (executable)
@@ -115,18 +115,20 @@ while (my $row = csv_row()) {
 
 csv_start($ARGV[0]);
 
+our %hflaghosts;
+
 while (my $row = csv_row()) {
     print DEBUG Dumper($row);
 
     $machine = $row->{'Server / Appliance'};
 
-    my @kindflags;
+    my @hflags;
 
     if ($machine =~ m/^([a-z]+) ([0-1])$/) {
         my $kind = $1;
         $machine = $1.$2;
         my $kindhvm = $kindhvm{$kind} or die "$kind ?";
-        push @kindflags, "equiv-$kind", "hvm-$kindhvm";
+        push @hflags, "equiv-$kind", "hvm-$kindhvm";
     } else {
         next;
     }
@@ -135,9 +137,6 @@ while (my $row = csv_row()) {
         next unless $only =~ m/\b$machine\b/;
     }
 
-    outfor "mg-hosts equiv",
-    "./mg-hosts setflags $machine -- @kindflags\n";
-
     print "# $machine\n";
 
     push @machines, $machine;
@@ -177,6 +176,8 @@ while (my $row = csv_row()) {
             $ttyrp, $machine;
     };
     reportno 'Serial';
+
+    push @{ $hflaghosts{ join " ", sort @hflags } }, $machine;
 }
 
 if (defined $createlike) {
@@ -189,6 +190,12 @@ if (@flags) {
     "./mg-hosts setflags @machines -- @flags\n";
 }
 
+foreach my $hflags (sort keys %hflaghosts) {
+    my $machines = join " ", @{ $hflaghosts{$hflags} };
+    outfor "mg-hosts hflags",
+    "./mg-hosts setflags $machines -- $hflags\n";
+}
+
 csv_end();
 
 foreach my $dest (sort { $dests{$a} <=> $dests{$b} } keys %dests) {