module Devops module API2_0 module Routes module DeployRoutes def self.registered(app) # Run chef-client on reserved server # # * *Request* # - method : POST # - headers : # - Content-Type: application/json # - body : # { # "names": [], -> array of servers names to run chef-client # "tags": [], -> array of tags to apply on each server before running chef-client # "build_number": "" -> string, build number to deploy # } # # * *Returns* : text stream app.post_with_headers "/deploy", :headers => [:content_type] do check_privileges("server", "x") if request["X-Stream"] stream() do |out| status = [] begin status = Devops::API2_0::Handler::Deploy.new(request).deploy_stream(out) out << create_status(status) rescue IOError => e logger.error e.message break end end # stream else ids = Devops::API2_0::Handler::Deploy.new(request).deploy() sleep 1 ids.each do |jid| uri.path = "#{DevopsConfig.config[:url_prefix]}/v2.0/report/" + jid files.push uri.to_s end json files end end puts "Deploy routes initialized" end end end end end