engineyard 3.1.3 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db1c2f9e038b686249fa2d9de438e2a4b15b97e5
4
- data.tar.gz: 812ae3efa8e5b4548ef34740ccf76e4f1121a0ce
3
+ metadata.gz: f1e06c616357b9704ae4bc72a77c8a3f1db653d6
4
+ data.tar.gz: 74c3b3bc128af34c303ef237e5ce93078e213732
5
5
  SHA512:
6
- metadata.gz: f8e2f9e4d93b5482a9901c5f0074ff19a9ec27d417b2137024894b1ffc21a67dd3a2ffa0bc4d25adec738f9ddb597d4b22217527bc8c056145fe9aae1d5ce577
7
- data.tar.gz: bdb090c43460f0e3bbf695f8229485633052456a390e5239377a1a6a162631c5289de1b9506d496026f384c35965261f291d52714c7b38661194e6de5923d0a5
6
+ metadata.gz: 046cb60b0d7a6c1c36f3577c86050da53a9d99fbb97ed4974886717aed1a08185d7fabfd931e6557241f28132305695c2c00c817aa7c81873bb3f750ab23d0c5
7
+ data.tar.gz: 4eff8c75b738ecdba7fbc0eb930acb3cd3311696faf1d9496a5aa84f36de13b838671a9ac5698d57572ba70c1ad739ce3ef4ae42ce867df75db3e787a3d45d21
@@ -522,6 +522,50 @@ WARNING: Interrupting again may prevent Engine Yard Cloud from recording this
522
522
  exit exits.detect {|status| status != 0 } || 0
523
523
  end
524
524
 
525
+ desc "console [--app APP] [--environment ENVIRONMENT] [--account ACCOUNT]", "Open a Rails console session to the master app server."
526
+ long_desc <<-DESC
527
+ Opens a Rails console session on app master.
528
+ DESC
529
+ method_option :environment, type: :string, aliases: %w(-e),
530
+ required: true, default: '',
531
+ desc: "Environment to console into"
532
+ method_option :app, type: :string, aliases: %w(-a),
533
+ required: true, default: '',
534
+ desc: "Name of the application"
535
+ method_option :account, type: :string, aliases: %w(-c),
536
+ required: true, default: '',
537
+ desc: "Name of the account in which the environment can be found"
538
+
539
+ def console
540
+ app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
541
+ instances = filter_servers(app_env.environment, options, default: {app_master: true})
542
+ user = app_env.environment.username
543
+ cmd = "cd /data/#{app_env.app.name}/current && bundle exec rails console"
544
+ cmd = Escape.shell_command(['bash','-lc',cmd])
545
+
546
+ ssh_cmd = ["ssh"]
547
+ ssh_cmd += ["-t"]
548
+
549
+ trap(:INT) { abort "Aborting..." }
550
+
551
+ exits = []
552
+ instances.each do |instance|
553
+ host = instance.public_hostname
554
+ name = instance.name ? "#{instance.role} (#{instance.name})" : instance.role
555
+ ui.info "\nConnecting to #{name} #{host}..."
556
+ unless cmd
557
+ ui.info "Ctrl + C to abort"
558
+ sleep 1.3
559
+ end
560
+ sshcmd = Escape.shell_command((ssh_cmd + ["#{user}@#{host}"] + [cmd]).compact)
561
+ ui.debug "$ #{sshcmd}"
562
+ system sshcmd
563
+ exits << $?.exitstatus
564
+ end
565
+
566
+ exit exits.detect {|status| status != 0 } || 0
567
+ end
568
+
525
569
  desc "scp [FROM_PATH] [TO_PATH] [--all] [--environment ENVIRONMENT]", "scp a file to/from multiple servers in an environment"
526
570
  long_desc <<-DESC
527
571
  Use the system `scp` command to copy files to some or all of the servers.
@@ -1,4 +1,4 @@
1
1
  module EY
2
- VERSION = '3.1.3'
2
+ VERSION = '3.2.0'
3
3
  ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || '2.6.3'
4
4
  end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ print_my_args_ssh = "#!/bin/sh\necho ssh $*"
4
+
5
+ shared_examples_for "running ey console" do
6
+ given "integration"
7
+
8
+ def extra_ey_options
9
+ {:prepend_to_path => {'ssh' => "#!/bin/sh\necho ssh $*"}}
10
+ end
11
+
12
+ def command_to_run(opts)
13
+ cmd = ["console"]
14
+ cmd << "--environment" << opts[:environment] if opts[:environment]
15
+ cmd << "--quiet" if opts[:quiet]
16
+ cmd
17
+ end
18
+ end
19
+
20
+ describe "ey console" do
21
+ include_examples "running ey console"
22
+
23
+ it "complains if it has no app master" do
24
+ login_scenario "one app, many environments"
25
+ ey %w[console -e bakon], :expect_failure => true
26
+ expect(@err).to match(/'bakon' does not have any matching instances/)
27
+ end
28
+
29
+ it "opens the console on the right server" do
30
+ login_scenario "one app, one environment"
31
+ ey command_to_run(:environment => 'giblets', :verbose => true)
32
+ expect(@raw_ssh_commands.select do |command|
33
+ command =~ /^ssh -t turkey@app_master_hostname.+ bash -lc '.+bundle exec rails console'$/
34
+ end).not_to be_empty
35
+ expect(@raw_ssh_commands.select do |command|
36
+ command =~ /^ssh -t turkey.+$/
37
+ end.count).to eq(1)
38
+ end
39
+
40
+ it "is quiet" do
41
+ login_scenario "one app, one environment"
42
+ ey command_to_run(:environment => 'giblets', :quiet => true)
43
+ expect(@out).to match(/ssh.*-t turkey/)
44
+ expect(@out).not_to match(/Loading application data/)
45
+ end
46
+
47
+ it "runs in bash by default" do
48
+ login_scenario "one app, one environment"
49
+ ey command_to_run(:environment => 'giblets', :quiet => true)
50
+ expect(@out).to match(/ssh.*bash -lc '.+bundle/)
51
+ end
52
+
53
+ it "raises an error when there are no matching hosts" do
54
+ login_scenario "one app, one environment, no instances"
55
+ ey command_to_run(:environment => 'giblets', :quiet => true), :expect_failure => true
56
+ end
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Engine Yard Cloud Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-05 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -303,6 +303,7 @@ files:
303
303
  - spec/engineyard/eyrc_spec.rb
304
304
  - spec/engineyard/repo_spec.rb
305
305
  - spec/engineyard_spec.rb
306
+ - spec/ey/console_spec.rb
306
307
  - spec/ey/deploy_spec.rb
307
308
  - spec/ey/ey_spec.rb
308
309
  - spec/ey/init_spec.rb
@@ -379,6 +380,7 @@ test_files:
379
380
  - spec/engineyard/eyrc_spec.rb
380
381
  - spec/engineyard/repo_spec.rb
381
382
  - spec/engineyard_spec.rb
383
+ - spec/ey/console_spec.rb
382
384
  - spec/ey/deploy_spec.rb
383
385
  - spec/ey/ey_spec.rb
384
386
  - spec/ey/init_spec.rb