aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-03-25 11:22:36 +0100
committerAngelo Naselli <anaselli@linux.it>2015-03-25 11:22:36 +0100
commit031f000833f385de8bc5142c571aec73399b4a1a (patch)
tree01ceb0781d87622e416c5b2286c23d5688532fec
parentb416dfb9d082d59c45adb67affc89f5f1c3994cc (diff)
downloadcolin-keep-031f000833f385de8bc5142c571aec73399b4a1a.tar
colin-keep-031f000833f385de8bc5142c571aec73399b4a1a.tar.gz
colin-keep-031f000833f385de8bc5142c571aec73399b4a1a.tar.bz2
colin-keep-031f000833f385de8bc5142c571aec73399b4a1a.tar.xz
colin-keep-031f000833f385de8bc5142c571aec73399b4a1a.zip
added refreshNTPServiceList attribute and its test
-rw-r--r--lib/ManaTools/Shared/TimeZone.pm28
-rw-r--r--t/04-Shared_TimeZone.t3
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/ManaTools/Shared/TimeZone.pm b/lib/ManaTools/Shared/TimeZone.pm
index 46810db..155de20 100644
--- a/lib/ManaTools/Shared/TimeZone.pm
+++ b/lib/ManaTools/Shared/TimeZone.pm
@@ -209,8 +209,9 @@ has 'ntpServiceConfig' => (
=head3 ntpServiceList
- This attribute is a ArrayRef containing configured ntp
- service into the system, retrieving info from services.
+ This attribute is a ArrayRef containing the sorted list of
+ configured NTP service into the system, retrieving info from
+ services.
=cut
@@ -232,7 +233,7 @@ sub _build_ntpServiceList {
push @list, $pair->[0] if eval {$self->sh_services->dbus_systemd1_object->GetUnitFileState( $pair->[0] . ".service")};
}
- return \@list;
+ return [ sort(@list) ];
}
#=============================================================
@@ -435,6 +436,27 @@ sub _buildNTPServers {
#=============================================================
+=head2 refreshNTPServiceList
+
+=head3 DESCRIPTION
+
+ Refresh the ntpServiceList attribute value, usefull
+ if any NTP service has been istalled after having
+ instantiated this object
+
+=cut
+
+#=============================================================
+sub refreshNTPServiceList {
+ my $self = shift;
+
+ my $list = $self->_build_ntpServiceList();
+
+ $self->ntpServiceList($list);
+}
+
+#=============================================================
+
=head2 get_timezone_prefix
=head3 OUTPUT
diff --git a/t/04-Shared_TimeZone.t b/t/04-Shared_TimeZone.t
index 0d72d5b..9f286cc 100644
--- a/t/04-Shared_TimeZone.t
+++ b/t/04-Shared_TimeZone.t
@@ -25,6 +25,9 @@ BEGIN {
}
ok (my $services = $tz->ntpServiceList(), 'ntpServiceList');
diag Dumper($services);
+ ok ($tz->refreshNTPServiceList(), 'refreshNTPServiceList');
+ ok ($services = $tz->ntpServiceList(), 'ntpServiceList after refresh');
+ diag Dumper($services);
SKIP: {
#remember to skip the right number of tests