From b416dfb9d082d59c45adb67affc89f5f1c3994cc Mon Sep 17 00:00:00 2001
From: Angelo Naselli <anaselli@linux.it>
Date: Wed, 25 Mar 2015 10:34:26 +0100
Subject: Added ntpServiceList attribute and its test

---
 lib/ManaTools/Shared/TimeZone.pm | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

(limited to 'lib')

diff --git a/lib/ManaTools/Shared/TimeZone.pm b/lib/ManaTools/Shared/TimeZone.pm
index 3be11d77..46810db0 100644
--- a/lib/ManaTools/Shared/TimeZone.pm
+++ b/lib/ManaTools/Shared/TimeZone.pm
@@ -203,11 +203,37 @@ has 'ntpServiceConfig' => (
     init_arg  => undef,
 );
 
-# has 'dmlist' => (
-#     is      => 'rw',
-#     isa     => 'ArrayRef',
-#     builder => '_build_dmlist',
-# );
+#=============================================================
+
+=head2 attribute
+
+=head3 ntpServiceList
+
+    This attribute is a ArrayRef containing configured ntp
+    service into the system, retrieving info from services.
+
+=cut
+
+#=============================================================
+has 'ntpServiceList' => (
+    is      => 'rw',
+    isa     => 'ArrayRef',
+    lazy    => 1,
+    builder => '_build_ntpServiceList',
+    init_arg  => undef,
+);
+
+# retrieves the installed ntp service list
+sub _build_ntpServiceList {
+    my $self = shift();
+
+    my @list = ();
+    for my $pair ($self->ntpServiceConfigPairs()) {
+        push @list, $pair->[0] if eval {$self->sh_services->dbus_systemd1_object->GetUnitFileState( $pair->[0] . ".service")};
+    }
+
+    return \@list;
+}
 
 #=============================================================
 
-- 
cgit v1.2.1