#840: refactored
This commit is contained in:
parent
9574b710b2
commit
ca21238de2
@ -119,17 +119,15 @@ module Devops
|
|||||||
|
|
||||||
# TODO: check bootstrap template name
|
# TODO: check bootstrap template name
|
||||||
def bootstrap_server_stream out
|
def bootstrap_server_stream out
|
||||||
s, rl, bt = prepare_bootstrap_server
|
options = prepare_bootstrap_server
|
||||||
|
s = options.delete[:server]
|
||||||
status = []
|
status = []
|
||||||
cert = Devops::Db.connector.key s.key
|
cert = Devops::Db.connector.key s.key
|
||||||
DevopsLogger.logger.debug "Bootstrap certificate path: #{cert.path}"
|
DevopsLogger.logger.debug "Bootstrap certificate path: #{cert.path}"
|
||||||
#bootstrap s, out, cert.path, logger
|
#bootstrap s, out, cert.path, logger
|
||||||
options = {
|
options[:cert_path] = cert.path
|
||||||
:bootstrap_template => bt,
|
executor = Devops::Executor::ServerExecutor.new(s, out)
|
||||||
:cert_path => cert.path,
|
r = executor.two_phase_bootstrap(options)
|
||||||
:run_list => rl
|
|
||||||
}
|
|
||||||
r = two_phase_bootstrap s, options, out
|
|
||||||
str = nil
|
str = nil
|
||||||
r = if check_server(s)
|
r = if check_server(s)
|
||||||
Devops::Db.connector.server_set_chef_node_name s
|
Devops::Db.connector.server_set_chef_node_name s
|
||||||
@ -148,17 +146,16 @@ module Devops
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bootstrap_server
|
def bootstrap_server
|
||||||
server, rl, bootstrap_template = prepare_bootstrap_server
|
options = prepare_bootstrap_server
|
||||||
dir = DevopsConfig[:report_dir_v2]
|
s = options.delete[:server]
|
||||||
files = []
|
options[:provider_name] = s.provider
|
||||||
uri = URI.parse(@request.url)
|
options[:server_attrs] = s.to_mongo_hash
|
||||||
|
options[:owner] = parser.current_user
|
||||||
|
# dir = DevopsConfig[:report_dir_v2]
|
||||||
|
# files = []
|
||||||
|
# uri = URI.parse(@request.url)
|
||||||
|
|
||||||
uri = Worker.start_async(BootstrapWorker, @request,
|
uri = Worker.start_async(BootstrapWorker, @request, options)
|
||||||
provider_name: server.provider,
|
|
||||||
server_attrs: server.to_mongo_hash,
|
|
||||||
bootstrap_template: bootstrap_template,
|
|
||||||
owner: parser.current_user
|
|
||||||
)
|
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
[uri]
|
[uri]
|
||||||
@ -171,6 +168,7 @@ module Devops
|
|||||||
rl = body["run_list"]
|
rl = body["run_list"]
|
||||||
t = body["bootstrap_template"]
|
t = body["bootstrap_template"]
|
||||||
s = Devops::Db.connector.server_by_instance_id(id)
|
s = Devops::Db.connector.server_by_instance_id(id)
|
||||||
|
res = {server: s}
|
||||||
|
|
||||||
p = Devops::Db.connector.check_project_auth s.project, s.deploy_env, parser.current_user
|
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)
|
||||||
@ -181,9 +179,11 @@ module Devops
|
|||||||
unless t.nil?
|
unless t.nil?
|
||||||
templates = get_templates
|
templates = get_templates
|
||||||
halt_response("Invalid bootstrap template '#{t}', available values: #{templates.join(", ")}", 400) unless templates.include?(t)
|
halt_response("Invalid bootstrap template '#{t}', available values: #{templates.join(", ")}", 400) unless templates.include?(t)
|
||||||
|
s[:bootstrap_template] = t
|
||||||
end
|
end
|
||||||
s.chef_node_name = name || provider.create_default_chef_node_name(s)
|
s.chef_node_name = name || provider.create_default_chef_node_name(s)
|
||||||
return s, rl || d.run_list, t
|
res[:run_list] = rl || d.run_list
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
def unbootstrap_server id
|
def unbootstrap_server id
|
||||||
|
|||||||
@ -215,7 +215,11 @@ module Devops
|
|||||||
bootstrap_options
|
bootstrap_options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prepare_two_phase_bootstrap options
|
||||||
|
end
|
||||||
|
|
||||||
def two_phase_bootstrap options
|
def two_phase_bootstrap options
|
||||||
|
prepare_two_phase_bootstrap(options)
|
||||||
# bootstrap phase
|
# bootstrap phase
|
||||||
begin
|
begin
|
||||||
provider = @server.provider_instance
|
provider = @server.provider_instance
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user