tprov 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -0
- data/bin/tprov +4 -6
- data/lib/tprov/app.rb +39 -13
- data/lib/version.rb +1 -1
- data/tprov.gemspec +1 -0
- metadata +38 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebc7196b5e44ee5beddea6ff802e08108e8becd1
|
4
|
+
data.tar.gz: 9a882f706a0f503321e0596ab250e2e86e7609cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c4221995fea6a03a199b21c6d4b5c87414ddcb1b0cf8d7cd551072e27b13de4de9ca37e44a4ad5b08338b91ca99a955bce906efc9628efa6870cd284e379916b
|
7
|
+
data.tar.gz: ef59e1f02f7ae6477a1c0231010303fdb1e6414ef0942c0b032cc29ea51f8a5979f53011117431fbe642078a21717ba351cfab1ff3753b20757c2707d95a7883
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
archive-tar-minitar (0.5.2)
|
5
|
+
docker-api (1.5.4)
|
6
|
+
archive-tar-minitar
|
7
|
+
excon (>= 0.22.0)
|
8
|
+
json
|
4
9
|
emk-sinatra-url-for (0.2.1)
|
5
10
|
sinatra (>= 0.9.1.1)
|
11
|
+
excon (0.31.0)
|
12
|
+
json (1.8.1)
|
6
13
|
rack (1.5.2)
|
7
14
|
rack-protection (1.5.0)
|
8
15
|
rack
|
@@ -23,6 +30,7 @@ PLATFORMS
|
|
23
30
|
ruby
|
24
31
|
|
25
32
|
DEPENDENCIES
|
33
|
+
docker-api
|
26
34
|
emk-sinatra-url-for
|
27
35
|
redis
|
28
36
|
sinatra
|
data/bin/tprov
CHANGED
@@ -2,16 +2,14 @@
|
|
2
2
|
|
3
3
|
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
5
|
+
require 'rubygems'
|
6
|
+
require 'optparse'
|
7
|
+
require 'tprov'
|
8
|
+
require 'version'
|
9
9
|
|
10
10
|
options = {}
|
11
11
|
|
12
12
|
optparse = OptionParser.new do |opts|
|
13
|
-
# Set a banner, displayed at the top
|
14
|
-
# of the help screen.
|
15
13
|
opts.banner = "Usage: TProv [options] ..."
|
16
14
|
|
17
15
|
opts.separator ''
|
data/lib/tprov/app.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
$: << File.dirname(__FILE__)
|
2
2
|
|
3
|
-
require 'sinatra'
|
3
|
+
require 'sinatra/base'
|
4
4
|
require 'sinatra/url_for'
|
5
5
|
require 'sinatra/static_assets'
|
6
6
|
require 'sinatra/flash'
|
7
7
|
require 'sinatra/redirect_with_flash'
|
8
8
|
require 'json'
|
9
|
+
require 'uri'
|
10
|
+
require 'docker'
|
11
|
+
require 'pp'
|
9
12
|
|
10
13
|
module TProv
|
11
14
|
class Application < Sinatra::Base
|
@@ -18,6 +21,11 @@ module TProv
|
|
18
21
|
set :views, File.join(File.dirname(__FILE__), 'views')
|
19
22
|
set :bind, '0.0.0.0'
|
20
23
|
|
24
|
+
Docker.url = ENV['DOCKER_URL'] || 'https://localhost:2375'
|
25
|
+
Docker.options = {
|
26
|
+
:ssl_verify_peer => false
|
27
|
+
}
|
28
|
+
|
21
29
|
enable :sessions, :logging, :dump_errors, :raise_errors, :show_exceptions
|
22
30
|
|
23
31
|
before do
|
@@ -29,12 +37,25 @@ module TProv
|
|
29
37
|
end
|
30
38
|
|
31
39
|
post '/tomcat/create' do
|
32
|
-
|
33
|
-
|
40
|
+
if params[:name].empty? or params[:url].empty?
|
41
|
+
redirect '/', :error => "You must specify a name and a URL."
|
42
|
+
end
|
43
|
+
success, output = get_war(params[:name], params[:url])
|
44
|
+
unless success
|
45
|
+
redirect '/', :error => "Tomcat application #{params[:name]} failed to be fetched because #{output}."
|
46
|
+
end
|
47
|
+
success, output = create_instance(params[:name])
|
48
|
+
unless success
|
49
|
+
redirect '/', :error => "Tomcat application #{params[:name]} failed to be created because #{output}."
|
50
|
+
end
|
51
|
+
redirect '/', :success => "Tomcat Application #{params[:name]} created!"
|
34
52
|
end
|
35
53
|
|
36
54
|
post '/tomcat/delete' do
|
37
|
-
delete_instance(params[:id])
|
55
|
+
success, output = delete_instance(params[:id])
|
56
|
+
unless success
|
57
|
+
redirect '/', :error => "Tomcat application #{params[:name]} failed to be deleted because #{output}."
|
58
|
+
end
|
38
59
|
redirect '/', :success => "Instance #{params[:id]} deleted!"
|
39
60
|
end
|
40
61
|
|
@@ -45,26 +66,31 @@ module TProv
|
|
45
66
|
|
46
67
|
helpers do
|
47
68
|
def get_war(name, url)
|
48
|
-
|
49
|
-
|
69
|
+
container = Docker::Container.create('Cmd' => url, 'Image' => 'jamtur01/fetcher', 'name' => name)
|
70
|
+
container.start
|
71
|
+
container.id
|
50
72
|
end
|
51
73
|
|
52
74
|
def create_instance(name)
|
53
|
-
|
54
|
-
|
75
|
+
container = Docker::Container.create('Image' => 'jamtur01/tomcat7')
|
76
|
+
container.start('PublishAllPorts' => true, 'VolumesFrom' => name)
|
77
|
+
container.id
|
55
78
|
end
|
56
79
|
|
57
80
|
def delete_instance(cid)
|
58
|
-
|
81
|
+
container = Docker::Container.get(cid)
|
82
|
+
container.kill
|
59
83
|
end
|
60
84
|
|
61
85
|
def list_instances
|
62
86
|
@list = {}
|
63
|
-
instance_ids =
|
87
|
+
instance_ids = Docker::Container.all
|
64
88
|
instance_ids.each { |id|
|
65
|
-
|
66
|
-
config =
|
67
|
-
|
89
|
+
container = Docker::Container.get(id.id)
|
90
|
+
config = container.json
|
91
|
+
if config['NetworkSettings']['Ports']['8080/tcp']
|
92
|
+
@list[id] = { 'hostname' => config['Config']['Hostname'], 'ip' => config['NetworkSettings']['IPAddress'], 'port' => config['NetworkSettings']['Ports']['8080/tcp'][0]['HostPort'] }
|
93
|
+
end
|
68
94
|
}
|
69
95
|
@list
|
70
96
|
end
|
data/lib/version.rb
CHANGED
data/tprov.gemspec
CHANGED
metadata
CHANGED
@@ -1,142 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tprov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- James Turnbull
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: sinatra
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: haml
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: sass
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: json
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: sinatra-flash
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: sinatra-static-assets
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: emk-sinatra-url-for
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: sinatra-redirect-with-flash
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :runtime
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: docker-api
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
140
137
|
- !ruby/object:Gem::Version
|
141
138
|
version: '0'
|
142
139
|
description: A simple app to provision Tomcat apps with Docker written for The Docker
|
@@ -177,28 +174,28 @@ files:
|
|
177
174
|
- tprov.gemspec
|
178
175
|
homepage: http://www.dockerbook.com
|
179
176
|
licenses: []
|
177
|
+
metadata: {}
|
180
178
|
post_install_message:
|
181
179
|
rdoc_options: []
|
182
180
|
require_paths:
|
183
181
|
- lib
|
184
182
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
183
|
requirements:
|
187
|
-
- -
|
184
|
+
- - '>='
|
188
185
|
- !ruby/object:Gem::Version
|
189
186
|
version: '0'
|
190
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
-
none: false
|
192
188
|
requirements:
|
193
|
-
- -
|
189
|
+
- - '>='
|
194
190
|
- !ruby/object:Gem::Version
|
195
191
|
version: '0'
|
196
192
|
requirements: []
|
197
193
|
rubyforge_project:
|
198
|
-
rubygems_version:
|
194
|
+
rubygems_version: 2.0.14
|
199
195
|
signing_key:
|
200
|
-
specification_version:
|
196
|
+
specification_version: 4
|
201
197
|
summary: A simple app to provision Tomcat apps with Docker
|
202
198
|
test_files:
|
203
199
|
- spec/spec_helper.rb
|
204
200
|
- spec/tprov_spec.rb
|
201
|
+
has_rdoc:
|