From 0a507ed5b2f880998d62947146e3488d42fab48d Mon Sep 17 00:00:00 2001 From: MS-Daniel-Matolcsi Date: Fri, 19 Apr 2024 11:58:57 +0000 Subject: [PATCH] [Fixes issue: 343] Adding capability to set bootloader filename by profile This commit adds the feature to aii-dhcp plugin to fetch bootloader filename for DHCP config to be included. Also handles situation if default bootloader may differ from the one would be used in case of rescue mode. --- aii-core/src/main/perl/Shellfe.pm | 16 ++++++++++++++++ aii-dhcp/src/main/perl/dhcp.pm | 19 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/aii-core/src/main/perl/Shellfe.pm b/aii-core/src/main/perl/Shellfe.pm index 80f9f44f..44010edb 100755 --- a/aii-core/src/main/perl/Shellfe.pm +++ b/aii-core/src/main/perl/Shellfe.pm @@ -577,6 +577,22 @@ sub run_plugin if ($plug->can('set_active_config')) { $plug->set_active_config($st->{configuration}); } + + my @params + if ($modulename eq "dhcp") { + if ($self->option("rescue") && $method eq CONFIGURE){ + $self->debug (4, "Setting params for DHCP plugin and rescue mode"); + @params = ($st->(configuration), "rescue"); + } + else { + $self->debug (4, "Setting params for DHCP plugin and non-rescue mode"); + @params = ($st ->(configuration), "none"); + } + } + else { + $self->debug (4, "Setting generic params"); + @params = ($st ->(configuration)); + } # The plugin method has to return success my $res = eval { $plug->$method ($st->{configuration}) }; diff --git a/aii-dhcp/src/main/perl/dhcp.pm b/aii-dhcp/src/main/perl/dhcp.pm index 6b408078..7173e5f2 100755 --- a/aii-dhcp/src/main/perl/dhcp.pm +++ b/aii-dhcp/src/main/perl/dhcp.pm @@ -138,7 +138,12 @@ sub update_dhcp_config_file push @newnodes, "$indent\t next-server $node->{ST_IP_TFTP};"; } - # additional options + # DHCP bootloader filename option + if ($node->{FILENAME}) { + push @newnodes, "$indent\t filename \"$node->{FILENAME}\";"; + } + + # additional options if ($node->{MORE_OPT}) { push @newnodes, "$indent\t $node->{MORE_OPT}"; } @@ -293,7 +298,7 @@ sub update_dhcp_config { # Adds the entry to dhcp sub Configure { - my ($self, $config) = @_; + my ($self, $config, $rescue) = @_; my $tree = $config->getElement("/system/network")->getTree(); my $fqdn = $tree->{hostname} . "." . $tree->{domainname}; @@ -315,9 +320,18 @@ sub Configure my $opts = $config->getElement("/system/aii/dhcp")->getTree(); my $tftpserver = ""; my $additional = ""; + my filename = ""; if ($opts->{tftpserver}) { $tftpserver = $opts->{tftpserver}; } + + if ($opts->(filename)) { + $filename = $opts->(filename); + } + if ($rescue eq 'rescue' && $opts->(rescue)) { + $filename = $opts->(rescue); + } + if ($opts->{options}) { foreach my $k (sort keys %{$opts->{options}}) { $additional .= "option $k $opts->{options}->{$k};\n"; @@ -331,6 +345,7 @@ sub Configure IP => unpack('N', Socket::inet_aton($ip)), MAC => $cards->{$bootable}->{hwaddr}, ST_IP_TFTP => $tftpserver, + FILENAME => $filename, MORE_OPT => $additional, }; if ($this_app->option('use_fqdn')) {