engineyard 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,8 @@ module EY
40
40
  :desc => "Git ref to deploy. May be a branch, a tag, or a SHA."
41
41
  method_option :app, :type => :string, :aliases => %w(-a),
42
42
  :desc => "Name of the application to deploy"
43
+ method_option :verbose, :type => :boolean, :aliases => %w(-v),
44
+ :desc => "Be verbose"
43
45
  def deploy
44
46
  app = fetch_app(options[:app])
45
47
  environment = fetch_environment(options[:environment], app)
@@ -56,9 +58,9 @@ module EY
56
58
 
57
59
  loudly_check_eysd(environment)
58
60
 
59
- EY.ui.info "Running deploy for '#{environment.name}' on server..."
61
+ EY.ui.info "Beginning deploy for '#{app.name}' in '#{environment.name}' on server..."
60
62
 
61
- if environment.deploy(app, deploy_ref, options[:migrate])
63
+ if environment.deploy(app, deploy_ref, options[:migrate], options[:verbose])
62
64
  EY.ui.info "Deploy complete"
63
65
  else
64
66
  raise EY::Error, "Deploy failed"
@@ -77,10 +79,18 @@ module EY
77
79
  DESC
78
80
 
79
81
  method_option :all, :type => :boolean, :aliases => %(-a)
82
+ method_option :simple, :type => :boolean, :aliases => %(-s)
80
83
  def environments
81
- apps = get_apps(options[:all])
82
- EY.ui.warn(NoAppError.new(repo).message) unless apps.any? || options[:all]
83
- EY.ui.print_envs(apps, EY.config.default_environment)
84
+ if options[:all] && options[:simple]
85
+ # just put each env
86
+ api.environments.each do |env|
87
+ puts env.name
88
+ end
89
+ else
90
+ apps = get_apps(options[:all])
91
+ EY.ui.warn(NoAppError.new(repo).message) unless apps.any? || options[:all]
92
+ EY.ui.print_envs(apps, EY.config.default_environment, options[:simple])
93
+ end
84
94
  end
85
95
  map "envs" => :environments
86
96
 
@@ -113,14 +123,16 @@ module EY
113
123
  :desc => "Environment in which to roll back the application"
114
124
  method_option :app, :type => :string, :aliases => %w(-a),
115
125
  :desc => "Name of the application to roll back"
126
+ method_option :verbose, :type => :boolean, :aliases => %w(-v),
127
+ :desc => "Be verbose"
116
128
  def rollback
117
129
  app = fetch_app(options[:app])
118
130
  env = fetch_environment(options[:environment], app)
119
131
 
120
132
  loudly_check_eysd(env)
121
133
 
122
- EY.ui.info("Rolling back #{env.name}")
123
- if env.rollback(app)
134
+ EY.ui.info("Rolling back '#{app.name}' in '#{env.name}'")
135
+ if env.rollback(app, options[:verbose])
124
136
  EY.ui.info "Rollback complete"
125
137
  else
126
138
  raise EY::Error, "Rollback failed"
@@ -59,25 +59,32 @@ module EY
59
59
  end
60
60
  end
61
61
 
62
- def print_envs(apps, default_env_name = nil)
63
- apps.each do |app|
64
- puts app.name
65
- if app.environments.any?
66
- app.environments.each do |env|
67
- short_name = env.shorten_name_for(app)
62
+ def print_envs(apps, default_env_name = nil, simple = false)
63
+ if simple
64
+ envs = apps.map{ |a| a.environments }
65
+ envs.flatten.map{|x| x.name}.uniq.each do |env|
66
+ puts env
67
+ end
68
+ else
69
+ apps.each do |app|
70
+ puts app.name
71
+ if app.environments.any?
72
+ app.environments.each do |env|
73
+ short_name = env.shorten_name_for(app)
68
74
 
69
- icount = env.instances_count
70
- iname = (icount == 1) ? "instance" : "instances"
75
+ icount = env.instances_count
76
+ iname = (icount == 1) ? "instance" : "instances"
71
77
 
72
- default_text = env.name == default_env_name ? " [default]" : ""
78
+ default_text = env.name == default_env_name ? " [default]" : ""
73
79
 
74
- puts " #{short_name}#{default_text} (#{icount} #{iname})"
80
+ puts " #{short_name}#{default_text} (#{icount} #{iname})"
81
+ end
82
+ else
83
+ puts " (This application is not in any environments; you can make one at #{EY.config.endpoint})"
75
84
  end
76
- else
77
- puts " (This application is not in any environments; you can make one at #{EY.config.endpoint})"
78
- end
79
85
 
80
- puts ""
86
+ puts ""
87
+ end
81
88
  end
82
89
  end
83
90
 
@@ -101,7 +108,7 @@ module EY
101
108
  end
102
109
 
103
110
  def set_color(string, color, bold=false)
104
- $stdout.tty? ? super : string
111
+ ($stdout.tty? || ENV['THOR_SHELL']) ? super : string
105
112
  end
106
113
 
107
114
  end
@@ -7,12 +7,14 @@ module EY
7
7
  :desc => "Environment on which to take down the maintenance page"
8
8
  method_option :app, :type => :string, :aliases => %w(-a),
9
9
  :desc => "Name of the application whose maintenance page will be removed"
10
+ method_option :verbose, :type => :boolean, :aliases => %w(-v),
11
+ :desc => "Be verbose"
10
12
  def enable
11
13
  app = fetch_app(options[:app])
12
14
  environment = fetch_environment(options[:environment], app)
13
15
  loudly_check_eysd(environment)
14
- EY.ui.info "Taking down maintenance page for #{environment.name}"
15
- environment.take_down_maintenance_page(app)
16
+ EY.ui.info "Taking down maintenance page for '#{app.name}' in '#{environment.name}'"
17
+ environment.take_down_maintenance_page(app, options[:verbose])
16
18
  end
17
19
 
18
20
  desc "disable [--environment/-e ENVIRONMENT]",
@@ -32,12 +34,14 @@ module EY
32
34
  :desc => "Environment on which to put up the maintenance page"
33
35
  method_option :app, :type => :string, :aliases => %w(-a),
34
36
  :desc => "Name of the application whose maintenance page will be put up"
37
+ method_option :verbose, :type => :boolean, :aliases => %w(-v),
38
+ :desc => "Be verbose"
35
39
  def disable
36
40
  app = fetch_app(options[:app])
37
41
  environment = fetch_environment(options[:environment], app)
38
42
  loudly_check_eysd(environment)
39
- EY.ui.info "Putting up maintenance page for #{environment.name}"
40
- environment.put_up_maintenance_page(app)
43
+ EY.ui.info "Putting up maintenance page for '#{app.name}' in '#{environment.name}'"
44
+ environment.put_up_maintenance_page(app, options[:verbose])
41
45
  end
42
46
  end
43
47
  end
@@ -32,20 +32,20 @@ module EY
32
32
  app_master!.ensure_eysd_present(&blk)
33
33
  end
34
34
 
35
- def deploy(app, ref, migration_command=nil)
36
- app_master!.deploy(app, ref, migration_command, config)
35
+ def deploy(app, ref, migration_command=nil, verbose=false)
36
+ app_master!.deploy(app, ref, migration_command, config, verbose)
37
37
  end
38
38
 
39
- def rollback(app)
40
- app_master!.rollback(app, config)
39
+ def rollback(app, verbose=false)
40
+ app_master!.rollback(app, config, verbose)
41
41
  end
42
42
 
43
- def take_down_maintenance_page(app)
44
- app_master!.take_down_maintenance_page(app)
43
+ def take_down_maintenance_page(app, verbose=false)
44
+ app_master!.take_down_maintenance_page(app, verbose)
45
45
  end
46
46
 
47
- def put_up_maintenance_page(app)
48
- app_master!.put_up_maintenance_page(app)
47
+ def put_up_maintenance_page(app, verbose=false)
48
+ app_master!.put_up_maintenance_page(app, verbose)
49
49
  end
50
50
 
51
51
  def rebuild
@@ -3,7 +3,7 @@ require 'escape'
3
3
  module EY
4
4
  module Model
5
5
  class Instance < ApiStruct.new(:id, :role, :name, :status, :amazon_id, :public_hostname, :environment)
6
- EYSD_VERSION = ENV["EY_DEPLOY_VERSION"] || "0.7.0"
6
+ EYSD_VERSION = ENV["EY_DEPLOY_VERSION"] || "0.7.1"
7
7
  EXIT_STATUS = Hash.new { |h,k| raise EY::Error, "ey-deploy version checker exited with unknown status code #{k}" }
8
8
  EXIT_STATUS.merge!({
9
9
  255 => :ssh_failed,
@@ -14,7 +14,7 @@ module EY
14
14
  alias :hostname :public_hostname
15
15
 
16
16
 
17
- def deploy(app, ref, migration_command=nil, extra_configuration=nil)
17
+ def deploy(app, ref, migration_command=nil, extra_configuration=nil, verbose=false)
18
18
  deploy_args = [
19
19
  '--app', app.name,
20
20
  '--repo', app.repository_uri,
@@ -30,10 +30,10 @@ module EY
30
30
  deploy_args << "--migrate" << migration_command
31
31
  end
32
32
 
33
- invoke_eysd_deploy(deploy_args)
33
+ invoke_eysd_deploy(deploy_args, verbose)
34
34
  end
35
35
 
36
- def rollback(app, extra_configuration=nil)
36
+ def rollback(app, extra_configuration=nil, verbose=false)
37
37
  deploy_args = ['rollback',
38
38
  '--app', app.name,
39
39
  '--stack', environment.stack_name,
@@ -43,16 +43,16 @@ module EY
43
43
  deploy_args << '--config' << extra_configuration.to_json
44
44
  end
45
45
 
46
- invoke_eysd_deploy(deploy_args)
46
+ invoke_eysd_deploy(deploy_args, verbose)
47
47
  end
48
48
 
49
49
 
50
- def put_up_maintenance_page(app)
51
- invoke_eysd_deploy(['enable_maintenance_page', '--app', app.name])
50
+ def put_up_maintenance_page(app, verbose=false)
51
+ invoke_eysd_deploy(['enable_maintenance_page', '--app', app.name], verbose)
52
52
  end
53
53
 
54
- def take_down_maintenance_page(app)
55
- invoke_eysd_deploy(['disable_maintenance_page', '--app', app.name])
54
+ def take_down_maintenance_page(app, verbose=false)
55
+ invoke_eysd_deploy(['disable_maintenance_page', '--app', app.name], verbose)
56
56
  end
57
57
 
58
58
 
@@ -76,7 +76,7 @@ module EY
76
76
  if ENV["NO_SSH"]
77
77
  :ok
78
78
  else
79
- ssh "#{gem_path} list ey-deploy | grep \"ey-deploy \" | egrep -q '#{escaped_eysd_version}[,)]'"
79
+ ssh "#{gem_path} list ey-deploy | grep \"ey-deploy \" | egrep -q '#{escaped_eysd_version}[,)]'", false
80
80
  EXIT_STATUS[$?.exitstatus]
81
81
  end
82
82
  end
@@ -100,7 +100,7 @@ module EY
100
100
 
101
101
  cmd = Escape.shell_command(%w[ssh -o StrictHostKeyChecking=no -q] << "#{user}@#{hostname}" << remote_command)
102
102
  cmd << " > /dev/null" unless output
103
- output ? puts(cmd) : EY.ui.debug(cmd)
103
+ EY.ui.debug(cmd)
104
104
  unless ENV["NO_SSH"]
105
105
  system cmd
106
106
  else
@@ -108,7 +108,7 @@ module EY
108
108
  end
109
109
  end
110
110
 
111
- def invoke_eysd_deploy(deploy_args)
111
+ def invoke_eysd_deploy(deploy_args, verbose=false)
112
112
  start = [eysd_path, "_#{EYSD_VERSION}_", 'deploy']
113
113
  instance_args = environment.instances.inject(['--instances']) do |command, inst|
114
114
  instance_tuple = [inst.public_hostname, inst.role]
@@ -117,7 +117,11 @@ module EY
117
117
  command << instance_tuple.join(',')
118
118
  end
119
119
 
120
- ssh Escape.shell_command(start + deploy_args + instance_args)
120
+ verbose_arg = verbose ? ['--verbose'] : []
121
+
122
+ cmd = Escape.shell_command(start + deploy_args + instance_args + verbose_arg)
123
+ puts cmd if verbose
124
+ ssh cmd
121
125
  end
122
126
 
123
127
  def eysd_path
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -31,11 +31,12 @@ describe "ey deploy" do
31
31
  cmd << " --environment #{options[:env]}" if options[:env]
32
32
  cmd << " --app #{options[:app]}" if options[:app]
33
33
  cmd << " --ref #{options[:ref]}" if options[:ref]
34
+ cmd << " --verbose" if options[:verbose]
34
35
  cmd
35
36
  end
36
37
 
37
38
  def verify_ran(scenario)
38
- @out.should match(/Running deploy for '#{scenario[:environment]}'/)
39
+ @out.should match(/Beginning deploy for.*#{scenario[:application]}.*#{scenario[:environment]}/)
39
40
  @ssh_commands.should have_command_like(/eysd.*deploy.*--app #{scenario[:application]}/)
40
41
  end
41
42
 
@@ -62,7 +63,7 @@ describe "ey deploy" do
62
63
  end
63
64
 
64
65
  it "complains when environment is not specified and app is in >1 environment" do
65
- api_scenario "one app, two environments"
66
+ api_scenario "one app, many environments"
66
67
  ey "deploy", :expect_failure => true
67
68
  @err.should match(/single environment.*2/i)
68
69
  end
@@ -193,7 +194,7 @@ describe "ey deploy" do
193
194
 
194
195
  it "lets you choose by complete name even if the complete name is ambiguous" do
195
196
  ey "deploy --environment railsapp_staging"
196
- @out.should match(/Running deploy for 'railsapp_staging'/)
197
+ @out.should match(/Beginning deploy for.*'railsapp_staging'/)
197
198
  end
198
199
  end
199
200
 
@@ -5,7 +5,7 @@ describe "ey environments" do
5
5
  given "integration"
6
6
 
7
7
  before(:all) do
8
- api_scenario "one app, two environments"
8
+ api_scenario "one app, many environments"
9
9
  end
10
10
 
11
11
  it "lists the environments your app is in" do
@@ -22,4 +22,20 @@ describe "ey environments" do
22
22
  end
23
23
  end
24
24
 
25
+ it "lists all environments that have apps with -a" do
26
+ ey "environments -a"
27
+ @out.should include("bakon")
28
+ @out.should include("giblets")
29
+ end
30
+
31
+ it "outputs simply with -s" do
32
+ ey "environments -s", :debug => false
33
+ @out.split(/\n/).sort.should == ["bakon", "giblets"]
34
+ end
35
+
36
+ it "outputs all environments (including ones with no apps) simply with -a and -s" do
37
+ ey "environments -a -s", :debug => false
38
+ @out.split(/\n/).sort.should == ["bakon", "beef", "giblets"]
39
+ end
40
+
25
41
  end
@@ -12,7 +12,7 @@ describe "ey logs" do
12
12
  end
13
13
 
14
14
  it "complains when it can't infer the environment" do
15
- api_scenario "one app, two environments"
15
+ api_scenario "one app, many environments"
16
16
  ey "logs", :expect_failure => true
17
17
  @err.should =~ /single environment/
18
18
  end
@@ -7,11 +7,12 @@ describe "ey rollback" do
7
7
  cmd = "rollback"
8
8
  cmd << " -e #{opts[:env]}" if opts[:env]
9
9
  cmd << " -a #{opts[:app]}" if opts[:app]
10
+ cmd << " --verbose" if opts[:verbose]
10
11
  cmd
11
12
  end
12
13
 
13
14
  def verify_ran(scenario)
14
- @out.should match(/Rolling back #{scenario[:environment]}/)
15
+ @out.should match(/Rolling back.*#{scenario[:application]}.*#{scenario[:environment]}/)
15
16
  @err.should be_empty
16
17
  @ssh_commands.last.should match(/eysd.*deploy rollback.*--app #{scenario[:application]}/)
17
18
  end
@@ -6,7 +6,7 @@ describe "ey ssh" do
6
6
  given "integration"
7
7
 
8
8
  before(:all) do
9
- api_scenario "one app, two environments"
9
+ api_scenario "one app, many environments"
10
10
  end
11
11
 
12
12
  it "complains if it has no app master" do
@@ -7,6 +7,7 @@ describe "ey web disable" do
7
7
  cmd = "web disable"
8
8
  cmd << " -e #{opts[:env]}" if opts[:env]
9
9
  cmd << " -a #{opts[:app]}" if opts[:app]
10
+ cmd << " --verbose" if opts[:verbose]
10
11
  cmd
11
12
  end
12
13
 
@@ -7,6 +7,7 @@ describe "ey web enable" do
7
7
  cmd = "web enable"
8
8
  cmd << " -e #{opts[:env]}" if opts[:env]
9
9
  cmd << " -a #{opts[:app]}" if opts[:app]
10
+ cmd << " --verbose" if opts[:verbose]
10
11
  cmd
11
12
  end
12
13
 
@@ -32,8 +32,8 @@ class FakeAwsm < Sinatra::Base
32
32
  Scenario::LinkedApp
33
33
  when "one app, one environment, app master red"
34
34
  Scenario::LinkedAppRedMaster
35
- when "one app, two environments"
36
- Scenario::OneAppTwoEnvs
35
+ when "one app, many environments"
36
+ Scenario::OneAppManyEnvs
37
37
  when "one app, many similarly-named environments"
38
38
  Scenario::OneAppManySimilarlyNamedEnvs
39
39
  else
@@ -252,7 +252,7 @@ private
252
252
  end
253
253
  end
254
254
 
255
- class OneAppTwoEnvs < Empty
255
+ class OneAppManyEnvs < Empty
256
256
  def apps
257
257
  apps = [{
258
258
  "name" => "rails232app",
@@ -325,6 +325,15 @@ private
325
325
  "stack_name" => "nginx_passenger",
326
326
  "id" => 8371,
327
327
  "app_master" => nil,
328
+ }, {
329
+ "ssh_username" => "hamburger",
330
+ "instances" => [],
331
+ "name" => "beef",
332
+ "apps" => [],
333
+ "instances_count" => 0,
334
+ "stack_name" => "nginx_passenger",
335
+ "id" => 8372,
336
+ "app_master" => nil,
328
337
  }]
329
338
  end
330
339
  end # OneAppTwoEnvs
@@ -20,8 +20,10 @@ module Spec
20
20
  hide_err = options.has_key?(:hide_err) ? options[:hide_err] : options[:expect_failure]
21
21
  path_prepends = options[:prepend_to_path]
22
22
 
23
- ey_env = {}
24
- ey_env['DEBUG'] = options[:debug].to_s if options[:debug]
23
+ ey_env = {'DEBUG' => 'true'}
24
+ if options.has_key?(:debug)
25
+ ey_env['DEBUG'] = options[:debug] ? "true" : nil
26
+ end
25
27
 
26
28
  if path_prepends
27
29
  tempdir = File.join(Dir.tmpdir, "ey_test_cmds_#{Time.now.tv_sec}#{Time.now.tv_usec}_#{$$}")
@@ -113,6 +113,12 @@ end
113
113
  shared_examples_for "it invokes eysd" do
114
114
  include Spec::Helpers::SharedIntegrationTestUtils
115
115
 
116
+ it "passes --verbose to eysd" do
117
+ api_scenario "one app, one environment"
118
+ run_ey({:env => 'giblets', :verbose => true})
119
+ @ssh_commands.should have_command_like(/eysd.*deploy.*--verbose/)
120
+ end
121
+
116
122
  it "passes along instance information to eysd" do
117
123
  api_scenario "one app, one environment"
118
124
  run_ey({:env => 'giblets'})
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - EY Cloud Team
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-25 00:00:00 -07:00
17
+ date: 2010-06-29 00:00:00 -07:00
18
18
  default_executable: ey
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency