17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/deploytool/command.rb', line 17
def self.run(command, args)
if args.include?("--debug")
args.delete("--debug")
$logger.level = Logger::DEBUG
elsif args.include?("-d")
args.delete("-d")
$logger.level = Logger::DEBUG
elsif args.include?("-v")
args.delete("-v")
$logger.level = Logger::DEBUG
else
$logger.level = Logger::INFO
end
change_to_toplevel_dir!
DeployTool::Config.load(".deployrc")
if command == "help"
print_help
elsif command == "add"
if args[0].nil?
puts "ERROR: Missing target name."
puts ""
puts "Use \"deploy help\" if you're lost."
exit
end
if args[1].nil?
puts "ERROR: Missing target specification."
puts ""
puts "Use \"deploy help\" if you're lost."
exit
end
unless target = DeployTool::Target.find(args[1])
puts "ERROR: Couldn't find provider for target \"#{args[1]}\""
puts ""
puts "Use \"deploy help\" if you're lost."
exit
end
if target.respond_to?(:verify)
target.verify
end
DeployTool::Config[args[0]] = target.to_h
elsif command == "list"
puts "Registered Targets:"
DeployTool::Config.all.each do |target_name, target|
target = DeployTool::Target.from_config(target)
puts " %s%s" % [target_name.ljust(15), target.to_s]
end
else
args.unshift command unless command == "to"
target_name = args[0]
unless (target = DeployTool::Config[target_name]) && !target.nil? && target.size > 0
puts "ERROR: Target \"#{target_name}\" is not configured"
puts ""
print_help
exit
end
opts = {}
opts[:timing] = true if args.include?("--timing")
target = DeployTool::Target.from_config(target)
begin
target.push(opts)
rescue => e
puts e
puts "\nPlease contact %s support: %s" % [DeployTool::Target::EfficientCloud.cloud_name, DeployTool::Target::EfficientCloud.support_email]
exit 2
end
DeployTool::Config[args[0]] = target.to_h
end
DeployTool::Config.save
rescue Net::HTTPServerException => e
$logger.info "ERROR: HTTP call returned %s %s" % [e.response.code, e.response.message]
if target
$logger.debug "\nTarget:"
target.to_h.each do |k, v|
next if k.to_sym == :password
$logger.debug " %s = %s" % [k, v]
end
end
$logger.debug "\nBacktrace:"
$logger.debug " " + e.backtrace.join("\n ")
$logger.debug "\nResponse:"
e.response. do |k, v|
$logger.debug " %s: %s" % [k, v]
end
$logger.debug "\n " + e.response.body.gsub("\n", "\n ")
$logger.info "\nPlease run again with \"--debug\" and report the output at http://bit.ly/deploytool-new-issue"
exit 2
end
|