lib/chef/knife/winrm.rb in knife-windows-0.5.10 vs lib/chef/knife/winrm.rb in knife-windows-0.5.12

- old
+ new

@@ -87,11 +87,20 @@ i = format_for_display(item)[config[:attribute]] r.push(i) unless i.nil? end r end - (ui.fatal("No nodes returned from search!"); exit 10) if list.length == 0 + if list.length == 0 + if @action_nodes.length == 0 + ui.fatal("No nodes returned from search!") + else + ui.fatal("#{@action_nodes.length} #{@action_nodes.length > 1 ? "nodes":"node"} found, " + + "but does not have the required attribute (#{config[:attribute]}) to establish the connection. " + + "Try setting another attribute to open the connection using --attribute.") + end + exit 10 + end session_from_list(list) end def session_from_list(list) list.each do |item| @@ -236,10 +245,10 @@ if config[:returns] check_for_errors! session.exit_codes end session.close - exit @exit_code || 0 + @exit_code || 0 end rescue WinRM::WinRMHTTPTransportError => e case e.message when /401/ ui.error "Failed to authenticate to #{@name_args[0].split(" ")} as #{config[:winrm_user]}"