Class: Visor::Image::DeleteAllImages

Inherits:
Goliath::API
  • Object
show all
Includes:
Common::Exception
Defined in:
lib/image/routes/delete_all_images.rb

Overview

Delete all images metadata

Instance Method Summary collapse

Instance Method Details

#exit_error(code, message) ⇒ Object



35
36
37
38
# File 'lib/image/routes/delete_all_images.rb', line 35

def exit_error(code, message)
  logger.error message
  [code, {}, {code: code, message: message}]
end

#on_headers(env, headers) ⇒ Object

Pre-process headers as they arrive and load them into a environment variable.

Parameters:

  • env (Object)

    The Goliath environment variables.

  • headers (Object)

    The incoming request HTTP headers.



17
18
19
20
# File 'lib/image/routes/delete_all_images.rb', line 17

def on_headers(env, headers)
  logger.debug "Received headers: #{headers.inspect}"
  env['headers'] = headers
end

#response(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/image/routes/delete_all_images.rb', line 22

def response(env)
  authorize(env, vas)
  images = vms.get_images
  images.each { |image| vms.delete_image(image[:_id]) }
  [200, {}, nil]
rescue Forbidden => e
  exit_error(403, e.message)
rescue NotFound => e
  exit_error(404, e.message)
rescue InternalError => e
  exit_error(503, e.message)
end