foreman_discovery 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/api/v2/discovered_hosts_controller.rb +6 -4
- data/app/controllers/api/v2/discovery_rules_controller.rb +3 -2
- data/app/controllers/concerns/foreman/controller/parameters/discovered_host.rb +24 -0
- data/app/controllers/concerns/foreman/controller/parameters/discovery_rule.rb +17 -0
- data/app/controllers/discovered_hosts_controller.rb +3 -2
- data/app/controllers/discovery_rules_controller.rb +4 -2
- data/app/helpers/discovered_hosts_helper.rb +7 -10
- data/app/models/concerns/discovery_subnet.rb +0 -2
- data/app/models/concerns/fact_value_extensions.rb +5 -0
- data/app/models/discovery_attribute_set.rb +0 -1
- data/app/models/discovery_rule.rb +0 -2
- data/app/models/host/discovered.rb +0 -2
- data/app/models/host/managed_extensions.rb +1 -3
- data/app/models/hostgroup_extensions.rb +0 -1
- data/app/models/nic/managed_extensions.rb +26 -0
- data/app/models/setting/discovered.rb +1 -0
- data/app/views/discovered_hosts/_discovered_host_modal.html.erb +30 -0
- data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +1 -29
- data/app/views/discovered_hosts/show.html.erb +20 -12
- data/app/views/discovery_rules/_form.html.erb +1 -1
- data/app/views/foreman_discovery/debian_kexec.erb +2 -3
- data/app/views/foreman_discovery/redhat_kexec.erb +2 -3
- data/lib/foreman_discovery/engine.rb +8 -1
- 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 +1 -1
- data/locale/ca/foreman_discovery.po +2 -2
- data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/de/foreman_discovery.edit.po +33 -33
- data/locale/de/foreman_discovery.po +67 -67
- data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en/foreman_discovery.edit.po +138 -130
- data/locale/en/foreman_discovery.po +13 -7
- data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en_GB/foreman_discovery.edit.po +34 -33
- data/locale/en_GB/foreman_discovery.po +33 -32
- data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/es/foreman_discovery.edit.po +51 -51
- data/locale/es/foreman_discovery.po +51 -51
- data/locale/foreman_discovery.pot +151 -144
- data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/fr/foreman_discovery.edit.po +1 -1
- data/locale/fr/foreman_discovery.po +33 -33
- data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/gl/foreman_discovery.edit.po +1 -1
- data/locale/gl/foreman_discovery.po +2 -2
- data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/it/foreman_discovery.edit.po +5 -5
- data/locale/it/foreman_discovery.po +5 -5
- data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ja/foreman_discovery.edit.po +37 -37
- data/locale/ja/foreman_discovery.po +36 -36
- data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ko/foreman_discovery.edit.po +36 -36
- data/locale/ko/foreman_discovery.po +35 -35
- data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/pt_BR/foreman_discovery.edit.po +40 -40
- data/locale/pt_BR/foreman_discovery.po +39 -39
- data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ru/foreman_discovery.edit.po +8 -8
- data/locale/ru/foreman_discovery.po +8 -8
- data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/sv_SE/foreman_discovery.edit.po +1 -1
- data/locale/sv_SE/foreman_discovery.po +2 -2
- data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_CN/foreman_discovery.edit.po +37 -37
- data/locale/zh_CN/foreman_discovery.po +36 -36
- data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_TW/foreman_discovery.edit.po +36 -36
- data/locale/zh_TW/foreman_discovery.po +35 -35
- data/test/factories/discovery_rule_related.rb +19 -2
- data/test/functional/api/v2/discovered_hosts_controller_test.rb +1 -0
- data/test/functional/api/v2/discovery_rules_controller_test.rb +13 -5
- data/test/functional/discovered_hosts_controller_test.rb +71 -3
- data/test/functional/discovery_rules_controller_test.rb +23 -6
- data/test/test_helper_discovery.rb +4 -0
- data/test/unit/discovered_extensions_test.rb +2 -0
- data/test/unit/fact_value_extensions_test.rb +11 -0
- metadata +9 -3
@@ -5,9 +5,9 @@
|
|
5
5
|
# Translators:
|
6
6
|
msgid ""
|
7
7
|
msgstr ""
|
8
|
-
"Project-Id-Version: foreman_discovery
|
8
|
+
"Project-Id-Version: foreman_discovery 7.0.0\n"
|
9
9
|
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"PO-Revision-Date: 2016-
|
10
|
+
"PO-Revision-Date: 2016-08-12 16:28+0000\n"
|
11
11
|
"Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>\n"
|
12
12
|
"Language-Team: Chinese (Taiwan) (http://www.transifex.com/foreman/foreman/lang"
|
13
13
|
"uage/zh_TW/)\n"
|
@@ -24,7 +24,7 @@ msgid "%s ago"
|
|
24
24
|
msgstr "%s 之前"
|
25
25
|
|
26
26
|
msgid "%s discovered hosts were provisioned"
|
27
|
-
msgstr ""
|
27
|
+
msgstr "%s 已發現的主機已供給"
|
28
28
|
|
29
29
|
msgid "<b>Foreman</b> Discovered hosts summary"
|
30
30
|
msgstr ""
|
@@ -78,7 +78,7 @@ msgid "Could not get facts from proxy %{url}: %{error}"
|
|
78
78
|
msgstr "無法由協定 %{url} 取得詳細資料:%{error}"
|
79
79
|
|
80
80
|
msgid "Create a discovered host for testing (use /facts to create new hosts)"
|
81
|
-
msgstr ""
|
81
|
+
msgstr "建立測試用的搜尋主機(使用 /facts 來建立新主機)"
|
82
82
|
|
83
83
|
msgid "Create a discovery rule"
|
84
84
|
msgstr "建立一項搜尋規則"
|
@@ -123,7 +123,7 @@ msgid "Discovered hosts are provisioning now"
|
|
123
123
|
msgstr "發現的主機現在正在佈建"
|
124
124
|
|
125
125
|
msgid "Discovered hosts are rebooting now"
|
126
|
-
msgstr ""
|
126
|
+
msgstr "發現的主機正在重新啟動"
|
127
127
|
|
128
128
|
msgid "Discovered hosts from Foreman server at %{foreman_url}"
|
129
129
|
msgstr ""
|
@@ -180,7 +180,7 @@ msgid "Errors during auto provisioning: %s"
|
|
180
180
|
msgstr "進行自動佈建時發生了錯誤:%s"
|
181
181
|
|
182
182
|
msgid "Errors during reboot: %s"
|
183
|
-
msgstr ""
|
183
|
+
msgstr "重新開機時發生了錯誤:%s"
|
184
184
|
|
185
185
|
msgid "Execute rules against a discovered host"
|
186
186
|
msgstr "針對於一部發現的主機執行規則"
|
@@ -192,10 +192,10 @@ msgid "Expand All"
|
|
192
192
|
msgstr "全部展開"
|
193
193
|
|
194
194
|
msgid "Expected discovery_fact '%s' is missing, unable to detect primary interface and set hostname"
|
195
|
-
msgstr ""
|
195
|
+
msgstr "沒有預期的 discovery_fact '%s',無法偵測主介面並設定主機名稱"
|
196
196
|
|
197
197
|
msgid "Extra facter columns to show in host lists (separate by comma)"
|
198
|
-
msgstr ""
|
198
|
+
msgstr "要在主機清單中顯示的額外事實欄(以逗號隔開)"
|
199
199
|
|
200
200
|
msgid "Fact columns"
|
201
201
|
msgstr ""
|
@@ -219,13 +219,13 @@ msgid "Failed to reboot host %{hostname} with error %{error_message}"
|
|
219
219
|
msgstr "重新啟動主機 %{hostname} 失敗,錯誤訊息為 %{error_message}"
|
220
220
|
|
221
221
|
msgid "Failed to reboot hosts with error %s"
|
222
|
-
msgstr ""
|
222
|
+
msgstr "重新啟動主機失敗,錯誤訊息為 %s"
|
223
223
|
|
224
224
|
msgid "Failed to refresh facts for %s"
|
225
225
|
msgstr "刷新 %s 的詳情失敗"
|
226
226
|
|
227
227
|
msgid "Failed to refresh facts for %{hostname} with error %{error_message}"
|
228
|
-
msgstr ""
|
228
|
+
msgstr "重新刷新主機 %{hostname} 的事實失敗,錯誤訊息為 %{error_message}"
|
229
229
|
|
230
230
|
msgid "Foreman discovered hosts summary"
|
231
231
|
msgstr ""
|
@@ -298,10 +298,10 @@ msgid "Identifier"
|
|
298
298
|
msgstr "辨識碼"
|
299
299
|
|
300
300
|
msgid "Image API processing error: %{msg} (HTTP/%{code}, body: %{body})"
|
301
|
-
msgstr ""
|
301
|
+
msgstr "映像檔 API 處理錯誤:%{msg} (HTTP/%{code}, body: %{body})"
|
302
302
|
|
303
303
|
msgid "Image API returned HTTP/%{code} with '%{body}"
|
304
|
-
msgstr ""
|
304
|
+
msgstr "映像檔 API 傳回 HTTP/%{code} 與 '%{body}"
|
305
305
|
|
306
306
|
msgid "In addition to @host attribute function rand for random integers is available. Examples:"
|
307
307
|
msgstr ""
|
@@ -322,7 +322,7 @@ msgid "Invalid hostname: Could not normalize the hostname"
|
|
322
322
|
msgstr ""
|
323
323
|
|
324
324
|
msgid "Kexec template not associated with operating system"
|
325
|
-
msgstr ""
|
325
|
+
msgstr "kexec 範本並不與作業系統相關連"
|
326
326
|
|
327
327
|
msgid "Last facts upload"
|
328
328
|
msgstr "最後上傳的詳情"
|
@@ -358,7 +358,7 @@ msgid "Maximum hosts provisioned with this rule (0 = unlimited)"
|
|
358
358
|
msgstr "以此規則佈建的主機已達到最大限制(0 = 無限制)"
|
359
359
|
|
360
360
|
msgid "Medium not set for host/hostgroup"
|
361
|
-
msgstr ""
|
361
|
+
msgstr "媒體並未設定給主機/主機群組使用"
|
362
362
|
|
363
363
|
msgid "Memory"
|
364
364
|
msgstr "記憶體"
|
@@ -391,7 +391,7 @@ msgid "New Rule"
|
|
391
391
|
msgstr "新規則"
|
392
392
|
|
393
393
|
msgid "New in the last 24 hours"
|
394
|
-
msgstr ""
|
394
|
+
msgstr "過去 24 小時的新項目"
|
395
395
|
|
396
396
|
msgid "No discovered hosts available"
|
397
397
|
msgstr "未發現可用的主機"
|
@@ -403,10 +403,10 @@ msgid "No discovered hosts to provision"
|
|
403
403
|
msgstr "未發現可佈建的主機"
|
404
404
|
|
405
405
|
msgid "No discovered hosts to reboot"
|
406
|
-
msgstr ""
|
406
|
+
msgstr "未發現可重新啟動的主機"
|
407
407
|
|
408
408
|
msgid "No hostgroup associated with rule '%s'"
|
409
|
-
msgstr ""
|
409
|
+
msgstr "沒有主機群組與規則 '%s' 相關連"
|
410
410
|
|
411
411
|
msgid "No hosts selected"
|
412
412
|
msgstr "未選擇主機"
|
@@ -421,10 +421,10 @@ msgid "No rule found for host %s"
|
|
421
421
|
msgstr "未找到主機 %s 的規則"
|
422
422
|
|
423
423
|
msgid "Not reported in more than 7 days"
|
424
|
-
msgstr ""
|
424
|
+
msgstr "七天內未回報"
|
425
425
|
|
426
426
|
msgid "Operating system not set for host/hostgroup"
|
427
|
-
msgstr ""
|
427
|
+
msgstr "作業系統並未設定給主機/主機群組使用"
|
428
428
|
|
429
429
|
msgid "Organization"
|
430
430
|
msgstr "組織"
|
@@ -454,7 +454,7 @@ msgid "Reboot"
|
|
454
454
|
msgstr "重新開機"
|
455
455
|
|
456
456
|
msgid "Reboot All"
|
457
|
-
msgstr ""
|
457
|
+
msgstr "全部重新開機"
|
458
458
|
|
459
459
|
msgid "Rebooting %s"
|
460
460
|
msgstr "重新啟動 %s"
|
@@ -463,7 +463,7 @@ msgid "Rebooting a discovered host"
|
|
463
463
|
msgstr "重新啟動一部已發現的主機"
|
464
464
|
|
465
465
|
msgid "Rebooting all discovered hosts"
|
466
|
-
msgstr ""
|
466
|
+
msgstr "重新啟動所有已發現的主機"
|
467
467
|
|
468
468
|
msgid "Rebooting host %s"
|
469
469
|
msgstr "重新啟動主機 %s"
|
@@ -475,28 +475,28 @@ msgid "Refreshing the facts of a discovered host"
|
|
475
475
|
msgstr "刷新一部已發現之主機的詳情"
|
476
476
|
|
477
477
|
msgid "Regex to organize facts for hardware section"
|
478
|
-
msgstr ""
|
478
|
+
msgstr "用來為 hardware 一節組織事實時使用的正規表示式"
|
479
479
|
|
480
480
|
msgid "Regex to organize facts for highlights section - e.g. ^(abc|cde)$"
|
481
481
|
msgstr ""
|
482
482
|
|
483
483
|
msgid "Regex to organize facts for ipmi section"
|
484
|
-
msgstr ""
|
484
|
+
msgstr "用來為 ipmi 一節組織事實時使用的正規表示式"
|
485
485
|
|
486
486
|
msgid "Regex to organize facts for network section"
|
487
|
-
msgstr ""
|
487
|
+
msgstr "用來為 network 一節組織事實時使用的正規表示式"
|
488
488
|
|
489
489
|
msgid "Regex to organize facts for software section"
|
490
|
-
msgstr ""
|
490
|
+
msgstr "用來為 software 一節組織事實時使用的正規表示式"
|
491
491
|
|
492
492
|
msgid "Regex to organize facts for storage section"
|
493
|
-
msgstr ""
|
493
|
+
msgstr "用來為 storage 一節組織事實時使用的正規表示式"
|
494
494
|
|
495
495
|
msgid "Reloading kernel on %s"
|
496
|
-
msgstr ""
|
496
|
+
msgstr "在 %s 上重新載入 kernel"
|
497
497
|
|
498
498
|
msgid "Reported in the last 7 days"
|
499
|
-
msgstr ""
|
499
|
+
msgstr "過去七天內已回報"
|
500
500
|
|
501
501
|
msgid "Rule disabled"
|
502
502
|
msgstr "規則已停用"
|
@@ -586,22 +586,22 @@ msgid "UUID to track orchestration tasks status, GET /api/orchestration/:UUID/ta
|
|
586
586
|
msgstr "用來追蹤協調流程任務狀態的 UUID,GET /api/orchestration/:UUID/tasks"
|
587
587
|
|
588
588
|
msgid "Unable to assign subnet, primary interface is missing IP address"
|
589
|
-
msgstr ""
|
589
|
+
msgstr "無法指定子網路,主介面沒有 IP 位址"
|
590
590
|
|
591
591
|
msgid "Unable to detect primary interface using MAC '%{mac}' specified by discovery_fact '%{fact}'"
|
592
|
-
msgstr ""
|
592
|
+
msgstr "無法偵測使用 MAC '%{mac}' 的主介面,由 discovery_fact '%{fact}' 所指定"
|
593
593
|
|
594
594
|
msgid "Unable to find a discovery rule, no host provided (check permissions)"
|
595
|
-
msgstr ""
|
595
|
+
msgstr "找不到探索規則,未提供主機(檢查權限)"
|
596
596
|
|
597
597
|
msgid "Unable to perform kexec on %{name} via %{url}: %{msg}"
|
598
|
-
msgstr ""
|
598
|
+
msgstr "無法透過 %{url} 在 %{name} 上執行 kexec:%{msg}"
|
599
599
|
|
600
600
|
msgid "Unable to provision %{host}: %{errors}"
|
601
|
-
msgstr ""
|
601
|
+
msgstr "無法供給 %{host}:%{errors}"
|
602
602
|
|
603
603
|
msgid "Unable to reboot %{name} via %{url}: %{msg}"
|
604
|
-
msgstr ""
|
604
|
+
msgstr "無法透過 %{url} 重新啟動 %{name}:%{msg}"
|
605
605
|
|
606
606
|
msgid "Update a rule"
|
607
607
|
msgstr "更新規則"
|
@@ -631,7 +631,7 @@ msgid "flag is used for temporary shutdown of rules"
|
|
631
631
|
msgstr "旗標可用來暫時性關閉規則"
|
632
632
|
|
633
633
|
msgid "hash containing facts for the host with minimum set of facts: discovery_bootif, macaddress_eth0, ipaddress, ipaddress_eth0, interfaces: eth0 (example in case primary interface is named eth0)"
|
634
|
-
msgstr ""
|
634
|
+
msgstr "包含主機詳情的雜湊,其中有最基本的詳情:discovery_bootif、macaddress_eth0、ipaddress、ipaddress_eth0、interfaces:eth0(大部分範例中,主介面的名稱都是 eth0)"
|
635
635
|
|
636
636
|
msgid "items selected. Uncheck to Clear"
|
637
637
|
msgstr "已選取項目。反選以清除"
|
@@ -10,12 +10,29 @@ FactoryGirl.define do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
# Not used yet, we need to refactor core first
|
14
13
|
FactoryGirl.define do
|
15
14
|
factory :discovered_host, class: 'Host::Discovered' do
|
16
15
|
sequence(:name) { |n| "host#{n}" }
|
17
16
|
sequence(:ip) { |n| IPAddr.new(n, Socket::AF_INET).to_s }
|
18
17
|
sequence(:mac) { |n| "02:23:45:67:" + n.to_s(16).rjust(4, '0').insert(2, ':') }
|
19
|
-
|
18
|
+
|
19
|
+
after(:build) do |discovered_host|
|
20
|
+
attribute_set = DiscoveryAttributeSet.new(:host => discovered_host,
|
21
|
+
:memory => '1',
|
22
|
+
:cpu_count => '4')
|
23
|
+
discovered_host.discovery_attribute_set = attribute_set
|
24
|
+
end
|
25
|
+
|
26
|
+
trait :with_facts do
|
27
|
+
transient do
|
28
|
+
fact_count 20
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:create) do |discovered_host, evaluator|
|
32
|
+
evaluator.fact_count.times do
|
33
|
+
FactoryGirl.create(:fact_value, :discovered_host => discovered_host)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
20
37
|
end
|
21
38
|
end
|
@@ -83,6 +83,7 @@ class Api::V2::DiscoveredHostsControllerTest < ActionController::TestCase
|
|
83
83
|
:hostgroup => FactoryGirl.create(:hostgroup, :with_os, :with_rootpass), :organizations => [Organization.first],
|
84
84
|
:locations => [Location.first])
|
85
85
|
post :facts, { :facts => facts }
|
86
|
+
assert_match /created_at/, response.body
|
86
87
|
assert_response :success
|
87
88
|
assert_equal "Auto-discovered and provisioned via rule 'rule'", Host.first.comment
|
88
89
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Api::V2::DiscoveryRulesControllerTest < ActionController::TestCase
|
4
|
-
|
5
4
|
setup do
|
6
5
|
User.current = User.find_by_login "admin"
|
7
6
|
|
@@ -24,18 +23,29 @@ class Api::V2::DiscoveryRulesControllerTest < ActionController::TestCase
|
|
24
23
|
assert !discovery_rules.empty?
|
25
24
|
end
|
26
25
|
|
26
|
+
test "should search discovery rule" do
|
27
|
+
FactoryGirl.create(:discovery_rule, :name => "test")
|
28
|
+
get :index, { :search => "name = test"}
|
29
|
+
assert_response :success
|
30
|
+
discovery_rules = ActiveSupport::JSON.decode(@response.body)
|
31
|
+
assert_equal 1, discovery_rules['total']
|
32
|
+
end
|
33
|
+
|
27
34
|
test "should show discovery rule" do
|
28
35
|
rule = FactoryGirl.create(:discovery_rule)
|
29
36
|
get :show, { :id => rule.to_param }
|
30
37
|
assert_response :success
|
31
38
|
end
|
32
39
|
|
33
|
-
test "should create discovery rule" do
|
40
|
+
test "should create discovery rule with taxonomy" do
|
34
41
|
assert_difference('DiscoveryRule.count') do
|
42
|
+
hostgroup = FactoryGirl.create(:hostgroup, :with_os, :with_rootpass, :organizations => [Organization.first], :locations => [Location.first])
|
35
43
|
post :create, {:discovery_rule => {
|
36
44
|
:name => "foo",
|
37
45
|
:search => "bar",
|
38
|
-
:hostgroup_id =>
|
46
|
+
:hostgroup_id => hostgroup.id,
|
47
|
+
:organization_ids => [Organization.first],
|
48
|
+
:location_ids => [Location.first.id],
|
39
49
|
:hostname => "",
|
40
50
|
:priority => 1}}
|
41
51
|
end
|
@@ -62,6 +72,4 @@ class Api::V2::DiscoveryRulesControllerTest < ActionController::TestCase
|
|
62
72
|
end
|
63
73
|
assert_response :success
|
64
74
|
end
|
65
|
-
|
66
75
|
end
|
67
|
-
|
@@ -15,6 +15,10 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
15
15
|
"physicalprocessorcount" => "42",
|
16
16
|
"discovery_version" => "3.0.0",
|
17
17
|
}
|
18
|
+
FactoryGirl.create(:setting,
|
19
|
+
:name => 'discovery_always_rebuild_dns',
|
20
|
+
:value => true,
|
21
|
+
:category => 'Setting::Discovered')
|
18
22
|
FactoryGirl.create(:setting,
|
19
23
|
:name => 'discovery_reboot',
|
20
24
|
:value => true,
|
@@ -95,8 +99,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
98
|
-
def
|
99
|
-
host = Host::Discovered.import_host(@facts)
|
102
|
+
def setup_hostgroup(host)
|
100
103
|
domain = FactoryGirl.create(:domain)
|
101
104
|
hostgroup = FactoryGirl.create(:hostgroup, :with_subnet, :with_environment, :with_rootpass, :with_os, :domain => domain, :organizations => [host.organization], :locations => [host.location])
|
102
105
|
hostgroup.medium.organizations << host.organization
|
@@ -108,6 +111,12 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
108
111
|
hostgroup.subnet.organizations << host.organization
|
109
112
|
hostgroup.subnet.locations << host.location
|
110
113
|
domain.subnets << hostgroup.subnet
|
114
|
+
hostgroup
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_edit_form_submit_parameters
|
118
|
+
host = Host::Discovered.import_host(@facts)
|
119
|
+
hostgroup = setup_hostgroup(host)
|
111
120
|
get :edit, {
|
112
121
|
:id => host.id,
|
113
122
|
:host => {
|
@@ -190,10 +199,14 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
190
199
|
disable_orchestration
|
191
200
|
facts = @facts.merge({"somefact" => "abc"})
|
192
201
|
host = Host::Discovered.import_host(facts)
|
193
|
-
|
202
|
+
hostgroup = setup_hostgroup(host)
|
203
|
+
FactoryGirl.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :hostgroup => hostgroup, :organizations => [host.organization], :locations => [host.location])
|
194
204
|
post :auto_provision, { :id => host.id }, set_session_user_default_manager
|
195
205
|
assert_response :redirect
|
196
206
|
assert_nil flash[:error]
|
207
|
+
assert_match /^Host macaabbccddeeff.* was provisioned/, flash[:notice]
|
208
|
+
managed_host = Host.find(host.id)
|
209
|
+
assert managed_host.build
|
197
210
|
end
|
198
211
|
|
199
212
|
def test_auto_provision_no_rule_success
|
@@ -203,6 +216,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
203
216
|
post :auto_provision, { :id => host.id }, set_session_user_default_manager
|
204
217
|
assert_response :redirect
|
205
218
|
assert_nil flash[:error]
|
219
|
+
assert_equal "No rule found for host macaabbccddeeff", flash[:notice]
|
206
220
|
end
|
207
221
|
|
208
222
|
def test_auto_provision_all_success
|
@@ -213,6 +227,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
213
227
|
post :auto_provision_all, {}, set_session_user_default_manager
|
214
228
|
assert_response :redirect
|
215
229
|
assert_nil flash[:error]
|
230
|
+
assert_equal "Discovered hosts are provisioning now", flash[:notice]
|
216
231
|
end
|
217
232
|
|
218
233
|
def test_auto_provision_all_no_rule_success
|
@@ -223,6 +238,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
223
238
|
post :auto_provision_all, {}, set_session_user_default_manager
|
224
239
|
assert_response :redirect
|
225
240
|
assert_nil flash[:error]
|
241
|
+
assert_equal "Discovered hosts are provisioning now", flash[:notice]
|
226
242
|
end
|
227
243
|
|
228
244
|
def test_reboot_all_success
|
@@ -232,6 +248,8 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
232
248
|
post "reboot", { :id => host.id }, set_session_user_default_manager
|
233
249
|
assert_redirected_to discovered_hosts_url
|
234
250
|
assert_equal "Rebooting host #{host.name}", flash[:notice]
|
251
|
+
assert_nil flash[:error]
|
252
|
+
assert_equal "Rebooting host macaabbccddeeff", flash[:notice]
|
235
253
|
end
|
236
254
|
|
237
255
|
def test_reboot_all_failure
|
@@ -241,6 +259,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
241
259
|
post "reboot_all", { }, set_session_user_default_manager
|
242
260
|
assert_redirected_to discovered_hosts_url
|
243
261
|
assert_equal "Errors during reboot: #{host.name}: failed to reboot", flash[:error]
|
262
|
+
assert_nil flash[:notice]
|
244
263
|
end
|
245
264
|
|
246
265
|
def test_reboot_all_error
|
@@ -250,6 +269,42 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
250
269
|
post "reboot_all", { }, set_session_user_default_manager
|
251
270
|
assert_redirected_to discovered_hosts_url
|
252
271
|
assert_match(/ERF50-4973/, flash[:error])
|
272
|
+
assert_nil flash[:notice]
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_no_dns_rebuild_if_dns_pending
|
276
|
+
host = Host::Discovered.import_host(@facts)
|
277
|
+
hostgroup = prepare_hostgroup_for_dns_rebuild(host)
|
278
|
+
Nic::Managed.any_instance.expects(:rebuild_dns).never
|
279
|
+
Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
|
280
|
+
put :update, {:commit => "Update", :id => host.id,
|
281
|
+
:host => {
|
282
|
+
:name => 'mytest',
|
283
|
+
:hostgroup_id => hostgroup.id,
|
284
|
+
}
|
285
|
+
}, set_session_user_default_manager
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_dns_rebuild
|
289
|
+
host = prepare_host_for_dns_rebuild
|
290
|
+
hostgroup = prepare_hostgroup_for_dns_rebuild(host)
|
291
|
+
Nic::Managed.any_instance.expects(:rebuild_dns)
|
292
|
+
Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
|
293
|
+
put :update, {:commit => "Update", :id => host.id,
|
294
|
+
:host => {
|
295
|
+
:name => 'mytest',
|
296
|
+
:hostgroup_id => hostgroup.id,
|
297
|
+
}
|
298
|
+
}, set_session_user_default_manager
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_dns_rebuild_with_auto_provision
|
302
|
+
host = prepare_host_for_dns_rebuild
|
303
|
+
hostgroup = prepare_hostgroup_for_dns_rebuild(host)
|
304
|
+
Nic::Managed.any_instance.expects(:rebuild_dns)
|
305
|
+
Host::Managed.any_instance.stubs(:skip_orchestration?).returns(false)
|
306
|
+
FactoryGirl.create(:discovery_rule, :priority => 1, :search => "name = mytest.myorchdomain.net", :hostgroup_id => hostgroup.id, :organizations => [host.organization], :locations => [host.location])
|
307
|
+
post :auto_provision, { :id => host.id }, set_session_user_default_manager
|
253
308
|
end
|
254
309
|
|
255
310
|
private
|
@@ -257,4 +312,17 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
257
312
|
def initialize_host
|
258
313
|
User.current = users(:admin)
|
259
314
|
end
|
315
|
+
|
316
|
+
def prepare_host_for_dns_rebuild
|
317
|
+
host = Host::Discovered.import_host(@facts)
|
318
|
+
host.name = 'mytest.myorchdomain.net'
|
319
|
+
host.save
|
320
|
+
host
|
321
|
+
end
|
322
|
+
|
323
|
+
def prepare_hostgroup_for_dns_rebuild(host)
|
324
|
+
hostgroup = setup_hostgroup(host)
|
325
|
+
hostgroup.domain = FactoryGirl.create(:domain, :name => 'myorchdomain.net', :dns => FactoryGirl.create(:smart_proxy, :features => [FactoryGirl.create(:feature, :dns)]))
|
326
|
+
hostgroup
|
327
|
+
end
|
260
328
|
end
|