[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 22/35] netboot: Break out subst_netboot_template



No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/TestSupport.pm | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index bb72fe5..990ddbc 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -116,6 +116,7 @@ BEGIN {
                       await_webspace_fetch_byleaf create_webfile
                       file_link_contents get_timeout
                       setup_netboot_di setup_netboot_local host_netboot_file
+                     subst_netboot_template
 
                       ether_prefix
 
@@ -2366,6 +2367,22 @@ sub file_link_contents ($$$) {
     logm("wrote $fn". (defined $stash ? " (stashed as $stash)" : ""));
 }
 
+sub subst_netboot_template ($$$) {
+    my ($templates, $v, $what) = (@_);
+    foreach my $pat (split /\s+/, $templates) {
+       # we skip patterns that contain any references to undefined %var%s
+       $pat =~ s{\%(\w*)\%}{
+                   $1 eq '' ? '%' :
+                   defined($v->{$1}) ? $v->{$1} :
+                   next;
+                }ge;
+       # and return the first pattern we managed to completely substitute
+        return $pat;
+    }
+    die "no netboot template ($what) matched $templates ".
+        (join ",", sort keys %$v)." ?";
+}
+
 sub host_netboot_file ($;$) {
     my ($ho, $templatekeytail) = @_;
     # returns the full netboot filename path
@@ -2394,18 +2411,8 @@ sub host_netboot_file ($;$) {
        $v{'ipaddr'} = $ip;
        $v{'ipaddrhex'} = sprintf "%02X%02X%02X%02X", split /\./, $ip;
     }
-    foreach my $pat (split /\s+/, $templates) {
-       # we skip patterns that contain any references to undefined %var%s
-       $pat =~ s{\%(\w*)\%}{
-                   $1 eq '' ? '%' :
-                   defined($v{$1}) ? $v{$1} :
-                   next;
-                }ge;
-       # and return the first pattern we managed to completely substitute
-        return wantarray ? ($dir,$pat) : $dir.$pat;
-    }
-    die "no netboot template ($templatekey) matched $templates ".
-        (join ",", sort keys %v)." ?";
+    my $got = subst_netboot_template($templates, \%v, $templatekey);
+    return wantarray ? ($dir,$got) : $dir.$got;
 }
 
 sub setup_netboot_bootcfg ($$) {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.