Skip to content

Commit

Permalink
[Fixes issue: 343] Adding capability to set bootloader filename by pr…
Browse files Browse the repository at this point in the history
…ofile

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.
  • Loading branch information
MS-Daniel-Matolcsi committed May 24, 2024
1 parent fd0feaf commit 0459d0d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
16 changes: 16 additions & 0 deletions aii-core/src/main/perl/Shellfe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}) };
Expand Down
19 changes: 17 additions & 2 deletions aii-dhcp/src/main/perl/dhcp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}
Expand Down Expand Up @@ -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};
Expand All @@ -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";
Expand All @@ -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')) {
Expand Down

0 comments on commit 0459d0d

Please sign in to comment.