Class: CPEE::Instantiation::InstantiateXML

Inherits:
Riddl::Implementation
  • Object
show all
Includes:
Helpers
Defined in:
lib/cpee/instantiation.rb

Overview

}}}

Instance Method Summary collapse

Methods included from Helpers

#handle_data, #handle_endpoints

Instance Method Details

#responseObject



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/cpee/instantiation.rb', line 227

def response
  cpee     = @h['X_CPEE'] || @a[0]
  behavior = @a[1] ? 'fork_ready' : @p[0].value
  data     = @a[1] ? 0 : 1
  selfurl  = @a[2]
  cblist   = @a[3]
  tdoc = if @p[data].additional =~ /base64/
    Base64.decode64(@p[data].value.read)
  else
    @p[data].value.read
  end

  if (instance, uuid = load_testset(tdoc,cpee)).first == -1
    @status = 500
  else
    handle_data cpee, instance, @p[data+1]&.value
    handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
    handle_starting cpee, instance, behavior

    send = {
      'CPEE-INSTANCE' => instance,
      'CPEE-INSTANCE-URL' => File.join(cpee,instance),
      'CPEE-INSTANCE-UUID' => uuid,
      'CPEE-BEHAVIOR' => behavior
    }
    Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
  end
end