foreman_discovery 5.0.2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/discovered_hosts_controller.rb +4 -7
- data/app/controllers/api/v2/discovery_rules_controller.rb +1 -0
- data/app/controllers/api/v2/fact_values_controller_extensions.rb +11 -0
- data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +6 -3
- data/app/controllers/discovered_hosts_controller.rb +46 -11
- data/app/controllers/discovery_rules_controller.rb +1 -1
- data/app/helpers/discovered_hosts_helper.rb +33 -16
- data/app/models/concerns/discovery_taxonomy_extensions.rb +7 -0
- data/app/models/concerns/fact_value_extensions.rb +8 -0
- data/app/models/discovery_rule.rb +4 -6
- data/app/models/host/discovered.rb +29 -10
- data/app/models/host/managed_extensions.rb +2 -10
- data/app/models/setting/discovered.rb +22 -28
- data/app/services/foreman_discovery/host_converter.rb +19 -10
- data/app/views/api/v2/discovered_hosts/main.json.rabl +1 -1
- data/app/views/dashboard/_discovery_widget_host.html.erb +1 -1
- data/app/views/discovered_hosts/_discovered_host.html.erb +1 -1
- data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +32 -1
- data/app/views/discovered_hosts/index.html.erb +2 -2
- data/app/views/discovered_hosts/show.html.erb +5 -5
- data/app/views/discovered_mailer/_discovered_host.html.erb +1 -1
- data/app/views/discovered_mailer/discovered_summary.text.erb +2 -2
- data/app/views/discovery_rules/_form.html.erb +2 -19
- data/app/views/discovery_rules/_template_inline.erb +10 -0
- data/app/views/discovery_rules/index.html.erb +1 -1
- data/app/views/foreman_discovery/debian_kexec.erb +34 -0
- data/app/views/foreman_discovery/redhat_kexec.erb +5 -4
- data/config/routes.rb +4 -0
- data/db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb +15 -1
- data/db/migrate/20160719124942_add_missing_view_permissions.rb +18 -0
- data/db/seeds.d/50_discovery_templates.rb +15 -13
- data/lib/discovery.rake +1 -0
- data/lib/foreman_discovery/engine.rb +24 -10
- data/lib/foreman_discovery/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ca/foreman_discovery.edit.po +274 -136
- data/locale/ca/foreman_discovery.po +396 -328
- data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/de/foreman_discovery.edit.po +309 -171
- data/locale/de/foreman_discovery.po +419 -361
- data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en/foreman_discovery.edit.po +881 -0
- data/locale/en/foreman_discovery.po +665 -0
- data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en_GB/foreman_discovery.edit.po +279 -141
- data/locale/en_GB/foreman_discovery.po +446 -391
- data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/es/foreman_discovery.edit.po +277 -139
- data/locale/es/foreman_discovery.po +415 -362
- data/locale/foreman_discovery.pot +241 -135
- data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/fr/foreman_discovery.edit.po +289 -151
- data/locale/fr/foreman_discovery.po +439 -411
- data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/gl/foreman_discovery.edit.po +266 -128
- data/locale/gl/foreman_discovery.po +320 -246
- data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/it/foreman_discovery.edit.po +277 -139
- data/locale/it/foreman_discovery.po +407 -352
- data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ja/foreman_discovery.edit.po +279 -141
- data/locale/ja/foreman_discovery.po +411 -339
- data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ko/foreman_discovery.edit.po +277 -139
- data/locale/ko/foreman_discovery.po +411 -339
- data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/pt_BR/foreman_discovery.edit.po +282 -144
- data/locale/pt_BR/foreman_discovery.po +430 -394
- data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ru/foreman_discovery.edit.po +371 -232
- data/locale/ru/foreman_discovery.po +448 -385
- data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/sv_SE/foreman_discovery.edit.po +270 -132
- data/locale/sv_SE/foreman_discovery.po +336 -260
- data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_CN/foreman_discovery.edit.po +279 -141
- data/locale/zh_CN/foreman_discovery.po +412 -336
- data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_TW/foreman_discovery.edit.po +279 -141
- data/locale/zh_TW/foreman_discovery.po +412 -338
- data/test/functional/api/v2/discovered_hosts_controller_test.rb +30 -22
- data/test/functional/api/v2/discovery_rules_controller_test.rb +7 -0
- data/test/functional/api/v2/fact_value_extensions_test.rb +37 -0
- data/test/functional/discovered_hosts_controller_test.rb +89 -16
- data/test/functional/discovery_rules_controller_test.rb +1 -1
- data/test/test_helper_discovery.rb +1 -1
- data/test/unit/discovered_extensions_test.rb +65 -21
- data/test/unit/discovery_attribute_set_test.rb +4 -4
- data/test/unit/discovery_taxonomy_extensions_test.rb +31 -0
- data/test/unit/host_discovered_test.rb +110 -14
- metadata +121 -110
- data/app/helpers/concerns/foreman_discovery/settings_helper_extensions.rb +0 -34
@@ -2,6 +2,7 @@ class ForemanDiscovery::HostConverter
|
|
2
2
|
|
3
3
|
# Converts discovered host to managed host without uptading the database.
|
4
4
|
# Record must be saved explicitly (using save! or update_attributes! or similar).
|
5
|
+
# Creates shallow copy.
|
5
6
|
def self.to_managed(original_host, set_managed = true, set_build = true)
|
6
7
|
host = original_host.becomes(::Host::Managed)
|
7
8
|
host.type = 'Host::Managed'
|
@@ -11,18 +12,26 @@ class ForemanDiscovery::HostConverter
|
|
11
12
|
host.primary_interface.managed = set_managed
|
12
13
|
end
|
13
14
|
# set build only and only on final save (facts are deleted)
|
14
|
-
if set_build
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
set_build_clean_facts(host) if set_build
|
16
|
+
host
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.set_build_clean_facts(host)
|
20
|
+
# set legacy_api flag for post_queue actions
|
21
|
+
host.legacy_api = self.legacy_host(host)
|
22
|
+
# fact cleaning
|
23
|
+
if Setting['discovery_clean_facts']
|
24
|
+
# clean all facts except those starting with "discovery_"
|
25
|
+
host.define_singleton_method(:clear_facts) do
|
26
|
+
keep_ids = FactValue.where("host_id = #{host.id}").joins(:fact_name).where("fact_names.name like 'discovery_%'").pluck("fact_values.id")
|
27
|
+
FactValue.where("host_id = #{host.id} and id not in (?)", keep_ids).delete_all
|
21
28
|
end
|
22
|
-
|
23
|
-
|
29
|
+
else
|
30
|
+
# clean no facts (default behavior)
|
31
|
+
host.define_singleton_method(:clear_facts) {}
|
24
32
|
end
|
25
|
-
|
33
|
+
# set build flag
|
34
|
+
host.build = true
|
26
35
|
end
|
27
36
|
|
28
37
|
def self.legacy_host(host)
|
@@ -2,7 +2,7 @@ object @discovered_host
|
|
2
2
|
|
3
3
|
extends "api/v2/discovered_hosts/base"
|
4
4
|
|
5
|
-
attributes :ip, :mac, :last_report, :subnet_id, :subnet_name, :
|
5
|
+
attributes :ip, :mac, :last_report, :subnet_id, :subnet_name, :hardware_model_name, :memory, :disk_count, :disks_size
|
6
6
|
attribute :cpu_count => :cpus
|
7
7
|
|
8
8
|
if SETTINGS[:organizations_enabled]
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<td><%= discovery_status_icon(host) %> <%= link_to trunc_with_tooltip(h(host.name)), discovered_host_path(host) %></td>
|
2
|
-
<td class="hidden-tablet hidden-xs"><%=
|
2
|
+
<td class="hidden-tablet hidden-xs"><%= host.try(:hardware_model_name) || 'N/A' %></td>
|
3
3
|
<td class="hidden-tablet hidden-xs"><%= discovery_attribute(host, :cpu_count) %></td>
|
4
4
|
<td class="hidden-tablet hidden-xs"><%= number_to_human_size(discovery_attribute(host, :memory, 0) * 1024 * 1024) %></td>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<td><%= discovery_status_icon(host) %> <%= link_to trunc_with_tooltip(h(host.name)), discovered_host_path(host) %></td>
|
2
|
-
<td class="hidden-tablet hidden-xs"><%=
|
2
|
+
<td class="hidden-tablet hidden-xs"><%= host.try(:hardware_model_name) || 'N/A' %></td>
|
3
3
|
<td class="hidden-tablet hidden-xs"><%= host.ip %></td>
|
4
4
|
<td class="hidden-tablet hidden-xs"><%= discovery_attribute(host, :cpu_count) %></td>
|
5
5
|
<td class="hidden-tablet hidden-xs"><%= number_to_human_size(discovery_attribute(host, :memory, 0) * 1024 * 1024) %></td>
|
@@ -38,8 +38,39 @@
|
|
38
38
|
<td class="hidden-tablet hidden-xs"><%= host.primary_interface.try(:subnet) %></td>
|
39
39
|
<td class="hidden-tablet hidden-xs"><%= disc_report_column(host) %></td>
|
40
40
|
<td>
|
41
|
+
<!-- Modal -->
|
42
|
+
<div class="modal" id="<%= "fixedPropertiesSelector-#{host.id}" %>" tabindex="-1" role="dialog" aria-labelledby="fixedPropertiesSelectorLabel">
|
43
|
+
<div class="modal-dialog" role="document">
|
44
|
+
<div class="modal-content">
|
45
|
+
<%= form_for host, :url => edit_discovered_host_path(host), :method => :get do |f| %>
|
46
|
+
<div class="modal-header">
|
47
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
48
|
+
<h4 class="modal-title" id="fixedPropertiesSelectorLabel"><%= _('Select initial host properties') %></h4>
|
49
|
+
</div>
|
50
|
+
<div class="modal-body">
|
51
|
+
<%= select_f f, :hostgroup_id, accessible_hostgroups, :id, :to_label,
|
52
|
+
{ :include_blank => true },
|
53
|
+
{ :help_inline => :indicator, :size => 'col-md-10' } %>
|
54
|
+
|
55
|
+
<% if show_organization_tab? %>
|
56
|
+
<%= select_f f, :organization_id, Organization.my_organizations, :id, :to_label, {}, {:size => 'col-md-10'} %>
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
<% if show_location_tab? %>
|
60
|
+
<%= select_f f, :location_id, Location.my_locations, :id, :to_label, {}, {:size => 'col-md-10'} %>
|
61
|
+
<% end %>
|
62
|
+
</div>
|
63
|
+
<div class="modal-footer">
|
64
|
+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
65
|
+
<input type="submit" class="btn btn-default" value="<%= _('Quick create') %>" name="quick_submit"></input>
|
66
|
+
<input type="submit" class="btn btn-primary" value="<%= _('Create host') %>"></input>
|
67
|
+
</div>
|
68
|
+
<% end %>
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</div>
|
41
72
|
<%= action_buttons(
|
42
|
-
|
73
|
+
provision_button(host, hash_for_edit_discovered_host_path(:id => host)),
|
43
74
|
display_link_if_authorized(_("Auto Provision"), hash_for_auto_provision_discovered_host_path(:id => host), :method => :post),
|
44
75
|
display_link_if_authorized(_("Refresh facts"), hash_for_refresh_facts_discovered_host_path(:id => host)),
|
45
76
|
display_link_if_authorized(_("Reboot"), hash_for_reboot_discovered_host_path(:id => host), :method => :put),
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<% title_actions multiple_discovered_hosts_actions_select -%>
|
2
|
-
<% title_actions display_link_if_authorized(_("Reboot All"), hash_for_reboot_all_discovered_hosts_path, {:method => :put, :disabled => @hosts.empty?}) %>
|
3
|
-
<% title_actions display_link_if_authorized(_("Auto Provision All"), hash_for_auto_provision_all_discovered_hosts_path, {:method => :post, :disabled => @hosts.empty?}) %>
|
2
|
+
<% title_actions display_link_if_authorized(_("Reboot All"), hash_for_reboot_all_discovered_hosts_path, {:class => 'btn btn-default', :method => :put, :disabled => @hosts.empty?}) %>
|
3
|
+
<% title_actions display_link_if_authorized(_("Auto Provision All"), hash_for_auto_provision_all_discovered_hosts_path, {:class => 'btn btn-default', :method => :post, :disabled => @hosts.empty?}) %>
|
4
4
|
<%= render 'discovered_hosts_list' %>
|
@@ -4,12 +4,12 @@
|
|
4
4
|
|
5
5
|
<div class="row">
|
6
6
|
<div class="col-md-6">
|
7
|
-
<div class="panel panel-default">
|
7
|
+
<div id="category-highlights" class="panel panel-default">
|
8
8
|
<div class="panel-heading" ><strong> <%= _(@categories_names[0]) %></strong> </div>
|
9
9
|
<table class="table table-bordered table-condensed table-fixed">
|
10
|
-
<% @categories[0].sort.each do |
|
11
|
-
<tr class="">
|
12
|
-
<th class="ellipsis" width="40%"> <strong> <%=
|
10
|
+
<% @categories[0].sort.each do |key, val| %>
|
11
|
+
<tr id="fact-<%= key.try(:downcase) %>" class="">
|
12
|
+
<th class="ellipsis" width="40%"> <strong> <%= key %> </strong></th>
|
13
13
|
<td><%= val %></td>
|
14
14
|
</tr>
|
15
15
|
<% end -%>
|
@@ -51,7 +51,7 @@
|
|
51
51
|
<div class="col-md-6">
|
52
52
|
<% @categories.each_with_index do |val, index| %>
|
53
53
|
<% next if index == 0 || val.empty? %>
|
54
|
-
<div class="panel panel-default">
|
54
|
+
<div id="category-<%= @categories_names[index].downcase %>" class="panel panel-default">
|
55
55
|
<div class="panel-heading" role="tab">
|
56
56
|
<h4 class="panel-title">
|
57
57
|
<a role="button" class="expendable-link" data-toggle="collapse" data-parent="#accordion" href="#<%= @categories_names[index].to_s + "panel" %>" aria-expanded="true" onclick="$(this).find(':first-child').toggleClass('glyphicon glyphicon-minus-sign glyphicon glyphicon-plus-sign')">
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<td style="<%= td_style%>">
|
3
3
|
<%= link_to host, discovered_host_path(:id => host, :host => @url.host, :port => @url.port, :only_path => false, :protocol => @url.scheme) %>
|
4
4
|
</td>
|
5
|
-
<td style="<%= td_style%>"><%= host.
|
5
|
+
<td style="<%= td_style%>"><%= host.try(:hardware_model_name) || 'N/A' %></td>
|
6
6
|
<td style="<%= td_style%>"><%= host.ip %></td>
|
7
7
|
<td style="<%= td_style%>"><%= discovery_attribute(host, :cpu_count) %></td>
|
8
8
|
<td style="<%= td_style%>"><%= number_to_human_size(discovery_attribute(host, :memory, 0) * 1024 * 1024) %></td>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
<% @discovered_hosts.each do |host| %>
|
9
9
|
<%= _('Name') %>: <%= host.to_label %>
|
10
|
-
<%= _('Model') %>: <%= host.
|
10
|
+
<%= _('Model') %>: <%= host.try(:hardware_model_name) || 'N/A' %>
|
11
11
|
<%= _('IP Address') %>: <%= host.ip %>
|
12
12
|
<%= _('CPUs') %>: <%= discovery_attribute(host, :cpu_count) %>
|
13
13
|
<%= _('Memory') %>: <%= number_to_human_size(discovery_attribute(host, :memory, 0) * 1024 * 1024) %>
|
@@ -21,4 +21,4 @@
|
|
21
21
|
<%= _('No new discovered hosts for this period') %>
|
22
22
|
<% end %>
|
23
23
|
|
24
|
-
<%=
|
24
|
+
<%= discovered_hosts_url(:host => @url.host, :port => @url.port, :only_path => false, :protocol => @url.scheme, :search => @query) %>
|
@@ -22,25 +22,8 @@
|
|
22
22
|
{ :help_inline => _('Target host group for this rule with all properties set') } %>
|
23
23
|
<%= text_f f, :hostname, :help_inline => popover(
|
24
24
|
_("Template"),
|
25
|
-
|
26
|
-
|
27
|
-
"</div>"+
|
28
|
-
"<div>" +
|
29
|
-
_("Domain will be appended automatically. A hostname based on MAC address will be used when left blank. In addition to @host attribute function rand for random integers is available. Examples:") +
|
30
|
-
"</div>"+
|
31
|
-
"<pre>"+
|
32
|
-
"myhost-<%= rand(99999) %>" + "\n\n" +
|
33
|
-
"abc-<%= @host.facts['bios_vendor'] + " + "\n" +
|
34
|
-
" '-' + rand(99999) %>" + "\n\n" +
|
35
|
-
"xyz-<%= @host.hostgroup.name %>" + "\n\n" +
|
36
|
-
"srv-<%= @host.discovery_rule.name %>" + "\n\n" +
|
37
|
-
"server-<%= @host.ip.gsub('.','-') + " + "\n" +
|
38
|
-
" '-' + @host.hostgroup.subnet.name %>" + "\n" +
|
39
|
-
"</pre>"+
|
40
|
-
"</div>"+
|
41
|
-
"<div>"+
|
42
|
-
_("When creating hostname patterns, make sure the resulting host names are unique. Hostnames must not start with numbers. A good approach is to use unique information provided by facter (MAC address, BIOS or serial ID).") +
|
43
|
-
"</div>", :title => _("Hostname for provisioned hosts")).html_safe %>
|
25
|
+
render('discovery_rules/template_inline'),
|
26
|
+
:title => _("Hostname for provisioned hosts"), :'data-placement' => 'bottom').html_safe %>
|
44
27
|
<%= text_f f, :max_count, :label => _('Hosts limit'), :help_inline => _('Maximum hosts provisioned with this rule (0 = unlimited)') %>
|
45
28
|
<%= text_f f, :priority, :help_inline => _('Rule priority (lower integer means higher priority)') %>
|
46
29
|
<%= checkbox_f f, :enabled %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div>
|
2
|
+
<%= _("Specify target hostname template pattern in the same syntax as in Provisioning Templates (ERB).") %>
|
3
|
+
</div><div>
|
4
|
+
<%= _("Domain will be appended automatically. A hostname based on MAC address will be used when left blank.") %><br/>
|
5
|
+
<%= _("In addition to @host attribute function rand for random integers is available. Examples:") %><br/>
|
6
|
+
<code>@host.facts['bios_vendor'], @host.discovery_rule.name</code> or <code>rand(9999)</code>.
|
7
|
+
</div><div>
|
8
|
+
<%= _("When creating hostname patterns, make sure the resulting host names are unique.") %><br/>
|
9
|
+
<%= _("Hostnames must not start with numbers. A good approach is to use unique information provided by facter (MAC address, BIOS or serial ID).") %>
|
10
|
+
</div>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% title _("Discovery Rules") %>
|
2
|
-
<% title_actions
|
2
|
+
<% title_actions new_link(_("New Rule")), help_path %>
|
3
3
|
|
4
4
|
<table class="table table-bordered table-striped table-two-pane">
|
5
5
|
<tr>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%#
|
2
|
+
kind: kexec
|
3
|
+
name: Debian kexec
|
4
|
+
oses:
|
5
|
+
- Debian
|
6
|
+
- Ubuntu
|
7
|
+
-%>
|
8
|
+
<%#
|
9
|
+
This template is used to pass command line options to kexec when reloading
|
10
|
+
kernel on a discovered host instead of rebooting. This is useful in PXE-less
|
11
|
+
environments. The template must generate JSON format with three items:
|
12
|
+
"kernel", "initram" and "append". Read kexec(8) man page for more
|
13
|
+
information about semantics.
|
14
|
+
-%>
|
15
|
+
<%
|
16
|
+
@kernel, @initrd = @host.operatingsystem.boot_files_uri(@host.medium, @host.architecture)
|
17
|
+
mac = @host.facts['discovery_bootif']
|
18
|
+
bootif = '00-' + mac.gsub(':', '-') rescue ''
|
19
|
+
ip_cidr = @host.facts['discovery_ip_cidr']
|
20
|
+
ip = @host.facts['discovery_ip']
|
21
|
+
mask = @host.facts['discovery_netmask']
|
22
|
+
gw = @host.facts['discovery_gateway']
|
23
|
+
dns = @host.facts['discovery_dns']
|
24
|
+
append = @host.facts['append']
|
25
|
+
options = ["auto=true"]
|
26
|
+
options << "domain=#{@host.domain}"
|
27
|
+
options << 'console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us localechooser/translation/warn-light=true localechooser/translation/warn-severe=true'
|
28
|
+
options << "locale=#{@host.params['lang'] || 'en_US'}"
|
29
|
+
-%>
|
30
|
+
{
|
31
|
+
"kernel": "<%= @kernel %>",
|
32
|
+
"initram": "<%= @initrd %>",
|
33
|
+
"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(' ') %>"
|
34
|
+
}
|
@@ -6,10 +6,10 @@ oses:
|
|
6
6
|
- CentOS 5
|
7
7
|
- CentOS 6
|
8
8
|
- CentOS 7
|
9
|
-
- Fedora 19
|
10
|
-
- Fedora 20
|
11
9
|
- Fedora 21
|
12
10
|
- Fedora 22
|
11
|
+
- Fedora 23
|
12
|
+
- Fedora 24
|
13
13
|
- RedHat 4
|
14
14
|
- RedHat 5
|
15
15
|
- RedHat 6
|
@@ -23,6 +23,7 @@ environments. The template must generate JSON format with three items:
|
|
23
23
|
information about semantics.
|
24
24
|
-%>
|
25
25
|
<%
|
26
|
+
@kernel, @initrd = @host.operatingsystem.boot_files_uri(@host.medium, @host.architecture)
|
26
27
|
mac = @host.facts['discovery_bootif']
|
27
28
|
bootif = '00-' + mac.gsub(':', '-') if mac
|
28
29
|
ip_cidr = @host.facts['discovery_ip_cidr']
|
@@ -37,8 +38,8 @@ information about semantics.
|
|
37
38
|
"initram": "<%= @initrd %>",
|
38
39
|
<% if (@host.operatingsystem.name == 'Fedora' and @host.operatingsystem.major.to_i > 16) or
|
39
40
|
(@host.operatingsystem.name != 'Fedora' and @host.operatingsystem.major.to_i >= 7) -%>
|
40
|
-
"append": "ks=<%= foreman_url('provision') + "&static=yes" %> inst.ks.sendmac <%= "ip=#{ip}::#{gw}:#{mask}:::none nameserver=#{dns} ksdevice=bootif BOOTIF=#{bootif} #{append}" %>"
|
41
|
+
"append": "ks=<%= foreman_url('provision') + "&static=yes" %> inst.ks.sendmac <%= "ip=#{ip}::#{gw}:#{mask}:::none nameserver=#{dns} ksdevice=bootif BOOTIF=#{bootif} nomodeset #{append}" %>"
|
41
42
|
<% else -%>
|
42
|
-
"append": "ks=<%= foreman_url('provision') + "&static=yes" %> kssendmac nicdelay=5 <%= "ip=#{ip} netmask=#{mask} gateway=#{gw} dns=#{dns} ksdevice=#{mac} BOOTIF=#{bootif} #{append}" %>"
|
43
|
+
"append": "ks=<%= foreman_url('provision') + "&static=yes" %> kssendmac nicdelay=5 <%= "ip=#{ip} netmask=#{mask} gateway=#{gw} dns=#{dns} ksdevice=#{mac} BOOTIF=#{bootif} nomodeset #{append}" %>"
|
43
44
|
<% end -%>
|
44
45
|
}
|
data/config/routes.rb
CHANGED
@@ -48,6 +48,10 @@ Rails.application.routes.draw do
|
|
48
48
|
post 'auto_provision_all'
|
49
49
|
put 'reboot_all'
|
50
50
|
end
|
51
|
+
|
52
|
+
constraints(:discovered_host_id => /[^\/]+/) do
|
53
|
+
resources :facts, :only => :index, :controller => :fact_values
|
54
|
+
end
|
51
55
|
end
|
52
56
|
resources :discovery_rules, :except => [:new, :edit]
|
53
57
|
end
|
@@ -1,6 +1,20 @@
|
|
1
|
+
class FakeDiscoveredHost < ActiveRecord::Base
|
2
|
+
self.table_name = 'hosts'
|
3
|
+
end
|
4
|
+
|
1
5
|
class FillDiscoveryAttributeSetsForExistingHosts < ActiveRecord::Migration
|
2
6
|
def up
|
3
|
-
Host::Discovered.all.each
|
7
|
+
FakeDiscoveredHost.where(:type => "Host::Discovered").all.each do |host|
|
8
|
+
begin
|
9
|
+
say "Populating attribute set for discovered host #{host.name}"
|
10
|
+
host.discovery_attribute_set = DiscoveryAttributeSet.where(:host_id => host.id).first_or_create
|
11
|
+
host.discovery_attribute_set.update_attributes(host.import_from_facts)
|
12
|
+
host.save!
|
13
|
+
rescue Exception => e
|
14
|
+
say "Error while populating host #{host.name}, deleting: #{e.message}:\n" + e.backtrace.join("\n")
|
15
|
+
host.destroy
|
16
|
+
end
|
17
|
+
end
|
4
18
|
end
|
5
19
|
|
6
20
|
def down
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class AddMissingViewPermissions < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
permissions = [
|
4
|
+
"view_architectures", "view_domains", "view_environments", "view_hosts",
|
5
|
+
"view_hostgroups", "view_media", "view_models", "view_operatingsystems",
|
6
|
+
"view_provisioning_templates", "view_ptables", "view_puppetclasses",
|
7
|
+
"view_realms", "view_smart_proxies", "view_subnets"
|
8
|
+
]
|
9
|
+
role = Role.find_by_name("Discovery Reader")
|
10
|
+
role.add_permissions!(permissions) if role
|
11
|
+
role = Role.find_by_name("Discovery Manager")
|
12
|
+
role.add_permissions!(permissions + ["create_hosts"]) if role
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
# not implemented
|
17
|
+
end
|
18
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
kind = TemplateKind.where(:name => 'kexec').first_or_create
|
2
2
|
|
3
3
|
ProvisioningTemplate.without_auditing do
|
4
|
-
|
5
|
-
|
6
|
-
:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
[['redhat_kexec.erb', 'Red Hat'], ['debian_kexec.erb', 'Debian']].each do |tmpl_names|
|
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(
|
7
|
+
:template_kind_id => kind.id,
|
8
|
+
:snippet => false,
|
9
|
+
:template => content
|
10
|
+
)
|
11
|
+
tmpl.attributes = {
|
12
|
+
:template => content,
|
13
|
+
:default => true,
|
14
|
+
:vendor => "Foreman Discovery",
|
15
|
+
:locked => false
|
16
|
+
}
|
17
|
+
tmpl.save!(:validate => false) if tmpl.changes.present?
|
18
|
+
end
|
17
19
|
end
|
data/lib/discovery.rake
CHANGED
@@ -26,10 +26,6 @@ module ForemanDiscovery
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
initializer 'foreman_discovery.helper' do |app|
|
30
|
-
ActionView::Base.send :include, DiscoveredHostsHelper
|
31
|
-
end
|
32
|
-
|
33
29
|
initializer 'foreman_discovery.register_gettext', :after => :load_config_initializers do |app|
|
34
30
|
locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
|
35
31
|
locale_domain = 'foreman_discovery'
|
@@ -46,7 +42,7 @@ module ForemanDiscovery
|
|
46
42
|
|
47
43
|
initializer 'foreman_discovery.register_plugin', :before => :finisher_hook do |app|
|
48
44
|
Foreman::Plugin.register :foreman_discovery do
|
49
|
-
requires_foreman '>= 1.
|
45
|
+
requires_foreman '>= 1.12.0'
|
50
46
|
|
51
47
|
# discovered hosts permissions
|
52
48
|
security_block :discovery do
|
@@ -114,8 +110,23 @@ module ForemanDiscovery
|
|
114
110
|
]
|
115
111
|
MANAGER = READER + [
|
116
112
|
# core permissions
|
113
|
+
:create_hosts,
|
114
|
+
:build_hosts,
|
117
115
|
:assign_organizations,
|
118
116
|
:assign_locations,
|
117
|
+
:view_architectures,
|
118
|
+
:view_domains,
|
119
|
+
:view_environments,
|
120
|
+
:view_hostgroups,
|
121
|
+
:view_media,
|
122
|
+
:view_models,
|
123
|
+
:view_operatingsystems,
|
124
|
+
:view_provisioning_templates,
|
125
|
+
:view_ptables,
|
126
|
+
:view_puppetclasses,
|
127
|
+
:view_realms,
|
128
|
+
:view_smart_proxies,
|
129
|
+
:view_subnets,
|
119
130
|
# discovered_hosts
|
120
131
|
:submit_discovered_hosts,
|
121
132
|
:provision_discovered_hosts,
|
@@ -166,17 +177,20 @@ module ForemanDiscovery
|
|
166
177
|
# Fact parsing
|
167
178
|
::FactParser.register_fact_parser(:foreman_discovery, ForemanDiscovery::FactParser)
|
168
179
|
|
180
|
+
# Taxonomy extensions
|
181
|
+
::Location.send :include, DiscoveryTaxonomyExtensions
|
182
|
+
::Organization.send :include, DiscoveryTaxonomyExtensions
|
183
|
+
|
169
184
|
# Model extensions
|
170
185
|
::Host::Managed.send :include, Host::ManagedExtensions
|
171
186
|
::Hostgroup.send :include, HostgroupExtensions
|
187
|
+
::FactValue.send :include, FactValueExtensions
|
188
|
+
|
189
|
+
# Controller extensions
|
190
|
+
::Api::V2::FactValuesController.send :include, Api::V2::FactValuesControllerExtensions
|
172
191
|
|
173
192
|
# Include subnet extensions
|
174
193
|
::Subnet.send :include, DiscoverySubnet
|
175
|
-
|
176
|
-
# Include helper for dashboard
|
177
|
-
::DashboardHelper.send(:include, DiscoveredHostsHelper)
|
178
|
-
|
179
|
-
::SettingsHelper.send :include, ForemanDiscovery::SettingsHelperExtensions
|
180
194
|
end
|
181
195
|
|
182
196
|
rake_tasks do
|