Class: CPEE::Instances

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

Overview

{{{

Instance Method Summary collapse

Instance Method Details

#responseObject



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/cpee/implementation.rb', line 233

def response
  opts = @a[0]
  pp @request[:env]['REMOTE_ADDR']
  if opts[:see_instances] || @h['SEE_INSTANCES'] == 'true'
    Riddl::Parameter::Complex.new("wis","text/xml") do
      ins = XML::Smart::string('<instances/>')
      CPEE::Persistence::each_object(opts) do |instance|
        info = CPEE::Persistence::extract_item(instance,opts,'attributes/info')
        uuid = CPEE::Persistence::extract_item(instance,opts,'attributes/uuid')
        state = CPEE::Persistence::extract_item(instance,opts,'state')
        state_changed = CPEE::Persistence::extract_item(instance,opts,'state/@changed')
        ins.root.add('instance', info,  'uuid' => uuid, 'id' => instance, 'state' => state, 'state_changed' => state_changed )
      end
      ins.to_s
    end
  else
    Riddl::Parameter::Complex.new("wis","text/xml",'<instances><!-- instances list disabled. --></instances>')
  end
end