ref: refs/heads/network
commit 009818d3f577daa383a6fd4d7cecb1305711692a
Author: Josef Reidinger
Date: Mon Sep 21 17:30:39 2009 +0200
add ntp to time module frontend and add localized string for ntp exception
---
.../app/controllers/systemtime_controller.rb | 28 +++++++++++++++----
.../systemtime/app/views/systemtime/index.rhtml | 6 +++-
webclient/lib/error_constructor.rb | 8 +++++-
3 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/plugins/systemtime/app/controllers/systemtime_controller.rb b/plugins/systemtime/app/controllers/systemtime_controller.rb
index 7f79a3b..0641aa7 100644
--- a/plugins/systemtime/app/controllers/systemtime_controller.rb
+++ b/plugins/systemtime/app/controllers/systemtime_controller.rb
@@ -31,6 +31,11 @@ class SystemtimeController < ApplicationController
raise _("Unknown timezone #{@timezone} on host") unless @region
end
+ def clear_time(proxy)
+ proxy.time = ""
+ proxy.date = ""
+ end
+
public
# cannot move to initialize, it is not finded - http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#ApplicationCont...
@@ -83,15 +88,26 @@ class SystemtimeController < ApplicationController
def update
t = load_proxy 'org.opensuse.yast.modules.yapi.time'
- unless t
- return false
- end
+ return false unless t
fill_proxy_with_timezone t, params, t.timezones
- #TODO for future change between init types
- fill_proxy_with_time t,params
+ case params[:timeconfig]
+ when "none"
+ clear_time t #do nothing
+ when "manual"
+ fill_proxy_with_time t,params
+ when "ntp_sync"
+ clear_time t
+ ntp = load_proxy 'org.opensuse.yast.modules.yapi.ntp'
+ return false unless ntp
+ ntp.synchronize = true
+ ntp.save #FIXME check return value
+ else
+ logger.error "Unknown value for timeconfig #{params[:timeconfig]}"
+ end
+
- t.timezone = [] #save bandwitch
+ t.timezones = [] #save bandwitch
begin
t.save
diff --git a/plugins/systemtime/app/views/systemtime/index.rhtml b/plugins/systemtime/app/views/systemtime/index.rhtml
index 2800876..dc2f5ef 100644
--- a/plugins/systemtime/app/views/systemtime/index.rhtml
+++ b/plugins/systemtime/app/views/systemtime/index.rhtml
@@ -66,8 +66,12 @@
<% end %>
<div>
- <input type="radio" name="timeconfig" value="manual" checked="true"/>
+ <input type="radio" name="timeconfig" value="none" checked="true"/>
+ <%=_("Don't set time")%>
+ <input type="radio" name="timeconfig" value="manual"/>
<%=_("Manually configure time")%>
+ <input type="radio" name="timeconfig" value="ntp_sync"/>
+ <%=_("Synchronize via NTP")%>
</div>
<% #TODO for tooltip _("Manual time configuration table, where user selects data and time for target machine")
%>
diff --git a/webclient/lib/error_constructor.rb b/webclient/lib/error_constructor.rb
index 6e1fae3..9c5aa86 100644
--- a/webclient/lib/error_constructor.rb
+++ b/webclient/lib/error_constructor.rb
@@ -14,8 +14,14 @@ module ErrorConstructor
return _("Noone is logged to rest service.")
when "BADFILE"
return _("Target system is not consistent: Missing or corrupted file #{error["file"]}")
+ when "NTP_ERROR"
+ problem = error["output"]
+ if error["output"]=="NOSERVERS" #special value indicates that there is no predefined ntp server
+ problem = _("There is no predefined ntp server at /etc/sysconfig/network/config - NETCONFIG_NTP_STATIC_SERVERS")
+ end
+ return _("Error occure during ntp synchronization: #{problem}")
else
- RAILS_DEFAULT_LOGGER.warning "Untranslated message for exception #{error["type"]}"
+ RAILS_DEFAULT_LOGGER.warn "Untranslated message for exception #{error["type"]}"
return error["description"]
end
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org