Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] <rest-service> resource-restful : improve NTP yapi to provide required functionality, properly package it
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Mon, 7 Sep 2009 16:01:07 +0200
  • Message-id: <E1Mq44E-00084v-4V@xxxxxxxxxxxxxxxx>
ref: refs/heads/resource-restful
commit cf98a78fb7b0ebef0f962c44f8b0d10b8a179dd7
Author: Josef Reidinger <jreidinger@xxxxxxx>
Date: Mon Sep 7 16:01:07 2009 +0200

improve NTP yapi to provide required functionality, properly package it
---
plugins/time/package/NTP.pm | 33 ++++++++++++++++-------
plugins/time/package/yast2-webservice-time.spec | 10 +++++++
2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/plugins/time/package/NTP.pm b/plugins/time/package/NTP.pm
index 36b401b..47f824a 100644
--- a/plugins/time/package/NTP.pm
+++ b/plugins/time/package/NTP.pm
@@ -3,19 +3,32 @@ package YaPI::NTP;
use strict;
use YaPI;

+our %TYPEINFO;
+
BEGIN{$TYPEINFO{Synchronize} = ["function",
- "string","string"];
+ "string"];
+}
sub Synchronize {
my $self = shift;
- my $server = shift;
+ my $servers = getServers();
+ my $out = undef;

- # -r: do set the system time
- # -P no: do not ask if time difference is too large
- # -c 1 -d 15: delay 15s, only one try (bnc#442287)
- $out = `/usr/sbin/sntp -c 1 -d 15 -r -P no '$server' 2>&1`
- if ($?){
- return $out;
- } else {
- return "OK"
+ foreach my $server (@{$servers}){
+ # -r: do set the system time
+ # -P no: do not ask if time difference is too large
+ # -c 1 -d 15: delay 15s, only one try (bnc#442287)
+ $out = `/usr/sbin/sntp -c 1 -d 15 -r -P no '$server' 2>&1`;
+ return "OK" unless ($?);
+ $out = "Error for server $server: $out";
}
+ return "NOSERVERS" unless (defined ($out));
+ return $out;
}
+
+sub getServers {
+ my $servers = `grep "^[:space:]*NETCONFIG_NTP_STATIC_SERVERS"
/etc/sysconfig/network/config | sed 's/.*="\\(.*\\)"/\\1/'`;
+ my @serv = split(/\s+/,$servers);
+ return \@serv;
+}
+
+1;
diff --git a/plugins/time/package/yast2-webservice-time.spec
b/plugins/time/package/yast2-webservice-time.spec
index 8f67c7e..67570a2 100644
--- a/plugins/time/package/yast2-webservice-time.spec
+++ b/plugins/time/package/yast2-webservice-time.spec
@@ -19,6 +19,8 @@ Version: 0.0.3
Release: 0
Summary: YaST2 - Webservice - Time
Source: www.tar.bz2
+Source1: NTP.pm
+Source2: org.opensuse.yast.modules.yapi.ntp.policy
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
BuildRequires: rubygem-mocha
@@ -50,6 +52,10 @@ Authors:
#
mkdir -p $RPM_BUILD_ROOT/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}
cp -a * $RPM_BUILD_ROOT/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}
+cp ${SOURCE1} $RPM_BUILD_ROOT/usr/share/YaST2/modules/YaPI/
+mkdir -p $RPM_BUILD_ROOT/usr/share/PolicyKit/policy/
+cp ${SOURCE2} $RPM_BUILD_ROOT/usr/share/PolicyKit/policy/
+

%clean
rm -rf $RPM_BUILD_ROOT
@@ -69,6 +75,8 @@ rm -rf $RPM_BUILD_ROOT
%dir /srv/www/%{pkg_user}/vendor/plugins
%dir /srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}
%dir /srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/doc
+%dir /usr/share/PolicyKit
+%dir /usr/share/PolicyKit/policy/
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/MIT-LICENSE
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/README
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/Rakefile
@@ -80,3 +88,5 @@ rm -rf $RPM_BUILD_ROOT
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/tasks
#/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/test
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/doc/README_FOR_APP
+/usr/share/YaST2/modules/YaPI/${SOURCE1}
+/usr/share/PolicyKit/policy/${SOURCE2}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages