shelly 0.4.28 → 0.4.29.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/lib/shelly/app.rb +8 -4
- data/lib/shelly/cli/main.rb +21 -3
- data/lib/shelly/version.rb +1 -1
- data/spec/input_faker.rb +4 -0
- data/spec/shelly/app_spec.rb +21 -4
- data/spec/shelly/cli/main_spec.rb +38 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzIyNDQ1M2JiYWFjODQzODI5MDNhNmJjMzVmMDkyMzEwNTJmMzc4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDQwN2FjNTRmMTg2Y2JlNDE3YWM0ZjIxMDhmMmM5ODg5ODA2ZjhmYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDZkZGJjYTY3NTg0MTFjYTI0YmI1NzQxZWNhYjE4OTRkYTNhMmUzNzM4MDk5
|
10
|
+
Mzk3YTExYzM2M2UyYTVlN2Y0ZWNjMzI0YWVmMzI3NzhlNmFlMjJkMTlhNDg4
|
11
|
+
ZTk1MzRkZDkxODNhNDc3YmY0NTFlNGRhMTdjMmM0NDQ1ZDRlMjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjM4ZWZjMmZjZTY5MzIwOTkzOTM0ZmVjODU4OGQ0NWFkZDZmNzc3MDc2NTc1
|
14
|
+
MzBkYTIwY2YwNzgxOTFkYjU5YjZjZDM4Nzk4NjcxMmJkZDc4NmQyN2I0NDNi
|
15
|
+
MmI2OWRiMjE3MjZmYTk4NzNjMmYzMGQzNWNmYTBlYTk2NTNjZmI=
|
data/CHANGELOG.md
CHANGED
data/lib/shelly/app.rb
CHANGED
@@ -216,15 +216,15 @@ module Shelly
|
|
216
216
|
end
|
217
217
|
|
218
218
|
def dbconsole
|
219
|
-
ssh_with_db_server(:command => "
|
219
|
+
ssh_with_db_server(:command => "start_dbconsole")
|
220
220
|
end
|
221
221
|
|
222
222
|
def mongoconsole
|
223
|
-
ssh_with_db_server(:command => "
|
223
|
+
ssh_with_db_server(:command => "start_mongodb")
|
224
224
|
end
|
225
225
|
|
226
226
|
def redis_cli
|
227
|
-
ssh_with_db_server(:command => "
|
227
|
+
ssh_with_db_server(:command => "start_redis")
|
228
228
|
end
|
229
229
|
|
230
230
|
def attributes
|
@@ -295,10 +295,14 @@ module Shelly
|
|
295
295
|
Launchy.open("http://#{attributes["domain"]}")
|
296
296
|
end
|
297
297
|
|
298
|
-
def
|
298
|
+
def ssh_console(server = nil)
|
299
299
|
ssh(:server => server)
|
300
300
|
end
|
301
301
|
|
302
|
+
def console(server = nil)
|
303
|
+
ssh(:command => "start_console", :server => server)
|
304
|
+
end
|
305
|
+
|
302
306
|
def list_files(path)
|
303
307
|
ssh(:command => "ls -l #{persistent_disk}/#{path}")
|
304
308
|
end
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -32,7 +32,7 @@ module Shelly
|
|
32
32
|
# FIXME: it should be possible to pass single symbol, instead of one element array
|
33
33
|
before_hook :logged_in?, :only => [:add, :status, :list, :start, :stop,
|
34
34
|
:delete, :info, :ip, :logout, :execute, :rake, :setup, :console,
|
35
|
-
:dbconsole, :mongoconsole, :redis_cli]
|
35
|
+
:dbconsole, :mongoconsole, :redis_cli, :ssh]
|
36
36
|
before_hook :inside_git_repository?, :only => [:add, :setup, :check]
|
37
37
|
|
38
38
|
map %w(-v --version) => :version
|
@@ -365,6 +365,20 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
365
365
|
say_error "Virtual server '#{options[:server]}' not found or not configured for running console"
|
366
366
|
end
|
367
367
|
|
368
|
+
desc "ssh", "Log into virtual server"
|
369
|
+
method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
|
370
|
+
method_option :server, :type => :string, :aliases => "-s",
|
371
|
+
:desc => "Specify virtual server, it's random by default"
|
372
|
+
def ssh
|
373
|
+
app = multiple_clouds(options[:cloud], "ssh")
|
374
|
+
app.ssh_console(options[:server])
|
375
|
+
rescue Client::ConflictException
|
376
|
+
say_error "Cloud #{app} is not running. Cannot run ssh console."
|
377
|
+
rescue Client::NotFoundException => e
|
378
|
+
raise unless e.resource == :virtual_server
|
379
|
+
say_error "Virtual server '#{options[:server]}' not found or not configured for running ssh console"
|
380
|
+
end
|
381
|
+
|
368
382
|
# FIXME: move to helpers
|
369
383
|
no_tasks do
|
370
384
|
# Returns valid arguments for rake, removes shelly gem arguments
|
@@ -433,11 +447,11 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
433
447
|
options = {:with_confirmation => true}.merge(options)
|
434
448
|
loop do
|
435
449
|
say "Password: "
|
436
|
-
password =
|
450
|
+
password = capture_input_without_echo_if_tty
|
437
451
|
say_new_line
|
438
452
|
return password unless options[:with_confirmation]
|
439
453
|
say "Password confirmation: "
|
440
|
-
password_confirmation =
|
454
|
+
password_confirmation = capture_input_without_echo_if_tty
|
441
455
|
say_new_line
|
442
456
|
if password.present?
|
443
457
|
return password if password == password_confirmation
|
@@ -506,6 +520,10 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
506
520
|
user.logout
|
507
521
|
exit 1
|
508
522
|
end
|
523
|
+
|
524
|
+
def capture_input_without_echo_if_tty
|
525
|
+
$stdin.tty? ? $stdin.noecho(&:gets).strip : $stdin.gets.strip
|
526
|
+
end
|
509
527
|
end
|
510
528
|
end
|
511
529
|
end
|
data/lib/shelly/version.rb
CHANGED
data/spec/input_faker.rb
CHANGED
data/spec/shelly/app_spec.rb
CHANGED
@@ -429,7 +429,7 @@ describe Shelly::App do
|
|
429
429
|
it "should return result of dbconsole" do
|
430
430
|
@client.stub(:configured_db_server).and_return(
|
431
431
|
{"host" => "console.example.com", "port" => "40010", "user" => "foo"})
|
432
|
-
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com
|
432
|
+
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com start_dbconsole")
|
433
433
|
@app.dbconsole
|
434
434
|
end
|
435
435
|
end
|
@@ -438,7 +438,7 @@ describe Shelly::App do
|
|
438
438
|
it "should return result of mongoconsole" do
|
439
439
|
@client.stub(:configured_db_server).and_return(
|
440
440
|
{"host" => "console.example.com", "port" => "40010", "user" => "foo"})
|
441
|
-
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com
|
441
|
+
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com start_mongodb")
|
442
442
|
@app.mongoconsole
|
443
443
|
end
|
444
444
|
end
|
@@ -447,7 +447,7 @@ describe Shelly::App do
|
|
447
447
|
it "should return result of redis-cli" do
|
448
448
|
@client.stub(:configured_db_server).and_return(
|
449
449
|
{"host" => "console.example.com", "port" => "40010", "user" => "foo"})
|
450
|
-
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com
|
450
|
+
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com start_redis")
|
451
451
|
@app.redis_cli
|
452
452
|
end
|
453
453
|
end
|
@@ -474,11 +474,28 @@ describe Shelly::App do
|
|
474
474
|
end
|
475
475
|
end
|
476
476
|
|
477
|
-
describe "#
|
477
|
+
describe "#ssh_console" do
|
478
478
|
it "should run ssh with all parameters" do
|
479
479
|
@client.stub(:tunnel).and_return(
|
480
480
|
{"host" => "console.example.com", "port" => "40010", "user" => "foo"})
|
481
481
|
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com ")
|
482
|
+
@app.ssh_console
|
483
|
+
end
|
484
|
+
|
485
|
+
context "when server passed" do
|
486
|
+
it "should request console on given server" do
|
487
|
+
@client.should_receive(:tunnel).with("foo-staging", "ssh", "app1").and_return({})
|
488
|
+
@app.stub(:system)
|
489
|
+
@app.console("app1")
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
describe "#console" do
|
495
|
+
it "should run ssh with all parameters" do
|
496
|
+
@client.stub(:tunnel).and_return(
|
497
|
+
{"host" => "console.example.com", "port" => "40010", "user" => "foo"})
|
498
|
+
@app.should_receive(:system).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t -t console.example.com start_console")
|
482
499
|
@app.console
|
483
500
|
end
|
484
501
|
|
@@ -51,6 +51,7 @@ describe Shelly::CLI::Main do
|
|
51
51
|
out.should include("shelly organization <command> # View organizations")
|
52
52
|
out.should include("shelly rake TASK # Run rake task")
|
53
53
|
out.should include("shelly redeploy # Redeploy application")
|
54
|
+
out.should include("shelly ssh # Log into virtual server")
|
54
55
|
out.should include("shelly redis-cli # Run redis-cli")
|
55
56
|
out.should include("shelly register [EMAIL] # Register new account")
|
56
57
|
out.should include("shelly setup # Set up git remotes for deployment on Shelly Cloud")
|
@@ -1626,6 +1627,43 @@ Wait until cloud is in 'turned off' state and try again.")
|
|
1626
1627
|
end
|
1627
1628
|
end
|
1628
1629
|
|
1630
|
+
describe "#ssh" do
|
1631
|
+
before do
|
1632
|
+
setup_project
|
1633
|
+
end
|
1634
|
+
|
1635
|
+
it "should ensure user has logged in" do
|
1636
|
+
hooks(@main, :ssh).should include(:logged_in?)
|
1637
|
+
end
|
1638
|
+
|
1639
|
+
it "should execute ssh command" do
|
1640
|
+
@app.should_receive(:ssh_console)
|
1641
|
+
invoke(@main, :ssh)
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
context "virtual servers are not running" do
|
1645
|
+
it "should display error" do
|
1646
|
+
@client.stub(:tunnel).and_raise(Shelly::Client::ConflictException)
|
1647
|
+
$stdout.should_receive(:puts).with(red "Cloud foo-production is not running. Cannot run ssh console.")
|
1648
|
+
lambda {
|
1649
|
+
invoke(@main, :ssh)
|
1650
|
+
}.should raise_error(SystemExit)
|
1651
|
+
end
|
1652
|
+
end
|
1653
|
+
|
1654
|
+
context "virtual server not found" do
|
1655
|
+
it "should display error" do
|
1656
|
+
ex = Shelly::Client::NotFoundException.new("resource" => "virtual_server")
|
1657
|
+
@client.stub(:tunnel).and_raise(ex)
|
1658
|
+
@main.options = {:server => "foobar"}
|
1659
|
+
$stdout.should_receive(:puts).with(red "Virtual server 'foobar' not found or not configured for running ssh console")
|
1660
|
+
lambda {
|
1661
|
+
invoke(@main, :ssh)
|
1662
|
+
}.should raise_error(SystemExit)
|
1663
|
+
end
|
1664
|
+
end
|
1665
|
+
end
|
1666
|
+
|
1629
1667
|
describe "#check" do
|
1630
1668
|
before do
|
1631
1669
|
Shelly::App.stub(:inside_git_repository?).and_return(true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.29.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shelly Cloud team
|
@@ -329,9 +329,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
329
329
|
version: '0'
|
330
330
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
331
331
|
requirements:
|
332
|
-
- - ! '
|
332
|
+
- - ! '>'
|
333
333
|
- !ruby/object:Gem::Version
|
334
|
-
version:
|
334
|
+
version: 1.3.1
|
335
335
|
requirements: []
|
336
336
|
rubyforge_project: shelly
|
337
337
|
rubygems_version: 2.2.2
|