diff options
-rw-r--r-- | lib/ManaTools/Shared/TimeZone.pm | 28 | ||||
-rw-r--r-- | t/04-Shared_TimeZone.t | 3 |
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 |