aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-03-25 10:34:26 +0100
committerAngelo Naselli <anaselli@linux.it>2015-03-25 10:34:26 +0100
commitb416dfb9d082d59c45adb67affc89f5f1c3994cc (patch)
treeea81809ca32ba641bcc78466a3e1a71a4c53cc2b
parent19cc50169058c43f67c78e81bb153a4581df2b3a (diff)
downloadcolin-keep-b416dfb9d082d59c45adb67affc89f5f1c3994cc.tar
colin-keep-b416dfb9d082d59c45adb67affc89f5f1c3994cc.tar.gz
colin-keep-b416dfb9d082d59c45adb67affc89f5f1c3994cc.tar.bz2
colin-keep-b416dfb9d082d59c45adb67affc89f5f1c3994cc.tar.xz
colin-keep-b416dfb9d082d59c45adb67affc89f5f1c3994cc.zip
Added ntpServiceList attribute and its test
-rw-r--r--lib/ManaTools/Shared/TimeZone.pm36
-rw-r--r--t/04-Shared_TimeZone.t2
2 files changed, 33 insertions, 5 deletions
diff --git a/lib/ManaTools/Shared/TimeZone.pm b/lib/ManaTools/Shared/TimeZone.pm
index 3be11d7..46810db 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;
+}
#=============================================================
diff --git a/t/04-Shared_TimeZone.t b/t/04-Shared_TimeZone.t
index 8f82786..0d72d5b 100644
--- a/t/04-Shared_TimeZone.t
+++ b/t/04-Shared_TimeZone.t
@@ -23,6 +23,8 @@ BEGIN {
for my $pair (@pairs) {
is ($tz->getNTPServiceConfig($pair->[0]), $pair->[1], "ntpServiceConfigPairs $pair->[0]");
}
+ ok (my $services = $tz->ntpServiceList(), 'ntpServiceList');
+ diag Dumper($services);
SKIP: {
#remember to skip the right number of tests