Author: arkurth
Date: Wed Sep 22 17:35:32 2010
New Revision: 1000099

URL: http://svn.apache.org/viewvc?rev=1000099&view=rev
Log:
VCL-145
Updated Windows.pm and Version_5.pm so that Windows 5.x image capture processes 
don't fail if Sysprep is enabled and no stroage driver .inf files are found.

VCL-298
Updated VMware.pm to remove the VM from the VM host when the VM is unassigned 
via the website.

Other
Added calls to kill the logon screen saver process in the Windows code before a 
reboot or shutdown is attempted. This occasionally causes a reboot or shutdown 
to hang.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
    
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1000099&r1=1000098&r2=1000099&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Wed Sep 22 
17:35:32 2010
@@ -3132,7 +3132,10 @@ sub reboot {
                        notify($ERRORS{'WARNING'}, 0, "reboot not attempted, 
failed to enable ping from private IP addresses");
                        return 0;
                }
-
+               
+               # Kill the screen saver process, it occasionally prevents 
reboots and shutdowns from working
+               $self->kill_process('logon.scr');
+               
                # Initiate the shutdown.exe command to reboot the computer
                my $shutdown_command = $system32_path . "/shutdown.exe -r -t 0 
-f";
                my ($shutdown_exit_status, $shutdown_output) = 
run_ssh_command($computer_node_name, $management_node_keys, $shutdown_command);
@@ -3276,6 +3279,9 @@ sub shutdown {
        my $computer_node_name   = $self->data->get_computer_node_name();
        my $system32_path        = $self->get_system32_path() || return;
        
+       # Kill the screen saver process, it occasionally prevents reboots and 
shutdowns from working
+       $self->kill_process('logon.scr');
+       
        my $shutdown_command = "/bin/cygstart.exe $system32_path/cmd.exe /c \"";
        
        if ($disable_dhcp) {
@@ -8742,12 +8748,7 @@ sub get_driver_inf_paths {
        elsif (defined($grep_output)) {
                my @inf_paths = grep(/:[\\\/]/, @$grep_output);
                notify($ERRORS{'DEBUG'}, 0, "found " . scalar(@inf_paths) . " 
driver .inf paths, grep output:\n". join("\n", @$grep_output));
-               if (@inf_paths) {
-                       return @inf_paths;
-               }
-               else {
-                       return 0;
-               }
+               return @inf_paths;
        }
        elsif (defined($grep_exit_status)) {
                notify($ERRORS{'WARNING'}, 0, "failed to find driver paths, 
exit status: $grep_exit_status, output:\...@{$grep_output}");

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm?rev=1000099&r1=1000098&r2=1000099&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm 
Wed Sep 22 17:35:32 2010
@@ -266,6 +266,9 @@ sub run_sysprep {
                notify($ERRORS{'WARNING'}, 0, "unable to configure firewall to 
allow sessmgr.exe program, Sysprep may hang");
        }
        
+       # Kill the screen saver process, it occasionally prevents reboots and 
shutdowns from working
+       $self->kill_process('logon.scr');
+       
        # Assemble the Sysprep command
        # Run Sysprep.exe, use cygstart to lauch the .exe and return immediately
        my $sysprep_command = "/bin/cygstart.exe $system32_path/cmd.exe /c \"";
@@ -477,18 +480,19 @@ sub get_sysprep_inf_contents {
        
        # Add the SysprepMassStorage section
        my $mass_storage_section = 
$self->get_sysprep_inf_mass_storage_section();
-       if (!$mass_storage_section) {
+       if ($mass_storage_section) {
+               $sysprep_contents .= 
"[SysprepMassStorage]\n$mass_storage_section";
+       }
+       elsif (!defined($mass_storage_section)) {
                notify($ERRORS{'WARNING'}, 0, "unable to build sysprep.inf 
SysprepMassStorage section");
                return;
        }
-       else {
-               $sysprep_contents .= 
"[SysprepMassStorage]\n$mass_storage_section";
-       }
+       
        
        # Replace Unix\Linux newlines with Windows newlines
        $sysprep_contents =~ s/\n/\r\n/g;
        
-       notify($ERRORS{'DEBUG'}, 0, "sysprep.inf contents:\n" . 
string_to_ascii($sysprep_contents));
+       notify($ERRORS{'DEBUG'}, 0, "sysprep.inf contents:\n$sysprep_contents");
        return $sysprep_contents;
 }
 
@@ -524,8 +528,8 @@ sub get_sysprep_inf_mass_storage_section
        my @storage_inf_paths = $self->get_driver_inf_paths('scsiadapter');
        #my @storage_inf_paths = 
$self->get_driver_inf_paths('(scsiadapter|hdc)');
        if (!...@storage_inf_paths) {
-               notify($ERRORS{'WARNING'}, 0, "failed to locate storage driver 
.inf paths");
-               return;
+               notify($ERRORS{'OK'}, 0, "no storage driver .inf paths were 
found");
+               return '';
        }
        
        # Extract hardware IDs from each storage driver .inf file 

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm?rev=1000099&r1=1000098&r2=1000099&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm 
Wed Sep 22 17:35:32 2010
@@ -1588,6 +1588,9 @@ EOF
        # Display licensing information
        $self->run_slmgr_dlv();
        
+       # Kill the screen saver process, it occasionally prevents reboots and 
shutdowns from working
+       $self->kill_process('logon.scr');
+       
        # Run Sysprep.exe, use cygstart to lauch the .exe and return immediately
        my $sysprep_command = "/bin/cygstart.exe $system32_path/cmd.exe /c \"";
        

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm?rev=1000099&r1=1000098&r2=1000099&view=diff
==============================================================================
--- 
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm 
(original)
+++ 
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm 
Wed Sep 22 17:35:32 2010
@@ -1053,7 +1053,9 @@ sub get_vmhost_api_object {
 
  Parameters  : none
  Returns     : boolean
- Description : 
+ Description : Removes VMs from a VMware host which were previously created for
+               the VM. It only removes VMs created for the VM assigned to the
+               reservation. It does not delete all VM's from the host.
 
 =cut
 
@@ -4120,23 +4122,12 @@ sub post_maintenance_action {
        my $computer_short_name = $self->data->get_computer_short_name();
        my $vmhost_hostname = $self->data->get_vmhost_hostname();
        
-       my $vmx_file_path = $self->get_vmx_file_path();
-       if (!$vmx_file_path) {
-               notify($ERRORS{'WARNING'}, 0, "vmx file path could not be 
determined");
+       # Delete the existing VM from the VM host which were created for the VM 
assigned to the reservation
+       if (!$self->remove_existing_vms()) {
+               notify($ERRORS{'WARNING'}, 0, "failed to delete existing VMs on 
VM host $vmhost_hostname which were created for VM $computer_short_name");
                return;
        }
-       
-       # Delete the existing VM from the VM host
-       if ($self->vmhost_os->file_exists($vmx_file_path)) {
-               if (!$self->delete_vm($vmx_file_path)) {
-                       notify($ERRORS{'WARNING'}, 0, "failed to delete VM on 
VM host $vmhost_hostname: $vmx_file_path");
-                       return;
-               }
-       }
-       else {
-               notify($ERRORS{'OK'}, 0, "vmx file does not exist on the VM 
host $vmhost_hostname: $vmx_file_path");
-       }
-       
+
        if (switch_vmhost_id($computer_id, 'NULL')) {
                notify($ERRORS{'OK'}, 0, "set vmhostid to NULL for for VM 
$computer_short_name");
        }


Reply via email to