foreman_docker 1.0.0 → 1.0.1

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_docker/image_step.js +4 -4
  3. data/app/controllers/concerns/foreman_docker/find_container.rb +1 -1
  4. data/app/controllers/containers/steps_controller.rb +18 -8
  5. data/app/controllers/containers_controller.rb +4 -4
  6. data/app/controllers/registries_controller.rb +1 -1
  7. data/app/helpers/container_steps_helper.rb +2 -2
  8. data/app/helpers/containers_helper.rb +8 -1
  9. data/app/models/docker_container_wizard_state.rb +4 -4
  10. data/app/models/docker_container_wizard_states/configuration.rb +3 -0
  11. data/app/models/docker_container_wizard_states/environment.rb +4 -3
  12. data/app/models/docker_container_wizard_states/environment_variable.rb +1 -1
  13. data/app/models/docker_container_wizard_states/preliminary.rb +12 -0
  14. data/app/models/foreman_docker/docker.rb +25 -6
  15. data/app/models/foreman_docker/taxonomy_extensions.rb +14 -0
  16. data/app/models/service/containers.rb +18 -6
  17. data/app/views/containers/_list.html.erb +2 -2
  18. data/app/views/containers/show.html.erb +1 -1
  19. data/app/views/containers/steps/configuration.html.erb +1 -1
  20. data/app/views/containers/steps/environment.html.erb +2 -2
  21. data/app/views/containers/steps/image.html.erb +15 -9
  22. data/app/views/containers/steps/preliminary.html.erb +2 -2
  23. data/app/views/image_search/_repository_search_results.html.erb +1 -1
  24. data/app/views/registries/index.html.erb +3 -3
  25. data/lib/foreman_docker/engine.rb +12 -9
  26. data/lib/foreman_docker/version.rb +1 -1
  27. data/test/functionals/containers_steps_controller_test.rb +2 -1
  28. data/test/units/containers_service_test.rb +7 -3
  29. metadata +3 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4806b85ddbb93562b7c2c718f5daa8bf5a84d48d
4
- data.tar.gz: 531ccfeaf0fadf4c227d89d98e1f53635a3dd7d2
3
+ metadata.gz: 79d46d67b21374126131d7fc7550feb71bbabb2c
4
+ data.tar.gz: 1b8d4d788c2ba1c72ab8aa62641082aff4a7c8e1
5
5
  SHA512:
6
- metadata.gz: 8601bd6d7fab40b502542717f707e4fbe60252140da0483c975e3b31749d3db3261a92176cfbe989a70ca12767d0c3551b3cd7dfd6c330d6163fa6432a51f209
7
- data.tar.gz: 721dc7939ecb7d142471baa127e30b83530b216b8f56738c609bdee784ba7346043f81513e13cd92d1eaed4adb4e973ca703f9ebff9384b5e33c9164e4e312db
6
+ metadata.gz: 813096a864f743b67807f6065aa581d18a6c5182653dcb93c5e0d187378dcf62e91e92c1a377090cd32b76eac5df61faf5d0ffc2efa6f8ceb6840f49cacba30b
7
+ data.tar.gz: 7d1e069cdbc84cc05078274476f19ad69441f454f5d20775e155fb3cdfe4df1cd949f25c8db582bbaa00284e4ac8db01ce5dbf64f1d5e008dae7538c476b00fc
@@ -18,7 +18,7 @@ $(document).ready(function() {
18
18
  });
19
19
 
20
20
  $('#hub_tab').click( function() {
21
- $('#wizard_states_image_registry_id').val('');
21
+ $('#docker_container_wizard_states_image_registry_id').val('');
22
22
  });
23
23
  });
24
24
 
@@ -26,7 +26,7 @@ function autoCompleteRepo(item) {
26
26
  $.ajax({
27
27
  type:'get',
28
28
  url: $(item).attr('data-url'),
29
- data: { search: item.val(), registry_id: $('#wizard_states_image_registry_id').val() },
29
+ data: { search: item.val(), registry_id: $('#docker_container_wizard_states_image_registry_id').val() },
30
30
  //data:'search=' + item.val(),
31
31
  success:function (result) {
32
32
  if(result == 'true'){
@@ -52,7 +52,7 @@ function setAutocompleteTags() {
52
52
  tag.addClass('tags-autocomplete-loading');
53
53
  tag.val('');
54
54
  var source = [];
55
- $.getJSON( tag.data("url"), { search: $('#search').val(), registry_id: $('#wizard_states_image_registry_id').val() },
55
+ $.getJSON( tag.data("url"), { search: $('#search').val(), registry_id: $('#docker_container_wizard_states_image_registry_id').val() },
56
56
  function(data) {
57
57
  $('#searching_spinner').hide();
58
58
  tag.removeClass('tags-autocomplete-loading');
@@ -72,7 +72,7 @@ function searchRepo(item) {
72
72
  type:'get',
73
73
  dataType:'text',
74
74
  url: $(item).attr('data-url'),
75
- data: { search: $('#search').val(), registry_id: $('#wizard_states_image_registry_id').val() },
75
+ data: { search: $('#search').val(), registry_id: $('#docker_container_wizard_states_image_registry_id').val() },
76
76
  success: function (result) {
77
77
  $('#repository_search_results').html(result);
78
78
  },
@@ -9,7 +9,7 @@ module ForemanDocker
9
9
  return
10
10
  end
11
11
  @container = Container.authorized("#{action_permission}_#{controller_name}".to_sym)
12
- .find(params[:id])
12
+ .find(params[:id])
13
13
  end
14
14
 
15
15
  def allowed_resources
@@ -5,8 +5,9 @@ module Containers
5
5
 
6
6
  steps :preliminary, :image, :configuration, :environment
7
7
 
8
- before_filter :build_state
9
- before_filter :set_form
8
+ before_filter :find_state
9
+ before_filter :build_state, :only => [:update]
10
+ before_filter :set_form, :only => [:show]
10
11
 
11
12
  def show
12
13
  @container_resources = allowed_resources if step == :preliminary
@@ -23,25 +24,34 @@ module Containers
23
24
 
24
25
  private
25
26
 
26
- def build_state
27
+ def find_state
27
28
  @state = DockerContainerWizardState.find(params[:wizard_state_id])
28
- @state.send(:"build_#{step}", params[:"docker_container_wizard_states_#{step}"])
29
29
  rescue ActiveRecord::RecordNotFound
30
30
  not_found
31
31
  end
32
32
 
33
+ def build_state
34
+ s = @state.send(:"build_#{step}", params[:"docker_container_wizard_states_#{step}"])
35
+ instance_variable_set("@docker_container_wizard_states_#{step}", s)
36
+ end
37
+
33
38
  def set_form
34
- instance_variable_set("@#{step}", @state.send(:"#{step}") || @state.send(:"build_#{step}"))
39
+ instance_variable_set(
40
+ "@docker_container_wizard_states_#{step}",
41
+ @state.send(:"#{step}") || @state.send(:"build_#{step}"))
35
42
  end
36
43
 
37
44
  def create_container
38
45
  @state.send(:"create_#{step}", params[:"docker_container_wizard_states_#{step}"])
39
- container = Service::Containers.start_container!(@state)
46
+ container = (service = Service::Containers.new).start_container!(@state)
40
47
  if container.present?
41
48
  process_success(:object => container, :success_redirect => container_path(container))
42
49
  else
43
- @environment = @state.environment
44
- process_error(:object => @state.environment, :render => 'environment')
50
+ @docker_container_wizard_states_environment = @state.environment
51
+ process_error(
52
+ :error_msg => service.errors,
53
+ :object => @state.environment,
54
+ :render => 'environment')
45
55
  end
46
56
  end
47
57
  end
@@ -42,10 +42,10 @@ class ContainersController < ::ApplicationController
42
42
 
43
43
  process_success :success_redirect => :back,
44
44
  :success_msg => _("%{container} commit was successful") %
45
- { :container => @container }
45
+ { :container => @container }
46
46
  rescue => e
47
47
  process_error :redirect => :back, :error_msg => _("Failed to commit %{container}: %{e}") %
48
- { :container => @container, :e => e }
48
+ { :container => @container, :e => e }
49
49
  end
50
50
 
51
51
  private
@@ -71,13 +71,13 @@ class ContainersController < ::ApplicationController
71
71
  @deleted_identifier = @container.name
72
72
 
73
73
  destroy_compute_resource_vm(@container.compute_resource, @container.uuid) &&
74
- @container.destroy
74
+ @container.destroy
75
75
  end
76
76
  end
77
77
 
78
78
  def destroy_compute_resource_vm(resource_id, uuid)
79
79
  @container_resource = ComputeResource.authorized(:destroy_compute_resources_vms)
80
- .find(resource_id)
80
+ .find(resource_id)
81
81
  @container_resource.destroy_vm(uuid)
82
82
  rescue => error
83
83
  logger.error "#{error.message} (#{error.class})\n#{error.backtrace.join("\n")}"
@@ -4,7 +4,7 @@ class RegistriesController < ::ApplicationController
4
4
 
5
5
  def index
6
6
  @registries = DockerRegistry.search_for(params[:search], :order => params[:order])
7
- .paginate :page => params[:page]
7
+ .paginate :page => params[:page]
8
8
  end
9
9
 
10
10
  def new
@@ -8,9 +8,9 @@ module ContainerStepsHelper
8
8
 
9
9
  def select_registry(f)
10
10
  registries = DockerRegistry.with_taxonomy_scope_override(@location, @organization)
11
- .authorized(:view_registries)
11
+ .authorized(:view_registries)
12
12
  field(f, 'docker_container_wizard_states_image[registry_id]', :label => _("Registry")) do
13
- collection_select :wizard_states_image, :registry_id,
13
+ collection_select :docker_container_wizard_states_image, :registry_id,
14
14
  registries,
15
15
  :id, :name,
16
16
  { :prompt => _("Select a registry") },
@@ -10,7 +10,7 @@ module ContainersHelper
10
10
  def uuids_in_resource(resource)
11
11
  @uuids_in_resource ||= {}
12
12
  @uuids_in_resource[resource.id] ||= Container.where(:compute_resource_id => resource.id)
13
- .pluck(:uuid)
13
+ .pluck(:uuid)
14
14
  end
15
15
 
16
16
  def link_to_container(container, resource)
@@ -63,4 +63,11 @@ module ContainersHelper
63
63
  "https://registry.hub.docker.com/u/#{image['name']}"
64
64
  end
65
65
  end
66
+
67
+ # Compatibility fixes - to be removed once 1.7 compatibility is no longer required
68
+ if SETTINGS[:version].to_s.to_f <= 1.7
69
+ def trunc_with_tooltip(text, length = 32)
70
+ trunc(text, length)
71
+ end
72
+ end
66
73
  end
@@ -1,12 +1,12 @@
1
1
  class DockerContainerWizardState < ActiveRecord::Base
2
2
  has_one :preliminary, :class_name => DockerContainerWizardStates::Preliminary,
3
- :dependent => :destroy, :validate => true, :autosave => true
3
+ :dependent => :destroy, :validate => true, :autosave => true
4
4
  has_one :image, :class_name => DockerContainerWizardStates::Image,
5
- :dependent => :destroy, :validate => true, :autosave => true
5
+ :dependent => :destroy, :validate => true, :autosave => true
6
6
  has_one :configuration, :class_name => DockerContainerWizardStates::Configuration,
7
- :dependent => :destroy, :validate => true, :autosave => true
7
+ :dependent => :destroy, :validate => true, :autosave => true
8
8
  has_one :environment, :class_name => DockerContainerWizardStates::Environment,
9
- :dependent => :destroy, :validate => true, :autosave => true
9
+ :dependent => :destroy, :validate => true, :autosave => true
10
10
 
11
11
  delegate :compute_resource_id, :to => :preliminary
12
12
  delegate :environment_variables, :to => :environment
@@ -3,5 +3,8 @@ module DockerContainerWizardStates
3
3
  self.table_name_prefix = 'docker_container_wizard_states_'
4
4
  belongs_to :wizard_state, :class_name => DockerContainerWizardState,
5
5
  :foreign_key => :docker_container_wizard_state_id
6
+
7
+ validates :name, :presence => true
8
+ validates :command, :presence => true
6
9
  end
7
10
  end
@@ -7,9 +7,10 @@ module DockerContainerWizardStates
7
7
  # that forces validation of reference_id. This will fail on new records as
8
8
  # validations are executed before parent and children records have been persisted.
9
9
  has_many :environment_variables, :dependent => :destroy, :foreign_key => :reference_id,
10
- :inverse_of => :environment,
11
- :class_name => 'DockerContainerWizardStates::EnvironmentVariable',
12
- :validate => false
10
+ :inverse_of => :environment,
11
+ :class_name =>
12
+ 'DockerContainerWizardStates::EnvironmentVariable',
13
+ :validate => false
13
14
  include ::ParameterValidators
14
15
 
15
16
  accepts_nested_attributes_for :environment_variables, :allow_destroy => true
@@ -1,7 +1,7 @@
1
1
  module DockerContainerWizardStates
2
2
  class EnvironmentVariable < Parameter
3
3
  belongs_to :environment, :foreign_key => :reference_id, :inverse_of => :environment_variables,
4
- :class_name => 'DockerContainerWizardStates::Environment'
4
+ :class_name => 'DockerContainerWizardStates::Environment'
5
5
  validates :name, :uniqueness => { :scope => :reference_id }
6
6
  end
7
7
  end
@@ -7,5 +7,17 @@ module DockerContainerWizardStates
7
7
  :foreign_key => :docker_container_wizard_state_id
8
8
 
9
9
  validates :compute_resource_id, :presence => true
10
+
11
+ def used_location_ids
12
+ Location.joins(:taxable_taxonomies).where(
13
+ 'taxable_taxonomies.taxable_type' => 'DockerContainerWizardStates::Preliminary',
14
+ 'taxable_taxonomies.taxable_id' => id).pluck(:id)
15
+ end
16
+
17
+ def used_organization_ids
18
+ Organization.joins(:taxable_taxonomies).where(
19
+ 'taxable_taxonomies.taxable_type' => 'DockerContainerWizardStates::Preliminary',
20
+ 'taxable_taxonomies.taxable_id' => id).pluck(:id)
21
+ end
10
22
  end
11
23
  end
@@ -24,6 +24,10 @@ module ForemanDocker
24
24
  16 * 1024 * 1024 * 1024
25
25
  end
26
26
 
27
+ def max_cpu_count
28
+ ::Docker.info['NCPU'] || 1
29
+ end
30
+
27
31
  def available_images
28
32
  client.images.all
29
33
  end
@@ -71,16 +75,21 @@ module ForemanDocker
71
75
  def create_container(args = {})
72
76
  options = vm_instance_defaults.merge(args)
73
77
  logger.debug("Creating container with the following options: #{options.inspect}")
74
- ::Docker::Container.create(options)
75
- rescue Excon::Errors::Error, ::Docker::Error::DockerError => e
76
- logger.debug "Fog error: #{e.message}\n " + e.backtrace.join("\n ")
77
- errors.add(:base, _("Error creating container. Check the Foreman logs: %s") % e.message.to_s)
78
- false
78
+ docker_command do
79
+ ::Docker::Container.create(options)
80
+ end
81
+ end
82
+
83
+ def create_image(args = {})
84
+ logger.debug("Creating docker image with the following options: #{args.inspect}")
85
+ docker_command do
86
+ ::Docker::Image.create(args)
87
+ end
79
88
  end
80
89
 
81
90
  def vm_instance_defaults
82
91
  ActiveSupport::HashWithIndifferentAccess.new('name' => "foreman_#{Time.now.to_i}",
83
- 'cmd' => ['/bin/bash'])
92
+ 'Cmd' => ['/bin/bash'])
84
93
  end
85
94
 
86
95
  def console(uuid)
@@ -104,6 +113,16 @@ module ForemanDocker
104
113
 
105
114
  protected
106
115
 
116
+ def docker_command
117
+ yield
118
+ rescue Excon::Errors::Error, ::Docker::Error::DockerError => e
119
+ logger.debug "Fog error: #{e.message}\n " + e.backtrace.join("\n ")
120
+ errors.add(:base,
121
+ _("Error creating communicating with Docker. Check the Foreman logs: %s") %
122
+ e.message.to_s)
123
+ false
124
+ end
125
+
107
126
  def bootstrap(args)
108
127
  client.servers.bootstrap vm_instance_defaults.merge(args.to_hash)
109
128
  rescue Fog::Errors::Error => e
@@ -0,0 +1,14 @@
1
+ module ForemanDocker
2
+ module TaxonomyExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ if SETTINGS[:version].to_s.to_f <= 1.7
7
+ def self.enabled_taxonomies
8
+ %w(locations organizations).select { |taxonomy| SETTINGS["#{taxonomy}_enabled".to_sym] }
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ # To be removed after 1.7 compatibility is no longer required
@@ -1,11 +1,15 @@
1
1
  module Service
2
2
  class Containers
3
- def self.start_container!(wizard_state)
3
+ def errors
4
+ @errors ||= []
5
+ end
6
+
7
+ def start_container!(wizard_state)
4
8
  ActiveRecord::Base.transaction do
5
9
  container = Container.new(wizard_state.container_attributes) do |r|
6
10
  # eagerly load environment variables
7
11
  state = DockerContainerWizardState.includes(:environment => [:environment_variables])
8
- .find(wizard_state.id)
12
+ .find(wizard_state.id)
9
13
  state.environment_variables.each do |environment_variable|
10
14
  r.environment_variables.build :name => environment_variable.name,
11
15
  :value => environment_variable.value,
@@ -16,7 +20,7 @@ module Service
16
20
  container.send(:"#{taxonomy}=", wizard_state.preliminary.send(:"#{taxonomy}"))
17
21
  end
18
22
 
19
- fail ActiveRecord::Rollback unless start_container(container)
23
+ fail ActiveRecord::Rollback unless pull_image(container) && start_container(container)
20
24
 
21
25
  container.save!
22
26
  destroy_wizard_state(wizard_state)
@@ -24,13 +28,21 @@ module Service
24
28
  end
25
29
  end
26
30
 
27
- def self.start_container(container)
31
+ def pull_image(container)
32
+ container.compute_resource.create_image(:fromImage => container.repository_pull_url)
33
+ end
34
+
35
+ def start_container(container)
28
36
  started = container.compute_resource.create_container(container.parametrize)
29
- container.uuid = started.id if started
37
+ if started
38
+ container.uuid = started.id
39
+ else
40
+ errors << container.compute_resource.errors[:base]
41
+ end
30
42
  started
31
43
  end
32
44
 
33
- def self.destroy_wizard_state(wizard_state)
45
+ def destroy_wizard_state(wizard_state)
34
46
  wizard_state.destroy
35
47
  DockerContainerWizardState.destroy_all(["updated_at < ?", (Time.now - 24.hours)])
36
48
  end
@@ -18,8 +18,8 @@
18
18
  <td class="ellipsis text-center"><%= link_to_container(container, resource) %></td>
19
19
  <td class="hidden-tablet hidden-xs text-center">
20
20
  <span <%= vm_power_class(container.ready?) %>><%= vm_state(container) %></span></td>
21
- <td class="hidden-tablet hidden-xs text-center"><%= trunc(container.image_friendly_name) %></td>
22
- <td class="hidden-tablet hidden-xs text-center"><%= trunc(container.command) %></td>
21
+ <td class="hidden-tablet hidden-xs text-center"><%= trunc_with_tooltip(container.image_friendly_name) %></td>
22
+ <td class="hidden-tablet hidden-xs text-center"><%= trunc_with_tooltip(container.command) %></td>
23
23
  <td class="hidden-tablet hidden-xs text-center">
24
24
  <span class="glyphicon glyphicon-time"></span> <%= container.ready? ? time_ago_in_words(container.started_at) : "N/A" %>
25
25
  </td>
@@ -29,7 +29,7 @@
29
29
  </tr>
30
30
  <tr>
31
31
  <td><%= _('UUID') %></td>
32
- <td><%= trunc @container.in_fog.identity %></td>
32
+ <td><%= trunc_with_tooltip @container.in_fog.identity %></td>
33
33
  </tr>
34
34
  <tr>
35
35
  <td><%= _('Memory') %></td>
@@ -1,5 +1,5 @@
1
1
  <%= render :layout => 'title', :locals => { :step => 3 } do %>
2
- <%= form_for @configuration, :url => wizard_path, :method => :put do |f| %>
2
+ <%= form_for @docker_container_wizard_states_configuration, :url => wizard_path, :method => :put do |f| %>
3
3
  <h3><%= _("Basic options") %></h3>
4
4
  <%= text_f f, :name, :size => 'col-md-4' %>
5
5
  <%= text_f f, :command, :size => 'col-md-4' %>
@@ -1,5 +1,5 @@
1
1
  <%= render :layout => 'title', :locals => { :step => 4 } do %>
2
- <%= form_for @environment, :url => wizard_path, :method => :put do |f| %>
2
+ <%= form_for @docker_container_wizard_states_environment, :url => wizard_path, :method => :put do |f| %>
3
3
  <div class='row'>
4
4
  <div class='col-md-6 col-md-push-7'>
5
5
  <h3><%= _("Shell") %></h3>
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <div class='col-md-6 col-md-pull-6'>
12
12
  <h3><%= _("Environment variables") %></h3>
13
- <%= f.fields_for :environment_variables, @environment.environment_variables do |builder| %>
13
+ <%= f.fields_for :environment_variables, @docker_container_wizard_states_environment.environment_variables do |builder| %>
14
14
  <%= render 'foreman_docker/common_parameters/environment_variable', :f => builder %>
15
15
  <% end %>
16
16
  <%= link_to_add_fields(_("Add environment variable"), f, :environment_variables,
@@ -3,21 +3,27 @@
3
3
 
4
4
  <%= render :layout => 'title', :locals => { :step => 2 } do %>
5
5
  <ul class="nav nav-tabs" data-tabs="tabs">
6
- <li class="active"><a href="#hub" data-toggle="tab" id="hub_tab">
6
+ <li class=<%= ("active" if @docker_container_wizard_states_image.registry_id.nil?) %>><a href="#hub" data-toggle="tab" id="hub_tab">
7
7
  <span class="glyphicon glyphicon-cloud-download"></span>
8
8
  <%= _("Docker hub") %>
9
9
  </a></li>
10
- <li><a href="#registry" data-toggle="tab" id="registry_tab">
10
+ <li class=<%= ("active" unless @docker_container_wizard_states_image.registry_id.nil?) %>><a href="#registry" data-toggle="tab" id="registry_tab">
11
11
  <span class="glyphicon glyphicon-cloud-download"></span>
12
12
  <%= _("External registry") %>
13
13
  </a></li>
14
14
  </ul>
15
15
 
16
- <%= form_for @image, :class => 'form-horizontal', :url => wizard_path, :method => :put do |f| %>
16
+ <%= form_for @docker_container_wizard_states_image, :class => 'form-horizontal', :url => wizard_path, :method => :put do |f| %>
17
17
  <div class="tab-content">
18
- <div class="tab-pane active" id="hub">
19
- </div>
20
- <div class="tab-pane" id="registry">
18
+ <% if @docker_container_wizard_states_image.registry_id.nil? %>
19
+ <div class="tab-pane active" id="hub">
20
+ </div>
21
+ <div class="tab-pane" id="registry">
22
+ <% else %>
23
+ <div class="tab-pane" id="hub">
24
+ </div>
25
+ <div class="tab-pane active" id="registry">
26
+ <% end %>
21
27
  <div class="input-group col-md-6">
22
28
  <%= select_registry f %>
23
29
  </div>
@@ -28,7 +34,7 @@
28
34
  <div class="input-group">
29
35
 
30
36
  <%= auto_complete_docker_search('docker_container_wizard_states_image[repository_name]', '',
31
- :'data-url' => auto_complete_repository_name_image_search_path(@image.compute_resource_id),
37
+ :'data-url' => auto_complete_repository_name_image_search_path(@docker_container_wizard_states_image.compute_resource_id),
32
38
  :value => f.object.repository_name.present? ? f.object.repository_name : '',
33
39
  :id => :search,
34
40
  :focus_on_load => true,
@@ -38,7 +44,7 @@
38
44
  <%= button_tag(:class => 'btn btn-default',
39
45
  :type => 'button',
40
46
  :id => 'search_repository',
41
- :'data-url' => search_repository_image_search_path(@image.compute_resource_id),
47
+ :'data-url' => search_repository_image_search_path(@docker_container_wizard_states_image.compute_resource_id),
42
48
  :onclick => 'searchRepo(this)') do %>
43
49
  <span class="glyphicon glyphicon-search"></span>
44
50
  <% end %>
@@ -47,7 +53,7 @@
47
53
  </div>
48
54
  <%= text_f f, :tag,
49
55
  :id => 'tag',
50
- :'data-url' => auto_complete_image_tag_image_search_path(@image.compute_resource_id) %>
56
+ :'data-url' => auto_complete_image_tag_image_search_path(@docker_container_wizard_states_image.compute_resource_id) %>
51
57
  <div class="col-md-12">
52
58
  <div id='searching_spinner' class='col-md-offset-3 hide'>
53
59
  <span id='waiting_text'>
@@ -1,5 +1,5 @@
1
1
  <%= render :layout => 'title', :locals => { :step => 1 } do %>
2
- <%= form_for @preliminary, :url => wizard_path, :method => :put do |f| %>
2
+ <%= form_for @docker_container_wizard_states_preliminary, :url => wizard_path, :method => :put do |f| %>
3
3
  <ul class="nav nav-tabs" data-tabs="tabs">
4
4
  <li class="active"><a href="#primary" data-toggle="tab">
5
5
  <span class="glyphicon glyphicon-tasks"></span>
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
  <% end %>
28
28
  </div>
29
- <%= render "taxonomies/loc_org_tabs", :f => f, :obj => @preliminary %>
29
+ <%= render "taxonomies/loc_org_tabs", :f => f, :obj => @docker_container_wizard_states_preliminary %>
30
30
  </div>
31
31
  <% if @container_resources.present? %>
32
32
  <%= render :partial => 'form_buttons' %>
@@ -6,7 +6,7 @@
6
6
  <span class="glyphicon glyphicon-star"></span> <%= repository['star_count'] %>
7
7
  </p>
8
8
  <p>
9
- <%= trunc(repository['description']) %>
9
+ <%= trunc_with_tooltip(repository['description']) %>
10
10
  <%= link_to '<span class="glyphicon glyphicon-share"></span>'.html_safe, hub_url(repository), :target => '_blank' %>
11
11
  </p>
12
12
  <% end %>
@@ -17,9 +17,9 @@
17
17
 
18
18
  <% @registries.each do |r| %>
19
19
  <tr>
20
- <td><%= link_to_if_authorized trunc(r.name), hash_for_edit_registry_path(:id => r).merge(:auth_object => r, :authorizer => authorizer) %></td>
21
- <td class="hidden-tablet hidden-xs text-center"><%= trunc(r.url) %></td>
22
- <td class="hidden-tablet hidden-xs text-center"><%= trunc(r.description) %></td>
20
+ <td><%= link_to_if_authorized trunc_with_tooltip(r.name), hash_for_edit_registry_path(:id => r).merge(:auth_object => r, :authorizer => authorizer) %></td>
21
+ <td class="hidden-tablet hidden-xs text-center"><%= trunc_with_tooltip(r.url) %></td>
22
+ <td class="hidden-tablet hidden-xs text-center"><%= trunc_with_tooltip(r.description) %></td>
23
23
  <td><%= display_delete_if_authorized hash_for_registry_path(:id => r).merge(:auth_object => r, :authorizer => authorizer), :confirm => _("Delete %s?") % r.name %></td>
24
24
  </tr>
25
25
  <% end %>
@@ -77,19 +77,22 @@ module ForemanDocker
77
77
  :search_repository]
78
78
  end
79
79
  end
80
-
81
80
  end
82
81
 
83
82
  rake_tasks do
84
83
  load "#{ForemanDocker::Engine.root}/lib/foreman_docker/tasks/test.rake"
85
84
  end
86
- end
87
85
 
88
- # extend fog docker server and image models.
89
- require 'fog/fogdocker/models/compute/server'
90
- require 'fog/fogdocker/models/compute/image'
91
- require File.expand_path('../../../app/models/concerns/fog_extensions/fogdocker/server', __FILE__)
92
- require File.expand_path('../../../app/models/concerns/fog_extensions/fogdocker/image', __FILE__)
93
- Fog::Compute::Fogdocker::Server.send(:include, ::FogExtensions::Fogdocker::Server)
94
- Fog::Compute::Fogdocker::Image.send(:include, ::FogExtensions::Fogdocker::Image)
86
+ require 'fog/fogdocker/models/compute/server'
87
+ require 'fog/fogdocker/models/compute/image'
88
+ require File.expand_path('../../../app/models/concerns/fog_extensions/fogdocker/server',
89
+ __FILE__)
90
+ require File.expand_path('../../../app/models/concerns/fog_extensions/fogdocker/image',
91
+ __FILE__)
92
+ config.to_prepare do
93
+ Fog::Compute::Fogdocker::Server.send(:include, ::FogExtensions::Fogdocker::Server)
94
+ Fog::Compute::Fogdocker::Image.send(:include, ::FogExtensions::Fogdocker::Image)
95
+ ::Taxonomy.send(:include, ForemanDocker::TaxonomyExtensions)
96
+ end
97
+ end
95
98
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanDocker
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -8,7 +8,8 @@ module Containers
8
8
 
9
9
  test 'wizard finishes with a redirect to the managed container' do
10
10
  state = DockerContainerWizardState.create!
11
- Service::Containers.expects(:start_container!).with(equals(state)).returns(@container)
11
+ Service::Containers.any_instance.expects(:start_container!).with(equals(state))
12
+ .returns(@container)
12
13
  put :update, { :wizard_state_id => state.id,
13
14
  :id => :environment,
14
15
  :docker_container_wizard_states_environment => { :tty => false } },
@@ -7,15 +7,19 @@ class ContainersServiceTest < ActiveSupport::TestCase
7
7
  :locations => [taxonomies(:location1)],
8
8
  :organizations => [taxonomies(:organization1)])
9
9
  s.build_image(:repository_name => 'test', :tag => 'test')
10
- s.build_configuration(:name => 'test')
10
+ s.build_configuration(:name => 'test', :command => '/bin/bash')
11
11
  s.build_environment(:tty => false)
12
12
  end
13
13
  end
14
14
 
15
15
  test 'removes current state after successful container creation' do
16
+ ret = OpenStruct.new(:id => 1)
17
+ ForemanDocker::Docker.any_instance.expects(:create_image).returns(ret).with do |subject|
18
+ subject.must_equal(:fromImage => "test:test")
19
+ end
16
20
  ForemanDocker::Docker.any_instance.expects(:create_container)
17
- .returns(OpenStruct.new(:uuid => 1))
18
- Service::Containers.start_container!(@state)
21
+ .returns(OpenStruct.new(:uuid => 1))
22
+ Service::Containers.new.start_container!(@state)
19
23
  assert_equal DockerContainerWizardState.where(:id => @state.id).count, 0
20
24
  end
21
25
  end
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.0.0
4
+ version: 1.0.1
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-01-12 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.1'
41
- - !ruby/object:Gem::Dependency
42
- name: rubocop
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.26'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.26'
55
41
  description: Provision and manage Docker containers and images from Foreman.
56
42
  email:
57
43
  - dlobatog@redhat.com, abenari@redhat.com
@@ -85,6 +71,7 @@ files:
85
71
  - app/models/docker_registry.rb
86
72
  - app/models/environment_variable.rb
87
73
  - app/models/foreman_docker/docker.rb
74
+ - app/models/foreman_docker/taxonomy_extensions.rb
88
75
  - app/models/service/containers.rb
89
76
  - app/models/service/registry_api.rb
90
77
  - app/views/api/v1/compute_resources/docker.json