Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] <rest-service> master : status module: added to_xml method again.
  • From: Bjoern Geuken <bgeuken@xxxxxxx>
  • Date: Fri, 3 Jul 2009 17:50:24 +0200
  • Message-id: <E1MMl2x-0005ZL-W5@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 55b03cb9a9f4261c26d573de3c89bf7e5c30a7e4
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Fri Jul 3 17:50:24 2009 +0200

status module: added to_xml method again.
need to fix depth of xml tree
---
plugins/status/app/models/status.rb | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/plugins/status/app/models/status.rb
b/plugins/status/app/models/status.rb
index 4409b2f..023474e 100644
--- a/plugins/status/app/models/status.rb
+++ b/plugins/status/app/models/status.rb
@@ -1,8 +1,27 @@
-class Status < ActiveRecord::Base
+class Status #< ActiveRecord::Base
require 'scr'

attr_accessor :data

+
+ def to_xml(options = {})
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
+
+ xml.status do
+ @data.each_pair do |branch, n|
+ #xml.branch
+ leaf = @data["#{branch}"].split "|"
+ leaf.each do |p|
+ pair = p.split "=>"
+ pair.each do |key, value|
+ xml.tag!("#{pair[0]}", "#{pair[1]}")
+ end
+ end
+ end
+ end
+ end
+
def initialize
@scr = Scr.instance
@health_status = nil
@@ -66,10 +85,13 @@ class Status < ActiveRecord::Base
unless @timestamp.nil?
@metrics.each_pair do |m, n|
@metrics["#{m}"][:rrds].each do |rrdb|
- @data["#{m}"] = {"#{rrdb}" => fetch_metric("#{m}/#{rrdb}", start,
stop)}
+ value = fetch_metric("#{m}/#{rrdb}", start, stop)
+ @data["#{m}"] = "#{@data["#{m}"]}|#{rrdb.chomp(".rrd")}=>#{value}"
+ # @data["#{m}"]["#{rrdb}"] = fetch_metric("#{m}/#{rrdb}", start, stop)
end
end
end
+@data
end

# creates one metric for defined period
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages