tprov 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebc7196b5e44ee5beddea6ff802e08108e8becd1
4
- data.tar.gz: 9a882f706a0f503321e0596ab250e2e86e7609cc
3
+ metadata.gz: f38ee7a2be8de3c14bddbeca562e53ac979fcd2e
4
+ data.tar.gz: c016cbdd4a55cea01c7dda262d64bf736fbb3d1d
5
5
  SHA512:
6
- metadata.gz: c4221995fea6a03a199b21c6d4b5c87414ddcb1b0cf8d7cd551072e27b13de4de9ca37e44a4ad5b08338b91ca99a955bce906efc9628efa6870cd284e379916b
7
- data.tar.gz: ef59e1f02f7ae6477a1c0231010303fdb1e6414ef0942c0b032cc29ea51f8a5979f53011117431fbe642078a21717ba351cfab1ff3753b20757c2707d95a7883
6
+ metadata.gz: a8fa04951580d185992e15f19f6eead373cd3b537244833c00bbcb562ed2430aceabf5f917cc4ad81e6d89498ec0da97e7a70c54fe8050534dab23b10fede11e
7
+ data.tar.gz: be5f205e0df05d3d4378afa4afef6ef1dfcce3074e49852462a77b6d7cca83ede1a2f20fc17bc0fa398e023255d6a022ca2baef89acaa9269d6417bdd5b2fa91
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ gem "sinatra-static-assets"
4
4
  gem "emk-sinatra-url-for"
5
5
  gem "sinatra-flash"
6
6
  gem "sinatra-redirect-with-flash"
7
- gem "docker-api", :require => "docker"
7
+ #gem "docker-api", :require => "docker"
8
8
  gem "redis"
@@ -1,15 +1,8 @@
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
9
4
  emk-sinatra-url-for (0.2.1)
10
5
  sinatra (>= 0.9.1.1)
11
- excon (0.31.0)
12
- json (1.8.1)
13
6
  rack (1.5.2)
14
7
  rack-protection (1.5.0)
15
8
  rack
@@ -30,7 +23,6 @@ PLATFORMS
30
23
  ruby
31
24
 
32
25
  DEPENDENCIES
33
- docker-api
34
26
  emk-sinatra-url-for
35
27
  redis
36
28
  sinatra
data/bin/tprov CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
4
 
5
- require 'rubygems'
6
- require 'optparse'
7
- require 'tprov'
8
- require 'version'
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.
13
15
  opts.banner = "Usage: TProv [options] ..."
14
16
 
15
17
  opts.separator ''
@@ -1,14 +1,12 @@
1
1
  $: << File.dirname(__FILE__)
2
2
 
3
- require 'sinatra/base'
3
+ require 'sinatra'
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
9
  require 'uri'
10
- require 'docker'
11
- require 'pp'
12
10
 
13
11
  module TProv
14
12
  class Application < Sinatra::Base
@@ -21,11 +19,6 @@ module TProv
21
19
  set :views, File.join(File.dirname(__FILE__), 'views')
22
20
  set :bind, '0.0.0.0'
23
21
 
24
- Docker.url = ENV['DOCKER_URL'] || 'https://localhost:2375'
25
- Docker.options = {
26
- :ssl_verify_peer => false
27
- }
28
-
29
22
  enable :sessions, :logging, :dump_errors, :raise_errors, :show_exceptions
30
23
 
31
24
  before do
@@ -66,31 +59,28 @@ module TProv
66
59
 
67
60
  helpers do
68
61
  def get_war(name, url)
69
- container = Docker::Container.create('Cmd' => url, 'Image' => 'jamtur01/fetcher', 'name' => name)
70
- container.start
71
- container.id
62
+ cid = `docker run --name "#{name}" jamtur01/fetcher "#{url}" 2>&1`.chop
63
+ puts cid
64
+ [$?.exitstatus == 0, cid]
72
65
  end
73
66
 
74
67
  def create_instance(name)
75
- container = Docker::Container.create('Image' => 'jamtur01/tomcat7')
76
- container.start('PublishAllPorts' => true, 'VolumesFrom' => name)
77
- container.id
68
+ cid = `docker run -P --volumes-from "#{name}" -d -t jamtur01/tomcat7 2>&1`.chop
69
+ [$?.exitstatus == 0, cid]
78
70
  end
79
71
 
80
72
  def delete_instance(cid)
81
- container = Docker::Container.get(cid)
82
- container.kill
73
+ kill = `docker kill #{cid} 2>&1`
74
+ [$?.exitstatus == 0, kill]
83
75
  end
84
76
 
85
77
  def list_instances
86
78
  @list = {}
87
- instance_ids = Docker::Container.all
79
+ instance_ids = `docker ps -q`.split(/\n/).reject(&:empty?)
88
80
  instance_ids.each { |id|
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
81
+ port = `docker port #{id} 8080`.chop
82
+ config = JSON.parse(`docker inspect #{id}`)
83
+ @list[id] = { 'hostname' => config[0]["Config"]["Hostname"], 'ip' => config[0]["NetworkSettings"]["IPAddress"], 'port' => port }
94
84
  }
95
85
  @list
96
86
  end
@@ -1,3 +1,3 @@
1
1
  module TProv
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://www.dockerbook.com"
11
11
  s.summary = %q{A simple app to provision Tomcat apps with Docker}
12
12
  s.description = %q{A simple app to provision Tomcat apps with Docker written for The Docker Book - http://www.dockerbook.com}
13
+ s.license = "MIT"
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -24,5 +25,4 @@ Gem::Specification.new do |s|
24
25
  s.add_dependency "sinatra-static-assets"
25
26
  s.add_dependency "emk-sinatra-url-for"
26
27
  s.add_dependency "sinatra-redirect-with-flash"
27
- s.add_dependency "docker-api"
28
28
  end
metadata CHANGED
@@ -1,139 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tprov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Turnbull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: haml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sass
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sinatra-flash
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sinatra-static-assets
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: emk-sinatra-url-for
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sinatra-redirect-with-flash
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
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
- - - '>='
122
+ - - ">="
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  description: A simple app to provision Tomcat apps with Docker written for The Docker
@@ -145,7 +131,7 @@ executables:
145
131
  extensions: []
146
132
  extra_rdoc_files: []
147
133
  files:
148
- - .gitignore
134
+ - ".gitignore"
149
135
  - Gemfile
150
136
  - Gemfile.lock
151
137
  - LICENSE
@@ -173,7 +159,8 @@ files:
173
159
  - spec/tprov_spec.rb
174
160
  - tprov.gemspec
175
161
  homepage: http://www.dockerbook.com
176
- licenses: []
162
+ licenses:
163
+ - MIT
177
164
  metadata: {}
178
165
  post_install_message:
179
166
  rdoc_options: []
@@ -181,17 +168,17 @@ require_paths:
181
168
  - lib
182
169
  required_ruby_version: !ruby/object:Gem::Requirement
183
170
  requirements:
184
- - - '>='
171
+ - - ">="
185
172
  - !ruby/object:Gem::Version
186
173
  version: '0'
187
174
  required_rubygems_version: !ruby/object:Gem::Requirement
188
175
  requirements:
189
- - - '>='
176
+ - - ">="
190
177
  - !ruby/object:Gem::Version
191
178
  version: '0'
192
179
  requirements: []
193
180
  rubyforge_project:
194
- rubygems_version: 2.0.14
181
+ rubygems_version: 2.4.5
195
182
  signing_key:
196
183
  specification_version: 4
197
184
  summary: A simple app to provision Tomcat apps with Docker