shelly 0.1.20 → 0.1.21.pre

Sign up to get free protection for your applications and to get access to all the features.
data/lib/shelly/app.rb CHANGED
@@ -229,22 +229,22 @@ module Shelly
229
229
  end
230
230
 
231
231
  def upload(source)
232
- rsync(source, "#{ssh['node_ip']}:/srv/glusterfs/disk")
232
+ rsync(source, "#{ssh['host']}:/srv/glusterfs/disk")
233
233
  end
234
234
 
235
235
  def download(relative_source, destination)
236
- source = File.join("#{ssh['node_ip']}:/srv/glusterfs/disk", relative_source)
236
+ source = File.join("#{ssh['host']}:/srv/glusterfs/disk", relative_source)
237
237
  rsync(source, destination)
238
238
  end
239
239
 
240
240
  private
241
241
 
242
242
  def ssh
243
- @ssh ||= shelly.node_and_port(code_name)
243
+ @ssh ||= shelly.console(code_name)
244
244
  end
245
245
 
246
246
  def ssh_command(command = "")
247
- exec "ssh #{ssh_options} #{ssh['node_ip']} #{command}"
247
+ exec "ssh #{ssh_options} #{ssh['host']} #{command}"
248
248
  end
249
249
 
250
250
  def ssh_options
data/lib/shelly/client.rb CHANGED
@@ -134,7 +134,7 @@ module Shelly
134
134
  post("/apps/#{cloud}/command", {:body => body, :type => type})
135
135
  end
136
136
 
137
- def node_and_port(code_name)
137
+ def console(code_name)
138
138
  get("/apps/#{code_name}/console")
139
139
  end
140
140
 
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21.pre"
3
3
  end
@@ -310,9 +310,9 @@ describe Shelly::App do
310
310
 
311
311
  describe "#rake" do
312
312
  it "should return result of rake task" do
313
- @client.stub(:node_and_port).and_return(
314
- {"node_ip" => "10.0.0.1", "port" => "40010", "user" => "foo"})
315
- @app.should_receive(:exec).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo 10.0.0.1 rake_runner \"test\"")
313
+ @client.stub(:console).and_return(
314
+ {"host" => "console.example.com", "port" => "40010", "user" => "foo"})
315
+ @app.should_receive(:exec).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo console.example.com rake_runner \"test\"")
316
316
  @app.rake("test")
317
317
  end
318
318
  end
@@ -340,27 +340,27 @@ describe Shelly::App do
340
340
 
341
341
  describe "#console" do
342
342
  it "should run ssh with all parameters" do
343
- @client.stub(:node_and_port).and_return(
344
- {"node_ip" => "10.0.0.1", "port" => "40010", "user" => "foo"})
345
- @app.should_receive(:exec).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo 10.0.0.1 ")
343
+ @client.stub(:console).and_return(
344
+ {"host" => "console.example.com", "port" => "40010", "user" => "foo"})
345
+ @app.should_receive(:exec).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo console.example.com ")
346
346
  @app.console
347
347
  end
348
348
  end
349
349
 
350
350
  describe "#upload" do
351
351
  it "should run rsync with proper parameters" do
352
- @client.stub(:node_and_port).and_return(
353
- {"node_ip" => "10.0.0.1", "port" => "40010", "user" => "foo"})
354
- @app.should_receive(:exec).with("rsync -avz -e 'ssh -o StrictHostKeyChecking=no -p 40010 -l foo' --progress /path 10.0.0.1:/srv/glusterfs/disk")
352
+ @client.stub(:console).and_return(
353
+ {"host" => "console.example.com", "port" => "40010", "user" => "foo"})
354
+ @app.should_receive(:exec).with("rsync -avz -e 'ssh -o StrictHostKeyChecking=no -p 40010 -l foo' --progress /path console.example.com:/srv/glusterfs/disk")
355
355
  @app.upload("/path")
356
356
  end
357
357
  end
358
358
 
359
359
  describe "#download" do
360
360
  it "should run rsync with proper parameters" do
361
- @client.stub(:node_and_port).and_return(
362
- {"node_ip" => "10.0.0.1", "port" => "40010", "user" => "foo"})
363
- @app.should_receive(:exec).with("rsync -avz -e 'ssh -o StrictHostKeyChecking=no -p 40010 -l foo' --progress 10.0.0.1:/srv/glusterfs/disk/. /tmp")
361
+ @client.stub(:console).and_return(
362
+ {"host" => "console.example.com", "port" => "40010", "user" => "foo"})
363
+ @app.should_receive(:exec).with("rsync -avz -e 'ssh -o StrictHostKeyChecking=no -p 40010 -l foo' --progress console.example.com:/srv/glusterfs/disk/. /tmp")
364
364
  @app.download(".", "/tmp")
365
365
  end
366
366
  end
@@ -383,5 +383,5 @@ describe Shelly::App do
383
383
  Shelly::Cloudfile.should_receive(:new).and_return(cloudfile)
384
384
  @app.create_cloudfile
385
385
  end
386
- end
386
+ end
387
387
  end
@@ -21,8 +21,8 @@ describe Shelly::CLI::Files do
21
21
  end
22
22
 
23
23
  it "should upload files" do
24
- expected = {"port" => "40010", "node_ip" => "10.0.0.10", "user"=>"foo-production"}
25
- @client.stub(:node_and_port).and_return(expected)
24
+ expected = {"host" => "console.example.com", "port" => "40010", "user" => "foo"}
25
+ @client.stub(:console).and_return(expected)
26
26
  @app.should_receive(:upload).with("some/path")
27
27
  invoke(@cli_files, :upload, "some/path")
28
28
  end
@@ -36,7 +36,7 @@ describe Shelly::CLI::Files do
36
36
 
37
37
  context "cloud is not running" do
38
38
  it "should display error" do
39
- @client.stub(:node_and_port).and_raise(Shelly::Client::ConflictException)
39
+ @client.stub(:console).and_raise(Shelly::Client::ConflictException)
40
40
  $stdout.should_receive(:puts).with(red "Cloud foo-production is not running. Cannot upload files.")
41
41
  lambda {
42
42
  invoke(@cli_files, :upload, "some/path")
@@ -57,8 +57,8 @@ describe Shelly::CLI::Files do
57
57
  end
58
58
 
59
59
  it "should download files" do
60
- expected = {"port" => "40010", "node_ip" => "10.0.0.10", "user"=>"foo-production"}
61
- @client.stub(:node_and_port).and_return(expected)
60
+ expected = {"host" => "console.example.com", "port" => "40010", "user" => "foo"}
61
+ @client.stub(:console).and_return(expected)
62
62
  @app.should_receive(:download).with("some/path", "/destination")
63
63
  invoke(@cli_files, :download, "some/path", "/destination")
64
64
  end
@@ -1267,15 +1267,13 @@ We have been notified about it. We will be adding new resources shortly")
1267
1267
  end
1268
1268
 
1269
1269
  it "execute ssh command" do
1270
- expected = {"port" => "40010", "node_ip" => "10.0.0.10", "user"=>"foo-production"}
1271
- @client.stub(:node_and_port).and_return(expected)
1272
1270
  @app.should_receive(:console)
1273
1271
  invoke(@main, :console)
1274
1272
  end
1275
1273
 
1276
1274
  context "Instances are not running" do
1277
1275
  it "should display error" do
1278
- @client.stub(:node_and_port).and_raise(Shelly::Client::ConflictException)
1276
+ @client.stub(:console).and_raise(Shelly::Client::ConflictException)
1279
1277
  $stdout.should_receive(:puts).with(red "Cloud foo-production is not running. Cannot run console.")
1280
1278
  lambda {
1281
1279
  invoke(@main, :console)
@@ -217,13 +217,13 @@ describe Shelly::Client do
217
217
  end
218
218
  end
219
219
 
220
- describe "#node_and_port" do
220
+ describe "#console" do
221
221
  it "should fetch instance data from API" do
222
- body = {:port => "40010", :node_ip => "10.0.0.10", :user => "foo-production"}
222
+ body = {:port => "40010", :host => "console.example.com", :user => "foo-production"}
223
223
  FakeWeb.register_uri(:get, api_url("apps/staging-foo/console"),
224
224
  :body => body.to_json)
225
- response = @client.node_and_port("staging-foo")
226
- response.should == {"port" => "40010", "node_ip" => "10.0.0.10", "user"=>"foo-production"}
225
+ response = @client.console("staging-foo")
226
+ response.should == {"port" => "40010", "host" => "console.example.com", "user"=>"foo-production"}
227
227
  end
228
228
  end
229
229
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
5
- prerelease:
4
+ version: 0.1.21.pre
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Shelly Cloud team
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -345,9 +345,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
345
345
  required_rubygems_version: !ruby/object:Gem::Requirement
346
346
  none: false
347
347
  requirements:
348
- - - ! '>='
348
+ - - ! '>'
349
349
  - !ruby/object:Gem::Version
350
- version: '0'
350
+ version: 1.3.1
351
351
  requirements: []
352
352
  rubyforge_project: shelly
353
353
  rubygems_version: 1.8.24