2014-10-22 15:01:55 +04:00
|
|
|
require File.join(File.dirname(__FILE__), "worker")
|
|
|
|
|
|
|
|
|
|
require "commands/deploy"
|
|
|
|
|
require "db/mongo/models/server"
|
2014-11-17 14:23:59 +03:00
|
|
|
require "db/mongo/models/report"
|
2014-10-22 15:01:55 +04:00
|
|
|
|
|
|
|
|
class DeployWorker < Worker
|
|
|
|
|
include DeployCommands
|
|
|
|
|
|
2015-07-30 15:37:43 +03:00
|
|
|
def perform(dir, server, tags, owner, conf, deploy_info)
|
|
|
|
|
call(conf, nil, dir) do |provider, out, file|
|
|
|
|
|
mongo = Devops::Db.connector
|
2014-12-04 13:07:25 +03:00
|
|
|
s = Server.new(server)
|
|
|
|
|
o = {
|
|
|
|
|
"file" => file,
|
|
|
|
|
"_id" => jid,
|
|
|
|
|
"created_by" => owner,
|
|
|
|
|
"project" => s.project,
|
|
|
|
|
"deploy_env" => s.deploy_env,
|
2015-07-30 15:37:43 +03:00
|
|
|
"type" => Report::DEPLOY_TYPE,
|
|
|
|
|
"status" => STATUS::RUNNING,
|
|
|
|
|
"chef_node_name" => s.chef_node_name,
|
|
|
|
|
"host" => s.public_ip || s.private_ip
|
2014-12-04 13:07:25 +03:00
|
|
|
}
|
|
|
|
|
mongo.save_report(Report.new(o))
|
2014-11-17 14:23:59 +03:00
|
|
|
|
2015-07-30 15:37:43 +03:00
|
|
|
status = deploy_server_proc.call(out, s, tags, deploy_info)
|
2014-12-04 13:07:25 +03:00
|
|
|
status
|
2014-10-22 15:01:55 +04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|