class Chef::Knife::JobStart
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/job_start.rb, line 87 def run job_name = @name_args[0] if job_name.nil? ui.error "No job specified." show_usage exit 1 end @node_names = process_search(config[:search], name_args[1, @name_args.length - 1]) job_json = { "command" => job_name, "nodes" => @node_names, } job_json["quorum"] = get_quorum(config[:quorum], @node_names.length) v2_json = job_json.dup v2_json["file"] = "raw:" + file_helper(config[:send_file]) if config[:send_file] v2_json["capture_output"] = config[:capture_output] env = get_env(config) v2_json["env"] = env if env v2_json["dir"] = config[:in_dir] if config[:in_dir] v2_json["user"] = config[:as_user] if config[:as_user] begin job = run_helper(config, v2_json) rescue Net::HTTPClientException => e raise e if e.response.code != "400" ui.warn "Falling back to Push Jobs v1 mode." unless env.empty? ui.error "Sending Environment attributes isn't possible for Push Jobs 1.0" exit 1 end %i{ send_file dir user }.each do |feature| if config[feature] ui.error "Can't use a 2.0 feature (#{feature}) with a 1.0 server" exit 1 end end job = run_helper(config, job_json) end output(job) exit(status_code(job)) end