make report url from job ids in console client
This commit is contained in:
parent
775c9758ca
commit
ac0a81831c
@ -26,7 +26,8 @@ class Deploy < Handler
|
||||
@options_parser.invalid_deploy_command
|
||||
abort()
|
||||
end
|
||||
post_chunk("/deploy", :names => names, :tags => tags)
|
||||
job_ids = post("/deploy", :names => names, :tags => tags)
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -13,6 +13,17 @@ module Outputtable
|
||||
outputter.output(options)
|
||||
end
|
||||
|
||||
def report_url(job_id)
|
||||
create_url "report/#{job_id}"
|
||||
end
|
||||
|
||||
def reports_urls(job_ids)
|
||||
raise "Parameter should be an array of strings" unless job_ids.is_a?(Array)
|
||||
job_ids.map do |job_id|
|
||||
report_url(job_id)
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
|
||||
def self.included(base)
|
||||
base.extend(ClassMethods)
|
||||
|
||||
@ -87,7 +87,6 @@ class Project < Handler
|
||||
when "delete_servers"
|
||||
self.options = @options_parser.delete_servers_options
|
||||
delete_servers_handler @options_parser.args
|
||||
output(output_type: :delete_servers)
|
||||
else
|
||||
@options_parser.invalid_command
|
||||
end
|
||||
@ -279,7 +278,8 @@ class Project < Handler
|
||||
q = {}
|
||||
q[:servers] = options[:servers] unless options[:servers].nil?
|
||||
q[:deploy_env] = args[3] unless args[3].nil?
|
||||
post_chunk "/project/#{args[2]}/deploy", q
|
||||
job_ids = post "/project/#{args[2]}/deploy", q
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
|
||||
def test_handler args
|
||||
@ -288,8 +288,8 @@ class Project < Handler
|
||||
@options_parser.invalid_test_command
|
||||
abort(r)
|
||||
end
|
||||
response = post "/project/test/#{args[2]}/#{args[3]}"
|
||||
puts response.inspect
|
||||
job_ids = post "/project/test/#{args[2]}/#{args[3]}"
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
|
||||
protected
|
||||
@ -456,7 +456,8 @@ protected
|
||||
deploy_env: env,
|
||||
dry_run: false
|
||||
}
|
||||
@list = delete("/project/#{project}/servers", body)
|
||||
response = delete("/project/#{project}/servers", body)
|
||||
reports_urls(response['reports'])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@ -75,7 +75,8 @@ class Server < Handler
|
||||
q[k] = self.options[k] unless self.options[k].nil?
|
||||
end
|
||||
|
||||
post_chunk "/server", q
|
||||
job_ids = post "/server", q
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
|
||||
def delete_handler
|
||||
@ -86,11 +87,11 @@ class Server < Handler
|
||||
abort(r)
|
||||
end
|
||||
if question(I18n.t("handler.server.question.delete", :name => name))
|
||||
puts "Server '#{name}', deleting..."
|
||||
puts delete("/server/#{name}", options)
|
||||
jobs_ids = delete("/server/#{name}", options) # returns array with one job id, actually
|
||||
puts reports_urls(jobs_ids)
|
||||
end
|
||||
end
|
||||
""
|
||||
nil
|
||||
end
|
||||
|
||||
def show_handler
|
||||
@ -117,7 +118,8 @@ class Server < Handler
|
||||
if q.has_key?(:run_list)
|
||||
abort unless Project.validate_run_list(q[:run_list])
|
||||
end
|
||||
post_chunk "/server/bootstrap", q
|
||||
job_ids = post "/server/bootstrap", q
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
|
||||
def add_static_handler # add <project> <env> <private_ip> <ssh_username> --public-ip <public_ip> -k <keyname>
|
||||
|
||||
@ -63,7 +63,8 @@ class Stack < Handler
|
||||
|
||||
json = JSON.pretty_generate(q)
|
||||
if question(I18n.t("handler.stack.question.create")) {puts json}
|
||||
post_body "/stack", json
|
||||
job_ids = post_body "/stack", json
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
end
|
||||
|
||||
@ -123,8 +124,8 @@ class Stack < Handler
|
||||
|
||||
def deploy_handler
|
||||
stack_id = @args[2]
|
||||
response = post "/stack/#{stack_id}/deploy"
|
||||
puts response.inspect
|
||||
job_ids = post "/stack/#{stack_id}/deploy"
|
||||
reports_urls(job_ids)
|
||||
end
|
||||
|
||||
def reserve_handler
|
||||
|
||||
@ -27,8 +27,6 @@ module Output
|
||||
when :test
|
||||
title = I18n.t("output.title.project.test", :project => ARGV[2], :env => ARGV[3])
|
||||
create_test(@data)
|
||||
when :delete_servers
|
||||
return delete_servers_output
|
||||
else
|
||||
title = I18n.t("output.title.project.list")
|
||||
create_list(@data)
|
||||
@ -151,18 +149,5 @@ module Output
|
||||
headers_and_rows(stacks, fields_to_output)
|
||||
end
|
||||
|
||||
def delete_servers_output
|
||||
output = ''
|
||||
|
||||
if @data['reports'].empty?
|
||||
output << 'There are no deleted servers.'
|
||||
else
|
||||
output << "Reports for servers deleting:\n----\n"
|
||||
output << @data['reports'].join("\n")
|
||||
end
|
||||
|
||||
output
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user