foreman_discovery 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +8 -8
  2. data/app/lib/puppet_fact_parser_extensions.rb +10 -6
  3. data/lib/foreman_discovery/version.rb +1 -1
  4. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  5. data/locale/de/foreman_discovery.po +1 -1
  6. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  7. data/locale/en_GB/foreman_discovery.po +1 -1
  8. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  9. data/locale/es/foreman_discovery.po +3 -3
  10. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  11. data/locale/fr/foreman_discovery.po +1 -1
  12. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  13. data/locale/gl/foreman_discovery.po +1 -1
  14. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  15. data/locale/it/foreman_discovery.po +1 -1
  16. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  17. data/locale/ja/foreman_discovery.po +1 -1
  18. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  19. data/locale/ko/foreman_discovery.po +1 -1
  20. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  21. data/locale/pt_BR/foreman_discovery.po +1 -1
  22. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  23. data/locale/ru/foreman_discovery.po +1 -1
  24. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  25. data/locale/sv_SE/foreman_discovery.po +1 -1
  26. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  27. data/locale/zh_CN/foreman_discovery.po +1 -1
  28. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  29. data/locale/zh_TW/foreman_discovery.po +1 -1
  30. data/test/unit/puppet_fact_parser_extensions_test.rb +63 -0
  31. metadata +4 -2
checksums.yaml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NmVlMWIxMzE4NzVlODY2MjNmYTdjNTczNGNhZjllNjg5
15
+ OTUyODA1MTY0ZDkzOWQ3YzBhY2E4N2Y5YTA4NjE5ZTZiM2UyOTM=
@@ -8,18 +8,22 @@ module PuppetFactParserExtensions
8
8
 
9
9
  # we prefer discovery_bootif fact to choose right primary interface (interface used to boot the image)
10
10
  def primary_interface_with_discovery_fact
11
- mac = facts[discovery_mac_fact_name]
12
- interfaces.each do |int, values|
13
- return int.to_s if (values[:macaddress] == mac)
11
+ if facts.has_key?(discovery_mac_fact_name)
12
+ mac = facts[discovery_mac_fact_name]
13
+ interfaces.each do |int, values|
14
+ return int.to_s if (values[:macaddress].try(:downcase) == mac.try(:downcase))
15
+ end
14
16
  end
15
17
  primary_interface_without_discovery_fact # fallback if we didn't find interface with such macaddress
16
18
  end
17
19
 
18
20
  # search for IP of interface with primary interface macaddress (ipaddress fact does not have to be interface used for boot)
19
21
  def ip_with_discovery_fact
20
- facts[:interfaces].split(',').each do |interface|
21
- if facts["macaddress_#{interface}"].try(:downcase) == facts[discovery_mac_fact_name].try(:downcase)
22
- return facts["ipaddress_#{interface}"]
22
+ if facts[:interfaces] && facts.has_key?(discovery_mac_fact_name)
23
+ facts[:interfaces].split(',').each do |interface|
24
+ if facts["macaddress_#{interface}"].try(:downcase) == facts[discovery_mac_fact_name].try(:downcase)
25
+ return facts["ipaddress_#{interface}"]
26
+ end
23
27
  end
24
28
  end
25
29
  ip_without_discovery_fact # fallback if IP was not found
@@ -1,3 +1,3 @@
1
1
  module ForemanDiscovery
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -9,7 +9,7 @@
9
9
  # simon11 <simon.stieger.98@live.de>, 2014
10
10
  msgid ""
11
11
  msgstr ""
12
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
12
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
13
13
  "Report-Msgid-Bugs-To: \n"
14
14
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
15
15
  "PO-Revision-Date: 2014-09-16 16:47+0000\n"
@@ -7,7 +7,7 @@
7
7
  # Dominic Cleal <dcleal@redhat.com>, 2013-2014
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
10
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
12
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
13
13
  "PO-Revision-Date: 2014-08-22 09:57+0000\n"
@@ -5,14 +5,14 @@
5
5
  #
6
6
  # Translators:
7
7
  # francis <hackgo@gmail.com>, 2013-2014
8
- # Sergio Ocón <sergio@redhat.com>, 2014
8
+ # Sergio Ocón <sergio.ocon@redhat.com>, 2014
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
11
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
14
14
  "PO-Revision-Date: 2014-08-29 11:11+0000\n"
15
- "Last-Translator: Sergio Ocón <sergio@redhat.com>\n"
15
+ "Last-Translator: Sergio Ocón <sergio.ocon@redhat.com>\n"
16
16
  "Language-Team: Spanish (http://www.transifex.com/projects/p/foreman/language/es/)\n"
17
17
  "MIME-Version: 1.0\n"
18
18
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -8,7 +8,7 @@
8
8
  # Pierre-Emmanuel Dutang <dutangp@gmail.com>, 2014
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
11
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
14
14
  "PO-Revision-Date: 2014-08-25 08:30+0000\n"
@@ -6,7 +6,7 @@
6
6
  # Translators:
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
9
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
12
12
  "PO-Revision-Date: 2014-08-22 09:57+0000\n"
@@ -7,7 +7,7 @@
7
7
  # caifti <caifti@gmail.com>, 2014
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
10
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
12
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
13
13
  "PO-Revision-Date: 2014-09-16 13:11+0000\n"
@@ -6,7 +6,7 @@
6
6
  # Translators:
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
9
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
12
12
  "PO-Revision-Date: 2014-09-16 13:21+0000\n"
@@ -6,7 +6,7 @@
6
6
  # Translators:
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
9
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
12
12
  "PO-Revision-Date: 2014-09-16 13:21+0000\n"
@@ -9,7 +9,7 @@
9
9
  # luizvasconcelos <luizvasconceloss@yahoo.com.br>, 2014
10
10
  msgid ""
11
11
  msgstr ""
12
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
12
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
13
13
  "Report-Msgid-Bugs-To: \n"
14
14
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
15
15
  "PO-Revision-Date: 2014-09-16 13:30+0000\n"
@@ -8,7 +8,7 @@
8
8
  # Dominic Cleal <dcleal@redhat.com>, 2014
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
11
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
14
14
  "PO-Revision-Date: 2014-09-16 13:30+0000\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 1.4.0.rc2\n"
11
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
14
14
  "PO-Revision-Date: 2014-09-16 13:30+0000\n"
@@ -6,7 +6,7 @@
6
6
  # Translators:
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
9
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
12
12
  "PO-Revision-Date: 2014-09-16 13:21+0000\n"
@@ -6,7 +6,7 @@
6
6
  # Translators:
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: foreman_discovery 1.4.0.rc2\n"
9
+ "Project-Id-Version: foreman_discovery 1.4.1\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "POT-Creation-Date: 2014-08-20 08:33+0100\n"
12
12
  "PO-Revision-Date: 2014-09-16 13:21+0000\n"
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+
3
+ class DummyPuppetFactParser
4
+ def ip
5
+ '192.168.0.30'
6
+ end
7
+
8
+ def primary_interface
9
+ 'eth1'
10
+ end
11
+
12
+ def interfaces
13
+ {
14
+ 'eth0' => {'macaddress' => 'aa:00:00:00:00:01', 'ipaddress' => '192.168.0.2'},
15
+ 'eth3' => {'ipaddress' => '192.168.2.2'},
16
+ 'eth2' => {'macaddress' => 'bb:00:00:00:00:01', 'ipaddress' => '192.168.1.2'}
17
+ }.with_indifferent_access
18
+ end
19
+
20
+ def facts
21
+ {
22
+ :ipaddress => '192.168.0.2', :macaddress => 'bb:00:00:00:00:01', :interfaces => 'eth0,eth1,lo',
23
+ :macaddress_eth1 => 'bb:00:00:00:00:01', :ipaddress_eth1 => '192.168.1.2',
24
+ :macaddress_eth0 => 'aa:00:00:00:00:01', :ipaddress_eth0 => '192.168.0.2',
25
+ :macaddress_lo => '', :ipaddress_lo => '127.0.0.1',
26
+ :mac_fact => 'AA:00:00:00:00:01'
27
+ }.with_indifferent_access
28
+ end
29
+
30
+ include PuppetFactParserExtensions
31
+ end
32
+
33
+ class PuppetFactParserTest < ActiveSupport::TestCase
34
+ setup do
35
+ @parser = DummyPuppetFactParser.new
36
+ end
37
+
38
+ test '#ip_with_discovery_fact ignores discovery part completely if discovery facts are not present' do
39
+ @parser.stubs(:discovery_mac_fact_name).returns('fact_that_does_not_exist')
40
+ assert_equal '192.168.0.30', @parser.ip
41
+ end
42
+
43
+ test '#ip_with_discovery_fact finds primary interface based on discovery facts and returns it\'s ip' do
44
+ @parser.stubs(:discovery_mac_fact_name).returns('mac_fact')
45
+ assert_equal '192.168.0.2', @parser.ip
46
+ end
47
+
48
+ test '#primary_interface_with_discovery_fact finds primary interface based on discovery facts' do
49
+ @parser.stubs(:discovery_mac_fact_name).returns('mac_fact')
50
+ assert_equal 'eth0', @parser.primary_interface
51
+ end
52
+
53
+ test '#primary_interface_with_discovery_fact falls back if no interface can be found by discovery mac' do
54
+ @parser.facts[:mac_fact] = 'cc:00:00:00:00:01'
55
+ @parser.stubs(:discovery_mac_fact_name).returns('mac_fact')
56
+ assert_equal 'eth0', @parser.primary_interface
57
+ end
58
+
59
+ test '#primary_interface_with_discovery_fact uses macaddress fact if discovery facts not available' do
60
+ @parser.stubs(:discovery_mac_fact_name).returns('fact_that_does_not_exist')
61
+ assert_equal 'eth1', @parser.primary_interface
62
+ end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_discovery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sutcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open4
@@ -118,6 +118,7 @@ files:
118
118
  - test/test_plugin_helper.rb
119
119
  - test/unit/facts.json
120
120
  - test/unit/host_discovered_test.rb
121
+ - test/unit/puppet_fact_parser_extensions_test.rb
121
122
  - test/unit/setting_discovered_test.rb
122
123
  homepage: http://github.com/theforeman/foreman_discovery
123
124
  licenses:
@@ -148,5 +149,6 @@ test_files:
148
149
  - test/functional/discovered_hosts_controller_test.rb
149
150
  - test/test_helper.rb
150
151
  - test/unit/facts.json
152
+ - test/unit/puppet_fact_parser_extensions_test.rb
151
153
  - test/unit/setting_discovered_test.rb
152
154
  - test/unit/host_discovered_test.rb