Author: arkurth
Date: Thu Jul 13 16:54:57 2017
New Revision: 1801845

URL: http://svn.apache.org/viewvc?rev=1801845&view=rev
Log:
VCL-867
Moved call to ad_delete_computer from ad_join_prepare to ad_join_ps after the 
computer hostname is changed and the computer is rebooted. ad_delete_computer 
was intermittently failing due to not being able to resolve the domain DNS 
name. It seems more reliable to set the static DNS server via ad_join_prepare, 
reboot, then try to delete an existing object.

Modified:
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.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=1801845&r1=1801844&r2=1801845&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Thu Jul 13 16:54:57 
2017
@@ -13497,12 +13497,6 @@ sub ad_join_prepare {
        # Set specific DNS servers for private and public interfaces if DNS 
servers are configured
        $self->set_static_dns_servers();
        
-       # Need to make sure computer object with same name doesn't already exist
-       # If object exists in different OU, the following error will occur when 
attempting to join the domain:
-       #    This command cannot be executed on target computer('<name>') due 
to following error: The account already exists.
-       # Don't bother moving existing objects
-       $self->ad_delete_computer();
-       
        return 1;
 }
 
@@ -13745,6 +13739,11 @@ sub ad_join_ps {
        #       }
        #}
        
+       # Need to make sure computer object with same name doesn't already exist
+       # If object exists in different OU, the following error will occur when 
attempting to join the domain:
+       #    This command cannot be executed on target computer('<name>') due 
to following error: The account already exists.
+       # Don't bother moving existing objects
+       $self->ad_delete_computer();
        
        # Assemble the PowerShell script
        my $ad_powershell_script = <<EOF;
@@ -13917,6 +13916,8 @@ sub ad_join_wmic {
                $rename_computer_reboot_duration = (time - 
$rename_computer_reboot_start);
        }
        
+       $self->ad_delete_computer();
+       
        my $error_messages = {
                5    => 'Access is denied',
                53   => 'Network path not found',
@@ -14412,7 +14413,7 @@ ForEach($result in $results) {
    }
 }
 EOF
-       
+
        my ($exit_status, $output);
        for (my $attempt=1; $attempt<=$attempt_limit; $attempt++) {
                ($exit_status, $output) = 
$self->run_powershell_as_script($powershell_script_contents, 0, 0);


Reply via email to