This is an automated email from the ASF dual-hosted git repository. jfthomps pushed a commit to branch VCL-1117_server_reservation_Linux_fixed_IP in repository https://gitbox.apache.org/repos/asf/vcl.git
commit e677172c330a4ff09f97a44c0042a7702fe5a39b Author: Josh Thompson <jftho...@ncsu.edu> AuthorDate: Fri Mar 22 14:16:50 2019 -0400 VCL-1117 - vcld fails to set fixed IP address for Linux server reservations if management node not set to static OS.pm: modified update_fixed_ip_info: added return for successful case; if fail to set router, netmask, or dns_servers, ensure returned value will be 0 Linux.pm: modified update_resolv_conf: added check for processing server request, and if so, use dns server info from it instead of failing if management node ip configuration is not set to static --- managementnode/lib/VCL/Module/OS.pm | 10 +++++---- managementnode/lib/VCL/Module/OS/Linux.pm | 34 ++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/managementnode/lib/VCL/Module/OS.pm b/managementnode/lib/VCL/Module/OS.pm index 2b74bf0..24bacca 100644 --- a/managementnode/lib/VCL/Module/OS.pm +++ b/managementnode/lib/VCL/Module/OS.pm @@ -4444,12 +4444,14 @@ sub update_fixed_ip_info { my $router = $server_variable_data->{router}; my $netmask = $server_variable_data->{netmask}; my @dns = @{$server_variable_data->{dns}}; + + my $return = 1; - notify($ERRORS{'OK'}, 0, "updated data server request router info") if ($self->data->set_server_request_router($server_variable_data->{router})); - notify($ERRORS{'OK'}, 0, "updated data server request netmask info") if ($self->data->set_server_request_netmask($server_variable_data->{netmask})); - notify($ERRORS{'OK'}, 0, "updated data server request dns info") if ($self->data->set_server_request_dns_servers(@{$server_variable_data->{dns}})); + notify($ERRORS{'OK'}, 0, "updated data server request router info") or $return = 0 if ($self->data->set_server_request_router($server_variable_data->{router})); + notify($ERRORS{'OK'}, 0, "updated data server request netmask info") or $return = 0 if ($self->data->set_server_request_netmask($server_variable_data->{netmask})); + notify($ERRORS{'OK'}, 0, "updated data server request dns info") or $return = 0 if ($self->data->set_server_request_dns_servers(@{$server_variable_data->{dns}})); notify($ERRORS{'DEBUG'}, 0, "router= $router, netmask= $netmask, dns= @dns"); - + return $return; } else { notify($ERRORS{'DEBUG'}, 0, "data is not set for $variable_name"); diff --git a/managementnode/lib/VCL/Module/OS/Linux.pm b/managementnode/lib/VCL/Module/OS/Linux.pm index 4fd61b1..4620b6a 100644 --- a/managementnode/lib/VCL/Module/OS/Linux.pm +++ b/managementnode/lib/VCL/Module/OS/Linux.pm @@ -6699,20 +6699,30 @@ sub update_resolv_conf { notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method"); return; } - + my $computer_name = $self->data->get_computer_short_name(); my $public_ip_configuration = $self->data->get_management_node_public_ip_configuration(); - my @public_dns_servers = shift || $self->data->get_management_node_public_dns_servers(); - - if ($public_ip_configuration !~ /static/i) { - notify($ERRORS{'WARNING'}, 0, "unable to update resolv.conf on $computer_name, management node's IP configuration is set to $public_ip_configuration"); - return; + my @mn_dns_servers = shift || $self->data->get_management_node_public_dns_servers(); + + my @server_request_dns_servers = $self->data->get_server_request_dns_servers(); + + my @dns_servers; + if (@server_request_dns_servers) { + @dns_servers = @server_request_dns_servers; + notify($ERRORS{'DEBUG'}, 0, "server request specific DNS servers will be statically set on $computer_name: " . join(", ", @dns_servers)); } - elsif (!@public_dns_servers) { - notify($ERRORS{'WARNING'}, 0, "unable to update resolv.conf on $computer_name, DNS server argument was not provided and management node's public DNS server is not configured"); + elsif ($public_ip_configuration =~ /static/i && @mn_dns_servers) { + @dns_servers = @mn_dns_servers; + notify($ERRORS{'DEBUG'}, 0, "management node IP configuration set to $public_ip_configuration, management node DNS servers will be statically set on $computer_name: " . join(", ", @dns_servers)); + } + else { + notify($ERRORS{'WARNING'}, 0, "$computer_name not configured to use static DNS servers:\n" . + "management node IP configuration : $public_ip_configuration\n" . + "management node DNS servers configured : " . (@mn_dns_servers ? 'yes' : 'no') + ); return; } - + my $resolv_conf_path = "/etc/resolv.conf"; my @resolv_conf_lines_existing = $self->get_file_contents($resolv_conf_path); @@ -6725,16 +6735,16 @@ sub update_resolv_conf { push @resolv_conf_lines_new, $line; } } - + # Add a comment marking what was added by VCL my $timestamp = POSIX::strftime("%m-%d-%Y %H:%M:%S", localtime); push @resolv_conf_lines_new, "# $timestamp: The following was added by VCL"; # Add a nameserver line for each configured DNS server - for my $public_dns_server (@public_dns_servers) { + for my $public_dns_server (@dns_servers) { push @resolv_conf_lines_new, "nameserver $public_dns_server"; } - + my $resolv_conf_contents_new = join("\n", @resolv_conf_lines_new); if ($self->create_text_file($resolv_conf_path, $resolv_conf_contents_new)) { notify($ERRORS{'DEBUG'}, 0, "updated $resolv_conf_path on $computer_name:\n$resolv_conf_contents_new");