ubalo 0.14 → 0.15
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 +48 -17
- data/lib/ubalo/account.rb +5 -1
- data/lib/ubalo/pod.rb +51 -4
- data/lib/ubalo/pod_dir.rb +10 -0
- data/lib/ubalo/task.rb +25 -3
- data/lib/ubalo/version.rb +1 -1
- data/resources/init_files/run.sh +1 -1
- metadata +23 -13
data/bin/ubalo
CHANGED
@@ -7,6 +7,8 @@ include GLI
|
|
7
7
|
|
8
8
|
require 'yaml'
|
9
9
|
require 'fileutils'
|
10
|
+
require 'shellwords'
|
11
|
+
require 'launchy'
|
10
12
|
|
11
13
|
require 'highline'
|
12
14
|
hl = HighLine.new
|
@@ -171,16 +173,12 @@ end
|
|
171
173
|
|
172
174
|
desc 'Run a pod'
|
173
175
|
command :run do |c|
|
174
|
-
c.
|
175
|
-
|
176
|
-
task = pod.run(args.shift)
|
176
|
+
c.flag :arg
|
177
|
+
c.switch :v2
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
tailer.update(task.process_output)
|
182
|
-
task.complete?
|
183
|
-
end
|
179
|
+
c.action do |global_options,options,args|
|
180
|
+
task = pod.run(options.v2 || pod_dir.v2?, args, options.arg)
|
181
|
+
task.tail_process
|
184
182
|
puts task.printable_result
|
185
183
|
end
|
186
184
|
end
|
@@ -193,11 +191,19 @@ command :pod do |c|
|
|
193
191
|
end
|
194
192
|
end
|
195
193
|
|
194
|
+
desc 'Open the pod in a browser'
|
195
|
+
command 'pod:open' do |c|
|
196
|
+
c.action do |global_options,options,args|
|
197
|
+
Launchy.open(pod.url)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
196
201
|
desc 'Run a pod in the background'
|
197
202
|
command :submit do |c|
|
203
|
+
c.flag :arg
|
204
|
+
|
198
205
|
c.action do |global_options,options,args|
|
199
|
-
|
200
|
-
task = pod.run(args.shift)
|
206
|
+
task = pod.run(pod_dir.v2?, args, options.arg)
|
201
207
|
logger.puts " done."
|
202
208
|
puts task.printable_result
|
203
209
|
end
|
@@ -217,6 +223,20 @@ command :task do |c|
|
|
217
223
|
end
|
218
224
|
end
|
219
225
|
|
226
|
+
desc 'Open the task in a browser'
|
227
|
+
arg_name '<task label>'
|
228
|
+
command 'task:open' do |c|
|
229
|
+
c.action do |global_options,options,args|
|
230
|
+
if label = args.shift
|
231
|
+
task = account.task_by_label!(label)
|
232
|
+
else
|
233
|
+
task = pod.latest_task
|
234
|
+
end
|
235
|
+
|
236
|
+
Launchy.open(task.url)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
220
240
|
desc 'Stop a task'
|
221
241
|
arg_name '<task label>'
|
222
242
|
command 'task:stop' do |c|
|
@@ -240,14 +260,25 @@ end
|
|
240
260
|
desc 'Push files to Ubalo'
|
241
261
|
command :push do |c|
|
242
262
|
c.action do |global_options,options,args|
|
243
|
-
logger.print "Pushing files to #{pod.fullname.inspect}..."
|
244
263
|
pod.push_from(pod_dir)
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
264
|
+
pod.tail_process
|
265
|
+
puts pod.printable_result
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
desc 'Push files and run'
|
270
|
+
command 'push-run' do |c|
|
271
|
+
c.flag :arg
|
272
|
+
c.switch :v2
|
273
|
+
|
274
|
+
c.action do |global_options,options,args|
|
275
|
+
pod.push_from(pod_dir)
|
276
|
+
pod.tail_process
|
250
277
|
puts pod.printable_result
|
278
|
+
|
279
|
+
task = pod.run(options.v2 || pod_dir.v2?, args, options.arg)
|
280
|
+
task.tail_process
|
281
|
+
puts task.printable_result
|
251
282
|
end
|
252
283
|
end
|
253
284
|
|
data/lib/ubalo/account.rb
CHANGED
@@ -15,7 +15,11 @@ module Ubalo
|
|
15
15
|
if authorization and !options[:skip_authorization]
|
16
16
|
options[:authorization] = authorization
|
17
17
|
end
|
18
|
-
Util.http_request(method,
|
18
|
+
Util.http_request(method, url_for(path), options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def url_for(path)
|
22
|
+
"#{@base_url}#{path}"
|
19
23
|
end
|
20
24
|
|
21
25
|
def authorize(login, password)
|
data/lib/ubalo/pod.rb
CHANGED
@@ -37,12 +37,28 @@ module Ubalo
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def run(arg)
|
40
|
+
def run(version2, argv, arg)
|
41
|
+
if version2
|
42
|
+
if argv.empty?
|
43
|
+
raise Ubalo::Error, "Specify the command to run"
|
44
|
+
end
|
45
|
+
else
|
46
|
+
arg = argv.shift || arg
|
47
|
+
argv = ["sh", "run.sh"]
|
48
|
+
end
|
49
|
+
|
50
|
+
logger.print "Running #{Shellwords.join(argv)} inside #{fullname}..."
|
51
|
+
|
41
52
|
params = {
|
42
53
|
:arg_content_type => UbaloJSON.content_type,
|
43
|
-
:arg => UbaloJSON.dump(arg)
|
54
|
+
:arg => UbaloJSON.dump(arg),
|
55
|
+
:argv => argv,
|
44
56
|
}
|
45
|
-
@account.task_from_json(request(:post, "/tasks", :params => params))
|
57
|
+
task = @account.task_from_json(request(:post, "/tasks", :params => params))
|
58
|
+
|
59
|
+
logger.puts " done."
|
60
|
+
|
61
|
+
task
|
46
62
|
rescue RestClient::Conflict
|
47
63
|
raise Ubalo::Error, "Cannot run pod while compiling"
|
48
64
|
rescue RestClient::ResourceNotFound
|
@@ -58,10 +74,14 @@ module Ubalo
|
|
58
74
|
end
|
59
75
|
|
60
76
|
def push_from(pod_dir)
|
77
|
+
logger.print "Pushing files to #{fullname.inspect}..."
|
78
|
+
|
61
79
|
pod_dir.assert_not_empty!
|
62
80
|
update!
|
63
81
|
new_archive.activate_from(pod_dir)
|
64
82
|
refresh!
|
83
|
+
|
84
|
+
logger.puts " done."
|
65
85
|
end
|
66
86
|
|
67
87
|
def clone_to(pod_dir)
|
@@ -74,6 +94,15 @@ module Ubalo
|
|
74
94
|
state == 'compiled'
|
75
95
|
end
|
76
96
|
|
97
|
+
def tail_process
|
98
|
+
tailer = Ubalo::Tailer.new(logger)
|
99
|
+
tailer.poll_on("Waiting for #{fullname.inspect} to compile") do
|
100
|
+
refresh!
|
101
|
+
tailer.update(process_output)
|
102
|
+
compiled?
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
77
106
|
def delete!
|
78
107
|
request(:delete, nil, :parse => false)
|
79
108
|
@deleted = true
|
@@ -107,6 +136,20 @@ module Ubalo
|
|
107
136
|
fullname == other.fullname
|
108
137
|
end
|
109
138
|
|
139
|
+
attr_reader :compilation_process
|
140
|
+
|
141
|
+
def process_output
|
142
|
+
if compilation_process
|
143
|
+
if data = compilation_process.fetch('output')
|
144
|
+
data
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def url
|
150
|
+
@account.url_for(path_prefix)
|
151
|
+
end
|
152
|
+
|
110
153
|
private
|
111
154
|
def update_attributes(attributes)
|
112
155
|
@state = attributes['state']
|
@@ -124,7 +167,11 @@ module Ubalo
|
|
124
167
|
end
|
125
168
|
|
126
169
|
def request method, path = nil, options = {}
|
127
|
-
@account.request(method, "
|
170
|
+
@account.request(method, "#{path_prefix}#{path}", options)
|
171
|
+
end
|
172
|
+
|
173
|
+
def path_prefix
|
174
|
+
"/pods/#{fullname}"
|
128
175
|
end
|
129
176
|
end
|
130
177
|
end
|
data/lib/ubalo/pod_dir.rb
CHANGED
data/lib/ubalo/task.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ubalo
|
2
2
|
class Task
|
3
|
-
attr_reader :label, :state, :pod_name, :arg_error, :output_error, :submitted_at, :elapsed_time
|
3
|
+
attr_reader :label, :state, :pod_name, :argv, :arg_error, :output_error, :submitted_at, :elapsed_time
|
4
4
|
|
5
5
|
def self.create_with_json(account, json)
|
6
6
|
new(account, json.fetch('label'), json)
|
@@ -26,6 +26,15 @@ module Ubalo
|
|
26
26
|
state == 'exited'
|
27
27
|
end
|
28
28
|
|
29
|
+
def tail_process
|
30
|
+
tailer = Ubalo::Tailer.new(logger)
|
31
|
+
tailer.poll_on("Waiting for task #{label.inspect}") do
|
32
|
+
refresh!
|
33
|
+
tailer.update(process_output)
|
34
|
+
complete?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
def stop!
|
30
39
|
request(:put, "/stop")
|
31
40
|
refresh!
|
@@ -43,6 +52,7 @@ module Ubalo
|
|
43
52
|
s = ""
|
44
53
|
s << " label: #{label}\n"
|
45
54
|
s << " pod: #{pod_name}\n"
|
55
|
+
s << " argv: #{pretty_argv}\n"
|
46
56
|
if arg?
|
47
57
|
if @arg_error
|
48
58
|
s << "! Parse error in arg: #{@arg_error.message}"
|
@@ -83,12 +93,21 @@ module Ubalo
|
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
96
|
+
def pretty_argv
|
97
|
+
Shellwords.join(argv)
|
98
|
+
end
|
99
|
+
|
86
100
|
attr_reader :container_process
|
87
101
|
|
102
|
+
def url
|
103
|
+
@account.url_for(path_prefix)
|
104
|
+
end
|
105
|
+
|
88
106
|
private
|
89
107
|
|
90
108
|
def update_attributes(attributes)
|
91
109
|
@state = attributes['state']
|
110
|
+
@argv = attributes['argv']
|
92
111
|
@arg = attributes['arg']
|
93
112
|
@pod_name = attributes['pod_name']
|
94
113
|
@container_process = attributes['container_process']
|
@@ -130,9 +149,12 @@ module Ubalo
|
|
130
149
|
@output || @output_error
|
131
150
|
end
|
132
151
|
|
133
|
-
|
134
152
|
def request method, path = nil, options = {}
|
135
|
-
@account.request(method, "
|
153
|
+
@account.request(method, "#{path_prefix}#{path}", options)
|
154
|
+
end
|
155
|
+
|
156
|
+
def path_prefix
|
157
|
+
"/tasks/#{label}"
|
136
158
|
end
|
137
159
|
end
|
138
160
|
end
|
data/lib/ubalo/version.rb
CHANGED
data/resources/init_files/run.sh
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.
|
4
|
+
version: '0.15'
|
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-
|
12
|
+
date: 2012-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &70318706609560 !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: *70318706609560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &70318706608600 !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: *70318706608600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70318706607400 !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: *70318706607400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70318706606660 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70318706606660
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: archive-tar-minitar
|
60
|
-
requirement: &
|
60
|
+
requirement: &70318706605940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,18 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70318706605940
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: launchy
|
71
|
+
requirement: &70318706604880 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70318706604880
|
69
80
|
description: CLI and API client for Ubalo
|
70
81
|
email: dev@ubalo.com
|
71
82
|
executables:
|
@@ -110,4 +121,3 @@ signing_key:
|
|
110
121
|
specification_version: 3
|
111
122
|
summary: CLI and API client for Ubalo
|
112
123
|
test_files: []
|
113
|
-
has_rdoc:
|