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

Instance Method Details

#responseObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/cpee/instantiation.rb', line 172

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