This commit is contained in:
amartynov 2015-09-11 12:05:13 +03:00
parent 85cb61e6b5
commit f9b9682c6d
3 changed files with 8 additions and 7 deletions

View File

@ -35,8 +35,6 @@ module Devops
# {"name" : "project_1"} # {"name" : "project_1"}
# ] # ]
app.get_with_headers "/projects", :headers => [:accept] do app.get_with_headers "/projects", :headers => [:accept] do
puts env.inspect
puts env["app"].inspect
check_privileges("project", "r") check_privileges("project", "r")
json Devops::API2_0::Handler::Project.new(request).projects.map(&:to_hash_list) json Devops::API2_0::Handler::Project.new(request).projects.map(&:to_hash_list)
end end

View File

@ -131,7 +131,6 @@ module Devops
# all exceptions are handled in @validate! method # all exceptions are handled in @validate! method
def validate_model(model) def validate_model(model)
DevopsLogger.logger.debug validators.inspect
validators.each do |validator| validators.each do |validator|
validator.new(model).validate! validator.new(model).validate!
end end

View File

@ -16,6 +16,8 @@ require "lib/knife/knife_factory"
class Worker class Worker
include Sidekiq::Worker include Sidekiq::Worker
attr_accessor :out
module STATUS module STATUS
INIT = "init" INIT = "init"
RUNNING = "running" RUNNING = "running"
@ -34,12 +36,14 @@ class Worker
uri.to_s uri.to_s
end end
def self.start_sync(worker_class, request, job_options) def self.start_sync(worker_class, request, job_options, out)
stringified_options = {} stringified_options = {}
job_options.each do |key, value| job_options.each do |key, value|
stringified_options[key.to_s] = value stringified_options[key.to_s] = value
end end
worker_class.new.perform(stringified_options) w = worker_class.new
w.out = out
w.perform(stringified_options)
end end
def self.set_status id, status def self.set_status id, status
@ -81,8 +85,9 @@ class Worker
File.open(file, "w") do |out| File.open(file, "w") do |out|
begin begin
update_job_status(STATUS::RUNNING) update_job_status(STATUS::RUNNING)
self.out = out
job_result = yield(provider, out, file) job_result = yield(provider, file)
canonical_status = (job_result == 0 ? STATUS::COMPLETED : STATUS::FAILED) canonical_status = (job_result == 0 ? STATUS::COMPLETED : STATUS::FAILED)
update_job_status(canonical_status) update_job_status(canonical_status)
rescue StandardError, RecordNotFound => e rescue StandardError, RecordNotFound => e
@ -124,7 +129,6 @@ class Worker
def convert_config conf def convert_config conf
config = {} config = {}
conf.each {|k,v| config[k.is_a?(String) ? k.to_sym : k] = v} conf.each {|k,v| config[k.is_a?(String) ? k.to_sym : k] = v}
DevopsLogger.logger.debug "Config: #{config.inspect}"
config config
end end