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
@@ -5,9 +5,9 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 8.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 9.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "PO-Revision-Date: 2017-03-15 12:38+0000\n"
10
+ "PO-Revision-Date: 2017-04-08 10:07+0000\n"
11
11
  "Last-Translator: Lukáš Zapletal\n"
12
12
  "Language-Team: Chinese (China) (http://www.transifex.com/foreman/foreman/langu"
13
13
  "age/zh_CN/)\n"
@@ -77,6 +77,9 @@ msgstr ""
77
77
  msgid "Could not get facts from proxy %{url}: %{error}"
78
78
  msgstr "无法从代理服务器 %{url} 获取详情: %{error}"
79
79
 
80
+ msgid "Create Rule"
81
+ msgstr ""
82
+
80
83
  msgid "Create a discovered host for testing (use /facts to create new hosts)"
81
84
  msgstr "创建发现的主机以进行测试(使用 /facts 创建新主机)"
82
85
 
@@ -104,6 +107,9 @@ msgstr ""
104
107
  msgid "Destroyed selected hosts"
105
108
  msgstr "消除所选主机"
106
109
 
110
+ msgid "Details"
111
+ msgstr ""
112
+
107
113
  msgid "Disable"
108
114
  msgstr "禁用"
109
115
 
@@ -285,6 +291,9 @@ msgstr ""
285
291
  msgid "Hostnames must not start with numbers. A good approach is to use unique information provided by facter (MAC address, BIOS or serial ID)."
286
292
  msgstr ""
287
293
 
294
+ msgid "Hosts"
295
+ msgstr ""
296
+
288
297
  msgid "Hosts limit"
289
298
  msgstr "主机限制"
290
299
 
@@ -402,9 +411,6 @@ msgstr ""
402
411
  msgid "New Discovery Rule"
403
412
  msgstr "新发现规则"
404
413
 
405
- msgid "New Rule"
406
- msgstr "新规则"
407
-
408
414
  msgid "New in the last 24 hours"
409
415
  msgstr "在过去 24 小时内新建"
410
416
 
@@ -438,6 +444,9 @@ msgstr "未找到主机 %s 的规则"
438
444
  msgid "Not reported in more than 7 days"
439
445
  msgstr "超过 7 天没有报告的"
440
446
 
447
+ msgid "One or more hosts have been discovered"
448
+ msgstr ""
449
+
441
450
  msgid "Organization"
442
451
  msgstr "机构"
443
452
 
@@ -585,9 +594,6 @@ msgstr ""
585
594
  msgid "Target host group for this rule with all properties set"
586
595
  msgstr "根据所有属性设置标定主机组"
587
596
 
588
- msgid "Template"
589
- msgstr "模板"
590
-
591
597
  msgid "The default location to place discovered hosts in"
592
598
  msgstr "找到主机的默认位置"
593
599
 
@@ -5,10 +5,10 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 8.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 9.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2017-01-06 08:26+0100\n"
11
- "PO-Revision-Date: 2017-03-15 12:38+0000\n"
10
+ "POT-Creation-Date: 2017-04-07 13:02+0200\n"
11
+ "PO-Revision-Date: 2017-04-08 10:07+0000\n"
12
12
  "Last-Translator: Lukáš Zapletal\n"
13
13
  "Language-Team: Chinese (Taiwan) (http://www.transifex.com/foreman/foreman/language/zh_TW/)\n"
14
14
  "MIME-Version: 1.0\n"
@@ -365,6 +365,7 @@ msgid "%s - The following hosts are about to be changed"
365
365
  msgstr "%s - 以下主機即將受到更改"
366
366
 
367
367
  #: ../app/helpers/discovered_hosts_helper.rb:49
368
+ #: ../app/views/dashboard/_discovery_widget_host.html.erb:2
368
369
  msgid "N/A"
369
370
  msgstr "N/A"
370
371
 
@@ -385,7 +386,7 @@ msgid "Provision"
385
386
  msgstr "佈建"
386
387
 
387
388
  #: ../app/helpers/discovery_rules_helper.rb:26
388
- #: ../lib/foreman_discovery/engine.rb:163
389
+ #: ../lib/foreman_discovery/engine.rb:165
389
390
  msgid "Discovered Hosts"
390
391
  msgstr ""
391
392
 
@@ -442,43 +443,43 @@ msgid_plural ""
442
443
  "Host group locations %s must also be associated to the discovery rule"
443
444
  msgstr[0] ""
444
445
 
445
- #: ../app/models/host/discovered.rb:38
446
+ #: ../app/models/host/discovered.rb:37
446
447
  msgid "Invalid facts, must be a Hash"
447
448
  msgstr "詳情無效,必須是雜湊"
448
449
 
449
- #: ../app/models/host/discovered.rb:43
450
+ #: ../app/models/host/discovered.rb:42
450
451
  msgid ""
451
452
  "Expected discovery_fact '%s' is missing, unable to detect primary interface "
452
453
  "and set hostname"
453
454
  msgstr "沒有預期的 discovery_fact '%s',無法偵測主介面並設定主機名稱"
454
455
 
455
- #: ../app/models/host/discovered.rb:50
456
+ #: ../app/models/host/discovered.rb:49
456
457
  msgid ""
457
458
  "Invalid facts: hash does not contain a valid value for any of the facts in "
458
459
  "the discovery_hostname setting: %s"
459
460
  msgstr ""
460
461
 
461
- #: ../app/models/host/discovered.rb:67
462
+ #: ../app/models/host/discovered.rb:66
462
463
  msgid "Facts could not be imported"
463
464
  msgstr ""
464
465
 
465
- #: ../app/models/host/discovered.rb:117
466
+ #: ../app/models/host/discovered.rb:116
466
467
  msgid "Unable to assign subnet, primary interface is missing IP address"
467
468
  msgstr "無法指定子網路,主介面沒有 IP 位址"
468
469
 
469
- #: ../app/models/host/discovered.rb:174
470
+ #: ../app/models/host/discovered.rb:173
470
471
  msgid "Could not get facts from proxy %{url}: %{error}"
471
472
  msgstr "無法由協定 %{url} 取得詳細資料:%{error}"
472
473
 
473
- #: ../app/models/host/discovered.rb:190
474
+ #: ../app/models/host/discovered.rb:189
474
475
  msgid "Unable to reboot %{name} via %{url}: %{msg}"
475
476
  msgstr "無法透過 %{url} 重新啟動 %{name}:%{msg}"
476
477
 
477
- #: ../app/models/host/discovered.rb:198
478
+ #: ../app/models/host/discovered.rb:197
478
479
  msgid "Unable to perform kexec on %{name} via %{url}: %{msg}"
479
480
  msgstr "無法透過 %{url} 在 %{name} 上執行 kexec:%{msg}"
480
481
 
481
- #: ../app/models/host/discovered.rb:217
482
+ #: ../app/models/host/discovered.rb:216
482
483
  msgid "Invalid hostname: Could not normalize the hostname"
483
484
  msgstr ""
484
485
 
@@ -715,7 +716,7 @@ msgid "Create host"
715
716
  msgstr ""
716
717
 
717
718
  #: ../app/views/discovered_hosts/_discovered_hosts_list.html.erb:2
718
- #: ../lib/foreman_discovery/engine.rb:148
719
+ #: ../lib/foreman_discovery/engine.rb:150
719
720
  msgid "Discovered hosts"
720
721
  msgstr "發現的主機"
721
722
 
@@ -878,23 +879,19 @@ msgstr "組織"
878
879
  msgid "Target host group for this rule with all properties set"
879
880
  msgstr "此規則的目標主機群組,並且設置了所有內容"
880
881
 
881
- #: ../app/views/discovery_rules/_form.html.erb:24
882
- msgid "Template"
883
- msgstr "範本"
884
-
885
- #: ../app/views/discovery_rules/_form.html.erb:26
882
+ #: ../app/views/discovery_rules/_form.html.erb:25
886
883
  msgid "Hostname for provisioned hosts"
887
884
  msgstr "已佈建之主機的主機名稱"
888
885
 
889
- #: ../app/views/discovery_rules/_form.html.erb:27
886
+ #: ../app/views/discovery_rules/_form.html.erb:26
890
887
  msgid "Hosts limit"
891
888
  msgstr "主機限制"
892
889
 
893
- #: ../app/views/discovery_rules/_form.html.erb:27
890
+ #: ../app/views/discovery_rules/_form.html.erb:26
894
891
  msgid "Maximum hosts provisioned with this rule (0 = unlimited)"
895
892
  msgstr "以此規則佈建的主機已達到最大限制(0 = 無限制)"
896
893
 
897
- #: ../app/views/discovery_rules/_form.html.erb:28
894
+ #: ../app/views/discovery_rules/_form.html.erb:27
898
895
  msgid "Rule priority (lower integer means higher priority)"
899
896
  msgstr "規則優先順序(愈小的數字代表愈高的優先權)"
900
897
 
@@ -937,8 +934,8 @@ msgid "Discovery Rules"
937
934
  msgstr "搜尋規則"
938
935
 
939
936
  #: ../app/views/discovery_rules/index.html.erb:2
940
- msgid "New Rule"
941
- msgstr "新規則"
937
+ msgid "Create Rule"
938
+ msgstr ""
942
939
 
943
940
  #: ../app/views/discovery_rules/index.html.erb:6
944
941
  msgid "DiscoveryRule|Name"
@@ -972,21 +969,33 @@ msgstr "新的搜尋規則"
972
969
  msgid "A summary of discovered hosts"
973
970
  msgstr ""
974
971
 
975
- #: ../lib/foreman_discovery/engine.rb:153
972
+ #: ../db/seeds.d/80_discovery_ui_notification.rb:4
973
+ msgid "Hosts"
974
+ msgstr ""
975
+
976
+ #: ../db/seeds.d/80_discovery_ui_notification.rb:6
977
+ msgid "One or more hosts have been discovered"
978
+ msgstr ""
979
+
980
+ #: ../db/seeds.d/80_discovery_ui_notification.rb:13
981
+ msgid "Details"
982
+ msgstr ""
983
+
984
+ #: ../lib/foreman_discovery/engine.rb:155
976
985
  msgid "Discovery rules"
977
986
  msgstr "搜尋規則"
978
987
 
979
- #: ../lib/foreman_discovery/engine.rb:176
988
+ #: ../lib/foreman_discovery/engine.rb:178
980
989
  msgid "Discovery Proxy"
981
990
  msgstr ""
982
991
 
983
- #: ../lib/foreman_discovery/engine.rb:177
992
+ #: ../lib/foreman_discovery/engine.rb:179
984
993
  msgid ""
985
994
  "Discovery Proxy to use within this subnet for managing connection to "
986
995
  "discovered hosts"
987
996
  msgstr ""
988
997
 
989
- #: ../lib/foreman_discovery/engine.rb:178
998
+ #: ../lib/foreman_discovery/engine.rb:180
990
999
  msgid ""
991
1000
  "ID of Discovery Proxy to use within this subnet for managing connection to "
992
1001
  "discovered hosts"
@@ -5,9 +5,9 @@
5
5
  # Translators:
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: foreman_discovery 8.0.0\n"
8
+ "Project-Id-Version: foreman_discovery 9.0.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
- "PO-Revision-Date: 2017-03-15 12:38+0000\n"
10
+ "PO-Revision-Date: 2017-04-08 10:07+0000\n"
11
11
  "Last-Translator: Lukáš Zapletal\n"
12
12
  "Language-Team: Chinese (Taiwan) (http://www.transifex.com/foreman/foreman/lang"
13
13
  "uage/zh_TW/)\n"
@@ -77,6 +77,9 @@ msgstr ""
77
77
  msgid "Could not get facts from proxy %{url}: %{error}"
78
78
  msgstr "無法由協定 %{url} 取得詳細資料:%{error}"
79
79
 
80
+ msgid "Create Rule"
81
+ msgstr ""
82
+
80
83
  msgid "Create a discovered host for testing (use /facts to create new hosts)"
81
84
  msgstr "建立測試用的搜尋主機(使用 /facts 來建立新主機)"
82
85
 
@@ -104,6 +107,9 @@ msgstr ""
104
107
  msgid "Destroyed selected hosts"
105
108
  msgstr "刪除選擇的主機"
106
109
 
110
+ msgid "Details"
111
+ msgstr ""
112
+
107
113
  msgid "Disable"
108
114
  msgstr "停用"
109
115
 
@@ -285,6 +291,9 @@ msgstr ""
285
291
  msgid "Hostnames must not start with numbers. A good approach is to use unique information provided by facter (MAC address, BIOS or serial ID)."
286
292
  msgstr ""
287
293
 
294
+ msgid "Hosts"
295
+ msgstr ""
296
+
288
297
  msgid "Hosts limit"
289
298
  msgstr "主機限制"
290
299
 
@@ -402,9 +411,6 @@ msgstr ""
402
411
  msgid "New Discovery Rule"
403
412
  msgstr "新的搜尋規則"
404
413
 
405
- msgid "New Rule"
406
- msgstr "新規則"
407
-
408
414
  msgid "New in the last 24 hours"
409
415
  msgstr "過去 24 小時的新項目"
410
416
 
@@ -438,6 +444,9 @@ msgstr "未找到主機 %s 的規則"
438
444
  msgid "Not reported in more than 7 days"
439
445
  msgstr "七天內未回報"
440
446
 
447
+ msgid "One or more hosts have been discovered"
448
+ msgstr ""
449
+
441
450
  msgid "Organization"
442
451
  msgstr "組織"
443
452
 
@@ -585,9 +594,6 @@ msgstr ""
585
594
  msgid "Target host group for this rule with all properties set"
586
595
  msgstr "此規則的目標主機群組,並且設置了所有內容"
587
596
 
588
- msgid "Template"
589
- msgstr "範本"
590
-
591
597
  msgid "The default location to place discovered hosts in"
592
598
  msgstr "放置已發現之主機的預設位置"
593
599
 
@@ -0,0 +1,26 @@
1
+ FactoryGirl.define do
2
+ factory :discovered_host, class: 'Host::Discovered' do
3
+ sequence(:name) { |n| "host#{n}" }
4
+ sequence(:ip) { |n| IPAddr.new(n, Socket::AF_INET).to_s }
5
+ sequence(:mac) { |n| "02:23:45:67:" + n.to_s(16).rjust(4, '0').insert(2, ':') }
6
+
7
+ after(:build) do |discovered_host|
8
+ attribute_set = DiscoveryAttributeSet.new(:host => discovered_host,
9
+ :memory => '1',
10
+ :cpu_count => '4')
11
+ discovered_host.discovery_attribute_set = attribute_set
12
+ end
13
+
14
+ trait :with_facts do
15
+ transient do
16
+ fact_count 20
17
+ end
18
+
19
+ after(:create) do |discovered_host, evaluator|
20
+ evaluator.fact_count.times do
21
+ FactoryGirl.create(:fact_value, :host => discovered_host)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -11,30 +11,3 @@ FactoryGirl.define do
11
11
  locations { [location_one] } if SETTINGS[:locations_enabled]
12
12
  end
13
13
  end
14
-
15
- FactoryGirl.define do
16
- factory :discovered_host, class: 'Host::Discovered' do
17
- sequence(:name) { |n| "host#{n}" }
18
- sequence(:ip) { |n| IPAddr.new(n, Socket::AF_INET).to_s }
19
- sequence(:mac) { |n| "02:23:45:67:" + n.to_s(16).rjust(4, '0').insert(2, ':') }
20
-
21
- after(:build) do |discovered_host|
22
- attribute_set = DiscoveryAttributeSet.new(:host => discovered_host,
23
- :memory => '1',
24
- :cpu_count => '4')
25
- discovered_host.discovery_attribute_set = attribute_set
26
- end
27
-
28
- trait :with_facts do
29
- transient do
30
- fact_count 20
31
- end
32
-
33
- after(:create) do |discovered_host, evaluator|
34
- evaluator.fact_count.times do
35
- FactoryGirl.create(:fact_value, :discovered_host => discovered_host)
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class Api::V2::DiscoveredHostsControllerTest < ActionController::TestCase
4
4
 
@@ -13,7 +13,6 @@ class Api::V2::DiscoveredHostsControllerTest < ActionController::TestCase
13
13
  SETTINGS[:organizations_enabled] = true
14
14
  SETTINGS[:locations_enabled] = true
15
15
  FactoryGirl.create(:subnet, :network => "192.168.100.1", :mask => "255.255.255.0", :locations => [location_one], :organizations => [organization_one])
16
- User.current = User.find_by_login "admin"
17
16
  @request.env['HTTP_REFERER'] = '/discovery_rules'
18
17
  @facts = {
19
18
  "interfaces" => "lo,eth0",
@@ -83,18 +82,21 @@ class Api::V2::DiscoveredHostsControllerTest < ActionController::TestCase
83
82
  end
84
83
 
85
84
  def test_auto_provision_success_via_upload
85
+ reset_api_credentials
86
+ User.current = nil
86
87
  disable_orchestration
87
88
  facts = @facts.merge({"somefact" => "abc"})
88
89
  taxonomy = { :organizations => [organization_one], :locations => [location_one] }
89
90
  DiscoveryRule.create({:priority => 1, :name => 'rule', :search => "facts.somefact = abc", :hostgroup => FactoryGirl.create(:hostgroup, :with_os, :with_rootpass, taxonomy)}.merge(taxonomy))
90
- as_user(:one) do
91
- post :facts, { :facts => facts }
92
- end
91
+ post :facts, { :facts => facts }
93
92
 
94
93
  assert_response :success
95
94
  actual = JSON.parse(response.body)
95
+ assert_not_nil id = actual['id']
96
+ assert !Host::Discovered.unscoped.where(id: id).exists?, 'discovered host still exists!'
97
+ assert Host.unscoped.where(id: id).exists?, 'host was not auto provisioned!'
96
98
  assert_not_nil actual['created_at']
97
- assert_equal "Auto-discovered and provisioned via rule 'rule'", Host.unscoped.find(actual['id']).comment
99
+ assert_equal "Auto-discovered and provisioned via rule 'rule'", Host.unscoped.find(id).comment
98
100
  end
99
101
 
100
102
  def test_auto_provision_success
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class Api::V2::DiscoveryRulesControllerTest < ActionController::TestCase
4
4
  setup do
@@ -23,10 +23,13 @@ class Api::V2::DiscoveryRulesControllerTest < ActionController::TestCase
23
23
  assert_equal 1, discovery_rules['total']
24
24
  end
25
25
 
26
- test "should show discovery rule" do
26
+ test "should show discovery rule with taxonomy" do
27
27
  rule = FactoryGirl.create(:discovery_rule)
28
28
  get :show, { :id => rule.to_param }
29
29
  assert_response :success
30
+ discovery_rule = ActiveSupport::JSON.decode(@response.body)
31
+ assert_equal "Organization 1", discovery_rule['organizations'].first['name']
32
+ assert_equal "Location 1", discovery_rule['locations'].first['name']
30
33
  end
31
34
 
32
35
  test "should create discovery rule with taxonomy" do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  module Api
4
4
  module V2
@@ -27,7 +27,7 @@ module Api
27
27
  disable_orchestration
28
28
  facts = @facts.merge({ "somefact" => "abc" })
29
29
  host = Host::Discovered.import_host(facts)
30
- get :index, { :discovered_host_id => host.id }
30
+ get :index, { :host_id => host.id }
31
31
  assert_response :success
32
32
  show_response = ActiveSupport::JSON.decode(@response.body)
33
33
  assert_equal "abc", show_response['results'].values.first['somefact']
@@ -1,5 +1,4 @@
1
1
  require 'test_plugin_helper'
2
- require 'test_helper_discovery'
3
2
 
4
3
  class DiscoveredHostsControllerTest < ActionController::TestCase
5
4
  setup :initialize_host
@@ -37,6 +36,15 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
37
36
  assert_response :success
38
37
  end
39
38
 
39
+ def test_show_multiple_actions
40
+ host = Host::Discovered.import_host(@facts)
41
+ [:multiple_destroy, :select_multiple_organization, :select_multiple_location].each do |path|
42
+ xhr :post, path, {:host_ids => [host.id]}, set_session_user
43
+ assert_response :success
44
+ assert response.body =~ /#{host.name}/
45
+ end
46
+ end
47
+
40
48
  def test_show_page_categories
41
49
  host = Host::Discovered.import_host(@facts)
42
50
  get :show, {:id => host.id}, set_session_user_default_reader
@@ -119,29 +127,31 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
119
127
  end
120
128
 
121
129
  def test_update_inheritance
122
- host = Host::Discovered.import_host(@facts)
123
- hostgroup = setup_hostgroup(host)
124
- put :update, {
125
- commit: 'Update',
126
- id: host.id,
127
- host: {
128
- name: 'mytest',
129
- hostgroup_id: hostgroup.id
130
- }
131
- }, set_session_user_default_manager
132
-
133
- # Get the managed host instance from the DB
134
- actual = Host.find(host.id)
135
-
136
- assert_equal hostgroup.id, actual.hostgroup_id
137
- assert_equal hostgroup.architecture_id, actual.architecture_id
138
- assert_equal hostgroup.operatingsystem_id, actual.operatingsystem_id
139
- assert_equal hostgroup.medium_id, actual.medium_id
140
- assert_equal hostgroup.ptable_id, actual.ptable_id
141
- assert_equal hostgroup.domain_id, actual.domain_id
142
- assert_equal hostgroup.environment_id, actual.environment_id
143
- assert_equal hostgroup.puppet_proxy_id, actual.puppet_proxy_id
144
- assert_equal hostgroup.puppet_ca_proxy_id, actual.puppet_ca_proxy_id
130
+ as_default_manager do
131
+ host = Host::Discovered.import_host(@facts)
132
+ hostgroup = setup_hostgroup(host)
133
+ put :update, {
134
+ commit: 'Update',
135
+ id: host.id,
136
+ host: {
137
+ name: 'mytest',
138
+ hostgroup_id: hostgroup.id
139
+ }
140
+ }, set_session_user(User.current)
141
+
142
+ # Get the managed host instance from the DB
143
+ actual = Host.find(host.id)
144
+
145
+ assert_equal hostgroup.id, actual.hostgroup_id
146
+ assert_equal hostgroup.architecture_id, actual.architecture_id
147
+ assert_equal hostgroup.operatingsystem_id, actual.operatingsystem_id
148
+ assert_equal hostgroup.medium_id, actual.medium_id
149
+ assert_equal hostgroup.ptable_id, actual.ptable_id
150
+ assert_equal hostgroup.domain_id, actual.domain_id
151
+ assert_equal hostgroup.environment_id, actual.environment_id
152
+ assert_equal hostgroup.puppet_proxy_id, actual.puppet_proxy_id
153
+ assert_equal hostgroup.puppet_ca_proxy_id, actual.puppet_ca_proxy_id
154
+ end
145
155
  end
146
156
 
147
157
  def test_add_entry_to_nav_menu
@@ -193,48 +203,68 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
193
203
  end
194
204
 
195
205
  def test_auto_provision_success
196
- disable_orchestration
197
- facts = @facts.merge({"somefact" => "abc"})
198
- host = Host::Discovered.import_host(facts)
199
- hostgroup = setup_hostgroup(host)
200
- FactoryGirl.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :hostgroup => hostgroup, :organizations => [host.organization], :locations => [host.location])
201
- post :auto_provision, { :id => host.id }, set_session_user_default_manager
202
- assert_response :redirect
203
- assert_nil flash[:error]
204
- assert_match /^Host macaabbccddeeff.* was provisioned/, flash[:notice]
205
- managed_host = Host.find(host.id)
206
- assert managed_host.build
206
+ as_default_manager do
207
+ disable_orchestration
208
+ facts = @facts.merge({"somefact" => "abc"})
209
+ host = Host::Discovered.import_host(facts)
210
+ hostgroup = setup_hostgroup(host)
211
+ FactoryGirl.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :hostgroup => hostgroup, :organizations => [host.organization], :locations => [host.location])
212
+ post :auto_provision, { :id => host.id }, set_session_user(User.current)
213
+ assert_response :redirect
214
+ assert_nil flash[:error]
215
+ assert_match(/^Host macaabbccddeeff.* was provisioned/, flash[:notice])
216
+ managed_host = Host.find(host.id)
217
+ assert managed_host.build
218
+ end
207
219
  end
208
220
 
209
221
  def test_auto_provision_no_rule_success
210
- disable_orchestration
211
- facts = @facts.merge({"somefact" => "abc"})
212
- host = Host::Discovered.import_host(facts)
213
- post :auto_provision, { :id => host.id }, set_session_user_default_manager
222
+ as_default_manager do
223
+ disable_orchestration
224
+ facts = @facts.merge({"somefact" => "abc"})
225
+ host = Host::Discovered.import_host(facts)
226
+ post :auto_provision, { :id => host.id }, set_session_user(User.current)
227
+ end
214
228
  assert_response :redirect
215
229
  assert_nil flash[:error]
216
230
  assert_equal "No rule found for host macaabbccddeeff", flash[:notice]
217
231
  end
218
232
 
219
233
  def test_auto_provision_all_success
220
- disable_orchestration
221
- facts = @facts.merge({"somefact" => "abc"})
222
- host = Host::Discovered.import_host(facts)
223
- taxonomy = { :organizations => [host.organization], :locations => [host.location] }
224
- FactoryGirl.create(:discovery_rule, {:priority => 1, :search => "facts.somefact = abc", :hostgroup => FactoryGirl.create(:hostgroup, :with_os, :with_rootpass, taxonomy)}.merge(taxonomy))
225
- post :auto_provision_all, {}, set_session_user_default_manager
234
+ as_default_manager do
235
+ disable_orchestration
236
+ facts = @facts.merge({"somefact" => "abc"})
237
+ host = Host::Discovered.import_host(facts)
238
+ hostgroup = setup_hostgroup(host)
239
+ FactoryGirl.create(
240
+ :discovery_rule,
241
+ :priority => 1,
242
+ :search => "facts.somefact = abc",
243
+ :hostgroup => hostgroup,
244
+ :organizations => [host.organization], :locations => [host.location]
245
+ )
246
+ post :auto_provision_all, {}, set_session_user(User.current)
247
+ end
226
248
  assert_response :redirect
227
249
  assert_nil flash[:error]
228
250
  assert_equal "Discovered hosts are provisioning now", flash[:notice]
229
251
  end
230
252
 
231
253
  def test_auto_provision_all_no_rule_success
232
- disable_orchestration
233
- facts = @facts.merge({"somefact" => "abc"})
234
- host = Host::Discovered.import_host(facts)
235
- taxonomy = { :organizations => [host.organization], :locations => [host.location] }
236
- FactoryGirl.create(:discovery_rule, {:priority => 1, :search => "facts.somefact = abc", :hostgroup => FactoryGirl.create(:hostgroup, :with_os, :with_rootpass, taxonomy)}.merge(taxonomy))
237
- post :auto_provision_all, {}, set_session_user_default_manager
254
+ as_default_manager do
255
+ disable_orchestration
256
+ facts = @facts.merge({"somefact" => "abc"})
257
+ host = Host::Discovered.import_host(facts)
258
+ hostgroup = setup_hostgroup(host)
259
+ FactoryGirl.create(
260
+ :discovery_rule,
261
+ :priority => 1,
262
+ :search => "facts.somefact = abc",
263
+ :hostgroup => hostgroup,
264
+ :organizations => [host.organization], :locations => [host.location]
265
+ )
266
+ post :auto_provision_all, {}, set_session_user(User.current)
267
+ end
238
268
  assert_response :redirect
239
269
  assert_nil flash[:error]
240
270
  assert_equal "Discovered hosts are provisioning now", flash[:notice]
@@ -263,7 +293,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
263
293
 
264
294
  def test_reboot_all_error
265
295
  @request.env["HTTP_REFERER"] = discovered_hosts_url
266
- host = Host::Discovered.import_host(@facts)
296
+ Host::Discovered.import_host(@facts)
267
297
  ::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).raises("request failed")
268
298
  post "reboot_all", { }, set_session_user_default_manager
269
299
  assert_redirected_to discovered_hosts_url
@@ -272,38 +302,44 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
272
302
  end
273
303
 
274
304
  def test_no_dns_rebuild_if_dns_pending
275
- host = Host::Discovered.import_host(@facts)
276
- hostgroup = prepare_hostgroup_for_dns_rebuild(host)
277
- Nic::Managed.any_instance.expects(:rebuild_dns).never
278
- Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
279
- put :update, {:commit => "Update", :id => host.id,
280
- :host => {
281
- :name => 'mytest',
282
- :hostgroup_id => hostgroup.id,
283
- }
284
- }, set_session_user_default_manager
305
+ as_default_manager do
306
+ host = Host::Discovered.import_host(@facts)
307
+ hostgroup = prepare_hostgroup_for_dns_rebuild(host)
308
+ Nic::Managed.any_instance.expects(:rebuild_dns).never
309
+ Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
310
+ put :update, {:commit => "Update", :id => host.id,
311
+ :host => {
312
+ :name => 'mytest',
313
+ :hostgroup_id => hostgroup.id,
314
+ }
315
+ }, set_session_user(User.current)
316
+ end
285
317
  end
286
318
 
287
319
  def test_dns_rebuild
288
- host = prepare_host_for_dns_rebuild
289
- hostgroup = prepare_hostgroup_for_dns_rebuild(host)
290
- Nic::Managed.any_instance.expects(:rebuild_dns)
291
- Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
292
- put :update, {:commit => "Update", :id => host.id,
293
- :host => {
294
- :name => 'mytest',
295
- :hostgroup_id => hostgroup.id,
296
- }
297
- }, set_session_user_default_manager
320
+ as_default_manager do
321
+ host = prepare_host_for_dns_rebuild
322
+ hostgroup = prepare_hostgroup_for_dns_rebuild(host)
323
+ Nic::Managed.any_instance.expects(:rebuild_dns)
324
+ Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
325
+ put :update, {:commit => "Update", :id => host.id,
326
+ :host => {
327
+ :name => 'mytest',
328
+ :hostgroup_id => hostgroup.id,
329
+ }
330
+ }, set_session_user(User.current)
331
+ end
298
332
  end
299
333
 
300
334
  def test_dns_rebuild_with_auto_provision
301
- host = prepare_host_for_dns_rebuild
302
- hostgroup = prepare_hostgroup_for_dns_rebuild(host)
303
- Nic::Managed.any_instance.expects(:rebuild_dns)
304
- Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
305
- FactoryGirl.create(:discovery_rule, :priority => 1, :search => "name = mytest.myorchdomain.net", :hostgroup_id => hostgroup.id, :organizations => [host.organization], :locations => [host.location])
306
- post :auto_provision, { :id => host.id }, set_session_user_default_manager
335
+ as_default_manager do
336
+ host = prepare_host_for_dns_rebuild
337
+ hostgroup = prepare_hostgroup_for_dns_rebuild(host)
338
+ Nic::Managed.any_instance.expects(:rebuild_dns)
339
+ Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
340
+ FactoryGirl.create(:discovery_rule, :priority => 1, :search => "name = mytest.myorchdomain.net", :hostgroup_id => hostgroup.id, :organizations => [host.organization], :locations => [host.location])
341
+ post :auto_provision, { :id => host.id }, set_session_user(User.current)
342
+ end
307
343
  end
308
344
 
309
345
  private