Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes issue: 343] Adding capability to set bootloader filename #344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it is not an elsif? It makes no point to set the filename to $opts->(filename) in rescue mode or did I miss something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a case when there's 'filename' set, and 'rescue' not, also if both 'filename' and 'rescue' are set.
I wanted to make sure if there's a 'filename' set, get it anyway, and if there's 'rescue' there as well, overwrite it.

$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