Class: CPEE::Instances

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

Overview

{{{

Instance Method Summary collapse

Instance Method Details

#responseObject



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/cpee/implementation.rb', line 176

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