diff mbox

[OSSTEST,15/35] pxe templates: Do defaulting outside host_pxefile

Message ID 1484914764-20861-16-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Jan. 20, 2017, 12:19 p.m. UTC
host_pxefile now returns undef if the specified $templatekey is not
configured, rather than defaulting to the plain PxeTemplates.

This is going to useful because we want host_pxefile not to hardcode
the default: with netgrub, the settings are all different.

If $templatekey is 'PxeTemplates' then this only has any effect if the
PxeTempltes is not defined - ie, a broken case.

There is one place where $templatekey is not 'PxeTemplates', in
mg-hosts.  The defaulting to the value of PxeTemplates now occurs there.

So, overall, no functional change in non-broken cases.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 3 ++-
 mg-hosts               | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 888f0ac..4c6a677 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -2370,7 +2370,8 @@  sub host_pxefile ($;$) {
     my ($ho, $templatekey) = @_;
     my %v = %r;
     $templatekey //= 'PxeTemplates';
-    my $templates = $ho->{Tftp}{$templatekey} || $ho->{Tftp}{PxeTemplates};
+    my $templates = $ho->{Tftp}{$templatekey};
+    return undef unless defined $templates;
     if (defined $ho->{Ether}) {
 	my $eth = $v{'ether'} = $ho->{Ether};
 	$eth =~ y/A-Z/a-z/;
diff --git a/mg-hosts b/mg-hosts
index f785454..ed51952 100755
--- a/mg-hosts
+++ b/mg-hosts
@@ -120,6 +120,7 @@  sub cmd_mkpxedir () {
         my $ho= selecthost("host=$hn");
 	my $pxefile = host_pxefile($ho);
 	my $pxerealfile = host_pxefile($ho, 'PxeTemplatesReal');
+	$pxerealfile //= $pxefile;
 	my $dirname = dirname $pxefile;
 	my $cmd = <<END;
             set -e