foreman_discovery 14.0.0 → 14.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/host/managed_extensions.rb +13 -6
  3. data/app/views/discovered_mailer/_discovered_host.html.erb +1 -1
  4. data/app/views/discovered_mailer/discovered_summary.text.erb +1 -1
  5. data/app/views/foreman_discovery/debian_kexec.erb +3 -4
  6. data/app/views/foreman_discovery/redhat_kexec.erb +4 -5
  7. data/db/seeds.d/50_discovery_templates.rb +1 -0
  8. data/lib/foreman_discovery/version.rb +1 -1
  9. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  10. data/locale/ca/foreman_discovery.edit.po +2 -2
  11. data/locale/ca/foreman_discovery.po +1 -1
  12. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  13. data/locale/de/foreman_discovery.edit.po +2 -2
  14. data/locale/de/foreman_discovery.po +1 -1
  15. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  16. data/locale/en/foreman_discovery.edit.po +1 -1
  17. data/locale/en/foreman_discovery.po +1 -1
  18. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  19. data/locale/en_GB/foreman_discovery.edit.po +2 -2
  20. data/locale/en_GB/foreman_discovery.po +1 -1
  21. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  22. data/locale/es/foreman_discovery.edit.po +2 -2
  23. data/locale/es/foreman_discovery.po +1 -1
  24. data/locale/foreman_discovery.pot +2 -2
  25. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  26. data/locale/fr/foreman_discovery.edit.po +2 -2
  27. data/locale/fr/foreman_discovery.po +1 -1
  28. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  29. data/locale/gl/foreman_discovery.edit.po +2 -2
  30. data/locale/gl/foreman_discovery.po +1 -1
  31. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  32. data/locale/it/foreman_discovery.edit.po +2 -2
  33. data/locale/it/foreman_discovery.po +1 -1
  34. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  35. data/locale/ja/foreman_discovery.edit.po +2 -2
  36. data/locale/ja/foreman_discovery.po +1 -1
  37. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  38. data/locale/ko/foreman_discovery.edit.po +2 -2
  39. data/locale/ko/foreman_discovery.po +1 -1
  40. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  41. data/locale/pt_BR/foreman_discovery.edit.po +2 -2
  42. data/locale/pt_BR/foreman_discovery.po +1 -1
  43. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  44. data/locale/ru/foreman_discovery.edit.po +2 -2
  45. data/locale/ru/foreman_discovery.po +1 -1
  46. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  47. data/locale/sv_SE/foreman_discovery.edit.po +2 -2
  48. data/locale/sv_SE/foreman_discovery.po +1 -1
  49. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  50. data/locale/zh_CN/foreman_discovery.edit.po +2 -2
  51. data/locale/zh_CN/foreman_discovery.po +1 -1
  52. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  53. data/locale/zh_TW/foreman_discovery.edit.po +2 -2
  54. data/locale/zh_TW/foreman_discovery.po +1 -1
  55. data/test/unit/discovered_mailer_test.rb +15 -7
  56. data/test/unit/managed_extensions_test.rb +81 -51
  57. metadata +2 -4
  58. data/test/facts/puppet3-virtual.json +0 -109
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49c30c64f46b94cdebd54bcc42191a28d4657b5cac08b9b85b55e033193f3e30
4
- data.tar.gz: 578f6f1feecbea23a712a13e5e4ece7df31a1e1fa3ec89dc0224df9472e4999b
3
+ metadata.gz: 6db307d435a16f1400f797101433c496b54191570025be1c57dd99b17f6de642
4
+ data.tar.gz: 3448174f47cda0c77c34f10224f7331f3f4abc472bcf0bda4648477ebff4e373
5
5
  SHA512:
6
- metadata.gz: 77d0a31672abf4bb351b0296c2fe2ac418b746fddefb7f3a9e8a2f58c7dd5d90ecaddf23cf35e2884ec49e187894abae9028e35b819ca83f31925adeb4ab18eb
7
- data.tar.gz: a5703c3c800bad9be03d9110dbc4ab831c849e8ba31fa2ae4667b70e4013a5e923b1c170be7b8a0fa5d55499cec8265bcd7d71740e4cae4bb375226631c49127
6
+ metadata.gz: 1cb57bb7847aba12ba8210621b6300768780e917c30d36c9fa0d20e5c4f5f2047d4e2c3fe55548c576447e66057def3c258adc5755c373d4a644f23313bb1add
7
+ data.tar.gz: 2a24c9feea20b333a350fab9ef535e0adc83d5e9d499198298ca44d6417a312c280e53cad885c986cc9aab5917246bce1815f65bef94deeb3fdf91f2734554dd
@@ -41,16 +41,23 @@ module Host::ManagedExtensions
41
41
  # no reboot on orchestration rollback
42
42
  end
43
43
 
44
- def setKexec
44
+ def render_kexec_template
45
45
  template = provisioning_template(:kind => 'kexec')
46
46
  raise ::Foreman::Exception.new(N_("Kexec template not associated with operating system")) unless template
47
- @host = self
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))
47
+
48
+ source = Foreman::Renderer::Source::String.new(name: template.name, content: template.template)
49
+ scope = Foreman::Renderer.get_scope(host: self, source: source)
50
+ json = JSON.parse(Foreman::Renderer.render(source, scope))
51
51
  ::Foreman::Exception.new(N_("Kernel kexec URL is invalid: '%s'"), json['kernel']) unless json['kernel'] =~ /\Ahttp.+\Z/
52
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_json
53
+ json
54
+ rescue StandardError => e
55
+ Foreman::Logging.exception("Unable render or parse kexec template, must be valid JSON", e)
56
+ {status: "Unable to render or parse template: " + e.to_s}
57
+ end
58
+
59
+ def setKexec
60
+ old.becomes(Host::Discovered).kexec(render_kexec_template.to_json)
54
61
  true
55
62
  rescue ::Foreman::Exception => e
56
63
  Foreman::Logging.exception("Unable to kexec", e)
@@ -1,6 +1,6 @@
1
1
  <% td_style = "text-align: left; border-collapse: collapse; background-color: #FFFFFF; padding: 4px; border: 1px solid #cccccc;" %>
2
2
  <td style="<%= td_style%>">
3
- <%= link_to host, discovered_host_path(:id => host, :host => @url.host, :port => @url.port, :only_path => false, :protocol => @url.scheme) %>
3
+ <%= link_to host, discovered_host_url(:id => host, :host => @url.host, :port => @url.port, :only_path => false, :protocol => @url.scheme) %>
4
4
  </td>
5
5
  <td style="<%= td_style%>"><%= host.try(:hardware_model_name) || 'N/A' %></td>
6
6
  <td style="<%= td_style%>"><%= host.ip %></td>
@@ -14,7 +14,7 @@
14
14
  <%= _('Disk count') %> <%= discovery_attribute(host, :disk_count) %>
15
15
  <%= _('Disks size') %> <%= number_to_human_size(discovery_attribute(host, :disks_size, 0) * 1024 * 1024) %>
16
16
 
17
- (<%= discovered_host_path(:id => host, :host => @url.host, :port => @url.port, :only_path => false, :protocol => @url.scheme) %>)
17
+ (<%= discovered_host_url(:id => host, :host => @url.host, :port => @url.port, :only_path => false, :protocol => @url.scheme) %>)
18
18
  -
19
19
  <% end %>
20
20
  <% else %>
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  kind: kexec
3
- name: Debian kexec
3
+ name: Discovery Debian kexec
4
4
  oses:
5
5
  - Debian
6
6
  - Ubuntu
@@ -32,9 +32,8 @@ Please read kexec(8) man page for more information about semantics.
32
32
  options << "inst.stage2=#{@host.operatingsystem.medium_uri(@host)}" if @host.operatingsystem.name.match(/Atomic/i)
33
33
  -%>
34
34
  {
35
- "comment": "WARNING: Both kernel and initram are not set in preview mode due to http://projects.theforeman.org/issues/19737",
36
- "kernel": "<%= @kexec_kernel %>",
37
- "initram": "<%= @kexec_initrd %>",
35
+ "kernel": "<%= @kernel_uri %>",
36
+ "initram": "<%= @initrd_uri %>",
38
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.compact.join(' ') %>",
39
38
  "extra": []
40
39
  }
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  kind: kexec
3
- name: Red Hat kexec
3
+ name: Discovery Red Hat kexec
4
4
  oses:
5
5
  - CentOS 4
6
6
  - CentOS 5
@@ -39,12 +39,11 @@ Please read kexec(8) man page for more information about semantics.
39
39
  options << "inst.stage2=#{@host.operatingsystem.medium_uri(@host)}" if @host.operatingsystem.name.match(/Atomic/i)
40
40
  -%>
41
41
  {
42
- "comment": "WARNING: Both kernel and initram are not set in preview mode due to http://projects.theforeman.org/issues/19737",
43
- "kernel": "<%= @kexec_kernel %>",
44
- "initram": "<%= @kexec_initrd %>",
42
+ "kernel": "<%= @kernel_uri %>",
43
+ "initram": "<%= @initrd_uri %>",
45
44
  <% if (@host.operatingsystem.name == 'Fedora' and @host.operatingsystem.major.to_i > 16) or
46
45
  (@host.operatingsystem.name != 'Fedora' and @host.operatingsystem.major.to_i >= 7) -%>
47
- "append": "ks=<%= foreman_url('provision') + "&static=yes" %> inst.ks.sendmac <%= "ip=#{ip}::#{gw}:#{mask}:::none nameserver=#{dns} ksdevice=bootif BOOTIF=#{bootif} nomodeset #{append}" %>",
46
+ "append": "ks=<%= foreman_url('provision') + "&static=yes" %> inst.ks.sendmac <%= "ip=#{ip}::#{gw}:#{mask}:::none nameserver=#{dns} ksdevice=bootif BOOTIF=#{bootif} nomodeset " + options.compact.join(' ') %>",
48
47
  <% else -%>
49
48
  "append": "ks=<%= foreman_url('provision') + "&static=yes" %> kssendmac nicdelay=5 <%= "ip=#{ip} netmask=#{mask} gateway=#{gw} dns=#{dns} ksdevice=#{mac} BOOTIF=#{bootif} " + options.compact.join(' ') %>",
50
49
  <% end -%>
@@ -19,6 +19,7 @@ ProvisioningTemplate.without_auditing do
19
19
  :vendor => "Foreman Discovery",
20
20
  :locked => true
21
21
  }
22
+ tmpl.template = content
22
23
  tmpl.organizations = organizations if SETTINGS[:organizations_enabled]
23
24
  tmpl.locations = locations if SETTINGS[:locations_enabled]
24
25
  tmpl.save!(:validate => false) if tmpl.changes.present?
@@ -1,3 +1,3 @@
1
1
  module ForemanDiscovery
2
- VERSION = "14.0.0"
2
+ VERSION = "14.0.1"
3
3
  end
@@ -7,9 +7,9 @@
7
7
  # Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2015-2016
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: foreman_discovery 13.0.0\n"
10
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
12
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
13
13
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
14
14
  "Last-Translator: Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>\n"
15
15
  "Language-Team: Catalan (http://www.transifex.com/foreman/foreman/language/ca/)\n"
@@ -7,7 +7,7 @@
7
7
  # Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2015-2016
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: foreman_discovery 13.0.0\n"
10
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
12
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
13
13
  "Last-Translator: Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>\n"
@@ -13,9 +13,9 @@
13
13
  # stbenjam <stephen@redhat.com>, 2016
14
14
  msgid ""
15
15
  msgstr ""
16
- "Project-Id-Version: foreman_discovery 13.0.0\n"
16
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
17
17
  "Report-Msgid-Bugs-To: \n"
18
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
18
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
19
19
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
20
20
  "Last-Translator: Ettore Atalan <atalanttore@googlemail.com>\n"
21
21
  "Language-Team: German (http://www.transifex.com/foreman/foreman/language/de/)\n"
@@ -13,7 +13,7 @@
13
13
  # stbenjam <stephen@redhat.com>, 2016
14
14
  msgid ""
15
15
  msgstr ""
16
- "Project-Id-Version: foreman_discovery 13.0.0\n"
16
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
17
17
  "Report-Msgid-Bugs-To: \n"
18
18
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
19
19
  "Last-Translator: Ettore Atalan <atalanttore@googlemail.com>\n"
@@ -2,7 +2,7 @@
2
2
  # This file is distributed under the same license as the foreman_discovery package.
3
3
  msgid ""
4
4
  msgstr ""
5
- "Project-Id-Version: foreman_discovery 13.0.0\n"
5
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
6
6
  "Report-Msgid-Bugs-To: foreman-dev@googlegroups.com\n"
7
7
  "PO-Revision-Date: 2015-12-27 01:18+0000\n"
8
8
  "Last-Translator: \n"
@@ -2,7 +2,7 @@
2
2
  # This file is distributed under the same license as the foreman_discovery package.
3
3
  msgid ""
4
4
  msgstr ""
5
- "Project-Id-Version: foreman_discovery 13.0.0\n"
5
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
6
6
  "Report-Msgid-Bugs-To: foreman-dev@googlegroups.com\n"
7
7
  "PO-Revision-Date: 2015-12-27 01:18+0000\n"
8
8
  "Last-Translator: \n"
@@ -10,9 +10,9 @@
10
10
  # Lukáš Zapletal, 2015
11
11
  msgid ""
12
12
  msgstr ""
13
- "Project-Id-Version: foreman_discovery 13.0.0\n"
13
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
14
14
  "Report-Msgid-Bugs-To: \n"
15
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
15
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
16
16
  "PO-Revision-Date: 2018-10-30 12:54+0000\n"
17
17
  "Last-Translator: Andi Chandler <andi@gowling.com>\n"
18
18
  "Language-Team: English (United Kingdom) (http://www.transifex.com/foreman/foreman/language/en_GB/)\n"
@@ -10,7 +10,7 @@
10
10
  # Lukáš Zapletal, 2015
11
11
  msgid ""
12
12
  msgstr ""
13
- "Project-Id-Version: foreman_discovery 13.0.0\n"
13
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
14
14
  "Report-Msgid-Bugs-To: \n"
15
15
  "PO-Revision-Date: 2018-10-30 12:54+0000\n"
16
16
  "Last-Translator: Andi Chandler <andi@gowling.com>\n"
@@ -9,9 +9,9 @@
9
9
  # Sergio Ocón <sergio.ocon@redhat.com>, 2014
10
10
  msgid ""
11
11
  msgstr ""
12
- "Project-Id-Version: foreman_discovery 13.0.0\n"
12
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
13
13
  "Report-Msgid-Bugs-To: \n"
14
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
14
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
15
15
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
16
16
  "Last-Translator: Félix Barbeira <fbarbeira@gmail.com>\n"
17
17
  "Language-Team: Spanish (http://www.transifex.com/foreman/foreman/language/es/)\n"
@@ -9,7 +9,7 @@
9
9
  # Sergio Ocón <sergio.ocon@redhat.com>, 2014
10
10
  msgid ""
11
11
  msgstr ""
12
- "Project-Id-Version: foreman_discovery 13.0.0\n"
12
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
13
13
  "Report-Msgid-Bugs-To: \n"
14
14
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
15
15
  "Last-Translator: Félix Barbeira <fbarbeira@gmail.com>\n"
@@ -8,8 +8,8 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: foreman_discovery 1.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2018-11-05 08:34+0100\n"
12
- "PO-Revision-Date: 2018-11-05 08:34+0100\n"
11
+ "POT-Creation-Date: 2019-01-30 10:57+0100\n"
12
+ "PO-Revision-Date: 2019-01-30 10:57+0100\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
15
  "Language: \n"
@@ -8,9 +8,9 @@
8
8
  # Pierre-Emmanuel Dutang <dutangp@gmail.com>, 2014,2016-2017
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 13.0.0\n"
11
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
13
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
14
14
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
15
15
  "Last-Translator: Pierre-Emmanuel Dutang <dutangp@gmail.com>\n"
16
16
  "Language-Team: French (http://www.transifex.com/foreman/foreman/language/fr/)\n"
@@ -8,7 +8,7 @@
8
8
  # Pierre-Emmanuel Dutang <dutangp@gmail.com>, 2014,2016-2017
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 13.0.0\n"
11
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
14
14
  "Last-Translator: Pierre-Emmanuel Dutang <dutangp@gmail.com>\n"
@@ -5,9 +5,9 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
10
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
11
11
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
12
12
  "Last-Translator: Carmela Rubiños <carmela.rubinos@gmail.com>\n"
13
13
  "Language-Team: Galician (http://www.transifex.com/foreman/foreman/language/gl/)\n"
@@ -5,7 +5,7 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
10
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
11
11
  "Last-Translator: Carmela Rubiños <carmela.rubinos@gmail.com>\n"
@@ -7,9 +7,9 @@
7
7
  # caifti <caifti@gmail.com>, 2014
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: foreman_discovery 13.0.0\n"
10
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
12
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
13
13
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
14
14
  "Last-Translator: Giuseppe Pignataro (Fastbyte01) <rogepix@gmail.com>\n"
15
15
  "Language-Team: Italian (http://www.transifex.com/foreman/foreman/language/it/)\n"
@@ -7,7 +7,7 @@
7
7
  # caifti <caifti@gmail.com>, 2014
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: foreman_discovery 13.0.0\n"
10
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
12
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
13
13
  "Last-Translator: Giuseppe Pignataro (Fastbyte01) <rogepix@gmail.com>\n"
@@ -6,9 +6,9 @@
6
6
  # Shuji Yamada <uzy.exe@gmail.com>, 2015
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 13.0.0\n"
9
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
11
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
12
12
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
13
13
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
14
14
  "Language-Team: Japanese (http://www.transifex.com/foreman/foreman/language/ja/)\n"
@@ -6,7 +6,7 @@
6
6
  # Shuji Yamada <uzy.exe@gmail.com>, 2015
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 13.0.0\n"
9
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
12
12
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
@@ -5,9 +5,9 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
10
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
11
11
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
12
12
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
13
13
  "Language-Team: Korean (http://www.transifex.com/foreman/foreman/language/ko/)\n"
@@ -5,7 +5,7 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
10
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
11
11
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
@@ -10,9 +10,9 @@
10
10
  # Valeria S Silva <valeriassilva@live.com>, 2015
11
11
  msgid ""
12
12
  msgstr ""
13
- "Project-Id-Version: foreman_discovery 13.0.0\n"
13
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
14
14
  "Report-Msgid-Bugs-To: \n"
15
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
15
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
16
16
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
17
17
  "Last-Translator: Flamarion Jorge <jorge.flamarion@gmail.com>\n"
18
18
  "Language-Team: Portuguese (Brazil) (http://www.transifex.com/foreman/foreman/language/pt_BR/)\n"
@@ -10,7 +10,7 @@
10
10
  # Valeria S Silva <valeriassilva@live.com>, 2015
11
11
  msgid ""
12
12
  msgstr ""
13
- "Project-Id-Version: foreman_discovery 13.0.0\n"
13
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
14
14
  "Report-Msgid-Bugs-To: \n"
15
15
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
16
16
  "Last-Translator: Flamarion Jorge <jorge.flamarion@gmail.com>\n"
@@ -10,9 +10,9 @@
10
10
  # Yulia <yulia.poyarkova@redhat.com>, 2016
11
11
  msgid ""
12
12
  msgstr ""
13
- "Project-Id-Version: foreman_discovery 13.0.0\n"
13
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
14
14
  "Report-Msgid-Bugs-To: \n"
15
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
15
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
16
16
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
17
17
  "Last-Translator: Andrei Burd <burdandrei@gmail.com>\n"
18
18
  "Language-Team: Russian (http://www.transifex.com/foreman/foreman/language/ru/)\n"
@@ -10,7 +10,7 @@
10
10
  # Yulia <yulia.poyarkova@redhat.com>, 2016
11
11
  msgid ""
12
12
  msgstr ""
13
- "Project-Id-Version: foreman_discovery 13.0.0\n"
13
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
14
14
  "Report-Msgid-Bugs-To: \n"
15
15
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
16
16
  "Last-Translator: Andrei Burd <burdandrei@gmail.com>\n"
@@ -8,9 +8,9 @@
8
8
  # johnny.westerlund <johnny.westerlund@gmail.com>, 2014
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 13.0.0\n"
11
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
13
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
14
14
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
15
15
  "Last-Translator: Mikael Fridh <frimik@gmail.com>\n"
16
16
  "Language-Team: Swedish (Sweden) (http://www.transifex.com/foreman/foreman/language/sv_SE/)\n"
@@ -8,7 +8,7 @@
8
8
  # johnny.westerlund <johnny.westerlund@gmail.com>, 2014
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 13.0.0\n"
11
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
14
14
  "Last-Translator: Mikael Fridh <frimik@gmail.com>\n"
@@ -5,9 +5,9 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
10
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
11
11
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
12
12
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
13
13
  "Language-Team: Chinese (China) (http://www.transifex.com/foreman/foreman/language/zh_CN/)\n"
@@ -5,7 +5,7 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
10
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
11
11
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
@@ -5,9 +5,9 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2018-10-25 13:56+0200\n"
10
+ "POT-Creation-Date: 2018-11-05 08:34+0100\n"
11
11
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
12
12
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
13
13
  "Language-Team: Chinese (Taiwan) (http://www.transifex.com/foreman/foreman/language/zh_TW/)\n"
@@ -5,7 +5,7 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 13.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 14.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
10
  "PO-Revision-Date: 2018-10-25 20:13+0000\n"
11
11
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
@@ -1,15 +1,21 @@
1
1
  require_relative '../test_plugin_helper'
2
2
 
3
3
  class DiscoveredMailerTest < ActiveSupport::TestCase
4
+ include FactImporterIsolation
5
+ allow_transactions_for_any_importer
6
+
4
7
  setup do
8
+ set_default_settings
5
9
  @user = User.current = users :admin
10
+ facts = parse_json_fixture('regular_host', true)
11
+ @host = discover_host_from_facts(facts)
6
12
 
7
13
  FactoryBot.create(:mail_notification,
8
14
  :name => :discovered_summary,
9
15
  :description => N_('A summary of discovered hosts'),
10
16
  :mailer => 'DiscoveredMailer',
11
17
  :method => 'discovered_summary',
12
- :subscription_type => 'report',
18
+ :subscription_type => 'report'
13
19
  )
14
20
 
15
21
  @user.mail_notifications << MailNotification[:discovered_summary]
@@ -23,22 +29,24 @@ class DiscoveredMailerTest < ActiveSupport::TestCase
23
29
  assert @email.to.include?("admin@someware.com")
24
30
  end
25
31
 
26
- test 'discovery mailer should contain body' do
27
- refute @email.body.nil?
32
+ test 'discovery mailer should contain body and two parts' do
33
+ assert_not @email.body.nil?
34
+ assert_equal 2, @email.body.parts.size
28
35
  end
29
36
 
30
37
  test 'discovery mailer should have a correct subject' do
31
- refute @email.subject.empty?
38
+ assert_not @email.subject.empty?
32
39
  assert @email.subject.include? Setting[:email_subject_prefix].first
33
40
  end
34
41
 
35
- test 'discovery mailer sends Foreman URL in body' do
36
- assert @email.body.parts.first.body.raw_source.include? Setting[:foreman_url]
42
+ test 'discovery mailer sends link to the discovered host in body' do
43
+ assert @email.body.parts.first.body.raw_source.include? "#{Setting[:foreman_url]}/discovered_hosts/#{@host.name}"
44
+ assert @email.body.parts.last.body.raw_source.include? "#{Setting[:foreman_url]}/discovered_hosts/#{@host.name}"
37
45
  end
38
46
 
39
47
  test 'discovery mailer sends both html and text emails' do
40
48
  assert_equal(2, @email.body.parts.size)
41
- refute(@email.body.parts.first.body.raw_source.start_with?('<!DOCTYPE')) # text email
49
+ assert_not(@email.body.parts.first.body.raw_source.start_with?('<!DOCTYPE')) # text email
42
50
  assert(@email.body.parts.last.body.raw_source.start_with?('<!DOCTYPE')) # html email
43
51
  end
44
52
 
@@ -10,63 +10,93 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
10
10
  end
11
11
  end
12
12
 
13
- setup do
14
- set_default_settings
13
+ let(:kexec_template) { FactoryBot.build(:provisioning_template, :template => File.read(File.expand_path(File.join("..", "..", "..", "app", "views", "foreman_discovery", "redhat_kexec.erb"), __FILE__))) }
15
14
 
16
- @host = StubHost.new
17
- @host.type = "Host::Discovered"
18
- @host.stubs(:old).returns(@host)
19
- @facts = {}
20
- @host.stubs(:facts).returns(@facts)
21
- @post_queue = mock('Post Queue')
22
- @host.stubs(:post_queue).returns(@post_queue)
23
- @operatingsystem = mock('OS')
24
- @host.stubs(:operatingsystem).returns(@operatingsystem)
25
- @host.stubs(:provisioning_template).returns('A template')
26
- @host.stubs(:medium).returns('http://a_medium')
27
- @host.stubs(:architecture).returns(FactoryBot.create(:architecture))
28
- @kexec_json = {
29
- :kernel => "http://a_host/vmlinuz",
30
- :initrd => "http://a_host/someimage.img"
31
- }
32
- @host.stubs(:unattended_render).returns(@kexec_json.to_json)
33
- end
15
+ context "stubbed orchestration" do
16
+ setup do
17
+ set_default_settings
34
18
 
35
- test "queue_reboot enques reboot command when there is no kexec fact" do
36
- @host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
37
- @host.stubs(:new_record?).returns(false)
38
- @host.id = 130513
39
- @post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
40
- @host.queue_reboot
41
- end
19
+ @host = StubHost.new
20
+ @host.type = "Host::Discovered"
21
+ @host.stubs(:old).returns(@host)
22
+ @facts = {}
23
+ @host.stubs(:facts).returns(@facts)
24
+ @post_queue = mock('Post Queue')
25
+ @host.stubs(:post_queue).returns(@post_queue)
26
+ @operatingsystem = mock('OS')
27
+ @operatingsystem.stubs(:additional_media).returns({})
28
+ @host.stubs(:operatingsystem).returns(@operatingsystem)
29
+ @host.stubs(:provisioning_template).returns(kexec_template)
30
+ @host.stubs(:medium).returns('http://a_medium')
31
+ @host.stubs(:architecture).returns(FactoryBot.create(:architecture))
32
+ ::MediumProviders::Default.any_instance.stubs(:validate).returns([])
33
+ end
42
34
 
43
- test "queue_reboot enques reboot command when there is no kexec template" do
44
- @host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
45
- @host.stubs(:new_record?).returns(false)
46
- @host.id = 130513
47
- @facts['discovery_kexec'] = "Kexec version X.Y.Z"
48
- @host.stubs(:provisioning_template).returns(nil)
49
- @post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
50
- @host.queue_reboot
51
- end
35
+ test "queue_reboot enques reboot command when there is no kexec fact" do
36
+ @host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
37
+ @host.stubs(:new_record?).returns(false)
38
+ @host.id = 130513
39
+ @post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
40
+ @host.queue_reboot
41
+ end
52
42
 
53
- test "queue_reboot enques kexec command" do
54
- @host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
55
- @host.stubs(:new_record?).returns(false)
56
- @host.id = 130513
57
- @facts['discovery_kexec'] = "Kexec version X.Y.Z"
58
- @post_queue.expects(:create).with(has_entry(:action, [@host, :setKexec])).once
59
- @host.queue_reboot
60
- end
43
+ test "queue_reboot enques reboot command when there is no kexec template" do
44
+ @host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
45
+ @host.stubs(:new_record?).returns(false)
46
+ @host.id = 130513
47
+ @facts['discovery_kexec'] = "Kexec version X.Y.Z"
48
+ @host.stubs(:provisioning_template).returns(nil)
49
+ @post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
50
+ @host.queue_reboot
51
+ end
61
52
 
62
- test "setReboot calls reboot API" do
63
- Host::Discovered.any_instance.expects(:reboot).once
64
- @host.setReboot
53
+ test "queue_reboot enques kexec command" do
54
+ @host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
55
+ @host.stubs(:new_record?).returns(false)
56
+ @host.id = 130513
57
+ @facts['discovery_kexec'] = "Kexec version X.Y.Z"
58
+ @post_queue.expects(:create).with(has_entry(:action, [@host, :setKexec])).once
59
+ @host.queue_reboot
60
+ end
61
+
62
+ test "setReboot calls reboot API" do
63
+ Host::Discovered.any_instance.expects(:reboot).once
64
+ @host.setReboot
65
+ end
66
+
67
+ test "setKexec calls renderer" do
68
+ Host::Discovered.any_instance.expects(:kexec).with() { |json| JSON.parse(json) }.once
69
+ Foreman::Renderer.expects(:render).returns({})
70
+ @host.setKexec
71
+ end
65
72
  end
66
73
 
67
- test "setKexec calls boot_files_uri and kexec API" do
68
- Host::Discovered.any_instance.expects(:kexec).with() { |json| JSON.parse(json) }.once
69
- @operatingsystem.expects(:boot_files_uri).with(@host.medium, @host.architecture, @host)
70
- @host.setKexec
74
+ context "host" do
75
+ setup do
76
+ set_default_settings
77
+ interface = FactoryBot.build(:nic_primary_and_provision, identifier: 'eth0', mac: '00-f0-54-1a-7e-e0', ip: '127.0.0.1')
78
+ domain = FactoryBot.build(:domain, name: 'snapshotdomain.com')
79
+ subnet = FactoryBot.build(:subnet_ipv4, name: 'one', network: interface.ip)
80
+ architecture = Architecture.find_by_name('x86_64')
81
+ medium = FactoryBot.create(:medium, name: 'CentOS mirror')
82
+ ptable = FactoryBot.create(:ptable, name: 'ptable')
83
+ @operatingsystem = FactoryBot.create(:operatingsystem, name: 'Redhat', major: 7, architectures: [architecture], media: [medium], ptables: [ptable]).becomes(::Redhat)
84
+ @host = FactoryBot.build(:host, :managed, hostname: 'snapshothost', domain: domain, subnet: subnet, architecture: architecture, medium: medium,
85
+ ptable: ptable, operatingsystem: @operatingsystem, interfaces: [interface])
86
+ @host.stubs(:provisioning_template).returns(kexec_template)
87
+ end
88
+
89
+ test "kexec template is correctly rendered" do
90
+ expected = {
91
+ "append" => "ks=http://foreman.some.host.fqdn/unattended/provision&static=yes inst.ks.sendmac ip=::::::none nameserver= ksdevice=bootif BOOTIF= nomodeset nomodeset",
92
+ "extra" => []
93
+ }
94
+ assert @host.operatingsystem.respond_to?(:pxe_type)
95
+ assert @host.medium_provider
96
+ result = @host.render_kexec_template
97
+ assert_match(/http:\/\/www.example.com.*vmlinuz/, result.delete("kernel"))
98
+ assert_match(/http:\/\/www.example.com.*initrd.img/, result.delete("initram"))
99
+ assert_equal expected, result
100
+ end
71
101
  end
72
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_discovery
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.0
4
+ version: 14.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditi Puntambekar
@@ -67,7 +67,7 @@ authors:
67
67
  autorequire:
68
68
  bindir: bin
69
69
  cert_chain: []
70
- date: 2018-11-05 00:00:00.000000000 Z
70
+ date: 2019-01-30 00:00:00.000000000 Z
71
71
  dependencies: []
72
72
  description: MaaS Discovery Plugin engine for Foreman
73
73
  email: gsutclif@redhat.com
@@ -238,7 +238,6 @@ files:
238
238
  - test/facts/dell_vlan.json
239
239
  - test/facts/facts_with_lldp.json
240
240
  - test/facts/facts_with_lldp_bond_candidate.json
241
- - test/facts/puppet3-virtual.json
242
241
  - test/facts/pxeless-vlan.json
243
242
  - test/facts/regular_host.json
244
243
  - test/facts/rhel-dl380-1kdisks.json
@@ -307,7 +306,6 @@ test_files:
307
306
  - test/facts/pxeless-vlan.json
308
307
  - test/facts/dell_npars.json
309
308
  - test/facts/simple-bond.json
310
- - test/facts/puppet3-virtual.json
311
309
  - test/facts/rhel-dl380-1kdisks.json
312
310
  - test/facts/suse-vmware.json
313
311
  - test/facts/default.json
@@ -1,109 +0,0 @@
1
- {
2
- aio_agent_version => 1.9.3
3
- augeas => {
4
- version => "1.4.0"
5
- }
6
- networking => {
7
- hostname => "lxserv940",
8
- interfaces => {
9
- eth0 => {
10
- bindings => [
11
- {
12
- address => "172.29.0.187",
13
- netmask => "255.255.252.0",
14
- network => "172.29.0.0"
15
- }
16
- ],
17
- bindings6 => [
18
- {
19
- address => "fe80::250:56ff:febe:50d5",
20
- netmask => "ffff:ffff:ffff:ffff::",
21
- network => "fe80::"
22
- }
23
- ],
24
- ip => "172.29.0.187",
25
- ip6 => "fe80::250:56ff:febe:50d5",
26
- mac => "00:50:56:be:50:d5",
27
- mtu => 1500,
28
- netmask => "255.255.252.0",
29
- netmask6 => "ffff:ffff:ffff:ffff::",
30
- network => "172.29.0.0",
31
- network6 => "fe80::"
32
- },
33
- eth0:0 => {
34
- bindings => [
35
- {
36
- address => "172.29.1.160",
37
- netmask => "255.255.252.0",
38
- network => "172.29.0.0"
39
- }
40
- ],
41
- ip => "172.29.1.160",
42
- netmask => "255.255.252.0",
43
- network => "172.29.0.0"
44
- },
45
- lo => {
46
- bindings => [
47
- {
48
- address => "127.0.0.1",
49
- netmask => "255.0.0.0",
50
- network => "127.0.0.0"
51
- }
52
- ],
53
- bindings6 => [
54
- {
55
- address => "::1",
56
- netmask => "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
57
- network => "::1"
58
- }
59
- ],
60
- ip => "127.0.0.1",
61
- ip6 => "::1",
62
- mtu => 65536,
63
- netmask => "255.0.0.0",
64
- netmask6 => "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
65
- network => "127.0.0.0",
66
- network6 => "::1"
67
- }
68
- },
69
- ip => "172.29.0.187",
70
- ip6 => "fe80::250:56ff:febe:50d5",
71
- mac => "00:50:56:be:50:d5",
72
- mtu => 1500,
73
- netmask => "255.255.252.0",
74
- netmask6 => "ffff:ffff:ffff:ffff::",
75
- network => "172.29.0.0",
76
- network6 => "fe80::",
77
- primary => "eth0"
78
- }
79
- os => {
80
- architecture => "x86_64",
81
- distro => {
82
- codename => "Maipo",
83
- description => "Red Hat Enterprise Linux Server release 7.3 (Maipo)",
84
- id => "RedHatEnterpriseServer",
85
- release => {
86
- full => "7.3",
87
- major => "7",
88
- minor => "3"
89
- },
90
- specification => ":core-4.1-amd64:core-4.1-noarch"
91
- },
92
- family => "RedHat",
93
- hardware => "x86_64",
94
- name => "RedHat",
95
- release => {
96
- full => "7.3",
97
- major => "7",
98
- minor => "3"
99
- },
100
- selinux => {
101
- config_mode => "permissive",
102
- config_policy => "targeted",
103
- current_mode => "permissive",
104
- enabled => true,
105
- enforced => false,
106
- policy_version => "28"
107
- }
108
- }
109
- }