Author: arkurth
Date: Thu May 18 20:23:32 2017
New Revision: 1795559
URL: http://svn.apache.org/viewvc?rev=1795559&view=rev
Log:
VCL-966
Added optional check for a @PROHIBITED_COMMANDS array in an init module when
being initialized by Linux.pm::get_init_modules.
Added @PROHIBITED_COMMANDS containing 'chkconfig' to Upstart.pm. CentOS images
were trying to use Upstart.pm because it was only checking for the existence of
the 'initctl' command, which exists on CentOS.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/init/Upstart.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1795559&r1=1795558&r2=1795559&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Thu May 18 20:23:32 2017
@@ -218,13 +218,25 @@ sub get_init_modules {
notify($ERRORS{'CRITICAL'}, 0,
"\@REQUIRED_COMMANDS variable is not defined in the $init_perl_package Linux
init daemon module");
next INIT_MODULE;
}
+ if (@required_commands) {
+ for my $command (@required_commands) {
+ if (!$self->command_exists($command)) {
+ next INIT_MODULE;
+ }
+ }
+ }
- for my $command (@required_commands) {
- if (!$self->command_exists($command)) {
- next INIT_MODULE;
+ my @prohibited_commands = eval "@" . $init_perl_package
. "::PROHIBITED_COMMANDS";
+ if (@prohibited_commands) {
+ for my $command (@prohibited_commands) {
+ if ($self->command_exists($command)) {
+ notify($ERRORS{'DEBUG'}, 0,
"ignoring $init_perl_package Linux init daemon module, '$command' command
exists on $computer_node_name");
+ next INIT_MODULE;
+ }
}
}
+
# init object successfully created, retrieve the
module's $INIT_DAEMON_ORDER variable
# An OS may have/support multiple Linux init daemons,
services may be registered under different init daemons
# In some cases, need to try multple init modules to
control a service
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=1795559&r1=1795558&r2=1795559&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 May 18
20:23:32 2017
@@ -81,6 +81,18 @@ our $INIT_DAEMON_ORDER = 10;
our @REQUIRED_COMMANDS = ('initctl');
+=head2 @PROHIBITED_COMMANDS
+
+ Data type : array
+ Values : initctl
+ Description : List of commands that must not exist on the computer if the
+ Upstart.pm module is to be used. This
array contains:
+ 'chkconfig'.
+
+=cut
+
+our @PROHIBITED_COMMANDS = ('chkconfig');
+
=head2 $SERVICE_NAME_MAPPINGS
Data type : hash reference
@@ -185,10 +197,11 @@ sub _get_service_info {
for my $line (@$initctl_output) {
my ($service_name) = $line =~ /^([^\s\t]+)/;
if ($service_name) {
+ #notify($ERRORS{'DEBUG'}, 0, "found
'$service_name' service via '$initctl_command', line: '$line'");
$self->{service_info}{$service_name} =
'initctl';
}
else {
- notify($ERRORS{'WARNING'}, 0, "failed to parse
service name from '$initctl_command' line: '$line'");
+ notify($ERRORS{'WARNING'}, 0, "failed to parse
service name on $computer_node_name, command: '$initctl_command', line:
'$line', output:\n" . join("\n", @$initctl_output));
}
}
}
@@ -212,13 +225,14 @@ sub _get_service_info {
# [ ? ] apport
# [ - ] dbus
for my $line (@$service_output) {
- my ($service_name) = $line =~ /(\S+)\s*$/;
- if (!$service_name) {
- notify($ERRORS{'WARNING'}, 0, "failed to parse
service name from '$service_command' line: '$line'");
- }
- elsif (!defined($self->{service_info}{$service_name})) {
+ my ($service_name) = $line =~ /\]\s*(\S+)\s*$/;
+ if ($service_name) {
+ #notify($ERRORS{'DEBUG'}, 0, "found
'$service_name' service via '$service_command', line: '$line'");
$self->{service_info}{$service_name} =
'service';
}
+ else {
+ #notify($ERRORS{'WARNING'}, 0, "failed to parse
service name on $computer_node_name, command: '$service_command', line: '" .
string_to_ascii($line) . "'\noutput:\n" . join("\n", @$service_output));
+ }
}
}