Class: CPEE::Instances

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee/implementation.rb

Overview

{{{

Instance Method Summary collapse

Instance Method Details

#responseObject



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/cpee/implementation.rb', line 161

def response
  redis = @a[0][:redis]
  Riddl::Parameter::Complex.new("wis","text/xml") do
    ins = XML::Smart::string('<instances/>')
    redis.zrevrange('instances',0,-1).each do |instance|
      statekey = "instance:#{instance}/state"
      attributes = "instance:#{instance}/attributes/"
      info = redis.get(attributes + 'info')
      uuid = redis.get(attributes + 'uuid')
      state = redis.get(statekey)
      state_changed = redis.get(File.join(statekey,'@changed'))
      ins.root.add('instance', info,  'uuid' => uuid, 'id' => instance, 'state' => state, 'state_changed' => state_changed )
    end
    ins.to_s
  end
end