ref: refs/heads/master
commit 27e90cfcc069485912013a8493df0751bc394617
Author: Ladislav Slezak
Date: Thu Aug 27 15:31:32 2009 +0200
services - added show method to query the current status
---
.../app/controllers/services_controller.rb | 18 ++++++++++++++++++
plugins/services/app/models/service.rb | 3 +++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/plugins/services/app/controllers/services_controller.rb b/plugins/services/app/controllers/services_controller.rb
index c3d5b51..246e822 100644
--- a/plugins/services/app/controllers/services_controller.rb
+++ b/plugins/services/app/controllers/services_controller.rb
@@ -11,6 +11,24 @@ class ServicesController < ApplicationController
@services = Service.find_all params
end
+ # GET /services/service_name
+ # GET /services/service_name.xml
+ # GET /services/service_name.json
+ def show
+ unless permission_check("org.opensuse.yast.modules.yapi.services.read")
+ render ErrorResult.error(403, 1, "no permission") and return
+ end
+
+ @service = Service.new(params[:id])
+ @service.read_status
+
+ respond_to do |format|
+ format.html { render :xml => @service.to_xml(:root => 'service', :dasherize => false), :location => "none" } #return xml only
+ format.xml { render :xml => @service.to_xml(:root => 'service', :dasherize => false), :location => "none" }
+ format.json { render :json => @service.to_json, :location => "none" }
+ end
+ end
+
# PUT /services/1.xml
# Shows service status. Requires execute permission for services YaPI.
def update
diff --git a/plugins/services/app/models/service.rb b/plugins/services/app/models/service.rb
index 978f0de..40ae6c3 100644
--- a/plugins/services/app/models/service.rb
+++ b/plugins/services/app/models/service.rb
@@ -76,6 +76,9 @@ class Service
Service.new(id)
end
+ def read_status
+ @status = save('status')['exit']
+ end
# execute a service command (start, stop, ...)
def save(cmd)
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org