31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/chef/knife/goiardi_job_cancel.rb', line 31
def run
job_id = @name_args[0]
if job_id.nil?
ui.error "No job id specified"
show_usage
exit 1
end
@node_names = name_args[1, name_args.length - 1]
rest = Chef::REST.new(Chef::Config[:chef_server_url])
cancel_json = {
'run_id' => job_id,
'nodes' => @node_names
}
if config[:kill_timeout]
cancel_json['kill_timeout'] = config[:kill_timeout]
end
result = rest.put_rest('shovey/jobs/cancel', cancel_json)
cancel_output = {
"command" => result["command"],
"id" => result["id"],
"status" => result["status"],
"cancelled nodes" => result["nodes"]["cancelled"]
}
output(cancel_output)
end
|