ref: refs/heads/master
commit 2c624a230049b879ddcc915b865bf06422bb5b1b
Author: Jiri Suchomel
Date: Fri Aug 21 16:01:57 2009 +0200
find_all can query for status of services
new API of SERVICES::Read
---
plugins/services/app/models/service.rb | 20 +++++++++++++++-----
plugins/services/config/resources/services.yml | 1 -
.../package/yast2-webservice-services.spec | 2 +-
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/plugins/services/app/models/service.rb b/plugins/services/app/models/service.rb
index 8e70ceb..2904bc0 100644
--- a/plugins/services/app/models/service.rb
+++ b/plugins/services/app/models/service.rb
@@ -5,7 +5,7 @@ require 'yast/config_file'
class Service
attr_accessor :name
- attr_accessor_with_default :status, 0
+ attr_accessor :status
def initialize(name)
@name = name
@@ -15,11 +15,17 @@ class Service
def self.find_all(params)
services = []
+ read_status = params.has_key?("read_status")
+
if params.has_key?("custom")
begin
cfg = YaST::ConfigFile.new(:custom_services)
cfg.each do |name, s|
service = Service.new(name)
+ if read_status and s.has_key?("status")
+ ret = Scr.instance.execute([s["status"]])
+ service.status = ret[:exit]
+ end
Rails.logger.debug "custom service: #{service.inspect}"
services << service
end
@@ -28,14 +34,18 @@ class Service
end
else
rl = `runlevel`.split(" ").last
- yapi_ret = YastService.Call("YaPI::SERVICES::Read", rl == "S" ? -1 : rl.to_i)
+ params = {
+ "runlevel" => [ "i", rl == "S" ? -1 : rl.to_i ],
+ "read_status" => [ "b", read_status]
+ }
+ yapi_ret = YastService.Call("YaPI::SERVICES::Read", params)
if yapi_ret.nil?
raise "Can't get services list"
else
yapi_ret.each do |s|
- service = Service.new(s)
- # read status on demand, it takes much time
+ service = Service.new(s["name"])
+ service.status= s["status"] if s.has_key?("status")
Rails.logger.debug "service: #{service.inspect}"
services << service
end
@@ -62,7 +72,7 @@ class Service
return { :stderr => e }
end
- if custom_service.blank?
+ if custom_service.blank? or not custom_service.has_key?(cmd)
Rails.logger.debug "no custom command found, calling YaPI..."
ret = YastService.Call("YaPI::SERVICES::Execute", self.name, cmd)
else
diff --git a/plugins/services/config/resources/services.yml b/plugins/services/config/resources/services.yml
index a3d3486..87506cd 100644
--- a/plugins/services/config/resources/services.yml
+++ b/plugins/services/config/resources/services.yml
@@ -1,3 +1,2 @@
interface: org.opensuse.yast.modules.yapi.services
controller: services
-nested: permissions
diff --git a/plugins/services/package/yast2-webservice-services.spec b/plugins/services/package/yast2-webservice-services.spec
index e96556d..b777b90 100644
--- a/plugins/services/package/yast2-webservice-services.spec
+++ b/plugins/services/package/yast2-webservice-services.spec
@@ -24,7 +24,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
# YaPI/SERVICES.pm
-Requires: yast2 >= 2.17.10.1
+Requires: yast2 >= 2.17.10.2
#
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org