Author: arkurth Date: Fri Jul 17 19:05:48 2009 New Revision: 795197 URL: http://svn.apache.org/viewvc?rev=795197&view=rev Log: VCL-23 Removed legacy Windows code from xCAT.pm::load(). These tasks are now handled by the Windows OS modules.
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=795197&r1=795196&r2=795197&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Fri Jul 17 19:05:48 2009 @@ -946,191 +946,16 @@ # Perform post load tasks - # Windows specific routines + # Check if OS module has implemented a post_load() subroutine if ($self->os->can('post_load')) { # If post-load has been implemented by the OS module, don't perform these tasks here - # new.pm calls the Windows module's post_load() subroutine to perform the same tasks as below - notify($ERRORS{'OK'}, 0, "post_load() has been implemented by the OS module, skipping these tasks in xCAT.pm, returning 1"); + # new.pm calls the OS module's post_load() subroutine + notify($ERRORS{'DEBUG'}, 0, "post_load() has been implemented by the OS module, returning 1"); return 1; } - elsif ($image_os_name =~ /winxp|wxp|win2003|winvista/) { - - insertloadlog($reservation_id, $computer_id, "info", "randomizing system level passwords"); - - #change passwords for root and administrator account - #skip changing root password for imageprep loads - if (changewindowspasswd($computer_node_name, "root")) { - notify($ERRORS{'OK'}, 0, "Successfully changed password, account $computer_node_name,root"); - } - - if (changewindowspasswd($computer_node_name, "administrator")) { - notify($ERRORS{'OK'}, 0, "Successfully changed password, account $computer_node_name,administrator"); - } - - #disable remote desktop port - if (remotedesktopport($computer_node_name, "DISABLE")) { - notify($ERRORS{'OK'}, 0, "remote desktop disabled on $computer_node_name"); - } - else { - notify($ERRORS{'OK'}, 0, "remote desktop not disable on $computer_node_name"); - } - - #due to sysprep sshd is set to manual start - if (_set_sshd_startmode($computer_node_name, "auto")) { - notify($ERRORS{'OK'}, 0, "successfully set sshd service on $computer_node_name to start auto"); - } - else { - notify($ERRORS{'WARNING'}, 0, "failed to set sshd service on $computer_node_name to start auto"); - } - - #check for root logged in on console and then logoff - notify($ERRORS{'OK'}, 0, "checking for any console users $computer_node_name"); - - my @QA = run_ssh_command($computer_node_name, $IDENTITY_wxp, "cmd /c qwinsta.exe", "root"); - foreach my $r (@{$QA[1]}) { - if ($r =~ /([>]?)([-a-zA-Z0-9]*)\s+([a-zA-Z0-9]*)\s+ ([0-9]*)\s+([a-zA-Z]*)/) { - my $state = $5; - my $session = $2; - my $user = $3; - if ($5 =~ /Active/) { - notify($ERRORS{'OK'}, 0, "detected $user on $session still logged on $computer_node_name $r, sleeping 7 before logging off"); - sleep 7; - my @LF = run_ssh_command($computer_node_name, $IDENTITY_wxp, "cmd /c logoff.exe $session"); - foreach my $l (@{$LF[1]}) { - notify($ERRORS{'OK'}, 0, "output from attempt to logoff $user on $session"); - } - - } - } ## end if ($r =~ /([>]?)([-a-zA-Z0-9]*)\s+([a-zA-Z0-9]*)\s+ ([0-9]*)\s+([a-zA-Z]*)/) - } ## end foreach my $r (@{$QA[1]}) - - #reboot the box based on options - if ($imagemeta_postoption =~ /reboot/i) { - my $rebooted = 1; - my $reboot_wait_count = 0; - my @retarray; - while ($rebooted) { - if ($reboot_wait_count > 55) { - notify($ERRORS{'CRITICAL'}, 0, "waited $reboot_wait_count on reboot after auto_create_image on $computer_node_name"); - $retarray[1] = "waited $reboot_wait_count on reboot after netdom on $computer_node_name"; - return @retarray; - } - notify($ERRORS{'OK'}, 0, "$computer_node_name not completed reboot sleeping for 25"); - sleep 25; - if (_pping($computer_node_name)) { - - #it pingable check if sshd is open - notify($ERRORS{'OK'}, 0, "$computer_node_name is pingable, checking sshd port"); - my $sshd = _sshd_status($computer_node_name, $image_name, $image_os_type); - if ($sshd =~ /on/) { - $rebooted = 0; - notify($ERRORS{'OK'}, 0, "$computer_node_name sshd is open"); - } - else { - notify($ERRORS{'OK'}, 0, "$computer_node_name sshd NOT open yet,sleep 5"); - sleep 5; - } - } #_pping - $reboot_wait_count++; - - } #while - } #reboot - - #win2003 only - need to set private adapter to static without a gateway - # win2003 and probably vista zero out one gateway and we only need a gateway on the public adapter - # so we need to remove the one on the private side - # downside - we need to reset it to dhcp before making an image..... - if ($image_os_name =~ /^(win2003)/) { - insertloadlog($reservation_id, $computer_id, "info", "detected OS which requires network gateway modification"); - notify($ERRORS{'OK'}, 0, "detected win2003 OS, proceeding to change private adapter to static from dhcp on $computer_node_name"); - my %ip; - my $myadapter; - my @ipconfig = run_ssh_command($computer_node_name, $IDENTITY_wxp, "ipconfig -all", "root"); - - # build hash of needed info and set the correct private adapter. - foreach my $a (@{$ipconfig[1]}) { - $myadapter = $1 if ($a =~ /Ethernet adapter (.*):/); - $ip{$myadapter}{"private"} = 1 - if ($a =~ /IP Address([\s.]*): $privateIP/); - $ip{$myadapter}{"subnetmask"} = $2 - if ($a =~ /Subnet Mask([\s.]*): ([.0-9]*)/); - } - - my $privateadapter; - my $subnetmask; - - foreach my $key (keys %ip) { - if (defined($ip{$key}{private})) { - if ($ip{$key}{private}) { - $privateadapter = "\"$key\""; - $subnetmask = $ip{$key}{subnetmask}; - } - } - } - - notify($ERRORS{'OK'}, 0, "attempted to convert private adapter on $computer_node_name to static with no gateway"); - - #not using run_ssh_command here - if (open(NETSH, "/usr/bin/ssh -x -i $IDENTITY_wxp $computer_node_name \"netsh interface ip set address name=\\\"$privateadapter\\\" source=static addr=$privateIP mask=$subnetmask\" & 2>&1 |")) { - - #losing connection - my $go = 1; - while ($go) { - - #print "hi\n"; - sleep 4; - if (open(PS, "ps -ef |")) { - my @ps = <PS>; - close(PS); - sleep 4; - foreach my $p (@ps) { - if ($p =~ /$computer_node_name netsh interface/) { - if ($p =~ /(root)\s+([0-9]*)/) { - if (open(KILLIT, "kill -9 $2 |")) { - close(KILLIT); - close(NETSH); - notify($ERRORS{'OK'}, 0, "killing ssh $computer_node_name netsh process"); - } - } - } - } ## end foreach my $p (@ps) - } ## end if (open(PS, "ps -ef |")) - - $go = 0; - } ## end while ($go) - } ## end if (open(NETSH, "/usr/bin/ssh -x -i $IDENTITY_wxp $computer_node_name \"netsh interface ip set address name=\\\"$privateadapter\\\" source=static addr=$privateIP mask=$subnetmask\" & 2>&1 |"... - - #make sure it came back - if (_sshd_status($computer_node_name, $image_name, $image_os_type)) { - notify($ERRORS{'OK'}, 0, "successful $computer_node_name is accessible after static assignment"); - insertloadlog($reservation_id, $computer_id, "info", "SUCCESS network gateway modification successful"); - } - else { - - } - - #disable NetBios - notify($ERRORS{'OK'}, 0, "attempted to convert private adapter on $computer_node_name to static with no gateway"); - my $path1 = "$TOOLS/disablenetbios.vbs"; - my $path2 = "$computer_node_name:disablenetbios.vbs"; - if (run_scp_command($path1, $path2, $IDENTITY_wxp)) { - notify($ERRORS{'DEBUG'}, 0, "copied $path1 to $path2"); - my @DNBIOS = run_ssh_command($computer_node_name, $IDENTITY_wxp, "cscript.exe //Nologo disablenetbios.vbs", "root"); - foreach my $l (@{$DNBIOS[1]}) { - if ($l =~ /denied|socket/) { - notify($ERRORS{'WARNING'}, 0, "failed to disablenetbios.vbs @{ $DNBIOS[1] }"); - } - } - - } ## end if (run_scp_command($path1, $path2, $IDENTITY_wxp... - else { - notify($ERRORS{'WARNING'}, 0, "run_scp_command failed to copy $path1 to $path2"); - } - - } ## end if ($image_os_name =~ /^(win2003)/) - } ## end elsif ($image_os_name =~ /winxp|wxp|win2003|winvista/) [ if ($self->os->can('post_load')) - + # Linux post-load tasks + # TODO: The following should be removed once Linux.pm post_load() has been implemented elsif ($image_os_type =~ /linux/i) { #linux specfic routines