Class: CPEE::NewInstance

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/cpee/implementation.rb', line 153

def response
  controller = @a[0]
  opts = @a[1]
  name = @p[0].value
  id = controller.keys.sort.last.to_i

  while true
    id += 1
    unless Dir.exists? opts[:instances] + "/#{id}"
      Dir.mkdir(opts[:instances] + "/#{id}") rescue nil
      break
    end
  end

  controller[id] = Controller.new(id,opts)
  controller[id].info = name
  controller[id].state_change!

  @headers << Riddl::Header.new("CPEE-INSTANCE", controller[id].instance)
  @headers << Riddl::Header.new("CPEE-INSTANCE-URL", controller[id].instance_url)
  @headers << Riddl::Header.new("CPEE-INSTANCE-UUID", controller[id].uuid)

  Riddl::Parameter::Simple.new("id", id)
end