def configure_session
list = case config[:manual]
when true
@name_args[0].split(" ")
when false
r = Array.new
q = Chef::Search::Query.new
@action_nodes = q.search(:node, @name_args[0])[0]
@action_nodes.each do |item|
next if item.nil?
if !config[:override_attribute] && item[:cloud] and item[:cloud][:public_hostname]
i = item[:cloud][:public_hostname]
elsif config[:override_attribute]
i = format_for_display(item)[config[:override_attribute]]
else
i = format_for_display(item)[config[:attribute]]
end
next if i.nil?
r.push(i)
end
r
end
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 to establish the connection. " +
"Try setting another attribute to open the connection using --attribute.")
end
exit 10
end
session_from_list(list)
end