From 56471eb366e0a25293157c24f5bba0409e637fdf Mon Sep 17 00:00:00 2001 From: stdweird Date: Thu, 23 Mar 2017 16:14:03 +0100 Subject: [PATCH 1/2] cleanup: switch to 00-tqu --- pom.xml | 2 +- src/main/perl/Application.pm | 23 ++++++++--------------- src/main/perl/Utils.pm | 4 ++-- src/main/scripts/ncm-cdispd | 36 +++++++++++++++++++----------------- src/test/perl/00-load.t | 21 --------------------- src/test/perl/00-tqu.t | 11 +++++++++++ src/test/perl/pod-syntax.t | 6 ------ 7 files changed, 41 insertions(+), 62 deletions(-) delete mode 100644 src/test/perl/00-load.t create mode 100644 src/test/perl/00-tqu.t delete mode 100644 src/test/perl/pod-syntax.t diff --git a/pom.xml b/pom.xml index bf169fd..6818052 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.quattor.maven build-profile - 1.51 + 1.52 scm:git:git://github.com/quattor/ncm-cdispd.git diff --git a/src/main/perl/Application.pm b/src/main/perl/Application.pm index 1f6ffbb..47f566d 100644 --- a/src/main/perl/Application.pm +++ b/src/main/perl/Application.pm @@ -1,12 +1,4 @@ -# ${license-info} -# ${developer-info} -# ${author-info} -# ${build-info} - -package CDISPD::Application; - -use strict; -use warnings; +#${PMpre} CDISPD::Application${PMpost} =pod @@ -21,15 +13,14 @@ This class provides the ncm-cdispd specific methods used to initialize the CAF:: =cut -use Exporter; - use CAF::Application; use CAF::Reporter 16.8.1; use CAF::Process; use CAF::Object; use LC::Exception qw (SUCCESS throw_error); -our @ISA = qw(CAF::Application CAF::Reporter Exporter); +use parent qw(CAF::Application CAF::Reporter Exporter); + our @EXPORT = qw(CDISPD_CONFIG_FILE); use constant CDISPD_CONFIG_FILE => "/etc/ncm-cdispd.conf"; @@ -38,7 +29,8 @@ use constant CDISPD_CONFIG_FILE => "/etc/ncm-cdispd.conf"; # Public Methods/Functions for CAF # -sub app_options { +sub app_options +{ my $self = shift; @@ -149,7 +141,8 @@ sub app_options { } -sub _initialize { +sub _initialize +{ my $self = shift; @@ -177,7 +170,7 @@ sub _initialize { # start initialization of CAF::Application # unless ( $self->SUPER::_initialize(@_) ) { - return undef; + return; } # start using log file diff --git a/src/main/perl/Utils.pm b/src/main/perl/Utils.pm index 6141d19..f53e0fd 100644 --- a/src/main/perl/Utils.pm +++ b/src/main/perl/Utils.pm @@ -22,8 +22,8 @@ which components must be run. #################################################################### use POSIX qw(setsid); -require Exporter; -our @ISA = qw(Exporter); + +use parent qw(Exporter); use CAF::Object qw (SUCCESS throw_error); use EDG::WP4::CCM::CacheManager; diff --git a/src/main/scripts/ncm-cdispd b/src/main/scripts/ncm-cdispd index 3ee6ec5..6f3f21c 100755 --- a/src/main/scripts/ncm-cdispd +++ b/src/main/scripts/ncm-cdispd @@ -209,11 +209,6 @@ one has exited, at the end of `ncm-ncd`. =cut -BEGIN { - # use perl libs in /usr/lib/perl - unshift( @INC, '/usr/lib/perl' ); -} - ############################################################# # cdispd program and its functions @@ -225,10 +220,14 @@ BEGIN { # (very verbose!) ############################################################# -package main; - use strict; use warnings; + +BEGIN { + # use perl libs in /usr/lib/perl + unshift( @INC, '/usr/lib/perl' ); +} + use POSIX qw(setsid); use CAF::Object qw ( throw_error); @@ -295,7 +294,8 @@ No return value. =cut -sub register_signal { +sub register_signal +{ my $signal = shift; unless ( $signal ) { @@ -369,7 +369,8 @@ Proccess HUP signal: reinitialize cdispd daemon =cut -sub signal_reinitialize { +sub signal_reinitialize +{ my $signal = shift; unless ( $signal ) { @@ -439,17 +440,17 @@ sub daemonize exit(-1); } - if ( !open( STDIN, '/dev/null' ) ) { + if ( !open(STDIN, '<', '/dev/null') ) { $this_app->error("Can't read /dev/null: $! : Exiting"); exit(-1); } - if ( !open( STDOUT, ">> $logfile" ) ) { + if ( !open(STDOUT, ">>", $logfile) ) { $this_app->error("Can't write to $logfile: $! : Exiting"); exit(-1); } - if ( !open( STDERR, ">> $logfile" ) ) { + if ( !open(STDERR, ">>", $logfile ) ) { $this_app->error("Can't write to $logfile: $! : Exiting"); exit(-1); } @@ -463,13 +464,14 @@ sub daemonize # Save the PID. if ( $this_app->option('pidfile') ) { - if ( !open( PIDFILE, ">" . $this_app->option('pidfile') ) ) { + if ( !open(my $PIDFILE, ">", $this_app->option('pidfile') ) ) { $this_app->error( "Cannot write PID to file \"" . $this_app->option('pidfile') . "\": $! : Exiting" ); exit(-1); } - print( PIDFILE "$$" ); + print $PIDFILE "$$"; + close $PIDFILE; } if ( $this_app->option('state') ) { @@ -549,7 +551,7 @@ sub launch_ncd my $result = 0; # Assume success my $p = CAF::Process->new([NCD_EXECUTABLE, '--configure'] , log => $this_app ); - if ( defined( $this_app->{ICLIST} ) && scalar(@{$this_app->{ICLIST}}) ) { + if ( defined( $this_app->{ICLIST} ) && scalar(@{$this_app->{ICLIST}}) ) { # At this point, ICLIST should contain only components present in the last profile received. # The only case where a component may be in the list without being part of the configuration # is the following: @@ -588,11 +590,11 @@ sub launch_ncd delay_signals(); # Execute ncm-ncd and report exit status - sub act { + my $act = sub { my ($logger, $message) = @_; $logger->verbose($message); } - my $errormsg = $p->stream_output(\&act, mode => 'line', arguments => [$this_app]); + my $errormsg = $p->stream_output($act, mode => 'line', arguments => [$this_app]); my $ec = $?; my $msg = "ncm-ncd finished with status: ". ($ec >> 8) . " (ec $ec"; diff --git a/src/test/perl/00-load.t b/src/test/perl/00-load.t deleted file mode 100644 index ee24af9..0000000 --- a/src/test/perl/00-load.t +++ /dev/null @@ -1,21 +0,0 @@ -# -*- mode: cperl -*- -# ${license-info} -# ${author-info} -# ${build-info} - -=pod - -=head1 Smoke test - -Basic test that ensures that our modules will load correctly. - -B. - -=cut - -use strict; -use warnings; -use Test::More tests => 2; - -use_ok("CDISPD::Application"); -use_ok("CDISPD::Utils"); diff --git a/src/test/perl/00-tqu.t b/src/test/perl/00-tqu.t new file mode 100644 index 0000000..4d43c39 --- /dev/null +++ b/src/test/perl/00-tqu.t @@ -0,0 +1,11 @@ +BEGIN { + our $TQU = <<'EOF'; +[load] +prefix=CDISPD:: +modules=Application,Utils +[doc] +poddirs=target/lib/perl,target/sbin +panpaths=NOPAN +EOF +} +use Test::Quattor::Unittest; diff --git a/src/test/perl/pod-syntax.t b/src/test/perl/pod-syntax.t deleted file mode 100644 index 27704eb..0000000 --- a/src/test/perl/pod-syntax.t +++ /dev/null @@ -1,6 +0,0 @@ - -use Test::More; -use Test::Pod; - -my @dirs = qw(target/lib/perl target/sbin); -all_pod_files_ok(all_pod_files(@dirs)); From 934f07fbba6daa6219155f757f70533c611fe294 Mon Sep 17 00:00:00 2001 From: stdweird Date: Thu, 23 Mar 2017 16:18:10 +0100 Subject: [PATCH 2/2] ncm-cdispd.conf: do not set a default value for state (i.e. let ncm-ncd determine the value) --- src/main/config/ncm-cdispd.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/config/ncm-cdispd.conf b/src/main/config/ncm-cdispd.conf index 30a9ffe..f34636a 100644 --- a/src/main/config/ncm-cdispd.conf +++ b/src/main/config/ncm-cdispd.conf @@ -24,7 +24,7 @@ # ncd-retries = # time in seconds between retries -# ncd-timeout = +# ncd-timeout = # profile to use as configuration profile # ncd-useprofile = @@ -36,4 +36,4 @@ # noaction = # Where to keep state information -state = /var/run/quattor-components +# state =