]> xenbits.xensource.com Git - people/royger/osstest.git/commitdiff
mg-hosts mknetbootdir: Introduce and require -F<firmware>
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 29 Aug 2019 09:12:44 +0000 (10:12 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Mon, 30 Sep 2019 10:52:43 +0000 (11:52 +0100)
If one runs
  ./mg-hosts mknetbootdir HOST
before having sorted out all the host configuration, it uses the
default configuration value for the host's firmware kind, which is
"bios".  If the configuration is then changed, things don't work.
This is confusing.

So ask the user to specify one or more -F<firmware>, or -Fany.

CC: Dominic Brekau <dominic.brekau@credativ.de>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
mg-hosts

index d68f7b4ee8ca33e8dee90a61a896642eb3e56859..14f816ae2218873e394e50ea4af6b8c80d90e236 100755 (executable)
--- a/mg-hosts
+++ b/mg-hosts
@@ -19,7 +19,7 @@
 
 # Usages:
 #
-#  ./mg-hosts mknetbootdir HOST...
+#  ./mg-hosts mknetbootdir -Fany | -F<firmware>... HOST...
 #               Create directories for netboot as expected by the rest
 #               of osstest.  Will use "sudo". The HOST(s) must be
 #               allocated (via mg-allocate HOST).
@@ -121,19 +121,29 @@ sub l ($) { return split /,/, $_[0]; }
 
 sub cmd_mknetbootdir () {
     my $dryrun = 0;
+    my %expect_firmware;
     while (@ARGV && $ARGV[0] =~ m/^-/) {
        $_ = shift @ARGV;
        last if $_ =~ m/^--?$/;
        while (m/^-./) {
            if (s/^-n/-/) { $dryrun= 1; }
+           elsif (s/^-F(.*)//) { $expect_firmware{$1} = 1 }
            else { die "unknown mknetbootdir option $_"; }
        }
     }
+    die "need at least one -F<firmware> or -Fany option"
+       unless %expect_firmware;
     die unless @ARGV>=1;
     my $sudo = $ENV{'OSSTEST_SUDO'} // 'sudo';
     foreach my $hn (@ARGV) {
         my $ho= selecthost("host=$hn");
        my ($dir, $file) = host_netboot_file($ho);
+       if (!$expect_firmware{any}) {
+           my $got_firmware = get_host_property($ho, "firmware");
+           die
+ "host $hn configuration says firmware \`$got_firmware', not as expected\n"
+               unless $expect_firmware{$got_firmware};
+       }
         die unless defined $dir;
        my ($rdir, $realfile) = host_netboot_file($ho, 'TemplatesReal');
        $realfile //= $file;