ubalo 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ubalo +28 -25
- data/lib/ubalo.rb +22 -21
- data/lib/ubalo/version.rb +1 -1
- metadata +11 -11
data/bin/ubalo
CHANGED
@@ -153,7 +153,7 @@ command :get do |c|
|
|
153
153
|
pod_name = normalize_pod_name(args.shift)
|
154
154
|
destination_path = args.shift
|
155
155
|
|
156
|
-
$stderr.print "Fetching
|
156
|
+
$stderr.print "Fetching files for #{pod_name}..."
|
157
157
|
response = ubalo.download(pod_name)
|
158
158
|
|
159
159
|
fullname, destination_path = process_download(response)
|
@@ -236,19 +236,25 @@ arg_name '<pod name>'
|
|
236
236
|
command :run do |c|
|
237
237
|
c.desc 'Use JSON for input and output'
|
238
238
|
c.switch :json
|
239
|
+
c.switch :ssh
|
239
240
|
|
240
241
|
c.action do |global_options,options,args|
|
241
242
|
pod_name = normalize_pod_name(args.shift)
|
242
243
|
if options.json
|
243
|
-
|
244
|
-
response = ubalo.submit_task_json(args)
|
244
|
+
arg = receive_json_from_stdin
|
245
245
|
else
|
246
|
+
arg = args.join(" ")
|
246
247
|
$stderr.print "Running #{pod_name}..."
|
247
|
-
response = ubalo.submit_task(pod_name, args.join(" "))
|
248
248
|
end
|
249
|
-
|
250
|
-
|
251
|
-
|
249
|
+
|
250
|
+
if options.ssh
|
251
|
+
result = ubalo.run_task(pod_name, arg)
|
252
|
+
else
|
253
|
+
response = ubalo.submit_task(pod_name, arg)
|
254
|
+
task_label = response.fetch('label')
|
255
|
+
result = ubalo.wait_task(task_label, options.json)
|
256
|
+
ubalo.show_result(result, options.json)
|
257
|
+
end
|
252
258
|
end
|
253
259
|
end
|
254
260
|
|
@@ -310,7 +316,7 @@ command :stop do |c|
|
|
310
316
|
task_label = args.first
|
311
317
|
$stderr.print "Stopping task #{task_label}..."
|
312
318
|
result = ubalo.stop_task(task_label)
|
313
|
-
$stderr.puts "
|
319
|
+
$stderr.puts " stopped."
|
314
320
|
end
|
315
321
|
end
|
316
322
|
|
@@ -334,48 +340,45 @@ command :clear_key do |c|
|
|
334
340
|
end
|
335
341
|
end
|
336
342
|
|
337
|
-
desc 'Push
|
343
|
+
desc 'Push files to Ubalo'
|
338
344
|
command :push do |c|
|
339
345
|
c.action do |global_options,options,args|
|
340
346
|
filenames = local_config.fetch('filenames')
|
341
|
-
|
347
|
+
files = {}
|
342
348
|
filenames.each do |filename|
|
343
|
-
|
349
|
+
files[filename] = File.read(filename)
|
344
350
|
end
|
345
351
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
print "Uploading changes to #{filenames.first}... "
|
350
|
-
result = ubalo.push(local_config.fetch('pod_url'), contents)
|
352
|
+
print "Uploading changes... "
|
353
|
+
result = ubalo.push(local_config.fetch('pod_url'), files)
|
351
354
|
puts "Code changes saved."
|
352
355
|
end
|
353
356
|
end
|
354
357
|
|
355
|
-
desc 'Pull
|
358
|
+
desc 'Pull files from Ubalo'
|
356
359
|
command :pull do |c|
|
357
360
|
c.action do |global_options,options,args|
|
358
361
|
print "Pulling changes from Ubalo..."
|
359
|
-
|
362
|
+
files = ubalo.pull(local_config.fetch('pod_url'))
|
360
363
|
puts " received."
|
361
364
|
|
362
365
|
filenames = local_config.fetch('filenames')
|
363
366
|
|
364
367
|
filenames.each do |filename|
|
365
368
|
if File.exists?(filename)
|
366
|
-
|
369
|
+
existing_content = File.read(filename)
|
367
370
|
else
|
368
|
-
|
371
|
+
existing_content = nil
|
369
372
|
end
|
370
373
|
|
371
|
-
if
|
374
|
+
if files.fetch(filename) == existing_content
|
372
375
|
puts "Checking #{filename}... no changes."
|
373
376
|
else
|
374
377
|
hl.choose do |menu|
|
375
378
|
menu.prompt = "Changes made to #{filename}. Overwrite your copy? "
|
376
379
|
menu.choice :yes do
|
377
380
|
open(filename, 'w') do |f|
|
378
|
-
f.puts
|
381
|
+
f.puts files.fetch(filename)
|
379
382
|
end
|
380
383
|
puts "Changes saved to #{filename}."
|
381
384
|
end
|
@@ -394,7 +397,7 @@ command :edit do |c|
|
|
394
397
|
c.action do |global_options,options,args|
|
395
398
|
username = args.first || local_username
|
396
399
|
puts "Opening an ssh connection to edit the environment belonging to #{username}."
|
397
|
-
ubalo.ssh(
|
400
|
+
ubalo.ssh('edit environment', username)
|
398
401
|
end
|
399
402
|
end
|
400
403
|
|
@@ -403,7 +406,7 @@ command "shared:edit" do |c|
|
|
403
406
|
c.action do |global_options,options,args|
|
404
407
|
username = args.first || local_username
|
405
408
|
puts "Opening an ssh connection to edit the shared data belonging to #{username}."
|
406
|
-
ubalo.ssh(
|
409
|
+
ubalo.ssh('edit shared data', username)
|
407
410
|
end
|
408
411
|
end
|
409
412
|
|
@@ -420,7 +423,7 @@ command :cp do |c|
|
|
420
423
|
ubalo.ssh_path
|
421
424
|
end
|
422
425
|
|
423
|
-
ubalo.scp(
|
426
|
+
ubalo.scp(opts, scp_args, local_username)
|
424
427
|
end
|
425
428
|
end
|
426
429
|
|
data/lib/ubalo.rb
CHANGED
@@ -134,15 +134,16 @@ class Ubalo
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def tasks count
|
137
|
-
get("#{base_url}/
|
137
|
+
get("#{base_url}/tasks", :count => count)
|
138
138
|
end
|
139
139
|
|
140
|
-
def
|
141
|
-
|
140
|
+
def run_task(pod_name, arg)
|
141
|
+
puts "Running #{pod_name} interactively..."
|
142
|
+
ssh('run task', pod_name, arg)
|
142
143
|
end
|
143
144
|
|
144
|
-
def
|
145
|
-
post("#{base_url}/
|
145
|
+
def submit_task pod_name, arg
|
146
|
+
post("#{base_url}/pods/#{pod_name}/tasks", :arg => arg)
|
146
147
|
end
|
147
148
|
|
148
149
|
def wait_task(label, silent=false)
|
@@ -189,26 +190,26 @@ class Ubalo
|
|
189
190
|
get("#{base_url}/pods")
|
190
191
|
end
|
191
192
|
|
192
|
-
def ssh(
|
193
|
-
ssh_command = "ssh -o SendEnv='
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
193
|
+
def ssh(action, *args)
|
194
|
+
ssh_command = "ssh -o SendEnv='UBALO_ARGS UBALO_ACTION TERM' -tq #{ssh_path}"
|
195
|
+
execute(action, args, ssh_command)
|
196
|
+
end
|
197
|
+
|
198
|
+
def scp(opts, command, *args)
|
199
|
+
scp_command = "scp -o SendEnv='UBALO_ARGS UBALO_ACTION' #{opts} #{command}"
|
200
|
+
execute('edit environment', args, scp_command)
|
199
201
|
end
|
200
202
|
|
201
|
-
def
|
202
|
-
|
203
|
-
Process.spawn({'UBALO_OWNER_NAME' => username, 'UBALO_ACTION' => 'edit-environment'}, scp_command)
|
203
|
+
def execute(action, args, command)
|
204
|
+
Process.spawn({'UBALO_ACTION' => action, 'UBALO_ARGS' => JSON.dump(args)}, command)
|
204
205
|
pid, status = Process.wait2
|
205
206
|
unless status.success?
|
206
|
-
abort "Error running
|
207
|
+
abort "Error running command"
|
207
208
|
end
|
208
209
|
end
|
209
210
|
|
210
211
|
def stop_task(label)
|
211
|
-
post("#{base_url}/
|
212
|
+
post("#{base_url}/tasks/#{label}/stop")
|
212
213
|
end
|
213
214
|
|
214
215
|
def show_result(result, json=false)
|
@@ -253,8 +254,8 @@ class Ubalo
|
|
253
254
|
post("#{base_url}/templates/#{template}/pods", :pod => {:name => name})
|
254
255
|
end
|
255
256
|
|
256
|
-
def push pod_url,
|
257
|
-
post("#{pod_url}/files", :
|
257
|
+
def push pod_url, files
|
258
|
+
post("#{pod_url}/files", :files => files)
|
258
259
|
end
|
259
260
|
|
260
261
|
def pull pod_url
|
@@ -262,11 +263,11 @@ class Ubalo
|
|
262
263
|
end
|
263
264
|
|
264
265
|
def check_task label
|
265
|
-
|
266
|
+
get("#{base_url}/tasks/#{label}")
|
266
267
|
end
|
267
268
|
|
268
269
|
def check_task_json hash
|
269
|
-
|
270
|
+
check_task(hash[:label])
|
270
271
|
end
|
271
272
|
|
272
273
|
def publish pod_name
|
data/lib/ubalo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ubalo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154176360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154176360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154175940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154175940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154175520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154175520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154175020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.6.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2154175020
|
58
58
|
description: CLI and API client for Ubalo
|
59
59
|
email: dev@ubalo.com
|
60
60
|
executables:
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.6
|
89
89
|
signing_key:
|
90
90
|
specification_version: 3
|
91
91
|
summary: CLI and API client for Ubalo
|