fixed bootstrap worker
This commit is contained in:
parent
f8b1d60fb1
commit
e0a62d88cf
@ -166,14 +166,14 @@ module Devops
|
||||
end
|
||||
|
||||
def bootstrap_server
|
||||
s = prepare_bootstrap_server
|
||||
s, rl, bt = prepare_bootstrap_server
|
||||
dir = DevopsConfig[:report_dir_v2]
|
||||
files = []
|
||||
uri = URI.parse(@request.url)
|
||||
h = s.to_hash
|
||||
h["options"] = s.options
|
||||
# h["options"] = s.options
|
||||
h["_id"] = s.id
|
||||
jid = BootstrapWorker.perform_async(dir, d.provider, h, parser.current_user, DevopsConfig.config)
|
||||
jid = BootstrapWorker.perform_async(dir, s.provider, h, bt, parser.current_user, DevopsConfig.config)
|
||||
Worker.set_status jid, Worker::STATUS::IN_QUEUE
|
||||
logger.info "Job '#{jid}' has been started"
|
||||
uri.path = "#{DevopsConfig[:url_prefix]}/v2.0/report/" + jid
|
||||
@ -188,24 +188,22 @@ module Devops
|
||||
body = parser.bootstrap
|
||||
id = body["instance_id"]
|
||||
name = body["name"]
|
||||
rl = body["run_list"]
|
||||
t = body["bootstrap_template"]
|
||||
s = Devops::Db.connector.server_by_instance_id(id)
|
||||
|
||||
p = Devops::Db.connector.check_project_auth s.project, s.deploy_env, parser.current_user
|
||||
d = p.deploy_env s.deploy_env
|
||||
d = p.deploy_env(s.deploy_env)
|
||||
|
||||
provider = ::Provider::ProviderFactory.get(s.provider)
|
||||
|
||||
check_chef_node_name(name, provider) unless name.nil?
|
||||
s.options = {
|
||||
:run_list => rl || d.run_list,
|
||||
}
|
||||
unless t.nil?
|
||||
templates = get_templates
|
||||
halt_response("Invalid bootstrap template '#{t}', available values: #{templates.join(", ")}", 400) unless templates.include?(t)
|
||||
s.options[:bootstrap_template] = t
|
||||
end
|
||||
s.chef_node_name = name || provider.create_default_chef_node_name(s)
|
||||
s
|
||||
return s, rl || d.run_list, t
|
||||
end
|
||||
|
||||
def add_server
|
||||
@ -225,7 +223,6 @@ module Devops
|
||||
s.remote_user = body["remote_user"]
|
||||
s.private_ip = body["private_ip"]
|
||||
s.public_ip = body["public_ip"]
|
||||
s.static = true
|
||||
s.id = "static_#{cert.id}-#{Time.now.to_i}"
|
||||
s.key = cert.id
|
||||
Devops::Db.connector.server_insert s
|
||||
|
||||
@ -6,7 +6,7 @@ require "exceptions/record_not_found"
|
||||
module ServerCommands
|
||||
|
||||
include DeployCommands
|
||||
|
||||
=begin
|
||||
def create_server_proc
|
||||
lambda do |out, s, provider|
|
||||
mongo = ::Devops::Db.connector
|
||||
@ -29,6 +29,7 @@ module ServerCommands
|
||||
end
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
||||
def create_server project, env, params, user, out
|
||||
provider = ::Provider::ProviderFactory.get(env.provider)
|
||||
|
||||
@ -11,11 +11,11 @@ require "db/mongo/models/report"
|
||||
class BootstrapWorker < Worker
|
||||
include ServerCommands
|
||||
|
||||
def perform(dir, e_provider, server, owner, conf)
|
||||
def perform(dir, e_provider, server, bootstrap_template, owner, conf)
|
||||
call(conf, e_provider, dir) do |provider, out, file|
|
||||
mongo = Devops::Db.connector
|
||||
s = Server.new(server)
|
||||
s.options = convert_config(server["options"])
|
||||
# s.options = convert_config(server["options"])
|
||||
o = {
|
||||
"file" => file,
|
||||
"_id" => jid,
|
||||
@ -27,8 +27,9 @@ class BootstrapWorker < Worker
|
||||
mongo.save_report(Report.new(o))
|
||||
|
||||
key = mongo.key(s.key)
|
||||
out << "\nBootstrap with run list: #{s.options[:run_list].inspect}"
|
||||
status = bootstrap(s, out, key.path)
|
||||
# out << "\nBootstrap with run list: #{s.options[:run_list].inspect}"
|
||||
status = two_phase_bootstrap s, provider.run_list, bootstrap_template, key.path, out
|
||||
# status = bootstrap(s, out, key.path)
|
||||
mongo.set_report_server_data(jid, s.chef_node_name, s.public_ip || s.private_ip)
|
||||
status
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user