shelly 0.2.14 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.15 / 2013-03-28
2
+
3
+ * [feature] `shelly files list [PATH]` lists files from cloud's disk
4
+ * [feature] Destination virtual server for `shelly console` can be specified.
5
+ Example `shelly console --server app1`. When not specyfied virtual server is chosen randomly.
6
+
1
7
  ## 0.2.14 / 2013-03-28
2
8
 
3
9
  * [bug] Structure validator recognizes puma as allowed web server
data/lib/shelly/app.rb CHANGED
@@ -173,11 +173,11 @@ module Shelly
173
173
  end
174
174
 
175
175
  def rake(task)
176
- ssh_command("rake_runner \"#{task}\"")
176
+ ssh(:command => "rake_runner \"#{task}\"")
177
177
  end
178
178
 
179
179
  def dbconsole
180
- ssh_command("dbconsole")
180
+ ssh(:command => "dbconsole")
181
181
  end
182
182
 
183
183
  def attributes
@@ -220,21 +220,27 @@ module Shelly
220
220
  Launchy.open("http://#{attributes["domain"]}")
221
221
  end
222
222
 
223
- def console
224
- ssh_command
223
+ def console(server = nil)
224
+ ssh(:server => server)
225
+ end
226
+
227
+ def list_files(path)
228
+ ssh(:command => "ls -l /srv/glusterfs/disk/#{path}")
225
229
  end
226
230
 
227
231
  def upload(source)
228
- rsync(source, "#{ssh['host']}:/srv/glusterfs/disk")
232
+ conn = console_connection
233
+ rsync(source, "#{conn['host']}:/srv/glusterfs/disk")
229
234
  end
230
235
 
231
236
  def download(relative_source, destination)
232
- source = File.join("#{ssh['host']}:/srv/glusterfs/disk", relative_source)
237
+ conn = console_connection
238
+ source = File.join("#{conn['host']}:/srv/glusterfs/disk", relative_source)
233
239
  rsync(source, destination)
234
240
  end
235
241
 
236
242
  def delete_file(remote_path)
237
- ssh_command("delete_file #{remote_path}")
243
+ ssh(:command => "delete_file #{remote_path}")
238
244
  end
239
245
 
240
246
  # Public: Return databases for given Cloud in Cloudfile
@@ -292,16 +298,17 @@ module Shelly
292
298
  content["servers"].any? {|_, settings| settings.has_key?(option)}
293
299
  end
294
300
 
295
- def ssh
296
- @ssh ||= shelly.console(code_name)
301
+ def console_connection(server = nil)
302
+ shelly.console(code_name, server)
297
303
  end
298
304
 
299
- def ssh_command(command = "")
300
- exec "ssh #{ssh_options} -t #{ssh['host']} #{command}"
305
+ def ssh(options = {})
306
+ conn = console_connection(options[:server])
307
+ exec "ssh #{ssh_options(conn)} -t #{conn['host']} #{options[:command]}"
301
308
  end
302
309
 
303
- def ssh_options
304
- "-o StrictHostKeyChecking=no -p #{ssh['port']} -l #{ssh['user']}"
310
+ def ssh_options(conn = console_connection)
311
+ "-o StrictHostKeyChecking=no -p #{conn['port']} -l #{conn['user']}"
305
312
  end
306
313
 
307
314
  def rsync(source, destination)
@@ -10,6 +10,14 @@ module Shelly
10
10
  before_hook :require_rsync, :only => [:upload, :download]
11
11
  class_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
12
12
 
13
+ desc "list [PATH]", "List files in given path"
14
+ def list(path = "/")
15
+ app = multiple_clouds(options[:cloud], "file list #{path}")
16
+ app.list_files(path)
17
+ rescue Client::ConflictException
18
+ say_error "Cloud #{app} is not running. Cannot list files."
19
+ end
20
+
13
21
  desc "upload PATH", "Upload files to persistent data storage"
14
22
  def upload(path)
15
23
  app = multiple_clouds(options[:cloud], "file upload #{path}")
@@ -395,11 +395,16 @@ Wait until cloud is in 'turned off' state and try again.}
395
395
 
396
396
  desc "console", "Open application console"
397
397
  method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
398
+ method_option :server, :type => :string, :aliases => "-s",
399
+ :desc => "Specify virtual server, it's random by default"
398
400
  def console
399
401
  app = multiple_clouds(options[:cloud], "console")
400
- app.console
402
+ app.console(options[:server])
401
403
  rescue Client::ConflictException
402
404
  say_error "Cloud #{app} is not running. Cannot run console."
405
+ rescue Client::NotFoundException => e
406
+ raise unless e.resource == :virtual_server
407
+ say_error "Virtual Server '#{options[:server]}' not found"
403
408
  end
404
409
 
405
410
  desc "check", "Check if application fulfills Shelly Cloud requirements"
data/lib/shelly/client.rb CHANGED
@@ -147,8 +147,8 @@ module Shelly
147
147
  post("/apps/#{cloud}/command", {:body => body, :type => type})
148
148
  end
149
149
 
150
- def console(code_name)
151
- get("/apps/#{code_name}/console")
150
+ def console(code_name, server = nil)
151
+ get("/apps/#{code_name}/console", {:server => server})
152
152
  end
153
153
 
154
154
  def deploy_logs(cloud)
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.2.14"
2
+ VERSION = "0.2.15"
3
3
  end
@@ -343,6 +343,21 @@ describe Shelly::App do
343
343
  @app.should_receive(:exec).with("ssh -o StrictHostKeyChecking=no -p 40010 -l foo -t console.example.com ")
344
344
  @app.console
345
345
  end
346
+
347
+ context "when server passed" do
348
+ it "should request console on given server" do
349
+ @client.should_receive(:console).with("foo-staging", "app1").and_return({})
350
+ @app.stub(:exec)
351
+ @app.console("app1")
352
+ end
353
+ end
354
+ end
355
+
356
+ describe "#list_files" do
357
+ it "should list files for given subpath in disk" do
358
+ @app.should_receive(:ssh).with(:command => "ls -l /srv/glusterfs/disk/foo")
359
+ @app.list_files("foo")
360
+ end
346
361
  end
347
362
 
348
363
  describe "#upload" do
@@ -365,7 +380,7 @@ describe Shelly::App do
365
380
 
366
381
  describe "#delete_file" do
367
382
  it "should delete file over ssh" do
368
- @app.should_receive(:ssh_command).with("delete_file foo/bar")
383
+ @app.should_receive(:ssh).with(:command => "delete_file foo/bar")
369
384
  @app.delete_file("foo/bar")
370
385
  end
371
386
  end
@@ -16,6 +16,28 @@ describe Shelly::CLI::File do
16
16
  File.open("Cloudfile", 'w') { |f| f.write("foo-production:\n") }
17
17
  end
18
18
 
19
+ describe "#list" do
20
+ it "should ensure user has logged in" do
21
+ hooks(@cli_files, :upload).should include(:logged_in?)
22
+ end
23
+
24
+ it "should list files" do
25
+ @app.should_receive(:list_files).with("some/path")
26
+ invoke(@cli_files, :list, "some/path")
27
+ end
28
+
29
+ context "cloud is not running" do
30
+ it "should display error" do
31
+ @client.stub(:console).and_raise(Shelly::Client::ConflictException)
32
+ $stdout.should_receive(:puts).with(red "Cloud foo-production is not running. Cannot list files.")
33
+ lambda {
34
+ invoke(@cli_files, :list, "some/path")
35
+ }.should raise_error(SystemExit)
36
+ end
37
+ end
38
+
39
+ end
40
+
19
41
  describe "#upload" do
20
42
  it "should ensure user has logged in" do
21
43
  hooks(@cli_files, :upload).should include(:logged_in?)
@@ -1415,7 +1415,7 @@ Wait until cloud is in 'turned off' state and try again.")
1415
1415
  invoke(@main, :console)
1416
1416
  end
1417
1417
 
1418
- context "Instances are not running" do
1418
+ context "virtual servers are not running" do
1419
1419
  it "should display error" do
1420
1420
  @client.stub(:console).and_raise(Shelly::Client::ConflictException)
1421
1421
  $stdout.should_receive(:puts).with(red "Cloud foo-production is not running. Cannot run console.")
@@ -1424,6 +1424,18 @@ Wait until cloud is in 'turned off' state and try again.")
1424
1424
  }.should raise_error(SystemExit)
1425
1425
  end
1426
1426
  end
1427
+
1428
+ context "virtual server not found" do
1429
+ it "should display error" do
1430
+ ex = Shelly::Client::NotFoundException.new("resource" => "virtual_server")
1431
+ @client.stub(:console).and_raise(ex)
1432
+ @main.options = {:server => "foobar"}
1433
+ $stdout.should_receive(:puts).with(red "Virtual Server 'foobar' not found")
1434
+ lambda {
1435
+ invoke(@main, :console)
1436
+ }.should raise_error(SystemExit)
1437
+ end
1438
+ end
1427
1439
  end
1428
1440
 
1429
1441
  describe "#dbconsole" do
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
5
4
  prerelease:
5
+ version: 0.2.15
6
6
  platform: ruby
7
7
  authors:
8
8
  - Shelly Cloud team
@@ -13,13 +13,13 @@ date: 2013-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
+ type: :development
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ~>
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.11.0
22
- type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
@@ -29,13 +29,13 @@ dependencies:
29
29
  version: 2.11.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
+ type: :development
32
33
  requirement: !ruby/object:Gem::Requirement
33
34
  none: false
34
35
  requirements:
35
36
  - - ! '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: '0'
38
- type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
@@ -45,13 +45,13 @@ dependencies:
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: guard
48
+ type: :development
48
49
  requirement: !ruby/object:Gem::Requirement
49
50
  none: false
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
@@ -61,13 +61,13 @@ dependencies:
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: guard-rspec
64
+ type: :development
64
65
  requirement: !ruby/object:Gem::Requirement
65
66
  none: false
66
67
  requirements:
67
68
  - - ! '>='
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
- type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
@@ -77,13 +77,29 @@ dependencies:
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: simplecov
80
+ type: :development
80
81
  requirement: !ruby/object:Gem::Requirement
81
82
  none: false
82
83
  requirements:
83
84
  - - ! '>='
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: ruby_gntp
86
96
  type: :development
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
87
103
  prerelease: false
88
104
  version_requirements: !ruby/object:Gem::Requirement
89
105
  none: false
@@ -92,14 +108,30 @@ dependencies:
92
108
  - !ruby/object:Gem::Version
93
109
  version: '0'
94
110
  - !ruby/object:Gem::Dependency
95
- name: fakefs
111
+ name: rb-fsevent
112
+ type: :development
96
113
  requirement: !ruby/object:Gem::Requirement
97
114
  none: false
98
115
  requirements:
99
116
  - - ! '>='
100
117
  - !ruby/object:Gem::Version
101
118
  version: '0'
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: fakefs
102
128
  type: :development
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
103
135
  prerelease: false
104
136
  version_requirements: !ruby/object:Gem::Requirement
105
137
  none: false
@@ -109,13 +141,13 @@ dependencies:
109
141
  version: '0'
110
142
  - !ruby/object:Gem::Dependency
111
143
  name: fakeweb
144
+ type: :development
112
145
  requirement: !ruby/object:Gem::Requirement
113
146
  none: false
114
147
  requirements:
115
148
  - - ! '>='
116
149
  - !ruby/object:Gem::Version
117
150
  version: '0'
118
- type: :development
119
151
  prerelease: false
120
152
  version_requirements: !ruby/object:Gem::Requirement
121
153
  none: false
@@ -125,13 +157,13 @@ dependencies:
125
157
  version: '0'
126
158
  - !ruby/object:Gem::Dependency
127
159
  name: wijet-thor
160
+ type: :runtime
128
161
  requirement: !ruby/object:Gem::Requirement
129
162
  none: false
130
163
  requirements:
131
164
  - - ~>
132
165
  - !ruby/object:Gem::Version
133
166
  version: 0.14.9
134
- type: :runtime
135
167
  prerelease: false
136
168
  version_requirements: !ruby/object:Gem::Requirement
137
169
  none: false
@@ -141,13 +173,13 @@ dependencies:
141
173
  version: 0.14.9
142
174
  - !ruby/object:Gem::Dependency
143
175
  name: rest-client
176
+ type: :runtime
144
177
  requirement: !ruby/object:Gem::Requirement
145
178
  none: false
146
179
  requirements:
147
180
  - - ! '>='
148
181
  - !ruby/object:Gem::Version
149
182
  version: '0'
150
- type: :runtime
151
183
  prerelease: false
152
184
  version_requirements: !ruby/object:Gem::Requirement
153
185
  none: false
@@ -157,13 +189,13 @@ dependencies:
157
189
  version: '0'
158
190
  - !ruby/object:Gem::Dependency
159
191
  name: json
192
+ type: :runtime
160
193
  requirement: !ruby/object:Gem::Requirement
161
194
  none: false
162
195
  requirements:
163
196
  - - ! '>='
164
197
  - !ruby/object:Gem::Version
165
198
  version: '0'
166
- type: :runtime
167
199
  prerelease: false
168
200
  version_requirements: !ruby/object:Gem::Requirement
169
201
  none: false
@@ -173,13 +205,13 @@ dependencies:
173
205
  version: '0'
174
206
  - !ruby/object:Gem::Dependency
175
207
  name: progressbar
208
+ type: :runtime
176
209
  requirement: !ruby/object:Gem::Requirement
177
210
  none: false
178
211
  requirements:
179
212
  - - ! '>='
180
213
  - !ruby/object:Gem::Version
181
214
  version: '0'
182
- type: :runtime
183
215
  prerelease: false
184
216
  version_requirements: !ruby/object:Gem::Requirement
185
217
  none: false
@@ -189,13 +221,13 @@ dependencies:
189
221
  version: '0'
190
222
  - !ruby/object:Gem::Dependency
191
223
  name: launchy
224
+ type: :runtime
192
225
  requirement: !ruby/object:Gem::Requirement
193
226
  none: false
194
227
  requirements:
195
228
  - - ! '>='
196
229
  - !ruby/object:Gem::Version
197
230
  version: '0'
198
- type: :runtime
199
231
  prerelease: false
200
232
  version_requirements: !ruby/object:Gem::Requirement
201
233
  none: false
@@ -291,8 +323,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
323
  version: '0'
292
324
  requirements: []
293
325
  rubyforge_project: shelly
294
- rubygems_version: 1.8.24
326
+ rubygems_version: 1.8.23
295
327
  signing_key:
296
328
  specification_version: 3
297
329
  summary: Shelly Cloud command line tool
298
- test_files: []
330
+ test_files:
331
+ - spec/helpers.rb
332
+ - spec/input_faker.rb
333
+ - spec/shelly/app_spec.rb
334
+ - spec/shelly/backup_spec.rb
335
+ - spec/shelly/cli/backup_spec.rb
336
+ - spec/shelly/cli/config_spec.rb
337
+ - spec/shelly/cli/deploy_spec.rb
338
+ - spec/shelly/cli/file_spec.rb
339
+ - spec/shelly/cli/main_spec.rb
340
+ - spec/shelly/cli/organization_spec.rb
341
+ - spec/shelly/cli/runner_spec.rb
342
+ - spec/shelly/cli/user_spec.rb
343
+ - spec/shelly/client_spec.rb
344
+ - spec/shelly/cloudfile_spec.rb
345
+ - spec/shelly/download_progress_bar_spec.rb
346
+ - spec/shelly/model_spec.rb
347
+ - spec/shelly/organization_spec.rb
348
+ - spec/shelly/structure_validator_spec.rb
349
+ - spec/shelly/user_spec.rb
350
+ - spec/spec_helper.rb
351
+ - spec/thor/options_spec.rb