Created
October 31, 2012 01:55
-
-
Save anonymous/3984352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 a command line attribute was not passed, and we have a cloud public_hostname, use that. | |
# see #configure_attribute for the source of config[:attribute] and config[:override_attribute] | |
if !config[:override_attribute] && item[:cloud] and item[:cloud][:public_hostname] && (item[:cloud][:provider] != "rackspace") | |
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 | |
r.push(i) unless i.nil? | |
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 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment