From 031f000833f385de8bc5142c571aec73399b4a1a Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Wed, 25 Mar 2015 11:22:36 +0100 Subject: added refreshNTPServiceList attribute and its test --- lib/ManaTools/Shared/TimeZone.pm | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'lib') 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) ]; } #============================================================= @@ -433,6 +434,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 -- cgit v1.2.1