foreman_docker 1.2.2 → 1.2.3

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: 04dedd7aef67d8c8ef5299bd13fba4bd06477b48
4
- data.tar.gz: 3f6d66e39d798470d169d00a4455b7701b44c92f
3
+ metadata.gz: 312b5ebf35209421ab37d4f6ce21b42f5c8a4f4c
4
+ data.tar.gz: a62f11d57a4d7eaadade21338983bf135883b7e8
5
5
  SHA512:
6
- metadata.gz: 2375f44e73e5a5bfc0a7e0cc213295fb6be2e831a8759deb73a846f5ebe565880ce6519d83d2827c4b758deadd1413977bb25d22a6a1b612bcf7d5a66b5f7698
7
- data.tar.gz: f5626d2ad14734c0337b304c5b85555e88d7116a9883127f570e49c98c5a54b0aa887153afad9237f984da1fe09852a8086f0cb9d21c4288aa1a7d3b951e5a81
6
+ metadata.gz: 5bbd89c9d4efe80997326ebc6fb46487144e443628de9dfeca2ee8e319bbd0cadee4c79ac9bf75d97eda83ccebb3f3457bc1301955610d11e4573d198581e438
7
+ data.tar.gz: 9a93d2c256eec38df60fa1d4d3c83c94f99641cef7f3960978f6c2da2ab4edc215c7ab3aa0098a4b7358cfd958d29e8ce02c1f80750e6fa81353d5b153d21df5
@@ -16,13 +16,13 @@ class ContainersController < ::ApplicationController
16
16
 
17
17
  def new
18
18
  redirect_to wizard_state_step_path(:wizard_state_id => DockerContainerWizardState.create.id,
19
- :id => :preliminary)
19
+ :id => :preliminary)
20
20
  end
21
21
 
22
22
  def destroy
23
23
  if container_deletion
24
24
  process_success(:success_redirect => containers_path,
25
- :success_msg => (_("Container %s is being deleted.") %
25
+ :success_msg => (_("Container %s is being deleted.") %
26
26
  @deleted_identifier))
27
27
  else
28
28
  process_error(:redirect => containers_path)
@@ -35,10 +35,10 @@ class ContainersController < ::ApplicationController
35
35
  end
36
36
 
37
37
  def commit
38
- Docker::Container.get(@container.uuid).commit(:author => params[:commit][:author],
39
- :repo => params[:commit][:repo],
40
- :tag => params[:commit][:tag],
41
- :comment => params[:commit][:comment])
38
+ ForemanDocker::Docker.get_container(@container).commit(:author => params[:commit][:author],
39
+ :repo => params[:commit][:repo],
40
+ :tag => params[:commit][:tag],
41
+ :comment => params[:commit][:comment])
42
42
 
43
43
  process_success :success_redirect => :back,
44
44
  :success_msg => _("%{container} commit was successful") %
@@ -15,9 +15,7 @@ module ContainersHelper
15
15
  end
16
16
 
17
17
  def link_to_taxonomies(taxonomies)
18
- taxonomies.map do |taxonomy|
19
- link_to(taxonomy)
20
- end.join(' ')
18
+ taxonomies.map { |taxonomy| link_to(taxonomy) }.join(" ")
21
19
  end
22
20
 
23
21
  def container_link_hash(container, resource)
@@ -93,4 +91,12 @@ module ContainersHelper
93
91
  trunc(text, length)
94
92
  end
95
93
  end
94
+
95
+ def processes(container)
96
+ ForemanDocker::Docker.get_container(container).top
97
+ end
98
+
99
+ def logs(container, opts = {})
100
+ ForemanDocker::Docker.get_container(container).logs(opts)
101
+ end
96
102
  end
@@ -9,6 +9,13 @@ module FogExtensions
9
9
  downcase_hash_keys(image)
10
10
  end
11
11
  end
12
+
13
+ def downcase_hash_keys(hash, k = [])
14
+ if hash.is_a?(Hash)
15
+ return hash.reduce({}) { |a, e| a.merge! downcase_hash_keys(e[-1], k + [e[0]]) }
16
+ end
17
+ { k.join('_').gsub(/([a-z])([A-Z])/, '\1_\2').downcase => hash }
18
+ end
12
19
  end
13
20
  end
14
21
  end
@@ -8,6 +8,11 @@ module ForemanDocker
8
8
  ComputeResource.model_name
9
9
  end
10
10
 
11
+ def self.get_container(container)
12
+ conn = container.compute_resource.docker_connection
13
+ ::Docker::Container.get(container.uuid, {}, conn)
14
+ end
15
+
11
16
  def capabilities
12
17
  [:image]
13
18
  end
@@ -29,12 +34,11 @@ module ForemanDocker
29
34
  end
30
35
 
31
36
  def available_images
32
- client.images.all
37
+ ::Docker::Image.all({}, docker_connection)
33
38
  end
34
39
 
35
40
  def local_images(filter = '')
36
- client # initialize Docker-Api
37
- ::Docker::Image.all('filter' => filter)
41
+ ::Docker::Image.all({ 'filter' => filter }, docker_connection)
38
42
  end
39
43
 
40
44
  def tags_for_local_image(image)
@@ -45,11 +49,11 @@ module ForemanDocker
45
49
  end
46
50
 
47
51
  def exist?(name)
48
- ::Docker::Image.exist?(name)
52
+ ::Docker::Image.exist?(name, {}, docker_connection)
49
53
  end
50
54
 
51
55
  def image(id)
52
- client.image_get(id)
56
+ ::Docker::Image.get(id, {}, docker_connection)
53
57
  end
54
58
 
55
59
  def tags(image_name)
@@ -76,14 +80,14 @@ module ForemanDocker
76
80
  options = vm_instance_defaults.merge(args)
77
81
  logger.debug("Creating container with the following options: #{options.inspect}")
78
82
  docker_command do
79
- ::Docker::Container.create(options)
83
+ ::Docker::Container.create(options, docker_connection)
80
84
  end
81
85
  end
82
86
 
83
87
  def create_image(args = {})
84
88
  logger.debug("Creating docker image with the following options: #{args.inspect}")
85
89
  docker_command do
86
- ::Docker::Image.create(args)
90
+ ::Docker::Image.create(args, credentials, docker_connection)
87
91
  end
88
92
  end
89
93
 
@@ -94,7 +98,7 @@ module ForemanDocker
94
98
 
95
99
  def console(uuid)
96
100
  test_connection
97
- container = ::Docker::Container.get(uuid)
101
+ container = ::Docker::Container.get(uuid, {}, docker_connection)
98
102
  {
99
103
  :name => container.info['Name'],
100
104
  'timestamp' => Time.now.utc,
@@ -102,15 +106,28 @@ module ForemanDocker
102
106
  }
103
107
  end
104
108
 
109
+ def api_version
110
+ ::Docker.version(docker_connection)
111
+ end
112
+
113
+ def authenticate!
114
+ ::Docker.authenticate!(credentials, docker_connection)
115
+ end
116
+
105
117
  def test_connection(options = {})
106
118
  super
107
- client.present?
119
+ api_version
120
+ credentials.empty? ? true : authenticate!
108
121
  # This should only rescue Fog::Errors, but Fog returns all kinds of errors...
109
122
  rescue => e
110
123
  errors[:base] << e.message
111
124
  false
112
125
  end
113
126
 
127
+ def docker_connection
128
+ @docker_connection ||= ::Docker::Connection.new(url, credentials)
129
+ end
130
+
114
131
  protected
115
132
 
116
133
  def docker_command
@@ -141,8 +158,12 @@ module ForemanDocker
141
158
  @client ||= ::Fog::Compute.new(opts)
142
159
  end
143
160
 
144
- def api_version
145
- @api_version ||= client.send(:client).api_version
161
+ def credentials
162
+ @credentials ||= {}.tap do |options|
163
+ options[:username] = user if user.present?
164
+ options[:password] = password if password.present?
165
+ options[:email] = email if email.present?
166
+ end
146
167
  end
147
168
  end
148
169
  end
@@ -87,9 +87,8 @@
87
87
  </ul>
88
88
  <div id="myTabContent" class="tab-content">
89
89
  <div class="tab-pane active in" id="processes">
90
- <% processes = Docker::Container.get(@container.uuid).top %>
91
90
  <div class='accordion' id='accordion'>
92
- <% processes.each do |process| %>
91
+ <% processes(@container).each do |process| %>
93
92
  <div>
94
93
  <h2>
95
94
  <a href='#<%= process['PID'] %>-index'
@@ -108,7 +107,9 @@
108
107
  </div>
109
108
  </div>
110
109
  <div class="tab-pane" id="logs">
111
- <pre class="terminal terminal-output pre-scrollable"><code><%= Docker::Container.get(@container.uuid).logs(:stdout => true, :tail => 100) %></code></pre>
110
+ <pre class="terminal terminal-output pre-scrollable"><code>
111
+ <%= logs(@container, :stdout => true, :tail => 100) %>
112
+ </code></pre>
112
113
  </div>
113
114
  </div>
114
115
  <% else %>
@@ -1,3 +1,3 @@
1
1
  module ForemanDocker
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end
@@ -31,7 +31,8 @@ class ContainersControllerTest < ActionController::TestCase
31
31
  commit_hash = { :author => 'a', :repo => 'b', :tag => 'c', :comment => 'd' }
32
32
 
33
33
  mock_container = mock
34
- ::Docker::Container.expects(:get).with(container.uuid).returns(mock_container)
34
+ ::Docker::Container.expects(:get).with(container.uuid, anything, anything)
35
+ .returns(mock_container)
35
36
  mock_container.expects(:commit).with(commit_hash)
36
37
 
37
38
  post :commit, { :commit => commit_hash,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato, Amos Benari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -45,100 +45,100 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - app/views/compute_resources/form/_docker.html.erb
49
- - app/views/compute_resources/show/_docker.html.erb
50
- - app/views/image_search/_repository_search_results.html.erb
48
+ - LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - app/assets/javascripts/foreman_docker/image_step.js
52
+ - app/assets/stylesheets/foreman_docker/autocomplete.css.scss
53
+ - app/assets/stylesheets/foreman_docker/terminal.css.scss
54
+ - app/controllers/api/v2/containers_controller.rb
55
+ - app/controllers/concerns/foreman_docker/find_container.rb
56
+ - app/controllers/containers/steps_controller.rb
57
+ - app/controllers/containers_controller.rb
58
+ - app/controllers/image_search_controller.rb
59
+ - app/controllers/registries_controller.rb
60
+ - app/helpers/container_steps_helper.rb
61
+ - app/helpers/containers_helper.rb
62
+ - app/models/concerns/fog_extensions/fogdocker/image.rb
63
+ - app/models/concerns/fog_extensions/fogdocker/images.rb
64
+ - app/models/concerns/fog_extensions/fogdocker/server.rb
65
+ - app/models/concerns/foreman_docker/parameter_validators.rb
66
+ - app/models/container.rb
67
+ - app/models/docker_container_wizard_state.rb
68
+ - app/models/docker_container_wizard_states/configuration.rb
69
+ - app/models/docker_container_wizard_states/environment.rb
70
+ - app/models/docker_container_wizard_states/environment_variable.rb
71
+ - app/models/docker_container_wizard_states/image.rb
72
+ - app/models/docker_container_wizard_states/preliminary.rb
73
+ - app/models/docker_registry.rb
74
+ - app/models/environment_variable.rb
75
+ - app/models/foreman_docker/docker.rb
76
+ - app/models/foreman_docker/taxonomy_extensions.rb
77
+ - app/models/service/containers.rb
78
+ - app/models/service/registry_api.rb
79
+ - app/views/api/v1/compute_resources/docker.json
51
80
  - app/views/api/v2/compute_resources/docker.json
52
- - app/views/api/v2/containers/main.json.rabl
53
81
  - app/views/api/v2/containers/base.json.rabl
54
82
  - app/views/api/v2/containers/index.json.rabl
83
+ - app/views/api/v2/containers/main.json.rabl
55
84
  - app/views/api/v2/containers/show.json.rabl
56
- - app/views/api/v1/compute_resources/docker.json
57
- - app/views/containers/steps/environment.html.erb
58
- - app/views/containers/steps/_title.html.erb
85
+ - app/views/compute_resources/form/_docker.html.erb
86
+ - app/views/compute_resources/show/_docker.html.erb
87
+ - app/views/compute_resources_vms/form/_docker.html.erb
88
+ - app/views/compute_resources_vms/index/_docker.html.erb
89
+ - app/views/compute_resources_vms/show/_docker.html.erb
90
+ - app/views/containers/_list.html.erb
91
+ - app/views/containers/index.html.erb
92
+ - app/views/containers/show.html.erb
59
93
  - app/views/containers/steps/_form_buttons.html.erb
60
- - app/views/containers/steps/image.html.erb
61
- - app/views/containers/steps/preliminary.html.erb
62
94
  - app/views/containers/steps/_image_hub_tab.html.erb
95
+ - app/views/containers/steps/_title.html.erb
63
96
  - app/views/containers/steps/configuration.html.erb
64
- - app/views/containers/_list.html.erb
65
- - app/views/containers/show.html.erb
66
- - app/views/containers/index.html.erb
67
- - app/views/registries/edit.html.erb
68
- - app/views/registries/new.html.erb
69
- - app/views/registries/_form.html.erb
70
- - app/views/registries/index.html.erb
97
+ - app/views/containers/steps/environment.html.erb
98
+ - app/views/containers/steps/image.html.erb
99
+ - app/views/containers/steps/preliminary.html.erb
71
100
  - app/views/foreman_docker/common_parameters/_environment_variable.html.erb
101
+ - app/views/image_search/_repository_search_results.html.erb
72
102
  - app/views/images/form/_docker.html.erb
73
- - app/views/compute_resources_vms/form/_docker.html.erb
74
- - app/views/compute_resources_vms/index/_docker.html.erb
75
- - app/views/compute_resources_vms/show/_docker.html.erb
76
- - app/models/docker_registry.rb
77
- - app/models/service/registry_api.rb
78
- - app/models/service/containers.rb
79
- - app/models/concerns/fog_extensions/fogdocker/image.rb
80
- - app/models/concerns/fog_extensions/fogdocker/images.rb
81
- - app/models/concerns/fog_extensions/fogdocker/server.rb
82
- - app/models/concerns/foreman_docker/parameter_validators.rb
83
- - app/models/docker_container_wizard_state.rb
84
- - app/models/container.rb
85
- - app/models/environment_variable.rb
86
- - app/models/foreman_docker/taxonomy_extensions.rb
87
- - app/models/foreman_docker/docker.rb
88
- - app/models/docker_container_wizard_states/environment.rb
89
- - app/models/docker_container_wizard_states/image.rb
90
- - app/models/docker_container_wizard_states/configuration.rb
91
- - app/models/docker_container_wizard_states/environment_variable.rb
92
- - app/models/docker_container_wizard_states/preliminary.rb
93
- - app/controllers/api/v2/containers_controller.rb
94
- - app/controllers/containers/steps_controller.rb
95
- - app/controllers/concerns/foreman_docker/find_container.rb
96
- - app/controllers/registries_controller.rb
97
- - app/controllers/image_search_controller.rb
98
- - app/controllers/containers_controller.rb
99
- - app/helpers/containers_helper.rb
100
- - app/helpers/container_steps_helper.rb
101
- - app/assets/javascripts/foreman_docker/image_step.js
102
- - app/assets/stylesheets/foreman_docker/terminal.css.scss
103
- - app/assets/stylesheets/foreman_docker/autocomplete.css.scss
103
+ - app/views/registries/_form.html.erb
104
+ - app/views/registries/edit.html.erb
105
+ - app/views/registries/index.html.erb
106
+ - app/views/registries/new.html.erb
104
107
  - config/routes.rb
105
- - db/migrate/20141018110810_add_uuid_to_containers.rb
106
- - db/migrate/20141028164206_change_memory_in_container.rb
108
+ - db/migrate/20140930175337_add_email_to_compute_resource.rb
107
109
  - db/migrate/20141005233312_create_containers.rb
108
- - db/migrate/20141028164633_change_cpuset_in_container.rb
109
- - db/migrate/20141009011026_add_attributes_to_container.rb
110
- - db/migrate/20141222113313_create_wizard_states.rb
111
- - db/migrate/20150129054944_add_katello_flag_to_containers.rb
112
110
  - db/migrate/20141007225130_add_compute_resource_id_to_container.rb
113
111
  - db/migrate/20141009001613_add_tag_to_container.rb
114
- - db/migrate/20141120123003_add_user_credentials_to_docker_registries.rb
115
- - db/migrate/20140930175337_add_email_to_compute_resource.rb
112
+ - db/migrate/20141009011026_add_attributes_to_container.rb
116
113
  - db/migrate/20141010173220_create_docker_images.rb
117
- - db/migrate/20150122011747_add_katello_flag_to_docker_wizard_image.rb
114
+ - db/migrate/20141018110810_add_uuid_to_containers.rb
118
115
  - db/migrate/20141024163003_create_docker_registries.rb
116
+ - db/migrate/20141028164206_change_memory_in_container.rb
117
+ - db/migrate/20141028164633_change_cpuset_in_container.rb
118
+ - db/migrate/20141120123003_add_user_credentials_to_docker_registries.rb
119
119
  - db/migrate/20141209182008_remove_docker_tables.rb
120
+ - db/migrate/20141222113313_create_wizard_states.rb
121
+ - db/migrate/20150122011747_add_katello_flag_to_docker_wizard_image.rb
122
+ - db/migrate/20150129054944_add_katello_flag_to_containers.rb
123
+ - lib/foreman_docker.rb
124
+ - lib/foreman_docker/engine.rb
120
125
  - lib/foreman_docker/tasks/test.rake
121
126
  - lib/foreman_docker/version.rb
122
- - lib/foreman_docker/engine.rb
123
- - lib/foreman_docker.rb
124
127
  - locale/Makefile
125
- - LICENSE
126
- - Rakefile
127
- - README.md
128
+ - test/factories/compute_resources.rb
129
+ - test/factories/containers.rb
130
+ - test/factories/docker_registry.rb
128
131
  - test/functionals/api/v2/containers_controller_test.rb
132
+ - test/functionals/containers_controller_test.rb
129
133
  - test/functionals/containers_steps_controller_test.rb
130
134
  - test/functionals/image_search_controller_test.rb
131
- - test/functionals/container_controller_test.rb
132
- - test/factories/docker_registry.rb
133
- - test/factories/compute_resources.rb
134
- - test/factories/containers.rb
135
+ - test/integration/container_steps_test.rb
136
+ - test/integration/container_test.rb
137
+ - test/test_plugin_helper.rb
135
138
  - test/units/container_test.rb
139
+ - test/units/containers_service_test.rb
136
140
  - test/units/docker_registry_test.rb
137
141
  - test/units/registry_api_test.rb
138
- - test/units/containers_service_test.rb
139
- - test/test_plugin_helper.rb
140
- - test/integration/container_steps_test.rb
141
- - test/integration/container_test.rb
142
142
  homepage: http://github.com/theforeman/foreman-docker
143
143
  licenses:
144
144
  - GPL-3
@@ -159,22 +159,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.0.14
162
+ rubygems_version: 2.4.3
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Provision and manage Docker containers and images from Foreman
166
166
  test_files:
167
+ - test/factories/compute_resources.rb
168
+ - test/factories/containers.rb
169
+ - test/factories/docker_registry.rb
170
+ - test/test_plugin_helper.rb
167
171
  - test/functionals/api/v2/containers_controller_test.rb
172
+ - test/functionals/containers_controller_test.rb
168
173
  - test/functionals/containers_steps_controller_test.rb
169
174
  - test/functionals/image_search_controller_test.rb
170
- - test/functionals/container_controller_test.rb
171
- - test/factories/docker_registry.rb
172
- - test/factories/compute_resources.rb
173
- - test/factories/containers.rb
175
+ - test/integration/container_steps_test.rb
176
+ - test/integration/container_test.rb
174
177
  - test/units/container_test.rb
178
+ - test/units/containers_service_test.rb
175
179
  - test/units/docker_registry_test.rb
176
180
  - test/units/registry_api_test.rb
177
- - test/units/containers_service_test.rb
178
- - test/test_plugin_helper.rb
179
- - test/integration/container_steps_test.rb
180
- - test/integration/container_test.rb
181
+ has_rdoc: