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

[Xen-devel] [OSSTEST PATCH 16/35] netboot: Rework interface to host_netboot_file (was host_pxefile)



* Now it takes the tail of the template key (currently, normally
  `Templates') rather than the whole of it (`PxeTemplates'); the
  `Pxe' part is implied.

* Now it normally returns the whole path, including PxeDir, which the
  caller is no longer expected to prepend.  In any case, it supplies
  the dir value.

* Rename it.

* All call sites adjusted.

Overall, no functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/TestSupport.pm | 20 +++++++++++++-------
 mg-hosts               |  6 +++---
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 4c6a677..54ff552 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -115,7 +115,7 @@ BEGIN {
 
                       await_webspace_fetch_byleaf create_webfile
                       file_link_contents get_timeout
-                      setup_pxeboot_di setup_pxeboot_local host_pxefile
+                      setup_pxeboot_di setup_pxeboot_local host_netboot_file
 
                       ether_prefix
 
@@ -2366,12 +2366,18 @@ sub file_link_contents ($$$) {
     logm("wrote $fn". (defined $stash ? " (stashed as $stash)" : ""));
 }
 
-sub host_pxefile ($;$) {
-    my ($ho, $templatekey) = @_;
+sub host_netboot_file ($;$) {
+    my ($ho, $templatekeytail) = @_;
+    # returns the full netboot filename path
+    # in array context, returns (dir, pathtail)
+    #  where dir does not depend on $templatekeytail
     my %v = %r;
-    $templatekey //= 'PxeTemplates';
+    my $templatekeybase = 'Pxe';
+    $templatekeytail //= 'Templates';
+    my $templatekey = $templatekeybase.$templatekeytail;
     my $templates = $ho->{Tftp}{$templatekey};
     return undef unless defined $templates;
+    my $dir = $ho->{Tftp}{$templatekeybase.'Dir'};
     if (defined $ho->{Ether}) {
        my $eth = $v{'ether'} = $ho->{Ether};
        $eth =~ y/A-Z/a-z/;
@@ -2396,7 +2402,7 @@ sub host_pxefile ($;$) {
                    next;
                 }ge;
        # and return the first pattern we managed to completely substitute
-        return $pat;
+        return wantarray ? ($dir,$pat) : $dir.$pat;
     }
     die "no pxe template ($templatekey) matched $templates ".
         (join ",", sort keys %v)." ?";
@@ -2404,8 +2410,8 @@ sub host_pxefile ($;$) {
 
 sub setup_pxelinux_bootcfg ($$) {
     my ($ho, $bootfile) = @_;
-    my $f= host_pxefile($ho);
-    file_link_contents("$ho->{Tftp}{Path}$ho->{Tftp}{PxeDir}$f", $bootfile,
+    my $f= host_netboot_file($ho);
+    file_link_contents("$ho->{Tftp}{Path}$f", $bootfile,
        hostnamepath($ho)."-pxelinux.cfg");
 }
 
diff --git a/mg-hosts b/mg-hosts
index ed51952..ed26df7 100755
--- a/mg-hosts
+++ b/mg-hosts
@@ -118,13 +118,13 @@ sub cmd_mkpxedir () {
     my $sudo = $ENV{'OSSTEST_SUDO'} // 'sudo';
     foreach my $hn (@ARGV) {
         my $ho= selecthost("host=$hn");
-       my $pxefile = host_pxefile($ho);
-       my $pxerealfile = host_pxefile($ho, 'PxeTemplatesReal');
+       my ($dir, $pxefile) = host_netboot_file($ho);
+       my ($rdir, $pxerealfile) = host_netboot_file($ho, 'TemplatesReal');
        $pxerealfile //= $pxefile;
        my $dirname = dirname $pxefile;
        my $cmd = <<END;
             set -e
-           cd $ho->{Tftp}{Path}$ho->{Tftp}{PxeDir}
+           cd $dir
 END
         $cmd .= <<END if $dirname ne '.';
            $sudo mkdir -p $dirname
-- 
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®.