foreman_discovery 1.4.1 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +52 -96
- data/app/controllers/api/v2/discovered_hosts_controller.rb +104 -3
- data/app/controllers/api/v2/discovery_rules_controller.rb +79 -0
- data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +55 -0
- data/app/controllers/discovered_hosts_controller.rb +82 -19
- data/app/controllers/discovery_rules_controller.rb +73 -0
- data/app/helpers/discovered_hosts_helper.rb +18 -6
- data/app/helpers/discovery_rules_helper.rb +36 -0
- data/app/lib/puppet_fact_parser_extensions.rb +9 -3
- data/app/models/concerns/discovery_subnet.rb +7 -0
- data/app/models/discovery_attribute_set.rb +8 -0
- data/app/models/discovery_rule.rb +24 -0
- data/app/models/host/discovered.rb +64 -7
- data/app/models/host/managed_extensions.rb +3 -8
- data/app/models/hostgroup_extensions.rb +7 -0
- data/app/models/setting/discovered.rb +14 -0
- data/app/overrides/subnet_form_with_discovery_proxy.rb +9 -0
- data/app/views/api/v2/discovered_hosts/auto_provision.json.rabl +3 -0
- data/app/views/api/v2/discovered_hosts/auto_provision_all.json.rabl +3 -0
- data/app/views/api/v2/discovered_hosts/main.json.rabl +1 -1
- data/app/views/api/v2/discovery_rules/base.json.rabl +3 -0
- data/app/views/api/v2/discovery_rules/index.json.rabl +3 -0
- data/app/views/api/v2/discovery_rules/main.json.rabl +5 -0
- data/app/views/api/v2/discovery_rules/show.json.rabl +3 -0
- data/app/views/dashboard/_discovery_widget.html.erb +5 -11
- data/app/views/dashboard/_discovery_widget_host_list.html.erb +17 -0
- data/app/views/discovered_hosts/_discovered_host.html.erb +12 -0
- data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +11 -2
- data/app/views/discovered_hosts/index.html.erb +1 -0
- data/app/views/discovery_rules/_form.html.erb +14 -0
- data/app/views/discovery_rules/edit.html.erb +3 -0
- data/app/views/discovery_rules/index.html.erb +26 -0
- data/app/views/discovery_rules/new.html.erb +3 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20141107091416_create_discovery_rules.rb +15 -0
- data/db/migrate/20141107091417_add_discovery_rule_to_host.rb +9 -0
- data/db/migrate/20141126165451_add_discovery_id_to_subnet.rb +9 -0
- data/db/migrate/20141223101707_create_discovery_attribute_sets.rb +14 -0
- data/db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb +8 -0
- data/db/seeds.d/60_discovery_proxy_feature.rb +2 -0
- data/lib/discovery.rake +0 -82
- data/lib/foreman_discovery/engine.rb +81 -14
- data/lib/foreman_discovery/proxy_operations.rb +18 -0
- data/lib/foreman_discovery/version.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/de/foreman_discovery.po +1 -1
- data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en_GB/foreman_discovery.po +1 -1
- data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/es/foreman_discovery.po +3 -3
- data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/fr/foreman_discovery.po +1 -1
- data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/gl/foreman_discovery.po +1 -1
- data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/it/foreman_discovery.po +1 -1
- data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ja/foreman_discovery.po +1 -1
- data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ko/foreman_discovery.po +1 -1
- data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/pt_BR/foreman_discovery.po +1 -1
- data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ru/foreman_discovery.po +1 -1
- data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/sv_SE/foreman_discovery.po +1 -1
- data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_CN/foreman_discovery.po +1 -1
- data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_TW/foreman_discovery.po +1 -1
- data/test/factories/discovery_rule_related.rb +20 -0
- data/test/functional/api/v2/discovered_hosts_controller_test.rb +81 -0
- data/test/functional/api/v2/discovery_rules_controller_test.rb +51 -0
- data/test/functional/discovered_hosts_controller_test.rb +96 -3
- data/test/functional/discovery_rules_controller_test.rb +62 -0
- data/test/test_helper.rb +0 -1
- data/test/unit/discovered_extensions_test.rb +106 -0
- data/test/unit/discovery_attribute_set_test.rb +43 -0
- data/test/unit/facts.json +4 -1
- data/test/unit/host_discovered_test.rb +44 -4
- metadata +100 -75
- data/Rakefile +0 -110
- data/lib/foreman_discovery/facts.rb +0 -12
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DiscoveryAttributeSetTest < ActiveSupport::TestCase
|
4
|
+
test "can search discovered hosts by cpu" do
|
5
|
+
raw = parse_json_fixture('/facts.json')
|
6
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
7
|
+
results = Host::Discovered.search_for("cpu_count = #{host.facts_hash['physicalprocessorcount'].to_i}")
|
8
|
+
assert_equal 1, results.count
|
9
|
+
results = Host::Discovered.search_for("cpu_count > #{host.facts_hash['physicalprocessorcount'].to_i}")
|
10
|
+
assert_equal 0, results.count
|
11
|
+
end
|
12
|
+
|
13
|
+
test "can search discovered hosts by memory" do
|
14
|
+
raw = parse_json_fixture('/facts.json')
|
15
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
16
|
+
results = Host::Discovered.search_for("memory = #{host.facts_hash['memorysize_mb'].to_f.ceil}")
|
17
|
+
assert_equal 1, results.count
|
18
|
+
results = Host::Discovered.search_for("memory > #{host.facts_hash['memorysize_mb'].to_f.ceil}")
|
19
|
+
assert_equal 0, results.count
|
20
|
+
end
|
21
|
+
|
22
|
+
test "can search discovered hosts by disk_count" do
|
23
|
+
raw = parse_json_fixture('/facts.json')
|
24
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
25
|
+
results = Host::Discovered.search_for("disk_count = 1")
|
26
|
+
assert_equal 1, results.count
|
27
|
+
results = Host::Discovered.search_for("disk_count = 3")
|
28
|
+
assert_equal 0, results.count
|
29
|
+
end
|
30
|
+
|
31
|
+
test "can search discovered hosts by disks_size" do
|
32
|
+
raw = parse_json_fixture('/facts.json')
|
33
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
34
|
+
results = Host::Discovered.search_for("disks_size = #{host.facts_hash['blockdevice_sda_size'].to_f.ceil}")
|
35
|
+
assert_equal 1, results.count
|
36
|
+
results = Host::Discovered.search_for("disks_size > #{host.facts_hash['blockdevice_sda_size'].to_f.ceil}")
|
37
|
+
assert_equal 0, results.count
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_json_fixture(relative_path)
|
41
|
+
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
42
|
+
end
|
43
|
+
end
|
data/test/unit/facts.json
CHANGED
@@ -87,6 +87,9 @@
|
|
87
87
|
"vlans": "181,182,183",
|
88
88
|
"lsbmajdistrelease": "6",
|
89
89
|
"swapfree": "16.72 GB",
|
90
|
-
"netmask": "255.255.255.192"
|
90
|
+
"netmask": "255.255.255.192",
|
91
|
+
"discovery_bootif": "AA:BB:CC:DD:EE:FF",
|
92
|
+
"memorysize_mb": "742.13",
|
93
|
+
"blockdevice_sda_size": "214749184"
|
91
94
|
}
|
92
95
|
}
|
@@ -4,8 +4,12 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
4
4
|
setup do
|
5
5
|
User.current = User.find_by_login "admin"
|
6
6
|
FactoryGirl.create(:setting,
|
7
|
-
:name
|
8
|
-
:value
|
7
|
+
:name => 'discovery_fact',
|
8
|
+
:value => 'discovery_bootif',
|
9
|
+
:category => 'Setting::Discovered')
|
10
|
+
FactoryGirl.create(:setting,
|
11
|
+
:name => 'discovery_prefix',
|
12
|
+
:value => 'mac',
|
9
13
|
:category => 'Setting::Discovered')
|
10
14
|
end
|
11
15
|
|
@@ -17,7 +21,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
17
21
|
test "should import facts from yaml as Host::Discovered" do
|
18
22
|
raw = parse_json_fixture('/facts.json')
|
19
23
|
assert Host::Discovered.import_host_and_facts(raw['facts'])
|
20
|
-
assert Host::Discovered.find_by_name('
|
24
|
+
assert Host::Discovered.find_by_name('macaabbccddeeff')
|
21
25
|
end
|
22
26
|
|
23
27
|
test "should raise when fact_name setting isn't present" do
|
@@ -31,10 +35,46 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
31
35
|
test "should be able to refresh facts" do
|
32
36
|
host = Host.create :name => "mydiscoveredhost", :ip => "1.2.3.4", :type => "Host::Discovered"
|
33
37
|
raw = parse_json_fixture('/facts.json')
|
34
|
-
ForemanDiscovery::
|
38
|
+
ForemanDiscovery::ProxyOperations.any_instance.stubs(:parse_get_operation).returns(raw['facts'])
|
35
39
|
assert host.refresh_facts
|
36
40
|
end
|
37
41
|
|
42
|
+
test "should create discovered host with fact_name as a name" do
|
43
|
+
raw = parse_json_fixture('/facts.json')
|
44
|
+
Setting[:discovery_fact] = 'lsbdistcodename'
|
45
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
46
|
+
assert_equal 'macsantiago', host.name
|
47
|
+
end
|
48
|
+
|
49
|
+
test "should create discovered host with prefix" do
|
50
|
+
raw = parse_json_fixture('/facts.json')
|
51
|
+
Setting[:discovery_prefix] = 'test'
|
52
|
+
Setting[:discovery_fact] = 'lsbdistcodename'
|
53
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
54
|
+
assert_equal 'testsantiago', host.name
|
55
|
+
end
|
56
|
+
|
57
|
+
test "should not name discovered host with prefix that starts with a number, fallback to 'mac'" do
|
58
|
+
raw = parse_json_fixture('/facts.json')
|
59
|
+
Setting[:discovery_prefix] = '123'
|
60
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
61
|
+
assert host.name.start_with?('mac')
|
62
|
+
end
|
63
|
+
|
64
|
+
test "should not name discovered host with prefix that starts with a special character, fallback to 'mac'" do
|
65
|
+
raw = parse_json_fixture('/facts.json')
|
66
|
+
Setting[:discovery_prefix] = '^abc'
|
67
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
68
|
+
assert host.name.start_with?('mac')
|
69
|
+
end
|
70
|
+
|
71
|
+
test "should not name discovered host with prefix that starts with a _, fallback to 'mac'" do
|
72
|
+
raw = parse_json_fixture('/facts.json')
|
73
|
+
Setting[:discovery_prefix] = '_abc'
|
74
|
+
host = Host::Discovered.import_host_and_facts(raw['facts']).first
|
75
|
+
assert host.name.start_with?('mac')
|
76
|
+
end
|
77
|
+
|
38
78
|
def parse_json_fixture(relative_path)
|
39
79
|
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
40
80
|
end
|
metadata
CHANGED
@@ -1,44 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_discovery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sutcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: deface
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - <
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - <
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
|
28
|
-
name: ftools
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
description: ! 'MaaS Discovery Plugin engine for Foreman '
|
26
|
+
version: '1.0'
|
27
|
+
description: 'MaaS Discovery Plugin engine for Foreman '
|
42
28
|
email: gsutclif@redhat.com
|
43
29
|
executables: []
|
44
30
|
extensions: []
|
@@ -46,80 +32,112 @@ extra_rdoc_files:
|
|
46
32
|
- LICENSE
|
47
33
|
- README.md
|
48
34
|
files:
|
49
|
-
-
|
50
|
-
- README.md
|
51
|
-
- Rakefile
|
52
|
-
- app/controllers/api/v2/discovered_hosts_controller.rb
|
35
|
+
- app/controllers/discovery_rules_controller.rb
|
53
36
|
- app/controllers/discovered_hosts_controller.rb
|
54
|
-
- app/
|
37
|
+
- app/controllers/concerns/foreman/controller/discovered_extensions.rb
|
38
|
+
- app/controllers/api/v2/discovery_rules_controller.rb
|
39
|
+
- app/controllers/api/v2/discovered_hosts_controller.rb
|
55
40
|
- app/lib/puppet_fact_parser_extensions.rb
|
41
|
+
- app/helpers/discovery_rules_helper.rb
|
42
|
+
- app/helpers/discovered_hosts_helper.rb
|
43
|
+
- app/overrides/subnet_form_with_discovery_proxy.rb
|
44
|
+
- app/models/setting/discovered.rb
|
45
|
+
- app/models/hostgroup_extensions.rb
|
56
46
|
- app/models/host/discovered.rb
|
57
47
|
- app/models/host/managed_extensions.rb
|
58
|
-
- app/models/
|
59
|
-
- app/
|
60
|
-
- app/
|
61
|
-
- app/views/
|
62
|
-
- app/views/api/v2/discovered_hosts/show.json.rabl
|
63
|
-
- app/views/api/v2/discovered_hosts/update.json.rabl
|
48
|
+
- app/models/discovery_rule.rb
|
49
|
+
- app/models/concerns/discovery_subnet.rb
|
50
|
+
- app/models/discovery_attribute_set.rb
|
51
|
+
- app/views/dashboard/_discovery_widget_host_list.html.erb
|
64
52
|
- app/views/dashboard/_discovery_widget.html.erb
|
65
|
-
- app/views/
|
53
|
+
- app/views/discovery_rules/new.html.erb
|
54
|
+
- app/views/discovery_rules/edit.html.erb
|
55
|
+
- app/views/discovery_rules/index.html.erb
|
56
|
+
- app/views/discovery_rules/_form.html.erb
|
57
|
+
- app/views/discovered_hosts/_discovered_host.html.erb
|
66
58
|
- app/views/discovered_hosts/_selected_hosts.html.erb
|
67
|
-
- app/views/discovered_hosts/index.html.erb
|
68
59
|
- app/views/discovered_hosts/multiple_destroy.html.erb
|
69
|
-
- app/views/discovered_hosts/
|
60
|
+
- app/views/discovered_hosts/index.html.erb
|
70
61
|
- app/views/discovered_hosts/select_multiple_organization.html.erb
|
62
|
+
- app/views/discovered_hosts/_discovered_hosts_list.html.erb
|
71
63
|
- app/views/discovered_hosts/show.html.erb
|
72
|
-
-
|
73
|
-
-
|
64
|
+
- app/views/discovered_hosts/select_multiple_location.html.erb
|
65
|
+
- app/views/api/v2/discovery_rules/index.json.rabl
|
66
|
+
- app/views/api/v2/discovery_rules/base.json.rabl
|
67
|
+
- app/views/api/v2/discovery_rules/main.json.rabl
|
68
|
+
- app/views/api/v2/discovery_rules/show.json.rabl
|
69
|
+
- app/views/api/v2/discovered_hosts/index.json.rabl
|
70
|
+
- app/views/api/v2/discovered_hosts/update.json.rabl
|
71
|
+
- app/views/api/v2/discovered_hosts/auto_provision_all.json.rabl
|
72
|
+
- app/views/api/v2/discovered_hosts/base.json.rabl
|
73
|
+
- app/views/api/v2/discovered_hosts/main.json.rabl
|
74
|
+
- app/views/api/v2/discovered_hosts/auto_provision.json.rabl
|
75
|
+
- app/views/api/v2/discovered_hosts/show.json.rabl
|
74
76
|
- extra/build_iso.sh
|
75
|
-
- extra/
|
76
|
-
- extra/discovery_init.sh.example
|
77
|
+
- extra/wait_for_network.sh
|
77
78
|
- extra/disk_facts.rb
|
79
|
+
- extra/discover_host
|
78
80
|
- extra/foreman_startup.rb
|
79
|
-
- extra/
|
81
|
+
- extra/discovery_init.sh.example
|
80
82
|
- extra/ovirt-node-build/build_image.sh
|
81
|
-
- extra/
|
83
|
+
- extra/ovirt-node-build/Vagrantfile
|
84
|
+
- config/routes.rb
|
85
|
+
- config/initializers/discovery_setup.rb
|
86
|
+
- db/migrate/20141107091416_create_discovery_rules.rb
|
87
|
+
- db/migrate/20141107091417_add_discovery_rule_to_host.rb
|
88
|
+
- db/migrate/20141126165451_add_discovery_id_to_subnet.rb
|
89
|
+
- db/migrate/20141223101707_create_discovery_attribute_sets.rb
|
90
|
+
- db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
|
91
|
+
- db/seeds.d/60_discovery_proxy_feature.rb
|
82
92
|
- lib/discovery.rake
|
83
93
|
- lib/foreman_discovery.rb
|
84
|
-
- lib/foreman_discovery/
|
85
|
-
- lib/foreman_discovery/facts.rb
|
94
|
+
- lib/foreman_discovery/proxy_operations.rb
|
86
95
|
- lib/foreman_discovery/version.rb
|
96
|
+
- lib/foreman_discovery/engine.rb
|
97
|
+
- locale/foreman_discovery.pot
|
87
98
|
- locale/Makefile
|
88
|
-
- locale/
|
99
|
+
- locale/ru/foreman_discovery.po
|
100
|
+
- locale/ru/LC_MESSAGES/foreman_discovery.mo
|
89
101
|
- locale/de/foreman_discovery.po
|
90
|
-
- locale/
|
102
|
+
- locale/de/LC_MESSAGES/foreman_discovery.mo
|
103
|
+
- locale/pt_BR/foreman_discovery.po
|
104
|
+
- locale/pt_BR/LC_MESSAGES/foreman_discovery.mo
|
91
105
|
- locale/en_GB/foreman_discovery.po
|
92
|
-
- locale/
|
106
|
+
- locale/en_GB/LC_MESSAGES/foreman_discovery.mo
|
107
|
+
- locale/zh_TW/foreman_discovery.po
|
108
|
+
- locale/zh_TW/LC_MESSAGES/foreman_discovery.mo
|
93
109
|
- locale/es/foreman_discovery.po
|
94
|
-
- locale/foreman_discovery.
|
95
|
-
- locale/fr/LC_MESSAGES/foreman_discovery.mo
|
110
|
+
- locale/es/LC_MESSAGES/foreman_discovery.mo
|
96
111
|
- locale/fr/foreman_discovery.po
|
97
|
-
- locale/
|
98
|
-
- locale/gl/foreman_discovery.po
|
99
|
-
- locale/it/LC_MESSAGES/foreman_discovery.mo
|
112
|
+
- locale/fr/LC_MESSAGES/foreman_discovery.mo
|
100
113
|
- locale/it/foreman_discovery.po
|
101
|
-
- locale/
|
114
|
+
- locale/it/LC_MESSAGES/foreman_discovery.mo
|
102
115
|
- locale/ja/foreman_discovery.po
|
103
|
-
- locale/
|
116
|
+
- locale/ja/LC_MESSAGES/foreman_discovery.mo
|
104
117
|
- locale/ko/foreman_discovery.po
|
105
|
-
- locale/
|
106
|
-
- locale/pt_BR/foreman_discovery.po
|
107
|
-
- locale/ru/LC_MESSAGES/foreman_discovery.mo
|
108
|
-
- locale/ru/foreman_discovery.po
|
109
|
-
- locale/sv_SE/LC_MESSAGES/foreman_discovery.mo
|
110
|
-
- locale/sv_SE/foreman_discovery.po
|
111
|
-
- locale/zanata.xml
|
112
|
-
- locale/zh_CN/LC_MESSAGES/foreman_discovery.mo
|
118
|
+
- locale/ko/LC_MESSAGES/foreman_discovery.mo
|
113
119
|
- locale/zh_CN/foreman_discovery.po
|
114
|
-
- locale/
|
115
|
-
- locale/
|
120
|
+
- locale/zh_CN/LC_MESSAGES/foreman_discovery.mo
|
121
|
+
- locale/zanata.xml
|
122
|
+
- locale/gl/foreman_discovery.po
|
123
|
+
- locale/gl/LC_MESSAGES/foreman_discovery.mo
|
124
|
+
- locale/sv_SE/foreman_discovery.po
|
125
|
+
- locale/sv_SE/LC_MESSAGES/foreman_discovery.mo
|
126
|
+
- LICENSE
|
127
|
+
- README.md
|
128
|
+
- test/functional/discovery_rules_controller_test.rb
|
129
|
+
- test/functional/api/v2/discovery_rules_controller_test.rb
|
130
|
+
- test/functional/api/v2/discovered_hosts_controller_test.rb
|
116
131
|
- test/functional/discovered_hosts_controller_test.rb
|
117
|
-
- test/
|
118
|
-
- test/
|
132
|
+
- test/factories/discovery_rule_related.rb
|
133
|
+
- test/unit/discovered_extensions_test.rb
|
134
|
+
- test/unit/discovery_attribute_set_test.rb
|
135
|
+
- test/unit/setting_discovered_test.rb
|
119
136
|
- test/unit/facts.json
|
120
|
-
- test/unit/host_discovered_test.rb
|
121
137
|
- test/unit/puppet_fact_parser_extensions_test.rb
|
122
|
-
- test/unit/
|
138
|
+
- test/unit/host_discovered_test.rb
|
139
|
+
- test/test_plugin_helper.rb
|
140
|
+
- test/test_helper.rb
|
123
141
|
homepage: http://github.com/theforeman/foreman_discovery
|
124
142
|
licenses:
|
125
143
|
- GPL-3
|
@@ -130,25 +148,32 @@ require_paths:
|
|
130
148
|
- lib
|
131
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
150
|
requirements:
|
133
|
-
- -
|
151
|
+
- - '>='
|
134
152
|
- !ruby/object:Gem::Version
|
135
153
|
version: '0'
|
136
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
155
|
requirements:
|
138
|
-
- -
|
156
|
+
- - '>'
|
139
157
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
158
|
+
version: 1.3.1
|
141
159
|
requirements: []
|
142
160
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.0.3
|
144
162
|
signing_key:
|
145
163
|
specification_version: 4
|
146
164
|
summary: MaaS Discovery Plugin for Foreman
|
147
165
|
test_files:
|
148
|
-
- test/
|
166
|
+
- test/functional/discovery_rules_controller_test.rb
|
167
|
+
- test/functional/api/v2/discovery_rules_controller_test.rb
|
168
|
+
- test/functional/api/v2/discovered_hosts_controller_test.rb
|
149
169
|
- test/functional/discovered_hosts_controller_test.rb
|
150
|
-
- test/
|
170
|
+
- test/factories/discovery_rule_related.rb
|
171
|
+
- test/unit/discovered_extensions_test.rb
|
172
|
+
- test/unit/discovery_attribute_set_test.rb
|
173
|
+
- test/unit/setting_discovered_test.rb
|
151
174
|
- test/unit/facts.json
|
152
175
|
- test/unit/puppet_fact_parser_extensions_test.rb
|
153
|
-
- test/unit/setting_discovered_test.rb
|
154
176
|
- test/unit/host_discovered_test.rb
|
177
|
+
- test/test_plugin_helper.rb
|
178
|
+
- test/test_helper.rb
|
179
|
+
has_rdoc:
|
data/Rakefile
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rake'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
task :default => :test
|
8
|
-
|
9
|
-
PLUGIN_NAME = "discovery"
|
10
|
-
ENGINE_DIR = File.expand_path('..', __FILE__)
|
11
|
-
FOREMAN_DIR = '.foreman_app'
|
12
|
-
|
13
|
-
ENV['TEXTDOMAIN'] = PLUGIN_NAME
|
14
|
-
import "#{FOREMAN_DIR}/Rakefile" if File.exists? "#{FOREMAN_DIR}/Rakefile"
|
15
|
-
|
16
|
-
namespace :setup do
|
17
|
-
desc "Download latest foreman core devel source and install dependencies"
|
18
|
-
task :foreman_prepare do
|
19
|
-
foreman_repo = 'https://github.com/theforeman/foreman.git'
|
20
|
-
foreman_gemfile = File.join(FOREMAN_DIR, "Gemfile")
|
21
|
-
unless File.exists?(foreman_gemfile)
|
22
|
-
puts "Foreman source code is not present at #{FOREMAN_DIR}"
|
23
|
-
puts "Downloading latest Foreman development branch into #{FOREMAN_DIR}..."
|
24
|
-
FileUtils.mkdir_p(FOREMAN_DIR)
|
25
|
-
|
26
|
-
unless system("git clone --depth 1 #{foreman_repo} #{FOREMAN_DIR}")
|
27
|
-
puts "Error while getting latest Foreman code from #{foreman_repo} into #{FOREMAN_DIR}"
|
28
|
-
fail
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
settings_file = "#{FOREMAN_DIR}/config/settings.yaml"
|
33
|
-
unless File.exists?(settings_file)
|
34
|
-
puts 'Preparing settings file'
|
35
|
-
FileUtils.copy("#{settings_file}.example", settings_file)
|
36
|
-
settings_content = File.read(settings_file)
|
37
|
-
settings_content.sub!('organizations_enabled: false', 'organizations_enabled: true')
|
38
|
-
settings_content << ":puppetgem: true\n"
|
39
|
-
File.open(settings_file, 'w') { |f| f << settings_content }
|
40
|
-
end
|
41
|
-
|
42
|
-
db_file = "#{FOREMAN_DIR}/config/database.yml"
|
43
|
-
unless File.exists?(db_file)
|
44
|
-
puts 'Preparing database file'
|
45
|
-
FileUtils.copy("#{db_file}.example", db_file)
|
46
|
-
end
|
47
|
-
|
48
|
-
["#{ENGINE_DIR}/.bundle/config", "#{FOREMAN_DIR}/.bundle/config"].each do |bundle_file|
|
49
|
-
unless File.exists?(bundle_file)
|
50
|
-
FileUtils.mkdir_p(File.dirname(bundle_file))
|
51
|
-
puts 'Preparing bundler configuration'
|
52
|
-
File.open(bundle_file, 'w') { |f| f << <<FILE }
|
53
|
-
---
|
54
|
-
BUNDLE_WITHOUT: console:development:fog:jsonp:libvirt:mysql:mysql2:ovirt:postgresql:vmware
|
55
|
-
FILE
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
local_gemfile = "#{FOREMAN_DIR}/bundler.d/Gemfile.local.rb"
|
60
|
-
unless File.exist?(local_gemfile)
|
61
|
-
File.open(local_gemfile, 'w') { |f| f << <<GEMFILE }
|
62
|
-
gem "puppet"
|
63
|
-
gem "facter"
|
64
|
-
GEMFILE
|
65
|
-
end
|
66
|
-
|
67
|
-
puts 'Installing dependencies...'
|
68
|
-
unless system('bundle install')
|
69
|
-
fail
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
task :db_prepare do
|
74
|
-
unless File.exists?(FOREMAN_DIR)
|
75
|
-
puts <<MESSAGE
|
76
|
-
Foreman source code not prepared. Run
|
77
|
-
|
78
|
-
rake setup:foreman_prepare
|
79
|
-
|
80
|
-
to download foreman source and its dependencies
|
81
|
-
MESSAGE
|
82
|
-
fail
|
83
|
-
end
|
84
|
-
|
85
|
-
# once we are Ruby19 only, switch to block variant of cd
|
86
|
-
pwd = FileUtils.pwd
|
87
|
-
FileUtils.cd(FOREMAN_DIR)
|
88
|
-
unless system('rake db:test:prepare RAILS_ENV=test')
|
89
|
-
puts "Migrating database first"
|
90
|
-
system('rake db:migrate db:schema:dump db:test:prepare RAILS_ENV=test') || fail
|
91
|
-
end
|
92
|
-
FileUtils.cd(pwd)
|
93
|
-
end
|
94
|
-
|
95
|
-
task :all => [:foreman_prepare, :db_prepare]
|
96
|
-
end
|
97
|
-
|
98
|
-
namespace :test do
|
99
|
-
task :set_loadpath do
|
100
|
-
%w[lib test].each do |dir|
|
101
|
-
$:.unshift(File.expand_path(dir, ENGINE_DIR))
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
task :all => ['setup:db_prepare', 'test:set_loadpath'] do
|
106
|
-
Dir.glob('test/**/*_test.rb') { |f| require f.sub('test/','') unless f.include? '.foreman_app/' }
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
task :test => 'test:all'
|