Class: CPEE::DeleteInstance

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/cpee/implementation.rb', line 374

def response
  opts = @a[0]
  redis = opts[:redis]
  id = @r[0].to_i
  unless CPEE::Persistence::exists?(id,opts)
    @status = 404
    return
  end

  content = {
    :state => 'purged',
    :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h
  }
  state = CPEE::Persistence::extract_item(id,opts,'state')
  if state == 'stopped' || state == 'ready'
    CPEE::Message::send(:event,'state/change',File.join(opts[:url],'/'),id,content[:attributes]['uuid'],content[:attributes]['info'],content,redis)
  end

  empt = CPEE::Persistence::keys(id,opts).to_a
  redis.multi do |multi|
    empt.each do |e|
      multi.expire e, 30
    end
    multi.zrem 'instances', id
  end
end