foreman_discovery 9.1.5 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/discovered_hosts_controller.rb +5 -4
  3. data/app/controllers/api/v2/discovery_rules_controller.rb +1 -1
  4. data/app/controllers/concerns/foreman/controller/parameters/discovered_host.rb +2 -9
  5. data/app/controllers/discovered_hosts_controller.rb +10 -21
  6. data/app/controllers/discovery_rules_controller.rb +1 -1
  7. data/app/controllers/foreman_discovery/concerns/hosts_controller_extensions.rb +1 -1
  8. data/app/helpers/discovered_hosts_helper.rb +2 -3
  9. data/app/models/discovery_attribute_set.rb +1 -1
  10. data/app/models/discovery_rule.rb +1 -1
  11. data/app/models/host/discovered.rb +23 -17
  12. data/app/models/host/managed_extensions.rb +2 -5
  13. data/app/services/foreman_discovery/host_converter.rb +0 -6
  14. data/app/services/foreman_discovery/node_api/power.rb +0 -8
  15. data/app/views/discovered_hosts/_discovered_host_modal.html.erb +12 -13
  16. data/app/views/discovered_hosts/_selected_hosts.html.erb +1 -1
  17. data/app/views/discovered_hosts/multiple_destroy.html.erb +5 -4
  18. data/app/views/discovered_hosts/show.html.erb +9 -1
  19. data/app/views/discovered_hosts/welcome.html.erb +10 -0
  20. data/db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb +1 -1
  21. data/db/migrate/20150714144500_review_discovery_permissions.rb +9 -7
  22. data/db/migrate/20161006094714_add_constraints_on_subnets_smart_proxies.rb +0 -3
  23. data/extra/discover-host +18 -11
  24. data/extra/discovery/rhel7-vlan.json +352 -0
  25. data/lib/foreman_discovery/engine.rb +2 -1
  26. data/lib/foreman_discovery/version.rb +1 -1
  27. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  28. data/locale/ca/foreman_discovery.edit.po +1 -1
  29. data/locale/ca/foreman_discovery.po +1 -1
  30. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  31. data/locale/de/foreman_discovery.edit.po +2 -2
  32. data/locale/de/foreman_discovery.po +2 -2
  33. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  34. data/locale/en/foreman_discovery.edit.po +79 -75
  35. data/locale/en/foreman_discovery.po +13 -10
  36. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  37. data/locale/en_GB/foreman_discovery.edit.po +1 -1
  38. data/locale/en_GB/foreman_discovery.po +1 -1
  39. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  40. data/locale/es/foreman_discovery.edit.po +2 -2
  41. data/locale/es/foreman_discovery.po +2 -2
  42. data/locale/foreman_discovery.pot +89 -81
  43. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  44. data/locale/fr/foreman_discovery.edit.po +2 -2
  45. data/locale/fr/foreman_discovery.po +2 -2
  46. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  47. data/locale/gl/foreman_discovery.edit.po +1 -1
  48. data/locale/gl/foreman_discovery.po +1 -1
  49. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  50. data/locale/it/foreman_discovery.edit.po +2 -2
  51. data/locale/it/foreman_discovery.po +2 -2
  52. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  53. data/locale/ja/foreman_discovery.edit.po +2 -2
  54. data/locale/ja/foreman_discovery.po +2 -2
  55. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  56. data/locale/ko/foreman_discovery.edit.po +2 -2
  57. data/locale/ko/foreman_discovery.po +2 -2
  58. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  59. data/locale/pt_BR/foreman_discovery.edit.po +2 -2
  60. data/locale/pt_BR/foreman_discovery.po +2 -2
  61. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  62. data/locale/ru/foreman_discovery.edit.po +2 -2
  63. data/locale/ru/foreman_discovery.po +2 -2
  64. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  65. data/locale/sv_SE/foreman_discovery.edit.po +1 -1
  66. data/locale/sv_SE/foreman_discovery.po +1 -1
  67. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  68. data/locale/zh_CN/foreman_discovery.edit.po +2 -2
  69. data/locale/zh_CN/foreman_discovery.po +2 -2
  70. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  71. data/locale/zh_TW/foreman_discovery.edit.po +2 -2
  72. data/locale/zh_TW/foreman_discovery.po +2 -2
  73. data/test/functional/api/v2/discovered_hosts_controller_test.rb +16 -17
  74. data/test/functional/api/v2/discovery_rules_controller_test.rb +2 -3
  75. data/test/functional/api/v2/fact_value_extensions_test.rb +1 -1
  76. data/test/functional/discovered_hosts_controller_test.rb +102 -133
  77. data/test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb +5 -6
  78. data/test/test_helper_discovery.rb +18 -0
  79. data/test/unit/discovered_extensions_test.rb +25 -33
  80. data/test/unit/discovery_attribute_set_test.rb +5 -8
  81. data/test/unit/discovery_taxonomy_extensions_test.rb +2 -2
  82. data/test/unit/host_discovered_test.rb +30 -30
  83. data/test/unit/managed_extensions_test.rb +0 -1
  84. metadata +6 -4
  85. data/app/services/foreman_discovery/node_api/power_legacy_direct_service.rb +0 -15
  86. data/app/services/foreman_discovery/node_api/power_legacy_proxied_service.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e877d7c59191394b18cf5904b63054d92df3ce0d
4
- data.tar.gz: e273a127b52a861f972200ddad15b98741b51a2d
3
+ metadata.gz: d782b90e35570098b6d74636a5a79a6a7f94026a
4
+ data.tar.gz: '07791a0d0a62b65eb04803473e2413748458b40a'
5
5
  SHA512:
6
- metadata.gz: a06f1b0fd6e1ed5e5096083fd79e45f41b0d5d795b60c60d6bcd2c56041353bcd44f2e8884e0736f04fee9baf50a876f04104b8a88a839b5a0f5af45cae51ba4
7
- data.tar.gz: 8fbab2d3cca72e08771cb6aa5e3e116322c724ce9c00d9a9e6fb854b2a1728aa7c6b19ec6e1bb646aaebdefd3824c98decf923489ab639c4e1d1158ef5d24ad0
6
+ metadata.gz: 3172b396efe8c2b9a7a8727bc26739bcbfb4da40cd0fc1222ad4c2cd91267de873d61ef3c4fdc2e7e6cbf44881679c79b990b9ed795f699150ecb8f806d7aa3b
7
+ data.tar.gz: a8daeeadb503811032caebe4f2c6dd26acad998d615b7e3deeb96dff59880494ba7ce01cd9459431adcc439e7a13ab91a24ca467b2774b54a4c4265a31c2b17f
@@ -4,8 +4,8 @@ module Api
4
4
  include Foreman::Controller::Parameters::DiscoveredHost
5
5
  include Foreman::Controller::DiscoveredExtensions
6
6
 
7
- before_filter :find_resource, :except => %w{index create facts auto_provision_all reboot_all}
8
- skip_before_filter :authorize, :only => :facts
7
+ before_action :find_resource, :except => %w{index create facts auto_provision_all reboot_all}
8
+ skip_before_action :authorize, :only => :facts
9
9
 
10
10
  resource_description do
11
11
  resource_id 'discovered_hosts'
@@ -80,7 +80,7 @@ module Api
80
80
  end
81
81
 
82
82
  def update
83
- @host = ::ForemanDiscovery::HostConverter.to_managed(@discovered_host, true, true, managed_host_params)
83
+ @host = ::ForemanDiscovery::HostConverter.to_managed(@discovered_host, true, true, discovered_host_params)
84
84
  forward_request_url
85
85
  update_response = @host.save
86
86
  process_response update_response
@@ -97,7 +97,8 @@ module Api
97
97
  param :facts, Hash, :required => true, :desc => N_("hash containing facts for the host with minimum set of facts: discovery_bootif, macaddress_eth0, ipaddress, ipaddress_eth0, interfaces: eth0 (example in case primary interface is named eth0)")
98
98
 
99
99
  def facts
100
- facts = params['facts']
100
+ # creating a host from facts is not a mass assignment - we store them individually
101
+ facts = params['facts'].to_unsafe_h
101
102
  state = true
102
103
  User.as_anonymous_admin do
103
104
  @discovered_host = Host::Discovered.import_host(facts)
@@ -3,7 +3,7 @@ module Api
3
3
  class DiscoveryRulesController < ::Api::V2::BaseController
4
4
  include Foreman::Controller::Parameters::DiscoveryRule
5
5
 
6
- before_filter :find_resource, :except => %w{index create facts}
6
+ before_action :find_resource, :except => %w{index create facts}
7
7
 
8
8
  resource_description do
9
9
  resource_id 'discovery_rules'
@@ -1,6 +1,7 @@
1
1
  module Foreman::Controller::Parameters::DiscoveredHost
2
2
  extend ActiveSupport::Concern
3
- include Foreman::Controller::Parameters::Host
3
+ include Foreman::Controller::Parameters::HostBase
4
+ include Foreman::Controller::Parameters::HostCommon
4
5
 
5
6
  class_methods do
6
7
  def discovered_host_params_filter
@@ -20,12 +21,4 @@ module Foreman::Controller::Parameters::DiscoveredHost
20
21
  def discovered_host_params_host
21
22
  self.class.discovered_host_params_filter.filter_params(params, parameter_filter_context, :host)
22
23
  end
23
-
24
- def managed_host_params_host
25
- self.class.host_params_filter.filter_params(params, parameter_filter_context, :host)
26
- end
27
-
28
- def managed_host_params
29
- self.class.host_params_filter.filter_params(params, parameter_filter_context)
30
- end
31
24
  end
@@ -5,17 +5,21 @@ class DiscoveredHostsController < ::ApplicationController
5
5
  include Foreman::Controller::DiscoveredExtensions
6
6
  include ActionView::Helpers::NumberHelper
7
7
 
8
- before_filter :find_by_name, :only => %w[edit update destroy refresh_facts convert reboot auto_provision]
9
- before_filter :find_by_name_incl_subnet, :only => [:show]
10
- before_filter :find_multiple, :only => [:multiple_destroy, :submit_multiple_destroy]
11
- before_filter :taxonomy_scope, :only => [:edit]
8
+ before_action :find_by_name, :only => %w[edit update destroy refresh_facts convert reboot auto_provision]
9
+ before_action :find_by_name_incl_subnet, :only => [:show]
10
+ before_action :find_multiple, :only => [:multiple_destroy, :submit_multiple_destroy]
11
+ before_action :taxonomy_scope, :only => [:edit]
12
12
 
13
- around_filter :skip_bullet, :only => [:edit]
13
+ around_action :skip_bullet, :only => [:edit]
14
14
 
15
15
  helper :hosts
16
16
 
17
17
  layout 'layouts/application'
18
18
 
19
+ def model_of_controller
20
+ Host::Discovered
21
+ end
22
+
19
23
  def index
20
24
  @hosts = resource_base.search_for(params[:search], :order => params[:order]).includes([
21
25
  :location,
@@ -62,7 +66,7 @@ class DiscoveredHostsController < ::ApplicationController
62
66
  end
63
67
 
64
68
  def update
65
- @host = ::ForemanDiscovery::HostConverter.to_managed(@host, true, true, managed_host_params_host)
69
+ @host = ::ForemanDiscovery::HostConverter.to_managed(@host, true, true, discovered_host_params_host)
66
70
  forward_url_options
67
71
 
68
72
  perform_update(@host)
@@ -142,21 +146,6 @@ class DiscoveredHostsController < ::ApplicationController
142
146
  redirect_to(discovered_hosts_path)
143
147
  end
144
148
 
145
- def auto_complete_search
146
- begin
147
- @items = Host::Discovered.complete_for(params[:search])
148
- @items = @items.map do |item|
149
- category = (['and','or','not','has'].include?(item.to_s.sub(/^.*\s+/,''))) ? 'Operators' : ''
150
- part = item.to_s.sub(/^.*\b(and|or)\b/i) {|match| match.sub(/^.*\s+/,'')}
151
- completed = item.to_s.chomp(part)
152
- {:completed => completed, :part => part, :label => item, :category => category}
153
- end
154
- rescue ScopedSearch::QueryNotSupported => e
155
- @items = [{:error =>e.to_s}]
156
- end
157
- render :json => @items
158
- end
159
-
160
149
  def auto_provision
161
150
  if rule = find_discovery_rule(@host)
162
151
  if perform_auto_provision(@host, rule)
@@ -4,7 +4,7 @@ class DiscoveryRulesController < ApplicationController
4
4
 
5
5
  include Foreman::Controller::Parameters::DiscoveryRule
6
6
 
7
- before_filter :find_resource, :only => [:edit, :update, :destroy, :enable, :disable, :auto_provision]
7
+ before_action :find_resource, :only => [:edit, :update, :destroy, :enable, :disable, :auto_provision]
8
8
 
9
9
  def index
10
10
  base = resource_base.search_for(params[:search], :order => (params[:order]))
@@ -10,7 +10,7 @@ module ForemanDiscovery
10
10
  # in the hosts controller like all the _selected methods, taxonomy_scope,
11
11
  # etc.. expect a params[:host] to work.
12
12
  def set_discovered_params
13
- return unless request.path.match(/discovered_hosts/).present?
13
+ return if params[:discovered_host].nil?
14
14
  params[:host] ||= params[:discovered_host]
15
15
  end
16
16
  end
@@ -20,12 +20,11 @@ module DiscoveredHostsHelper
20
20
  ),
21
21
  select_action_button( _("Select Action"), {}, provision_button(host, hash_for_edit_discovered_host_path(:id => host)), actions.map { |action| display_link_if_authorized(action[0] , action[1], action[2] || {}) }.flatten ),
22
22
  button_group(
23
- link_to(_("Expand All"),"#",:class => "btn btn-default",:onclick => "$('.glyphicon-plus-sign').toggleClass('glyphicon glyphicon-minus-sign glyphicon glyphicon-plus-sign');
24
- $('.facts-panel').addClass('collapse in').height('auto');"
23
+ link_to(_("Expand All"),"#", :id => "expand_all", :class => "btn btn-default"
25
24
  )
26
25
  ),
27
26
  button_group(
28
- display_delete_if_authorized(hash_for_discovered_host_path(:id => host).merge(:auth_object => host, :permission => :destroy_discovered_hosts), :class => "btn btn-danger", :data => { :confirm => _('Delete %s?') % host.name })
27
+ display_delete_if_authorized(hash_for_discovered_host_path(:id => host).merge(:auth_object => host, :permission => :destroy_discovered_hosts), :class => "btn btn-default", :data => { :confirm => _('Delete %s?') % host.name })
29
28
  )
30
29
  )
31
30
  end
@@ -1,4 +1,4 @@
1
- class DiscoveryAttributeSet < ActiveRecord::Base
1
+ class DiscoveryAttributeSet < ApplicationRecord
2
2
  belongs_to :host, :class_name => "Host::Discovered", :foreign_key => :host_id
3
3
 
4
4
  validates :cpu_count, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
@@ -1,4 +1,4 @@
1
- class DiscoveryRule < ActiveRecord::Base
1
+ class DiscoveryRule < ApplicationRecord
2
2
  include Authorizable
3
3
  extend FriendlyId
4
4
  friendly_id :name
@@ -34,7 +34,7 @@ class Host::Discovered < ::Host::Base
34
34
  }
35
35
 
36
36
  def self.import_host facts
37
- raise(::Foreman::Exception.new(N_("Invalid facts, must be a Hash"))) unless facts.is_a?(Hash)
37
+ raise(::Foreman::Exception.new(N_("Invalid facts, must be a Hash"))) unless facts.is_a?(Hash) || facts.is_a?(ActionController::Parameters)
38
38
 
39
39
  # filter facts
40
40
  facts.reject!{|k,v| k =~ /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|filesystem/i }
@@ -67,11 +67,13 @@ class Host::Discovered < ::Host::Base
67
67
  host
68
68
  end
69
69
 
70
- def import_facts facts
70
+ def import_facts(facts)
71
71
  # Discovered Hosts won't report in via puppet, so we can use that field to
72
72
  # record the last time it sent facts...
73
73
  self.last_report = Time.now
74
- super
74
+ # Set the correct facts type for new foreman facts importing code.
75
+ facts[:_type] = :foreman_discovery if SETTINGS[:version].short > '1.16'
76
+ super(facts)
75
77
  end
76
78
 
77
79
  def setup_clone
@@ -84,10 +86,23 @@ class Host::Discovered < ::Host::Base
84
86
  super
85
87
  end
86
88
 
87
- def populate_fields_from_facts(facts = self.facts_hash, ignored_type = nil)
88
- # detect interfaces and primary interface using extensions
89
- parser = super(facts, :foreman_discovery)
89
+ def populate_fields_from_facts(*params)
90
+ if SETTINGS[:version].short > '1.16'
91
+ parser, type, source_proxy = params
92
+ facts = parser.facts
93
+ # detect interfaces and primary interface using extensions
94
+ super(parser, type, source_proxy)
95
+ else
96
+ # backwards compatibility
97
+ facts = params[0] || self.facts_hash
98
+ parser = super(facts, :foreman_discovery)
99
+ end
100
+
101
+ populate_discovery_fields_from_facts(facts)
102
+ parser
103
+ end
90
104
 
105
+ def populate_discovery_fields_from_facts(facts)
91
106
  # set additional discovery attributes
92
107
  primary_ip = self.primary_interface.ip
93
108
  unless primary_ip.nil?
@@ -122,7 +137,6 @@ class Host::Discovered < ::Host::Base
122
137
  # lock the host into discovery via PXE, if feature is enabled in settings
123
138
  lock_templates if Setting::Discovered.discovery_lock? && self.subnet.tftp?
124
139
  self.save!
125
- parser
126
140
  end
127
141
 
128
142
  def lock_templates
@@ -176,16 +190,8 @@ class Host::Discovered < ::Host::Base
176
190
  raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url, :error => e)
177
191
  end
178
192
 
179
- def reboot legacy_api = ForemanDiscovery::HostConverter.legacy_host(self)
180
- if legacy_api
181
- if proxied?
182
- resource = ::ForemanDiscovery::NodeAPI::Power.legacy_proxied_service(:url => proxy_url)
183
- else
184
- resource = ::ForemanDiscovery::NodeAPI::Power.legacy_direct_service(:url => proxy_url)
185
- end
186
- else
187
- resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => proxy_url)
188
- end
193
+ def reboot
194
+ resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => proxy_url)
189
195
  resource.reboot
190
196
  rescue => e
191
197
  ::Foreman::Logging.exception("Unable to reboot #{name}", e)
@@ -9,9 +9,6 @@ module Host::ManagedExtensions
9
9
  belongs_to :discovery_rule
10
10
 
11
11
  scoped_search :relation => :discovery_rule, :on => :name, :rename => :discovery_rule, :complete_value => true
12
-
13
- # extra flag for post_queue callbacks which has no access to facts
14
- attr_accessor :legacy_api
15
12
  end
16
13
 
17
14
  def queue_reboot
@@ -27,7 +24,7 @@ module Host::ManagedExtensions
27
24
  end
28
25
 
29
26
  def setReboot
30
- old.becomes(Host::Discovered).reboot legacy_api
27
+ old.becomes(Host::Discovered).reboot
31
28
  # It is too late to report error in the post_queue, we catch them and
32
29
  # continue. If flash is implemented for new hosts (http://projects.theforeman.org/issues/10559)
33
30
  # we can report the error to the user perhaps.
@@ -63,7 +60,7 @@ module Host::ManagedExtensions
63
60
 
64
61
  def delete_discovery_attribute_set
65
62
  return if new_record?
66
- DiscoveryAttributeSet.destroy_all(:host_id => self.id) if type_changed?
63
+ DiscoveryAttributeSet.where(:host_id => self.id).destroy_all if type_changed?
67
64
  end
68
65
 
69
66
  def update_notifications
@@ -20,8 +20,6 @@ class ForemanDiscovery::HostConverter
20
20
  end
21
21
 
22
22
  def self.set_build_clean_facts(host)
23
- # set legacy_api flag for post_queue actions
24
- host.legacy_api = self.legacy_host(host)
25
23
  # fact cleaning
26
24
  if Setting['discovery_clean_facts']
27
25
  # clean all facts except those starting with "discovery_"
@@ -37,8 +35,4 @@ class ForemanDiscovery::HostConverter
37
35
  host.build = true
38
36
  end
39
37
 
40
- def self.legacy_host(host)
41
- Gem::Version.new(host.facts['discovery_version'] || '1.0.0') < Gem::Version.new('3.0.0')
42
- end
43
-
44
38
  end
@@ -4,14 +4,6 @@ module ForemanDiscovery::NodeAPI
4
4
  def service(data)
5
5
  ForemanDiscovery::NodeAPI::PowerService.new(data)
6
6
  end
7
-
8
- def legacy_direct_service(data)
9
- ForemanDiscovery::NodeAPI::PowerLegacyDirectService.new(data)
10
- end
11
-
12
- def legacy_proxied_service(data)
13
- ForemanDiscovery::NodeAPI::PowerLegacyProxiedService.new(data)
14
- end
15
7
  end
16
8
  end
17
9
  end
@@ -1,12 +1,11 @@
1
- <div class="modal" id="<%= "fixedPropertiesSelector-#{host.id}" %>" tabindex="-1" role="dialog" aria-labelledby="fixedPropertiesSelectorLabel">
1
+ <div class="modal fade" id="<%= "fixedPropertiesSelector-#{host.id}" %>" tabindex="-1" role="dialog" aria-labelledby="fixedPropertiesSelectorLabel">
2
2
  <div class="modal-dialog" role="document">
3
3
  <div class="modal-content">
4
- <%= form_for host, :url => edit_discovered_host_path(host), :method => :get do |f| %>
5
- <div class="modal-header">
6
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
7
- <h4 class="modal-title" id="fixedPropertiesSelectorLabel"><%= _('Select initial host properties') %></h4>
8
- </div>
9
- <div class="modal-body">
4
+ <div class="modal-header">
5
+ <h4 class="modal-title" id="fixedPropertiesSelectorLabel">Select initial host properties</h4>
6
+ </div>
7
+ <div class="modal-body">
8
+ <%= form_for host, :url => edit_discovered_host_path(host), :method => :get do |f| %>
10
9
  <%= select_f f, :hostgroup_id, accessible_resource_records(:hostgroup, :title).to_a, :id, :to_label,
11
10
  { :include_blank => true },
12
11
  { :help_inline => :indicator, :size => 'col-md-10' } %>
@@ -18,12 +17,12 @@
18
17
  <% if show_location_tab? %>
19
18
  <%= select_f f, :location_id, Location.my_locations, :id, :to_label, {}, {:size => 'col-md-10'} %>
20
19
  <% end %>
21
- </div>
22
- <div class="modal-footer">
23
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
24
- <input type="submit" class="btn btn-default" value="<%= _('Quick Create') %>" name="quick_submit" />
25
- <input type="submit" class="btn btn-primary" value="<%= _('Create Host') %>" />
26
- </div>
20
+ </div>
21
+ <div class="modal-footer">
22
+ <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
23
+ <input type="submit" class="btn btn-default" value="<%= _('Customize Host') %>" />
24
+ <input type="submit" class="btn btn-primary" value="<%= _('Create Host') %>" name="quick_submit" />
25
+ </div>
27
26
  <% end %>
28
27
  </div>
29
28
  </div>
@@ -1,5 +1,5 @@
1
1
  <div class="row">
2
- <div class="col-md-8">
2
+ <div class="col-md-12">
3
3
 
4
4
  <table class="table table-bordered table-striped">
5
5
  <thead>
@@ -1,6 +1,7 @@
1
- <%= render 'selected_hosts', :hosts => @hosts %>
2
-
3
1
  <%= form_tag submit_multiple_destroy_discovered_hosts_path(:host_ids => params[:host_ids]), :onsubmit => "resetSelection()" do -%>
4
- <span class="label label-warning"><%= _('Warning') -%></span>
5
- <%= _('This might take a while, as all hosts, facts and reports will be destroyed as well') %>
2
+ <%= alert :class => 'alert-warning',
3
+ :text => _("This might take a while, as all hosts, facts and reports will be destroyed as well"),
4
+ :header => '' %>
6
5
  <% end %>
6
+
7
+ <%= render 'selected_hosts', :hosts => @hosts %>
@@ -69,7 +69,7 @@
69
69
  </a>
70
70
  </h4>
71
71
  </div>
72
- <div id="<%= @categories_names[index].to_s + "panel" %>" class="panel-collapse collapse facts-panel <%= "in" if @categories_names[index].to_s.include?"Storage"%>" role="tabpanel">
72
+ <div id="<%= @categories_names[index].to_s + "panel" %>" class="panel-collapse collapse facts-panel" role="tabpanel">
73
73
  <table class="table table-bordered table-condensed table-fixed">
74
74
  <% val.sort.each do |key, value| %>
75
75
  <tr class="">
@@ -99,5 +99,13 @@
99
99
  $('.flag-provision').append(flags_provision);
100
100
  $('.primary-flag').tooltip();
101
101
  $('.provision-flag').tooltip();
102
+
103
+ $('#expand_all').on('click', function () {
104
+ $('#accordion .panel-collapse').collapse('toggle');
105
+ $(this).text(function(i, text){
106
+ return text === "Expand All" ? "Collapse All" : "Expand All";
107
+ })
108
+ });
109
+
102
110
  });
103
111
  </script>
@@ -0,0 +1,10 @@
1
+ <% content_for(:title, _("Discovered Hosts")) %>
2
+ <div class="blank-slate-pf">
3
+ <div class="blank-slate-pf-icon">
4
+ <%= icon_text("gears", "", :kind => "fa") %>
5
+ </div>
6
+ <h1><%= _('Discovered Hosts') %></h1>
7
+ <p><%= _("No discovered hosts found in this context.") %>
8
+ <%= _("This page shows discovered bare-metal or virtual nodes waiting to be provisioned.") %></p>
9
+ <p><%= link_to _('Learn more about this in the documentation.'), documentation_url("#{ForemanDiscovery::VERSION.scan(/\d+\.\d+/).first}/index.html", {:root_url => 'https://theforeman.org/plugins/foreman_discovery/'})%></p>
10
+ </div>
@@ -1,4 +1,4 @@
1
- class FakeDiscoveredHost < ActiveRecord::Base
1
+ class FakeDiscoveredHost < ApplicationRecord
2
2
  self.table_name = 'hosts'
3
3
  end
4
4
 
@@ -1,12 +1,14 @@
1
1
  class ReviewDiscoveryPermissions < ActiveRecord::Migration
2
2
  def up
3
- if (mgr = Role.find_by_name("Discovery Manager"))
4
- perms = []
5
- perms << "submit_discovered_hosts" if Permission.find_by_name("edit_discovered_hosts")
6
- perms << "auto_provision_discovered_hosts" if Permission.find_by_name("provision_discovered_hosts")
7
- perms << "create_discovery_rules" if Permission.find_by_name("new_discovery_rules")
8
- perms << "destroy_discovery_rules" if Permission.find_by_name("delete_discovery_rules")
9
- mgr.add_permissions!(perms)
3
+ Role.ignore_locking do
4
+ if (mgr = Role.find_by_name("Discovery Manager"))
5
+ perms = []
6
+ perms << "submit_discovered_hosts" if Permission.find_by_name("edit_discovered_hosts")
7
+ perms << "auto_provision_discovered_hosts" if Permission.find_by_name("provision_discovered_hosts")
8
+ perms << "create_discovery_rules" if Permission.find_by_name("new_discovery_rules")
9
+ perms << "destroy_discovery_rules" if Permission.find_by_name("delete_discovery_rules")
10
+ mgr.add_permissions!(perms)
11
+ end
10
12
  end
11
13
  Permission.find_by_name("new_discovery_rules").try(:destroy)
12
14
  end
@@ -7,9 +7,6 @@ class AddConstraintsOnSubnetsSmartProxies < ActiveRecord::Migration
7
7
  ActiveRecord::Migration.execute "SET FOREIGN_KEY_CHECKS=0;"
8
8
  end
9
9
 
10
- # if there's some wrong key already, clean the foreign key first
11
- Subnet.unscoped.where(["discovery_id IS NOT NULL AND discovery_id NOT IN (?)", SmartProxy.unscoped.pluck(:id)]).update_all(:discovery_id => nil)
12
-
13
10
  add_foreign_key "subnets", "smart_proxies", :name => "subnets_discovery_id_fk", :column => "discovery_id"
14
11
 
15
12
  # turn on Foreign Key checks in MySQL only