summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXabier de Zuazo <xabier@zuazo.org>2012-09-17 14:48:49 +0200
committerBryan McLellan <btm@opscode.com>2012-09-19 16:33:49 -0700
commit6fb8f266a9603a742fa6d4d003bd5596eeec5ada (patch)
treeae71790cd232909e7e5ebc984827ef85105fe33c
parentfefa091626b4f79dcc62efb68915b5ccca767fde (diff)
downloadchef-6fb8f266a9603a742fa6d4d003bd5596eeec5ada.tar.gz
CHEF-3402 fixed: knife ssh says "No nodes returned from search!" when FQDN attribute is missing
-rw-r--r--chef/lib/chef/knife/ssh.rb11
-rw-r--r--chef/spec/unit/knife/ssh_spec.rb15
2 files changed, 25 insertions, 1 deletions
diff --git a/chef/lib/chef/knife/ssh.rb b/chef/lib/chef/knife/ssh.rb
index f458aa3a88..4ef408ddf9 100644
--- a/chef/lib/chef/knife/ssh.rb
+++ b/chef/lib/chef/knife/ssh.rb
@@ -137,7 +137,16 @@ class Chef
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 do not have the required attribute to stablish the connection. " +
+ "Try setting another attribute to open the connection using --attribute.")
+ end
+ exit 10
+ end
session_from_list(list)
end
diff --git a/chef/spec/unit/knife/ssh_spec.rb b/chef/spec/unit/knife/ssh_spec.rb
index e8a4d02397..4ac12117ae 100644
--- a/chef/spec/unit/knife/ssh_spec.rb
+++ b/chef/spec/unit/knife/ssh_spec.rb
@@ -105,6 +105,21 @@ describe Chef::Knife::Ssh do
@knife.should_receive(:exit).with(10)
@knife.configure_session
end
+
+ context "when there are some hosts found but they do not have an attribute to connect with" do
+ before do
+ @query.stub!(:search).and_return([[@node_foo, @node_bar]])
+ @node_foo[:fqdn] = nil
+ @node_bar[:fqdn] = nil
+ Chef::Search::Query.stub!(:new).and_return(@query)
+ end
+
+ it "should raise a specific error (CHEF-3402)" do
+ @knife.ui.should_receive(:fatal).with(/^2 nodes found/)
+ @knife.should_receive(:exit).with(10)
+ @knife.configure_session
+ end
+ end
end
context "manual is set to true" do