Author: arkurth
Date: Fri Apr 14 21:10:40 2017
New Revision: 1791416
URL: http://svn.apache.org/viewvc?rev=1791416&view=rev
Log:
VCL-1033
Improved Windows.pm::post_load to attempt to retrieve or set the public IP
before settings a persistent default route.
Added code in post_load if the retrieval failed and DHCP is used to call
'ipconfig /renew' and check again.
Cleaned up and modernized Windows.pm::ipconfig_renew.
Changed Version_6.pm::wait_for_response to check if the computer is a VM. If
so, the total wait time is reduced to 5 minutes from 10-30. If the wait time is
reached without a response, an attempt is made to call the provisioning
object's power_reset subroutine, then another response loop is attempted.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1791416&r1=1791415&r2=1791416&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Fri Apr 14 21:10:40
2017
@@ -828,24 +828,45 @@ sub post_load {
=item *
- Set persistent public default route
+ Update the public IP address
=cut
- if (!$self->set_public_default_route()) {
- notify($ERRORS{'WARNING'}, 0, "unable to set persistent public
default route");
+ if (!$self->update_public_ip_address()) {
+ my $public_ip_configuration =
$self->data->get_management_node_public_ip_configuration();
+ if ($public_ip_configuration =~ /dhcp/i) {
+ notify($ERRORS{'WARNING'}, 0, "computer should have
received a public IP address from DHCP but the address could not be determined,
attempting to execute 'ipconfig /renew'");
+
+ if (!$self->ipconfig_renew()) {
+ notify($ERRORS{'WARNING'}, 0, "public IP
address from DHCP but the address could not be determined, 'ipconfig /renew'
failed");
+ return;
+ }
+
+ # Try to update the public IP address again
+ if (!$self->update_public_ip_address()) {
+ notify($ERRORS{'WARNING'}, 0, "computer should
have received a public IP address from DHCP but the address could not be
determined on second attempt after executing 'ipconfig /renew'");
+ return;
+ }
+ else {
+ notify($ERRORS{'DEBUG'}, 0, "computer initially
failed to obtain a public IP address from DHCP, executed 'ipconfig /renew',
public IP address could then be determined");
+ }
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "management node failed
to set a static public IP address on the computer");
+ return;
+ }
}
-
+
=item *
- Update the public IP address
+ Set persistent public default route
=cut
- if (!$self->update_public_ip_address()) {
- notify($ERRORS{'WARNING'}, 0, "unable to retrieve or set the
public IP address");
+ if (!$self->set_public_default_route()) {
+ notify($ERRORS{'WARNING'}, 0, "unable to set persistent public
default route");
}
-
+
=item *
Configure and synchronize time
@@ -6277,7 +6298,7 @@ sub is_dhcp_enabled {
=head2 ipconfig_renew
- Parameters : $interface_name, $release_first (optional)
+ Parameters :
Returns :
Description :
@@ -6297,51 +6318,29 @@ sub ipconfig_renew {
delete $self->{public_interface_name};
delete $self->{private_interface_name};
- my $interface_name = shift;
- if (!$interface_name) {
- notify($ERRORS{'WARNING'}, 0, "interface name argument was not
supplied");
- return;
- }
- elsif ($interface_name =~ /^public$/i) {
- $interface_name = $self->get_public_interface_name() || return;
- }
- elsif ($interface_name =~ /^private$/i) {
- $interface_name = $self->get_private_interface_name() || return;
- }
-
- # Delete cached network configuration information again
- delete $self->{network_configuration};
- delete $self->{public_interface_name};
- delete $self->{private_interface_name};
-
- my $release_first = shift;
-
# Assemble the ipconfig command, include the interface name if argument
was specified
- my $ipconfig_command;
- if ($release_first) {
- $ipconfig_command = "$system32_path/ipconfig.exe /release
\"$interface_name\" ; ";
- }
- $ipconfig_command .= "$system32_path/ipconfig.exe /renew
\"$interface_name\"";
+ my $ipconfig_command = "$system32_path/ipconfig.exe /renew";
+ notify($ERRORS{'OK'}, 0, "attempting to renew IP configuration");
+ my ($ipconfig_status, $ipconfig_output) = $self->execute({
+ command => $ipconfig_command,
+ timeout => 65,
+ max_attempts => 1,
+ ignore_error => 1
+ });
- # Run ipconfig
- my ($ipconfig_status, $ipconfig_output) =
$self->execute({command => $ipconfig_command, timeout => 65, ignore_error =>
1});
- if (!defined($ipconfig_output)) {
- notify($ERRORS{'WARNING'}, 0, "failed to execute command to
renew IP configuration for interface '$interface_name'");
+ if (!defined($ipconfig_output)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to execute command to
renew IP configuration");
return;
- }
- elsif (grep(/error occurred/i, @$ipconfig_output)) {
- notify($ERRORS{'WARNING'}, 0, "failed to renew IP configuration
for interface '$interface_name', exit status: $ipconfig_status, output:\n" .
join("\n", @$ipconfig_output));
- return;
- }
- elsif ($ipconfig_status ne '0' || grep(/error occurred/i,
@$ipconfig_output)) {
- notify($ERRORS{'WARNING'}, 0, "failed to renew IP configuration
for interface '$interface_name', exit status: $ipconfig_status, command:
'$ipconfig_command', output:\n" . join("\n", @$ipconfig_output));
+ }
+ elsif ($ipconfig_status ne 0) {
+ notify($ERRORS{'WARNING'}, 0, "failed to renew IP
configuration, exit status: $ipconfig_status, output:\n" . join("\n",
@$ipconfig_output));
return;
- }
- else {
- notify($ERRORS{'OK'}, 0, "renewed IP configuration for
interface '$interface_name', output:\n" . join("\n", @$ipconfig_output));
- return 1;
- }
}
+ else {
+ notify($ERRORS{'OK'}, 0, "renewed IP configuration, output:\n"
. join("\n", @$ipconfig_output));
+ return 1;
+ }
+}
#/////////////////////////////////////////////////////////////////////////////
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm?rev=1791416&r1=1791415&r2=1791416&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm Fri Apr 14
21:10:40 2017
@@ -2030,8 +2030,12 @@ sub wait_for_response {
my $initial_delay_seconds;
my $ssh_response_timeout_seconds;
- if ($self->data->get_imagemeta_sysprep()) {
+ if ($self->data->get_computer_type() eq 'virtualmachine') {
$initial_delay_seconds = 5;
+ $ssh_response_timeout_seconds = 300;
+ }
+ elsif ($self->data->get_imagemeta_sysprep()) {
+ $initial_delay_seconds = 60;
$ssh_response_timeout_seconds = 1800;
}
else {
@@ -2039,8 +2043,23 @@ sub wait_for_response {
$ssh_response_timeout_seconds = 600;
}
- # Call parent class's wait_for_response subroutine
- return $self->SUPER::wait_for_response($initial_delay_seconds,
$ssh_response_timeout_seconds);
+ if ($self->SUPER::wait_for_response($initial_delay_seconds,
$ssh_response_timeout_seconds, 5)) {
+ return 1;
+ }
+
+ if ($self->provisioner->can('power_reset')) {
+ if ($self->provisioner->power_reset()) {
+ return $self->SUPER::wait_for_response(15, 600, 5);
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "computer never responded
and provisioning module failed to perform a power reset, returning false");
+ return;
+ }
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "computer never responded and
provisioning does not implement a power_reset subroutine, returning false");
+ return;
+ }
}
#/////////////////////////////////////////////////////////////////////////////