Author: arkurth
Date: Thu Nov 29 16:21:04 2012
New Revision: 1415246

URL: http://svn.apache.org/viewvc?rev=1415246&view=rev
Log:
VCL-582
Fixed problem in Upstart.pm::stop_service where it was not stopping the 
existing ext_sshd service. It was assuming the service was named ext_ssh.

Modified:
    vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/init/Upstart.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/init/Upstart.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/init/Upstart.pm?rev=1415246&r1=1415245&r2=1415246&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/init/Upstart.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/init/Upstart.pm Thu Nov 29 
16:21:04 2012
@@ -263,40 +263,50 @@ sub stop_service {
                return;
        }
        
-       my $service_name = shift;
-       if (!$service_name) {
+       my $service_name_argument = shift;
+       if (!$service_name_argument) {
                notify($ERRORS{'WARNING'}, 0, "service name argument was not 
supplied");
                return;
        }
-       $service_name = $SERVICE_NAME_MAPPINGS->{$service_name} || 
$service_name;
        
-       my $computer_node_name = $self->data->get_computer_node_name();
+       # Need to attempt to stop both the service with a name matching the 
argument as well as the mapped service name
+       my @service_names = ($service_name_argument);
        
-       my $command = "initctl stop $service_name";
-       my ($exit_status, $output) = $self->execute($command);
-       if (!defined($output)) {
-               notify($ERRORS{'WARNING'}, 0, "failed to execute command to 
stop '$service_name' service on $computer_node_name");
-               return;
-       }
-       elsif (grep(/Unknown job/i, @$output)) {
-               # Output if the service doesn't exist: 'initctl: Unknown job: 
<service name>'
-               notify($ERRORS{'DEBUG'}, 0, "'$service_name' service does not 
exist on $computer_node_name");
-               return 1;
-       }
-       elsif (grep(/Unknown instance/i, @$output)) {
-               # Output if the service is not running: 'initctl: Unknown 
instance:'
-               notify($ERRORS{'DEBUG'}, 0, "'$service_name' is already stopped 
on $computer_node_name");
-               return 1;
+       # If a mapped service name also exists, attempt to stop it as well
+       if ($SERVICE_NAME_MAPPINGS->{$service_name_argument}) {
+               push @service_names, 
$SERVICE_NAME_MAPPINGS->{$service_name_argument};
        }
-       elsif (grep(/ stop\//i, @$output)) {
-               # Output if the service was stopped: '<service name> 
stop/waiting'
-               notify($ERRORS{'DEBUG'}, 0, "stopped '$service_name' service on 
$computer_node_name");
-               return 1;
-       }
-       else {
-               notify($ERRORS{'WARNING'}, 0, "failed to stop '$service_name' 
service on $computer_node_name, exit status: $exit_status, command: '$command', 
output:\n" . join("\n", @$output));
-               return;
+       
+       my $computer_node_name = $self->data->get_computer_node_name();
+       
+       for my $service_name (@service_names) {
+               my $command = "initctl stop $service_name";
+               my ($exit_status, $output) = $self->execute($command);
+               if (!defined($output)) {
+                       notify($ERRORS{'WARNING'}, 0, "failed to execute 
command to stop '$service_name' service on $computer_node_name");
+                       return;
+               }
+               elsif (grep(/Unknown job/i, @$output)) {
+                       # Output if the service doesn't exist: 'initctl: 
Unknown job: <service name>'
+                       notify($ERRORS{'DEBUG'}, 0, "'$service_name' service 
does not exist on $computer_node_name");
+               }
+               elsif (grep(/Unknown instance/i, @$output)) {
+                       # Output if the service is not running: 'initctl: 
Unknown instance:'
+                       notify($ERRORS{'DEBUG'}, 0, "'$service_name' is already 
stopped on $computer_node_name");
+                       return 1;
+               }
+               elsif (grep(/ stop\//i, @$output)) {
+                       # Output if the service was stopped: '<service name> 
stop/waiting'
+                       notify($ERRORS{'DEBUG'}, 0, "stopped '$service_name' 
service on $computer_node_name");
+                       return 1;
+               }
+               else {
+                       notify($ERRORS{'WARNING'}, 0, "failed to stop 
'$service_name' service on $computer_node_name, exit status: $exit_status, 
command: '$command', output:\n" . join("\n", @$output));
+                       return;
+               }
        }
+       
+       return 1;
 }
 
 #/////////////////////////////////////////////////////////////////////////////


Reply via email to