larrow-runner 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/larrow-runner.gemspec +0 -3
- data/lib/active_support/core_ext/hash.rb +7 -0
- data/lib/active_support/core_ext/hash/compact.rb +20 -0
- data/lib/active_support/core_ext/hash/deep_merge.rb +38 -0
- data/lib/active_support/core_ext/hash/except.rb +15 -0
- data/lib/active_support/core_ext/hash/indifferent_access.rb +23 -0
- data/lib/active_support/core_ext/hash/keys.rb +162 -0
- data/lib/active_support/core_ext/hash/reverse_merge.rb +22 -0
- data/lib/active_support/core_ext/hash/slice.rb +42 -0
- data/lib/active_support/hash_with_indifferent_access.rb +272 -0
- data/lib/larrow/runner.rb +3 -3
- data/lib/larrow/runner/cli/tools.rb +5 -1
- data/lib/larrow/runner/errors.rb +2 -1
- data/lib/larrow/runner/logger.rb +2 -2
- data/lib/larrow/runner/manager.rb +10 -3
- data/lib/larrow/runner/manifest.rb +15 -4
- data/lib/larrow/runner/manifest/adapter/larrow.rb +28 -26
- data/lib/larrow/runner/manifest/adapter/travis.rb +53 -52
- data/lib/larrow/runner/manifest/base_loader.rb +18 -16
- data/lib/larrow/runner/manifest/configuration.rb +118 -116
- data/lib/larrow/runner/model/app.rb +4 -4
- data/lib/larrow/runner/model/node.rb +56 -56
- data/lib/larrow/runner/service/cloud.rb +10 -4
- data/lib/larrow/runner/session.rb +14 -11
- data/lib/larrow/runner/vcs/base.rb +14 -12
- data/lib/larrow/runner/vcs/github.rb +40 -38
- data/lib/larrow/runner/version.rb +1 -1
- metadata +11 -50
@@ -1,11 +1,11 @@
|
|
1
1
|
module Larrow::Runner
|
2
2
|
module Model
|
3
3
|
class App
|
4
|
-
|
4
|
+
include Service
|
5
5
|
attr_accessor :vcs, :node, :configuration
|
6
6
|
def initialize vcs, attributes={}
|
7
7
|
self.vcs = vcs
|
8
|
-
self.configuration =
|
8
|
+
self.configuration = Manifest.configuration vcs
|
9
9
|
self.assign attributes unless attributes.empty?
|
10
10
|
end
|
11
11
|
|
@@ -29,7 +29,7 @@ module Larrow::Runner
|
|
29
29
|
RunLogger.title 'allocate resource'
|
30
30
|
begin_at = Time.new
|
31
31
|
option = {image_id: configuration.image}
|
32
|
-
self.node = Node.new(*
|
32
|
+
self.node = Node.new(*Session.cloud.create(option).first)
|
33
33
|
during = sprintf('%.2f', Time.new - begin_at)
|
34
34
|
RunLogger.level(1).detail "allocated(#{during}s)"
|
35
35
|
end
|
@@ -37,7 +37,7 @@ module Larrow::Runner
|
|
37
37
|
def build_image
|
38
38
|
action :image
|
39
39
|
node.stop
|
40
|
-
new_image =
|
40
|
+
new_image = Session.cloud.create_image node.instance.id
|
41
41
|
RunLogger.level(1).detail "New Image Id: #{new_image.id}"
|
42
42
|
[
|
43
43
|
"To reduce the system setup, you might want to change larrow.yml.",
|
@@ -1,73 +1,73 @@
|
|
1
|
+
require 'larrow/qingcloud'
|
1
2
|
module Larrow::Runner
|
2
3
|
module Model
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
class Node
|
5
|
+
include Larrow::Runner::Service
|
6
|
+
include Larrow::Qingcloud
|
7
|
+
attr_accessor :instance, :eip
|
8
|
+
attr_accessor :user,:host
|
9
|
+
def initialize instance, eip, user='root'
|
10
|
+
self.instance = instance
|
11
|
+
self.eip = eip
|
12
|
+
self.host = eip.address
|
13
|
+
self.user = user
|
14
|
+
@executor = Executor.new host, user, nil, nil
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
def execute command, base_dir:nil
|
18
|
+
block = if block_given?
|
19
|
+
-> (data) { yield data }
|
20
|
+
else
|
21
|
+
-> (data) {
|
22
|
+
data.split(/\r?\n/).each do |msg|
|
23
|
+
RunLogger.level(1).info msg
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
@executor.execute command, base_dir: base_dir, &block
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def stop
|
31
|
+
self.instance = instance.stop
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
34
|
+
def destroy
|
35
|
+
Session.cloud.destroy instance,eip
|
36
|
+
self
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
def dump
|
40
|
+
{
|
41
|
+
instance:{id: instance.id},
|
42
|
+
eip:{id:eip.id, address:eip.address}
|
43
|
+
}
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
def self.show resources, level=0
|
47
|
+
resources.map do |hash|
|
48
|
+
node = load_obj hash
|
49
|
+
RunLogger.level(level).detail "instance: #{node.instance.id}"
|
50
|
+
RunLogger.level(level).detail "eip:"
|
51
|
+
RunLogger.level(level+1).detail "id: #{node.eip.id}"
|
52
|
+
RunLogger.level(level+1).detail "address: #{node.eip.address}"
|
53
|
+
end
|
53
54
|
end
|
54
|
-
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
def self.cleanup resources
|
57
|
+
resources.map do |hash|
|
58
|
+
node = load_obj hash
|
59
|
+
future{node.destroy}
|
60
|
+
end.map do |node|
|
61
|
+
RunLogger.info "node cleaned: #{node.eip.address}"
|
62
|
+
end
|
62
63
|
end
|
63
|
-
end
|
64
64
|
|
65
|
-
|
65
|
+
def self.load_obj data
|
66
66
|
instance = Instance.new data[:instance][:id]
|
67
67
|
eip = Eip.new data[:eip][:id],address:data[:eip][:address]
|
68
68
|
new instance,eip
|
69
|
-
|
69
|
+
end
|
70
70
|
|
71
|
-
|
71
|
+
end
|
72
72
|
end
|
73
73
|
end
|
@@ -19,10 +19,10 @@ module Larrow
|
|
19
19
|
def create image_id:nil,count:1
|
20
20
|
RunLogger.level(1).detail "assign node"
|
21
21
|
instances = Instance.create(image_id: image_id||'trustysrvx64c',
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
count:count,
|
23
|
+
login_mode:'keypair',
|
24
|
+
keypair_id: @keypair_id
|
25
|
+
)
|
26
26
|
|
27
27
|
eips = Eip.create(count:count)
|
28
28
|
|
@@ -42,8 +42,14 @@ module Larrow
|
|
42
42
|
Image.list(:self, ids: [image_id]).size == 1
|
43
43
|
end
|
44
44
|
|
45
|
+
# concurrent destroy(force)
|
46
|
+
def destroy *args
|
47
|
+
args.map(&:destroy).map(&:force)
|
48
|
+
end
|
49
|
+
|
45
50
|
def check_available
|
46
51
|
KeyPair.list
|
52
|
+
self
|
47
53
|
rescue
|
48
54
|
Qingcloud.remove_connection
|
49
55
|
raise $!
|
@@ -16,9 +16,9 @@ module Larrow
|
|
16
16
|
:keypair_id].
|
17
17
|
reduce({}){|s,key| s.update key => value_for(key)}
|
18
18
|
|
19
|
-
|
19
|
+
tmp_cloud = Service::Cloud.new data
|
20
20
|
begin
|
21
|
-
|
21
|
+
tmp_cloud.check_available
|
22
22
|
RunLogger.info "login success! write to ~/.larrow"
|
23
23
|
break
|
24
24
|
rescue Exception => e
|
@@ -30,15 +30,18 @@ module Larrow
|
|
30
30
|
File.write FILE, YAML.dump(content)
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
def cloud
|
34
|
+
@cloud ||= begin
|
35
|
+
args = YAML.
|
36
|
+
load(File.read FILE).
|
37
|
+
with_indifferent_access[:qingcloud]
|
38
|
+
Service::Cloud.new(args).check_available
|
39
|
+
rescue
|
40
|
+
fail(InvalidConfigFile,
|
41
|
+
{file:FILE,
|
42
|
+
wiki:"setup-cloud-account"}
|
43
|
+
)
|
44
|
+
end
|
42
45
|
end
|
43
46
|
|
44
47
|
def value_for name
|
@@ -1,17 +1,19 @@
|
|
1
|
-
module Larrow::Runner
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Manifest.add_base_scripts configuration,self
|
1
|
+
module Larrow::Runner
|
2
|
+
module Vcs
|
3
|
+
class Base
|
4
|
+
attr_accessor :larrow_file
|
5
|
+
|
6
|
+
def get filename
|
7
|
+
raise 'not implement yet'
|
9
8
|
end
|
10
|
-
configuration
|
11
|
-
end
|
12
9
|
|
13
|
-
|
14
|
-
|
10
|
+
def update_source node, target_dir
|
11
|
+
raise 'not implement yet'
|
12
|
+
end
|
13
|
+
|
14
|
+
def formatted_url
|
15
|
+
raise 'not implement yet'
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,48 +1,50 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
|
3
|
-
module Larrow::Runner
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
module Larrow::Runner
|
4
|
+
module Vcs
|
5
|
+
class Github < Base
|
6
|
+
URL_TEMPLATE='https://raw.githubusercontent.com/%s/%s/%s/%s'
|
7
|
+
attr_accessor :organize, :name, :branch
|
8
|
+
# url sample:
|
9
|
+
# git@github.com:fsword/larrow-qingcloud.git
|
10
|
+
# https://github.com/fsword/larrow-qingcloud.git
|
11
|
+
def initialize url
|
12
|
+
self.branch = 'master'
|
13
|
+
case url
|
14
|
+
when /git@github\.com:(.+)\/(.+)\.git/
|
15
|
+
self.organize = $1
|
16
|
+
self.name = $2
|
17
|
+
when /http.:\/\/github.com\/(.+)\/(.+)\.git/
|
18
|
+
self.organize = $1
|
19
|
+
self.name = $2
|
20
|
+
end
|
19
21
|
end
|
20
|
-
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def formatted_url
|
24
|
+
'git@github.com:%s/%s.git' % [organize, name]
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
def get filename
|
28
|
+
url = URL_TEMPLATE % [organize, name, branch, filename]
|
29
|
+
resp = Faraday.get(url)
|
30
|
+
case resp.status
|
31
|
+
when 200
|
32
|
+
resp.body
|
33
|
+
when 404
|
34
|
+
nil
|
35
|
+
else
|
36
|
+
raise resp.body
|
37
|
+
end
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
def update_source node, target_dir
|
41
|
+
template = ["git clone ",
|
42
|
+
"--depth 1",
|
43
|
+
"http://github.com/%s/%s.git",
|
44
|
+
"-b %s %s"].join(' ')
|
45
|
+
cmd = template % [organize, name, branch, target_dir]
|
46
|
+
node.execute cmd
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: larrow-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fsword
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: tilt
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '2'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: thor
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,20 +94,6 @@ dependencies:
|
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0.19'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: activesupport
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '4.1'
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '4.1'
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: pry
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,26 +134,6 @@ dependencies:
|
|
162
134
|
- - '='
|
163
135
|
- !ruby/object:Gem::Version
|
164
136
|
version: 0.2.4
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: minitest
|
167
|
-
requirement: !ruby/object:Gem::Requirement
|
168
|
-
requirements:
|
169
|
-
- - "~>"
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
version: '5.4'
|
172
|
-
- - '='
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: 5.4.1
|
175
|
-
type: :runtime
|
176
|
-
prerelease: false
|
177
|
-
version_requirements: !ruby/object:Gem::Requirement
|
178
|
-
requirements:
|
179
|
-
- - "~>"
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: '5.4'
|
182
|
-
- - '='
|
183
|
-
- !ruby/object:Gem::Version
|
184
|
-
version: 5.4.1
|
185
137
|
- !ruby/object:Gem::Dependency
|
186
138
|
name: net-ssh
|
187
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -269,6 +221,15 @@ files:
|
|
269
221
|
- Rakefile
|
270
222
|
- bin/larrow
|
271
223
|
- larrow-runner.gemspec
|
224
|
+
- lib/active_support/core_ext/hash.rb
|
225
|
+
- lib/active_support/core_ext/hash/compact.rb
|
226
|
+
- lib/active_support/core_ext/hash/deep_merge.rb
|
227
|
+
- lib/active_support/core_ext/hash/except.rb
|
228
|
+
- lib/active_support/core_ext/hash/indifferent_access.rb
|
229
|
+
- lib/active_support/core_ext/hash/keys.rb
|
230
|
+
- lib/active_support/core_ext/hash/reverse_merge.rb
|
231
|
+
- lib/active_support/core_ext/hash/slice.rb
|
232
|
+
- lib/active_support/hash_with_indifferent_access.rb
|
272
233
|
- lib/larrow/runner.rb
|
273
234
|
- lib/larrow/runner/cli.rb
|
274
235
|
- lib/larrow/runner/cli/build.rb
|