foreman_osc 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/foreman_osc/host_parameter_extensions.rb +22 -0
- data/lib/foreman_osc/engine.rb +2 -3
- data/lib/foreman_osc/version.rb +1 -1
- data/lib/osc.rake +6 -0
- data/test/factories/foreman_osc_factories.rb +5 -5
- data/test/test_plugin_helper.rb +2 -2
- data/test/unit/foreman_osc_test.rb +57 -2
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec9d24873a21e45a7fa9df7f109e935698f9cd0b
|
4
|
+
data.tar.gz: 3571576c186a4932f9db9b0a44e5f0b4a9699f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43fc88df8054b96a28fcae7b9d506cb36d8083fbfc1ea33d62ec76a38eab218e852996406ca58c6cb0c5aeb22d76b9e389183176adb896b522de88c47b3afef7
|
7
|
+
data.tar.gz: 5be375d10c724a43f42966b8d4d2f612d1202ef13f41e020cc9dfae1d35c0db13f5a0b09e27d15417d2dba762dba00a24caafa6446dcef63760b5a3880344cb3
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ForemanOsc
|
2
|
+
module HostParameterExtensions
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
validate :rw_nfsroot_path_unique, if: :rw_host_nfsroot_path?
|
7
|
+
end
|
8
|
+
|
9
|
+
def rw_nfsroot_path_unique
|
10
|
+
rw_hosts = self.host.hostgroup.hosts
|
11
|
+
other_params = self.class.where.not(id: self.id).where(name: 'nfsroot_path', value: value, host: rw_hosts)
|
12
|
+
if ! other_params.empty?
|
13
|
+
errors.add(:value, "should be unique for RW hosts")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def rw_host_nfsroot_path?
|
18
|
+
self.name == 'nfsroot_path' && self.host.hostgroup.present? && self.host.hostgroup.name == 'rw'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/foreman_osc/engine.rb
CHANGED
@@ -18,14 +18,13 @@ module ForemanOsc
|
|
18
18
|
load 'osc.rake'
|
19
19
|
end
|
20
20
|
|
21
|
-
=begin
|
22
21
|
config.to_prepare do
|
23
22
|
begin
|
24
|
-
Parameter.send(:include, ForemanOsc::ParameterExtensions)
|
23
|
+
#Parameter.send(:include, ForemanOsc::ParameterExtensions)
|
24
|
+
#HostParameter.send(:include, ForemanOsc::HostParameterExtensions)
|
25
25
|
rescue => e
|
26
26
|
Rails.logger.warn "ForemanOsc: skipping engine hook (#{e})"
|
27
27
|
end
|
28
28
|
end
|
29
|
-
=end
|
30
29
|
end
|
31
30
|
end
|
data/lib/foreman_osc/version.rb
CHANGED
data/lib/osc.rake
CHANGED
@@ -24,6 +24,8 @@ Example:
|
|
24
24
|
exit 1
|
25
25
|
end
|
26
26
|
|
27
|
+
User.current = User.find_by_login('admin')
|
28
|
+
|
27
29
|
Host.search_for(search).each do |host|
|
28
30
|
next unless host.provision_interface.present?
|
29
31
|
next unless host.tftp?
|
@@ -61,6 +63,8 @@ Example:
|
|
61
63
|
exit 1
|
62
64
|
end
|
63
65
|
|
66
|
+
User.current = User.find_by_login('admin')
|
67
|
+
|
64
68
|
Host.search_for(search).each do |host|
|
65
69
|
next unless host.dns?
|
66
70
|
host.interfaces.each do |interface|
|
@@ -100,6 +104,8 @@ Example:
|
|
100
104
|
exit 1
|
101
105
|
end
|
102
106
|
|
107
|
+
User.current = User.find_by_login('admin')
|
108
|
+
|
103
109
|
Host.search_for(search).each do |host|
|
104
110
|
next unless host.dhcp?
|
105
111
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
FactoryGirl.define do
|
2
|
-
factory :host do
|
3
|
-
name 'foreman_osc'
|
4
|
-
end
|
5
|
-
end
|
1
|
+
#FactoryGirl.define do
|
2
|
+
# factory :host do
|
3
|
+
# name 'foreman_osc'
|
4
|
+
# end
|
5
|
+
#end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -2,5 +2,5 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
# Add plugin to FactoryGirl's paths
|
5
|
-
FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
6
|
-
FactoryGirl.reload
|
5
|
+
#FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
6
|
+
#FactoryGirl.reload
|
@@ -3,9 +3,64 @@ require 'test_plugin_helper'
|
|
3
3
|
class ForemanOscTest < ActiveSupport::TestCase
|
4
4
|
setup do
|
5
5
|
User.current = User.find_by_login 'admin'
|
6
|
+
disable_orchestration
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
context 'HostParameterExtensions' do
|
10
|
+
setup do
|
11
|
+
@parent_hostgroup = FactoryGirl.create(:hostgroup, name: 'owens')
|
12
|
+
@normal_hostgroup = FactoryGirl.create(:hostgroup, name: 'compute', parent: @parent_hostgroup)
|
13
|
+
@rw_hostgroup = FactoryGirl.create(:hostgroup, name: 'rw', parent: @parent_hostgroup)
|
14
|
+
@normal_host1 = FactoryGirl.create(:host, hostgroup: @normal_hostgroup)
|
15
|
+
@normal_host2 = FactoryGirl.create(:host, hostgroup: @normal_hostgroup)
|
16
|
+
@rw_host1 = FactoryGirl.create(:host, hostgroup: @rw_hostgroup)
|
17
|
+
@rw_host2 = FactoryGirl.create(:host, hostgroup: @rw_hostgroup)
|
18
|
+
@normal_parameter1 = FactoryGirl.create(:host_parameter, name: 'nfsroot_path', value: '/foo1', host: @normal_host1)
|
19
|
+
@normal_parameter2 = FactoryGirl.create(:host_parameter, name: 'nfsroot_path', value: '/foo2', host: @normal_host2)
|
20
|
+
@rw_parameter1 = FactoryGirl.create(:host_parameter, name: 'nfsroot_path', value: '/foo1', host: @rw_host1)
|
21
|
+
@rw_parameter2 = FactoryGirl.create(:host_parameter, name: 'nfsroot_path', value: '/foo2', host: @rw_host2)
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'verify fixtures' do
|
25
|
+
assert_equal false, @normal_parameter1.rw_host_nfsroot_path?
|
26
|
+
assert_equal false, @normal_parameter2.rw_host_nfsroot_path?
|
27
|
+
assert_equal true, @rw_parameter1.rw_host_nfsroot_path?
|
28
|
+
assert_equal true, @rw_parameter2.rw_host_nfsroot_path?
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'rw_host_nfsroot_path? - false if not nfsroot_path' do
|
32
|
+
param = FactoryGirl.build(:host_parameter, name: 'nfsroot_kernel_version', value: '2.6.32')
|
33
|
+
assert_equal false, param.rw_host_nfsroot_path?
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'rw_host_nfsroot_path? - false if not RW host' do
|
37
|
+
host = FactoryGirl.create(:host, hostgroup: FactoryGirl.create(:hostgroup, name: 'foo'))
|
38
|
+
param = FactoryGirl.build(:host_parameter, name: 'nfsroot_path', value: '/foo1', host: host)
|
39
|
+
assert_equal false, param.rw_host_nfsroot_path?
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'rw hosts valid when nfsroot_path is different' do
|
43
|
+
assert_valid @rw_parameter1
|
44
|
+
assert_valid @rw_parameter2
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'rw hosts invalid when nfsroot_path is the same' do
|
48
|
+
@rw_parameter1.value = '/foo1'
|
49
|
+
@rw_parameter2.value = '/foo1'
|
50
|
+
#puts "DEBUG"
|
51
|
+
#puts @rw_parameter2.valid?
|
52
|
+
refute_valid @rw_parameter2
|
53
|
+
assert_includes @rw_parameter2.errors[:value], "should be unique for RW hosts"
|
54
|
+
end
|
55
|
+
|
56
|
+
test 'non-rw hosts are valid when nfsroot_path is different and the same' do
|
57
|
+
assert_valid @normal_parameter1
|
58
|
+
assert_valid @normal_parameter2
|
59
|
+
@normal_parameter1.value = '/foo1'
|
60
|
+
@normal_parameter2.value = '/foo1'
|
61
|
+
assert_valid @normal_parameter1
|
62
|
+
assert_valid @normal_parameter2
|
63
|
+
end
|
10
64
|
end
|
65
|
+
|
11
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_osc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Dockendorf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -59,15 +59,16 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
-
|
63
|
-
- README.md
|
64
|
-
- Rakefile
|
62
|
+
- app/models/concerns/foreman_osc/host_parameter_extensions.rb
|
65
63
|
- app/models/concerns/foreman_osc/parameter_extensions.rb
|
66
|
-
- lib/foreman_osc.rb
|
67
|
-
- lib/foreman_osc/engine.rb
|
68
|
-
- lib/foreman_osc/version.rb
|
69
64
|
- lib/osc.rake
|
70
65
|
- lib/tasks/foreman_osc_tasks.rake
|
66
|
+
- lib/foreman_osc/engine.rb
|
67
|
+
- lib/foreman_osc/version.rb
|
68
|
+
- lib/foreman_osc.rb
|
69
|
+
- LICENSE
|
70
|
+
- Rakefile
|
71
|
+
- README.md
|
71
72
|
- test/factories/foreman_osc_factories.rb
|
72
73
|
- test/test_plugin_helper.rb
|
73
74
|
- test/unit/foreman_osc_test.rb
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
94
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.0.14.1
|
95
96
|
signing_key:
|
96
97
|
specification_version: 4
|
97
98
|
summary: OSC Foreman Plugin
|