ubalo 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ubalo +41 -57
- data/lib/ubalo.rb +24 -35
- metadata +8 -8
data/bin/ubalo
CHANGED
@@ -44,7 +44,7 @@ def ubalo
|
|
44
44
|
end
|
45
45
|
|
46
46
|
program_desc 'Command-line access to ubalo.com.'
|
47
|
-
version "0.0.
|
47
|
+
version "0.0.6"
|
48
48
|
|
49
49
|
desc "Change the connect url"
|
50
50
|
flag 'connect-url'
|
@@ -56,39 +56,28 @@ command :whoami do |c|
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
desc 'Display pods'
|
60
|
-
command :
|
61
|
-
c.desc 'show all pods you can snap (default)'
|
62
|
-
c.switch :all
|
63
|
-
|
64
|
-
c.desc 'show only your pods'
|
65
|
-
c.switch :mine
|
66
|
-
|
67
|
-
c.desc 'show only the pods you can edit and snap'
|
68
|
-
c.switch :editable
|
69
|
-
|
59
|
+
desc 'Display a list of available pods'
|
60
|
+
command :list do |c|
|
70
61
|
c.action do |global_options,options,args|
|
71
|
-
|
72
|
-
# Default to showing just your pods.
|
73
|
-
options.mine = true
|
74
|
-
end
|
75
|
-
|
76
|
-
your_pods, editable_pods, snappable_pods = ubalo.pods
|
62
|
+
response = ubalo.pods
|
77
63
|
|
78
|
-
|
79
|
-
your_pods
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
puts Ubalo.format_pod(pod)
|
64
|
+
puts "your pods:"
|
65
|
+
your_pods = response['your_pods']
|
66
|
+
if your_pods.empty?
|
67
|
+
puts " (none)"
|
68
|
+
else
|
69
|
+
response['your_pods'].each do |pod|
|
70
|
+
puts Ubalo.format_pod(pod, false)
|
86
71
|
end
|
87
72
|
end
|
88
73
|
|
89
|
-
|
90
|
-
|
91
|
-
|
74
|
+
puts "other pods:"
|
75
|
+
other_pods = response['other_pods']
|
76
|
+
if other_pods.empty?
|
77
|
+
puts " (none)"
|
78
|
+
else
|
79
|
+
other_pods.each do |pod|
|
80
|
+
puts Ubalo.format_pod(pod, true)
|
92
81
|
end
|
93
82
|
end
|
94
83
|
end
|
@@ -230,15 +219,7 @@ end
|
|
230
219
|
|
231
220
|
desc 'Snap a pod'
|
232
221
|
arg_name '<pod name>'
|
233
|
-
command :
|
234
|
-
c.desc 'detach, leaving task running in the background; return an id'
|
235
|
-
c.switch [:detach, :d]
|
236
|
-
|
237
|
-
c.desc 'explicitly show the complete result'
|
238
|
-
c.switch [:verbose, :v]
|
239
|
-
|
240
|
-
c.desc 'outputs as json to stdout; stdout > stderr'
|
241
|
-
c.switch [:json, :j]
|
222
|
+
command :run do |c|
|
242
223
|
|
243
224
|
c.action do |global_options,options,args|
|
244
225
|
pod_name = args.shift
|
@@ -246,15 +227,12 @@ command :snap do |c|
|
|
246
227
|
raise "please specify a pod"
|
247
228
|
end
|
248
229
|
|
249
|
-
|
250
|
-
|
230
|
+
$stderr.print "Running #{pod_name}..."
|
231
|
+
response = ubalo.submit_task(pod_name, args.join(" "))
|
232
|
+
task_id = response['id']
|
251
233
|
|
252
|
-
|
253
|
-
|
254
|
-
else
|
255
|
-
result = ubalo.check_task(task_id, true)
|
256
|
-
ubalo.show_result(result, options.verbose, options.json)
|
257
|
-
end
|
234
|
+
result = ubalo.check_task(task_id, true)
|
235
|
+
ubalo.show_result(result)
|
258
236
|
end
|
259
237
|
end
|
260
238
|
|
@@ -281,38 +259,44 @@ command :check do |c|
|
|
281
259
|
end
|
282
260
|
end
|
283
261
|
|
284
|
-
desc '
|
285
|
-
command :
|
262
|
+
desc 'Sign into Ubalo'
|
263
|
+
command :signin do |c|
|
286
264
|
c.action do |global_options,options,args|
|
287
265
|
puts "Please enter your Ubalo username/email and password to unlock command-line access."
|
288
266
|
login = hl.ask(" login: "){|q| q.echo = true}
|
289
267
|
password = hl.ask(" password: "){|q| q.echo = false}
|
290
268
|
|
291
269
|
ubalo.token = ubalo.get_api_token(login, password)
|
292
|
-
Ubalo.write_config('token' => ubalo.token)
|
270
|
+
Ubalo.write_config("connect-url" => ubalo.base_url, ubalo.base_url => {'token' => ubalo.token})
|
293
271
|
puts "Access details saved to ~/.ubalorc."
|
294
272
|
puts ubalo.whoami
|
295
273
|
end
|
296
274
|
end
|
297
275
|
|
298
|
-
desc '
|
299
|
-
command :
|
276
|
+
desc 'Sign out of Ubalo'
|
277
|
+
command :signout do |c|
|
300
278
|
c.action do |global_options,options,args|
|
301
|
-
Ubalo.write_config(
|
279
|
+
Ubalo.write_config(ubalo.base_url => nil)
|
302
280
|
puts "Access details deleted."
|
303
281
|
end
|
304
282
|
end
|
305
283
|
|
306
284
|
pre do |global,command,options,args|
|
307
285
|
config = Ubalo.config
|
308
|
-
|
286
|
+
connect_url = global['connect-url'] || config['connect-url']
|
287
|
+
|
288
|
+
# When signing in, don't use the token:
|
289
|
+
unless command && command.name == :signin
|
290
|
+
if host_config = config[connect_url]
|
291
|
+
token = host_config['token']
|
292
|
+
end
|
293
|
+
end
|
309
294
|
|
310
|
-
unless token or (command && command.name == :
|
311
|
-
raise "No credentials found. Please run 'ubalo
|
295
|
+
unless token or (command && command.name == :signin)
|
296
|
+
raise "No credentials found. Please run 'ubalo signin'."
|
312
297
|
end
|
313
298
|
|
314
|
-
|
315
|
-
@ubalo ||= Ubalo.authorize(token, connect_url)
|
299
|
+
@ubalo ||= Ubalo.signin(token, connect_url)
|
316
300
|
|
317
301
|
true
|
318
302
|
end
|
data/lib/ubalo.rb
CHANGED
@@ -50,15 +50,20 @@ class Ubalo
|
|
50
50
|
"#{task['id'].to_s[0,6]} #{task['state'].lfit(8)} #{task['pod_name'].lfit(25)} #{task['arg'].to_s.lfit(40)}"
|
51
51
|
end
|
52
52
|
|
53
|
-
def format_pod pod
|
54
|
-
|
53
|
+
def format_pod pod, with_username
|
54
|
+
if with_username
|
55
|
+
name = "#{pod['user']}/#{pod['name']}"
|
56
|
+
else
|
57
|
+
name = pod['name']
|
58
|
+
end
|
59
|
+
" #{name} - #{pod['environ']}"
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
58
63
|
attr_reader :base_url
|
59
64
|
attr_accessor :token
|
60
65
|
|
61
|
-
def self.
|
66
|
+
def self.signin token, base_url=nil
|
62
67
|
new(token, base_url)
|
63
68
|
end
|
64
69
|
|
@@ -95,7 +100,6 @@ class Ubalo
|
|
95
100
|
end
|
96
101
|
|
97
102
|
def submit_task(pod_name, arg)
|
98
|
-
$stderr.puts "Snapping #{pod_name}"
|
99
103
|
parse(post(:submit_task, {:pod_name => pod_name, :arg => arg}))
|
100
104
|
end
|
101
105
|
|
@@ -104,7 +108,7 @@ class Ubalo
|
|
104
108
|
60.times do
|
105
109
|
h = check_task_once(id)
|
106
110
|
if %w{complete failed}.include?(h['state'])
|
107
|
-
$stderr.puts "done"
|
111
|
+
$stderr.puts " done."
|
108
112
|
return h
|
109
113
|
end
|
110
114
|
$stderr.print '.'
|
@@ -140,8 +144,7 @@ class Ubalo
|
|
140
144
|
end
|
141
145
|
|
142
146
|
def pods
|
143
|
-
|
144
|
-
[h['your_pods'], h['editable_pods'], h['snappable_pods']]
|
147
|
+
parse(get(:pods))
|
145
148
|
end
|
146
149
|
|
147
150
|
def ssh(pod_name)
|
@@ -170,36 +173,22 @@ class Ubalo
|
|
170
173
|
if json
|
171
174
|
puts outputs
|
172
175
|
else
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
186
|
-
else
|
187
|
-
if result['stdout']
|
188
|
-
print result['stdout']
|
189
|
-
end
|
190
|
-
if result['stderr']
|
191
|
-
$stderr.print result['stderr']
|
192
|
-
end
|
193
|
-
|
194
|
-
exit_code = Integer(result['status'] || 0)
|
195
|
-
unless exit_code.zero?
|
196
|
-
raise UbaloExit, exit_code
|
197
|
-
end
|
176
|
+
puts " id: #{result['id']}"
|
177
|
+
puts " name: #{result['pod_name']}"
|
178
|
+
puts " arg: #{result['arg']}"
|
179
|
+
puts " state: #{result['state']}"
|
180
|
+
puts "status: #{result['status']}" if result['status']
|
181
|
+
if result['stdout']
|
182
|
+
puts "stdout:"
|
183
|
+
puts result['stdout'].indent
|
184
|
+
end
|
185
|
+
if result['stderr']
|
186
|
+
puts "stderr:"
|
187
|
+
puts result['stderr'].indent
|
198
188
|
end
|
199
|
-
|
200
189
|
if outputs
|
201
|
-
|
202
|
-
|
190
|
+
puts "outputs:"
|
191
|
+
puts outputs.indent
|
203
192
|
end
|
204
193
|
end
|
205
194
|
end
|
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.6
|
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: 2011-
|
12
|
+
date: 2011-12-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153089760 !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: *2153089760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153089320 !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: *2153089320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rest-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153088800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.6.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153088800
|
47
47
|
description: CLI and API client for Ubalo
|
48
48
|
email: dev@ubalo.com
|
49
49
|
executables:
|