foreman_discovery 9.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/discovered_hosts_controller.rb +6 -4
  3. data/app/controllers/api/v2/fact_values_controller_extensions.rb +2 -2
  4. data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +6 -1
  5. data/app/controllers/discovered_hosts_controller.rb +2 -2
  6. data/app/helpers/discovered_hosts_helper.rb +5 -0
  7. data/app/models/discovery_attribute_set.rb +1 -1
  8. data/app/models/discovery_rule.rb +1 -1
  9. data/app/models/host/discovered.rb +3 -2
  10. data/app/models/host/managed_extensions.rb +10 -5
  11. data/app/services/foreman_discovery/host_converter.rb +0 -2
  12. data/app/views/api/v2/discovery_rules/main.json.rabl +12 -0
  13. data/app/views/discovered_hosts/_discovered_host_modal.html.erb +2 -2
  14. data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +5 -5
  15. data/app/views/discovered_hosts/edit.html.erb +3 -0
  16. data/app/views/discovery_rules/_form.html.erb +1 -1
  17. data/app/views/discovery_rules/index.html.erb +2 -2
  18. data/app/views/foreman_discovery/debian_kexec.erb +1 -0
  19. data/app/views/foreman_discovery/redhat_kexec.erb +1 -0
  20. data/config/routes.rb +3 -3
  21. data/db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb +1 -1
  22. data/db/migrate/20160818091421_add_permissions_from_default_roles.rb +1 -7
  23. data/db/seeds.d/50_discovery_templates.rb +2 -2
  24. data/db/seeds.d/60_discovery_proxy_feature.rb +2 -2
  25. data/db/seeds.d/70_discovery_mail_notification.rb +1 -1
  26. data/db/seeds.d/90_add_permissions_from_default_roles.rb +12 -0
  27. data/lib/foreman_discovery/engine.rb +3 -2
  28. data/lib/foreman_discovery/version.rb +1 -1
  29. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  30. data/locale/ca/foreman_discovery.edit.po +37 -28
  31. data/locale/ca/foreman_discovery.po +14 -8
  32. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  33. data/locale/de/foreman_discovery.edit.po +38 -29
  34. data/locale/de/foreman_discovery.po +15 -9
  35. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  36. data/locale/en/foreman_discovery.edit.po +62 -38
  37. data/locale/en/foreman_discovery.po +27 -9
  38. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  39. data/locale/en_GB/foreman_discovery.edit.po +37 -28
  40. data/locale/en_GB/foreman_discovery.po +14 -8
  41. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  42. data/locale/es/foreman_discovery.edit.po +37 -28
  43. data/locale/es/foreman_discovery.po +14 -8
  44. data/locale/foreman_discovery.pot +63 -41
  45. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  46. data/locale/fr/foreman_discovery.edit.po +38 -29
  47. data/locale/fr/foreman_discovery.po +15 -9
  48. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  49. data/locale/gl/foreman_discovery.edit.po +36 -27
  50. data/locale/gl/foreman_discovery.po +14 -8
  51. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  52. data/locale/it/foreman_discovery.edit.po +37 -28
  53. data/locale/it/foreman_discovery.po +14 -8
  54. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  55. data/locale/ja/foreman_discovery.edit.po +37 -28
  56. data/locale/ja/foreman_discovery.po +14 -8
  57. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  58. data/locale/ko/foreman_discovery.edit.po +37 -28
  59. data/locale/ko/foreman_discovery.po +14 -8
  60. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  61. data/locale/pt_BR/foreman_discovery.edit.po +37 -28
  62. data/locale/pt_BR/foreman_discovery.po +14 -8
  63. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  64. data/locale/ru/foreman_discovery.edit.po +37 -28
  65. data/locale/ru/foreman_discovery.po +14 -8
  66. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  67. data/locale/sv_SE/foreman_discovery.edit.po +36 -27
  68. data/locale/sv_SE/foreman_discovery.po +14 -8
  69. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  70. data/locale/zh_CN/foreman_discovery.edit.po +37 -28
  71. data/locale/zh_CN/foreman_discovery.po +14 -8
  72. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  73. data/locale/zh_TW/foreman_discovery.edit.po +37 -28
  74. data/locale/zh_TW/foreman_discovery.po +14 -8
  75. data/test/factories/discovery_host_related.rb +26 -0
  76. data/test/factories/discovery_rule_related.rb +0 -27
  77. data/test/functional/api/v2/discovered_hosts_controller_test.rb +8 -6
  78. data/test/functional/api/v2/discovery_rules_controller_test.rb +5 -2
  79. data/test/functional/api/v2/fact_value_extensions_test.rb +2 -2
  80. data/test/functional/discovered_hosts_controller_test.rb +114 -78
  81. data/test/functional/discovery_rules_controller_test.rb +1 -1
  82. data/test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb +0 -1
  83. data/test/test_helper_discovery.rb +42 -6
  84. data/test/test_plugin_helper.rb +2 -0
  85. data/test/unit/discovered_extensions_test.rb +55 -10
  86. data/test/unit/discovery_attribute_set_test.rb +1 -1
  87. data/test/unit/discovery_rule_test.rb +1 -1
  88. data/test/unit/discovery_taxonomy_extensions_test.rb +1 -1
  89. data/test/unit/fact_parser_test.rb +1 -1
  90. data/test/unit/host_discovered_test.rb +48 -3
  91. data/test/unit/managed_extensions_test.rb +76 -0
  92. data/test/unit/setting_discovered_test.rb +1 -1
  93. data/test/unit/ui_notifications/destroy_host_test.rb +0 -1
  94. metadata +25 -23
  95. data/app/models/concerns/fact_value_extensions.rb +0 -13
  96. data/test/test_helper.rb +0 -25
  97. data/test/unit/fact_value_extensions_test.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03c711025f53c06a36ba964681c0cbbe7604bae9
4
- data.tar.gz: 879d5b312293af0b221aa89269c3f53368cad5d3
3
+ metadata.gz: b8add68d8512242fea5a6faac1954c4b7ec01409
4
+ data.tar.gz: 37d4675caf253247f1a958f4c448a270af9d83ad
5
5
  SHA512:
6
- metadata.gz: 772b13ff12d09b6fd64229c9a1302940d7298c584eebd46a55fc587c093aa48eed95a43d62f04f2ce13afe68c33ad4d5752c75df9f80f11bbaaf432083b07987
7
- data.tar.gz: 1637053aa3384051c54c5096c17bf2fd8d0c2154ebfb394a16e539d49eeb2736495021a2efecee4f8430ba92a3300beeca3b59dff725dfcfc090243a339d360b
6
+ metadata.gz: 18f14ea75515d25ed150eb5afb2b5a3809a5ea97869b23de86c801948d803fd530892a249aad6aa1166fff1584f610e5465b7991cdce7671c26135bbcf7502a7
7
+ data.tar.gz: a32ed0d140eef3e1e75c427788d4ddf2806953c6edcc0dd07f12a90c9d5c8acf6b14cb5b9db7bb45232a5c9112a79f70f0e37e18cdd6652a92c1ea251bf8af1f
@@ -96,10 +96,12 @@ module Api
96
96
  def facts
97
97
  facts = params['facts']
98
98
  state = true
99
- @discovered_host = Host::Discovered.import_host(facts)
100
- Rails.logger.warn "Discovered facts import unsuccessful, skipping auto provisioning" unless @discovered_host
101
- if Setting['discovery_auto'] && @discovered_host && rule = find_discovery_rule(@discovered_host)
102
- state = perform_auto_provision(@discovered_host, rule)
99
+ User.as_anonymous_admin do
100
+ @discovered_host = Host::Discovered.import_host(facts)
101
+ Rails.logger.warn 'Discovered facts import unsuccessful, skipping auto provisioning' unless @discovered_host
102
+ if Setting['discovery_auto'] && @discovered_host && (rule = find_discovery_rule(@discovered_host))
103
+ state = perform_auto_provision(@discovered_host, rule)
104
+ end
103
105
  end
104
106
  process_response state
105
107
  rescue Exception => e
@@ -4,8 +4,8 @@ module Api
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- api :GET, "/discovered_hosts/:discovered_host_id/facts/", N_("List all fact values of a given discovered host")
7
+ api :GET, "/discovered_hosts/:host_id/facts/", N_("List all fact values of a given discovered host")
8
8
  end
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -58,7 +58,12 @@ module Foreman::Controller::DiscoveredExtensions
58
58
  host.attributes = host.apply_inherited_attributes(hostgroup_id: rule.hostgroup_id)
59
59
  host.set_hostgroup_defaults
60
60
  # save! does not work here
61
- host.save ? host : false
61
+ if host.save
62
+ host
63
+ else
64
+ Rails.logger.error "Auto provisioning failed: #{host.errors.full_messages.to_sentence}"
65
+ false
66
+ end
62
67
  end
63
68
 
64
69
  def perform_reboot_all hosts = Host::Discovered.all
@@ -56,7 +56,7 @@ class DiscoveredHostsController < ::ApplicationController
56
56
  if params[:quick_submit]
57
57
  perform_update(@host, _('Successfully provisioned %s') % @host.name)
58
58
  else
59
- render :template => 'hosts/edit'
59
+ render :template => 'discovered_hosts/edit'
60
60
  end
61
61
  end
62
62
 
@@ -78,7 +78,7 @@ class DiscoveredHostsController < ::ApplicationController
78
78
  taxonomy_scope
79
79
  load_vars_for_ajax
80
80
  offer_to_overwrite_conflicts
81
- process_error :object => host, :render => 'hosts/edit'
81
+ process_error :object => host, :render => 'discovered_hosts/edit'
82
82
  end
83
83
  end
84
84
  end
@@ -95,4 +95,9 @@ module DiscoveredHostsHelper
95
95
  :toggle => 'modal',
96
96
  :target => "#fixedPropertiesSelector-#{host.id}"})
97
97
  end
98
+
99
+ def host_path(host)
100
+ return super unless controller_name == 'discovered_hosts'
101
+ discovered_host_path(host)
102
+ end
98
103
  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
@@ -169,8 +169,9 @@ class Host::Discovered < ::Host::Base
169
169
  facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url).facter
170
170
  self.class.import_host facts
171
171
  import_facts facts
172
- rescue Exception => e
173
- raise _("Could not get facts from proxy %{url}: %{error}") % {:url => proxy_url, :error => e}
172
+ rescue => e
173
+ ::Foreman::Logging.exception("Unable to get facts from proxy", e)
174
+ raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url, :error => e)
174
175
  end
175
176
 
176
177
  def reboot legacy_api = ForemanDiscovery::HostConverter.legacy_host(self)
@@ -32,7 +32,8 @@ module Host::ManagedExtensions
32
32
  # continue. If flash is implemented for new hosts (http://projects.theforeman.org/issues/10559)
33
33
  # we can report the error to the user perhaps.
34
34
  true
35
- rescue ::Foreman::Exception
35
+ rescue ::Foreman::Exception => e
36
+ Foreman::Logging.exception("Unable to reboot", e)
36
37
  true
37
38
  end
38
39
 
@@ -44,11 +45,15 @@ module Host::ManagedExtensions
44
45
  template = provisioning_template(:kind => 'kexec')
45
46
  raise ::Foreman::Exception.new(N_("Kexec template not associated with operating system")) unless template
46
47
  @host = self
47
- @kexec_kernel, @kexec_initrd = operatingsystem.boot_files_uri(@host.medium, @host.architecture)
48
- json = unattended_render(template)
49
- old.becomes(Host::Discovered).kexec json
48
+ @kexec_kernel, @kexec_initrd = operatingsystem.boot_files_uri(@host.medium, @host.architecture, @host)
49
+ # try to parse JSON and error out early
50
+ json = JSON.parse(unattended_render(template))
51
+ ::Foreman::Exception.new(N_("Kernel kexec URL is invalid: '%s'"), json['kernel']) unless json['kernel'] =~ /\Ahttp.+\Z/
52
+ ::Foreman::Exception.new(N_("Init RAM kexec URL is invalid: '%s'"), json['initrd']) unless json['initrd'] =~ /\Ahttp.+\Z/
53
+ old.becomes(Host::Discovered).kexec json.to_s
50
54
  true
51
- rescue ::Foreman::Exception
55
+ rescue ::Foreman::Exception => e
56
+ Foreman::Logging.exception("Unable to kexec", e)
52
57
  true
53
58
  end
54
59
 
@@ -5,9 +5,7 @@ class ForemanDiscovery::HostConverter
5
5
  # Creates shallow copy.
6
6
  def self.to_managed(original_host, set_managed = true, set_build = true, added_attributes = {})
7
7
  host = original_host.becomes(::Host::Managed)
8
- host.clear_association_cache
9
8
  host.type = 'Host::Managed'
10
-
11
9
  host.attributes = host.apply_inherited_attributes(added_attributes)
12
10
  host.set_hostgroup_defaults if host.hostgroup_id.present?
13
11
 
@@ -8,3 +8,15 @@ attribute :max_count => :hosts_limit
8
8
  child :hosts do
9
9
  extends "api/v2/discovered_hosts/base"
10
10
  end
11
+
12
+ if SETTINGS[:organizations_enabled]
13
+ child :organizations => :organizations do
14
+ attributes :id, :name
15
+ end
16
+ end
17
+
18
+ if SETTINGS[:locations_enabled]
19
+ child :locations => :locations do
20
+ attributes :id, :name
21
+ end
22
+ end
@@ -21,8 +21,8 @@
21
21
  </div>
22
22
  <div class="modal-footer">
23
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') %>" />
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
26
  </div>
27
27
  <% end %>
28
28
  </div>
@@ -1,5 +1,5 @@
1
- <%= javascript "jquery.cookie", "host_checkbox" %>
2
- <% title _('Discovered hosts') %>
1
+ <%= javascript "host_checkbox" %>
2
+ <% title _('Discovered Hosts') %>
3
3
  <table class="table table-bordered table-striped table-condensed" >
4
4
  <tr>
5
5
  <th class="ca"><%= check_box_tag "check_all", "", false, { :onclick => "toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
@@ -8,8 +8,8 @@
8
8
  <th class="hidden-tablet hidden-xs"><%= sort :ip, :as => _('IP Address') %></th>
9
9
  <th class="hidden-tablet hidden-xs"><%= sort :cpu_count, :as => _('CPUs') %></th>
10
10
  <th class="hidden-tablet hidden-xs"><%= sort :memory, :as => _('Memory') %></th>
11
- <th class="hidden-tablet hidden-xs"><%= sort :disk_count, :as => _('Disk count') %></th>
12
- <th class="hidden-tablet hidden-xs"><%= sort :disks_size, :as => _('Disks size') %></th>
11
+ <th class="hidden-tablet hidden-xs"><%= sort :disk_count, :as => _('Disk Count') %></th>
12
+ <th class="hidden-tablet hidden-xs"><%= sort :disks_size, :as => _('Disks Size') %></th>
13
13
  <% Setting::Discovered.discovery_fact_column_array.each do |fact_column| %>
14
14
  <th class="hidden-tablet hidden-xs"><%= fact_column.capitalize %></th>
15
15
  <% end %>
@@ -20,7 +20,7 @@
20
20
  <th class="hidden-tablet hidden-xs"><%= sort :organization, :as => _('Organization') %></th>
21
21
  <% end -%>
22
22
  <th class="hidden-tablet hidden-xs"><%= sort :subnet, :as => _("Subnet") %></th>
23
- <th class="hidden-tablet hidden-xs"><%= sort :last_report, :as => _("Last facts upload") %></th>
23
+ <th class="hidden-tablet hidden-xs"><%= sort :last_report, :as => _("Last Facts Upload") %></th>
24
24
  <th></th>
25
25
  </tr>
26
26
  <% @hosts.each do |host| -%>
@@ -0,0 +1,3 @@
1
+ <% title(_("Provision %s") % @host) %>
2
+
3
+ <%= render :partial => 'hosts/form' %>
@@ -23,7 +23,7 @@
23
23
  <%= text_f f, :hostname,
24
24
  :label_help => render('discovery_rules/template_inline').html_safe,
25
25
  :label_help_options => {:title => _("Hostname for provisioned hosts"), :'data-placement' => 'bottom' } %>
26
- <%= number_f f, :max_count, :label => _('Hosts limit'), :help_inline => _('Maximum hosts provisioned with this rule (0 = unlimited)'), :min => 0, :max => (2**31 - 1) %>
26
+ <%= number_f f, :max_count, :label => _('Hosts Limit'), :help_inline => _('Maximum hosts provisioned with this rule (0 = unlimited)'), :min => 0, :max => (2**31 - 1) %>
27
27
  <%= number_f f, :priority, :help_inline => _('Rule priority (lower integer means higher priority)'), :min => 0, :max => (2**31 - 1) %>
28
28
  <%= checkbox_f f, :enabled %>
29
29
  </div>
@@ -6,8 +6,8 @@
6
6
  <th><%= sort :name, :as => s_("DiscoveryRule|Name") %></th>
7
7
  <th><%= sort :priority, :as => s_("DiscoveryRule|Priority") %></th>
8
8
  <th><%= sort :search, :as => s_("DiscoveryRule|Query") %></th>
9
- <th><%= _("Host group") %></th>
10
- <th><%= _("Hosts/limit") %></th>
9
+ <th><%= _("Host Group") %></th>
10
+ <th><%= _("Hosts/Limit") %></th>
11
11
  <th><%= sort :enabled, :as => s_("DiscoveryRule|Enabled") %></th>
12
12
  <th></th>
13
13
  </tr>
@@ -31,6 +31,7 @@ Please read kexec(8) man page for more information about semantics.
31
31
  options << "locale=#{@host.params['lang'] || 'en_US'}"
32
32
  -%>
33
33
  {
34
+ "comment": "WARNING: Both kernel and initram are not set in preview mode due to http://projects.theforeman.org/issues/19737",
34
35
  "kernel": "<%= @kexec_kernel %>",
35
36
  "initram": "<%= @kexec_initrd %>",
36
37
  "append": "url=<%= foreman_url('provision') + "&static=yes" %> interface=<%= mac %> netcfg/get_ipaddress=<%= ip %> netcfg/get_netmask=<%= mask %> netcfg/get_gateway=<%= gw %> netcfg/get_nameservers=<%= dns %> netcfg/disable_dhcp=true netcfg/get_hostname=<%= @host.name %> BOOTIF=<%= bootif %> <%= options.join(' ') %>",
@@ -37,6 +37,7 @@ Please read kexec(8) man page for more information about semantics.
37
37
  append = @host.facts['append']
38
38
  -%>
39
39
  {
40
+ "comment": "WARNING: Both kernel and initram are not set in preview mode due to http://projects.theforeman.org/issues/19737",
40
41
  "kernel": "<%= @kexec_kernel %>",
41
42
  "initram": "<%= @kexec_initrd %>",
42
43
  <% if (@host.operatingsystem.name == 'Fedora' and @host.operatingsystem.major.to_i > 16) or
data/config/routes.rb CHANGED
@@ -14,11 +14,11 @@ Rails.application.routes.draw do
14
14
  post 'auto_provision'
15
15
  end
16
16
  collection do
17
- get 'multiple_destroy'
17
+ post 'multiple_destroy'
18
18
  post 'submit_multiple_destroy'
19
- get 'select_multiple_organization'
19
+ post 'select_multiple_organization'
20
20
  post 'update_multiple_organization'
21
- get 'select_multiple_location'
21
+ post 'select_multiple_location'
22
22
  post 'update_multiple_location'
23
23
  get 'auto_complete_search'
24
24
  post 'auto_provision_all'
@@ -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,6 @@
1
1
  class AddPermissionsFromDefaultRoles < ActiveRecord::Migration
2
2
  def up
3
- default_permissions = Foreman::Plugin.find("foreman_discovery").default_roles
4
- ["Discovery Reader", "Discovery Manager"].each do |role_name|
5
- role = Role.find_by_name(role_name) || next
6
- default_permissions[role_name].each do |permission|
7
- role.add_permissions!(permission) unless role.permission_names.include?(permission.to_sym)
8
- end
9
- end
3
+ # Moved to seeds see http://projects.theforeman.org/issues/17585
10
4
  end
11
5
 
12
6
  def down
@@ -1,9 +1,9 @@
1
- kind = TemplateKind.where(:name => 'kexec').first_or_create
1
+ kind = TemplateKind.unscoped.where(:name => 'kexec').first_or_create
2
2
 
3
3
  ProvisioningTemplate.without_auditing do
4
4
  [['redhat_kexec.erb', 'Red Hat'], ['debian_kexec.erb', 'Debian']].each do |tmpl_names|
5
5
  content = File.read(File.join(ForemanDiscovery::Engine.root, 'app', 'views', 'foreman_discovery', tmpl_names[0]))
6
- tmpl = ProvisioningTemplate.where(:name => "Discovery #{tmpl_names[1]} kexec").first_or_create(
6
+ tmpl = ProvisioningTemplate.unscoped.where(:name => "Discovery #{tmpl_names[1]} kexec").first_or_create(
7
7
  :template_kind_id => kind.id,
8
8
  :snippet => false,
9
9
  :template => content
@@ -1,2 +1,2 @@
1
- f = Feature.where(:name => 'Discovery').first_or_create
2
- raise "Unable to create proxy feature: #{format_errors f}" if f.nil? || f.errors.any?
1
+ f = Feature.unscoped.where(:name => 'Discovery').first_or_create
2
+ raise "Unable to create proxy feature: #{format_errors f}" if f.nil? || f.errors.any?
@@ -6,4 +6,4 @@ discovery_mail_notification = {
6
6
  :subscription_type => 'report',
7
7
  }
8
8
 
9
- MailNotification.where(discovery_mail_notification).first_or_create
9
+ MailNotification.unscoped.where(discovery_mail_notification).first_or_create
@@ -0,0 +1,12 @@
1
+ default_permissions = Foreman::Plugin.find("foreman_discovery").default_roles
2
+
3
+ ["Discovery Reader", "Discovery Manager"].each do |role_name|
4
+ role = Role.find_by_name(role_name) || next
5
+ default_permissions[role_name].each do |permission|
6
+ role.add_permissions!(permission) unless role.permission_names.include?(permission.to_sym)
7
+ end
8
+ role.ignore_locking do |r|
9
+ r.update_attributes :origin => "discovery", :description => "Discovery plugin built-in role"
10
+ end
11
+ role.save!
12
+ end
@@ -164,10 +164,12 @@ module ForemanDiscovery
164
164
  # add dashboard widget
165
165
  widget 'discovery_widget', :name=>N_('Discovered Hosts'), :sizex => 6, :sizey =>1
166
166
 
167
- # add template helpers
167
+ # allowed helpers and variables
168
168
  allowed_template_helpers :rand
169
169
  allowed_template_variables :kexec_kernel, :kexec_initrd
170
170
 
171
+ template_labels 'kexec' => N_('Discovery Kexec template')
172
+
171
173
  # apipie API documentation
172
174
  # Only available in 1.8, otherwise it has to be in the initializer below
173
175
  apipie_documented_controllers ["#{ForemanDiscovery::Engine.root}/app/controllers/api/v2/*.rb"]
@@ -200,7 +202,6 @@ module ForemanDiscovery
200
202
  # Model extensions
201
203
  ::Host::Managed.send :include, Host::ManagedExtensions
202
204
  ::Hostgroup.send :include, HostgroupExtensions
203
- ::FactValue.send :include, FactValueExtensions
204
205
  ::Nic::Managed.send :include, Nic::ManagedExtensions
205
206
 
206
207
  # Controller extensions
@@ -1,3 +1,3 @@
1
1
  module ForemanDiscovery
2
- VERSION = "9.0.0"
2
+ VERSION = "9.1.0"
3
3
  end
@@ -6,10 +6,10 @@
6
6
  # Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2015-2016
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 8.0.0\n"
9
+ "Project-Id-Version: foreman_discovery 9.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2017-01-06 08:26+0100\n"
12
- "PO-Revision-Date: 2017-01-06 08:44+0000\n"
11
+ "POT-Creation-Date: 2017-04-07 13:02+0200\n"
12
+ "PO-Revision-Date: 2017-04-08 10:07+0000\n"
13
13
  "Last-Translator: Lukáš Zapletal\n"
14
14
  "Language-Team: Catalan (http://www.transifex.com/foreman/foreman/language/ca/)\n"
15
15
  "MIME-Version: 1.0\n"
@@ -366,6 +366,7 @@ msgid "%s - The following hosts are about to be changed"
366
366
  msgstr "%s - Els següents amfitrions estan a punt de ser canviats"
367
367
 
368
368
  #: ../app/helpers/discovered_hosts_helper.rb:49
369
+ #: ../app/views/dashboard/_discovery_widget_host.html.erb:2
369
370
  msgid "N/A"
370
371
  msgstr "N/D"
371
372
 
@@ -386,7 +387,7 @@ msgid "Provision"
386
387
  msgstr "Aprovisiona"
387
388
 
388
389
  #: ../app/helpers/discovery_rules_helper.rb:26
389
- #: ../lib/foreman_discovery/engine.rb:163
390
+ #: ../lib/foreman_discovery/engine.rb:165
390
391
  msgid "Discovered Hosts"
391
392
  msgstr ""
392
393
 
@@ -445,43 +446,43 @@ msgid_plural ""
445
446
  msgstr[0] ""
446
447
  msgstr[1] ""
447
448
 
448
- #: ../app/models/host/discovered.rb:38
449
+ #: ../app/models/host/discovered.rb:37
449
450
  msgid "Invalid facts, must be a Hash"
450
451
  msgstr "Objectes d'interès no vàlids, han de tenir un Hash"
451
452
 
452
- #: ../app/models/host/discovered.rb:43
453
+ #: ../app/models/host/discovered.rb:42
453
454
  msgid ""
454
455
  "Expected discovery_fact '%s' is missing, unable to detect primary interface "
455
456
  "and set hostname"
456
457
  msgstr ""
457
458
 
458
- #: ../app/models/host/discovered.rb:50
459
+ #: ../app/models/host/discovered.rb:49
459
460
  msgid ""
460
461
  "Invalid facts: hash does not contain a valid value for any of the facts in "
461
462
  "the discovery_hostname setting: %s"
462
463
  msgstr ""
463
464
 
464
- #: ../app/models/host/discovered.rb:67
465
+ #: ../app/models/host/discovered.rb:66
465
466
  msgid "Facts could not be imported"
466
467
  msgstr ""
467
468
 
468
- #: ../app/models/host/discovered.rb:117
469
+ #: ../app/models/host/discovered.rb:116
469
470
  msgid "Unable to assign subnet, primary interface is missing IP address"
470
471
  msgstr ""
471
472
 
472
- #: ../app/models/host/discovered.rb:174
473
+ #: ../app/models/host/discovered.rb:173
473
474
  msgid "Could not get facts from proxy %{url}: %{error}"
474
475
  msgstr "No s'han pogut obtenir els objectes d'interès del servidor intermediari %{url}: %{error}"
475
476
 
476
- #: ../app/models/host/discovered.rb:190
477
+ #: ../app/models/host/discovered.rb:189
477
478
  msgid "Unable to reboot %{name} via %{url}: %{msg}"
478
479
  msgstr "No es pot reiniciar %{name} a través de %{url}: %{msg}"
479
480
 
480
- #: ../app/models/host/discovered.rb:198
481
+ #: ../app/models/host/discovered.rb:197
481
482
  msgid "Unable to perform kexec on %{name} via %{url}: %{msg}"
482
483
  msgstr "No es pot realitzar kexec a %{name} a través de %{url}: %{msg}"
483
484
 
484
- #: ../app/models/host/discovered.rb:217
485
+ #: ../app/models/host/discovered.rb:216
485
486
  msgid "Invalid hostname: Could not normalize the hostname"
486
487
  msgstr ""
487
488
 
@@ -718,7 +719,7 @@ msgid "Create host"
718
719
  msgstr ""
719
720
 
720
721
  #: ../app/views/discovered_hosts/_discovered_hosts_list.html.erb:2
721
- #: ../lib/foreman_discovery/engine.rb:148
722
+ #: ../lib/foreman_discovery/engine.rb:150
722
723
  msgid "Discovered hosts"
723
724
  msgstr "Amfitrions descoberts"
724
725
 
@@ -881,23 +882,19 @@ msgstr "Organitzacions"
881
882
  msgid "Target host group for this rule with all properties set"
882
883
  msgstr ""
883
884
 
884
- #: ../app/views/discovery_rules/_form.html.erb:24
885
- msgid "Template"
886
- msgstr "Plantilla"
887
-
888
- #: ../app/views/discovery_rules/_form.html.erb:26
885
+ #: ../app/views/discovery_rules/_form.html.erb:25
889
886
  msgid "Hostname for provisioned hosts"
890
887
  msgstr "Nom d'amfitrió per als amfitrions aprovisionats"
891
888
 
892
- #: ../app/views/discovery_rules/_form.html.erb:27
889
+ #: ../app/views/discovery_rules/_form.html.erb:26
893
890
  msgid "Hosts limit"
894
891
  msgstr "Límit d'amfitrions"
895
892
 
896
- #: ../app/views/discovery_rules/_form.html.erb:27
893
+ #: ../app/views/discovery_rules/_form.html.erb:26
897
894
  msgid "Maximum hosts provisioned with this rule (0 = unlimited)"
898
895
  msgstr "Nombre màxim d'amfitrions aprovisionats amb aquesta regla (0 = il·limitat)"
899
896
 
900
- #: ../app/views/discovery_rules/_form.html.erb:28
897
+ #: ../app/views/discovery_rules/_form.html.erb:27
901
898
  msgid "Rule priority (lower integer means higher priority)"
902
899
  msgstr ""
903
900
 
@@ -940,8 +937,8 @@ msgid "Discovery Rules"
940
937
  msgstr "Regles de descobriment"
941
938
 
942
939
  #: ../app/views/discovery_rules/index.html.erb:2
943
- msgid "New Rule"
944
- msgstr "Nova regla"
940
+ msgid "Create Rule"
941
+ msgstr ""
945
942
 
946
943
  #: ../app/views/discovery_rules/index.html.erb:6
947
944
  msgid "DiscoveryRule|Name"
@@ -975,21 +972,33 @@ msgstr "Nova regla de descobriment"
975
972
  msgid "A summary of discovered hosts"
976
973
  msgstr ""
977
974
 
978
- #: ../lib/foreman_discovery/engine.rb:153
975
+ #: ../db/seeds.d/80_discovery_ui_notification.rb:4
976
+ msgid "Hosts"
977
+ msgstr ""
978
+
979
+ #: ../db/seeds.d/80_discovery_ui_notification.rb:6
980
+ msgid "One or more hosts have been discovered"
981
+ msgstr ""
982
+
983
+ #: ../db/seeds.d/80_discovery_ui_notification.rb:13
984
+ msgid "Details"
985
+ msgstr ""
986
+
987
+ #: ../lib/foreman_discovery/engine.rb:155
979
988
  msgid "Discovery rules"
980
989
  msgstr "Regles de descobriment"
981
990
 
982
- #: ../lib/foreman_discovery/engine.rb:176
991
+ #: ../lib/foreman_discovery/engine.rb:178
983
992
  msgid "Discovery Proxy"
984
993
  msgstr ""
985
994
 
986
- #: ../lib/foreman_discovery/engine.rb:177
995
+ #: ../lib/foreman_discovery/engine.rb:179
987
996
  msgid ""
988
997
  "Discovery Proxy to use within this subnet for managing connection to "
989
998
  "discovered hosts"
990
999
  msgstr ""
991
1000
 
992
- #: ../lib/foreman_discovery/engine.rb:178
1001
+ #: ../lib/foreman_discovery/engine.rb:180
993
1002
  msgid ""
994
1003
  "ID of Discovery Proxy to use within this subnet for managing connection to "
995
1004
  "discovered hosts"