foreman_enc_hostgrouponly 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,19 +1,28 @@
|
|
1
1
|
# ForemanEncHostgrouponly
|
2
2
|
|
3
|
-
|
3
|
+
This rails engine/plugin to Foreman leverages the existing ENC functionality meanwhile only return data that being overriden in hostgroup. This would allow user sepereate ENC/classes and data management so data could be managed in an auditable manner.
|
4
|
+
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
7
8
|
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
8
9
|
for how to install Foreman plugins
|
9
10
|
|
10
|
-
|
11
|
+
The gem name is "foreman_enc_hostgrouponly".
|
12
|
+
|
13
|
+
## Compatibility
|
11
14
|
|
12
|
-
|
15
|
+
| Foreman Version | Plugin Version |
|
16
|
+
| --------------- | --------------:|
|
17
|
+
| >= 1.5 | 1.0.0 |
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
There is a new setting under `Settings -> General`
|
13
21
|
|
14
|
-
|
22
|
+
| Setting | Description |
|
23
|
+
| ------- | ----------- |
|
24
|
+
| `enc_hostgrouponly` | Setting this to `true` will let ENC return host group parameters only Default: `false` |
|
15
25
|
|
16
|
-
*Todo list here*
|
17
26
|
|
18
27
|
## Contributing
|
19
28
|
|
@@ -21,7 +30,7 @@ Fork and send a Pull Request. Thanks!
|
|
21
30
|
|
22
31
|
## Copyright
|
23
32
|
|
24
|
-
Copyright (c) *
|
33
|
+
Copyright (c) *2014* *Huai Jiang*
|
25
34
|
|
26
35
|
This program is free software: you can redistribute it and/or modify
|
27
36
|
it under the terms of the GNU General Public License as published by
|
@@ -1,13 +1,8 @@
|
|
1
|
-
require 'deface'
|
2
1
|
require 'foreman_enc_hostgrouponly_patch'
|
3
2
|
|
4
3
|
module ForemanEncHostgrouponly
|
5
4
|
class Engine < ::Rails::Engine
|
6
5
|
|
7
|
-
#config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
8
|
-
#config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
9
|
-
#config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
10
|
-
#config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
11
6
|
|
12
7
|
# Load this before the Foreman config initizializers, so that the Setting.descendants
|
13
8
|
# list includes the plugin STI setting class
|
@@ -25,8 +20,6 @@ module ForemanEncHostgrouponly
|
|
25
20
|
#Include concerns in this config.to_prepare block
|
26
21
|
config.to_prepare do
|
27
22
|
begin
|
28
|
-
# Host::Managed.send(:include, ForemanEncHostgrouponly::HostExtensions)
|
29
|
-
# HostsHelper.send(:include, ForemanEncHostgrouponly::HostsHelperExtensions)
|
30
23
|
Classification::ClassParam.send(:include, ForemanEncHostgrouponlyPatch)
|
31
24
|
rescue => e
|
32
25
|
puts e.backtrace
|
@@ -16,32 +16,29 @@ module ForemanEncHostgrouponlyPatch
|
|
16
16
|
Rails.logger.debug "ForemanEncHostgrouponlyPatch: return host group parameters only"
|
17
17
|
h = {}
|
18
18
|
begin
|
19
|
-
|
20
|
-
LookupValue.where(:match => hostgroup_match).where(:lookup_key_id => class_parameters.map(&:id)).each do |value|
|
21
|
-
key = class_parameters.detect{|k| k.id == value.lookup_key_id }
|
22
|
-
Rails.logger.debug "ForemanEncHostgrouponlyPatch: detect host group parameters (#{key.to_s})"
|
23
|
-
klass_id = key.environment_classes.first.puppetclass_id
|
24
|
-
h[klass_id] ||= []
|
25
|
-
h[klass_id] << key
|
26
|
-
end
|
27
|
-
end
|
28
|
-
h
|
29
|
-
rescue => e
|
30
|
-
Rails.logger.error "ForemanEncHostgrouponlyPatch: return host group parameters only (#{e.to_s})"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def hostgroup_match
|
35
|
-
hostgroup_matches = []
|
19
|
+
hostgroup_matches = []
|
36
20
|
possible_value_orders.each do |rule|
|
37
21
|
match = Array.wrap(rule).map do |element|
|
38
|
-
|
22
|
+
"#{element}#{LookupKey::EQ_DELM}#{attr_to_value(element)}"
|
39
23
|
end if Array.wrap(rule).include?("hostgroup")
|
40
24
|
if match
|
41
|
-
|
25
|
+
hostgroup_matches << match.join(LookupKey::KEY_DELM)
|
42
26
|
end
|
43
27
|
end
|
44
|
-
|
28
|
+
|
29
|
+
hostgroup_matches.each do |hostgroup_match|
|
30
|
+
LookupValue.where(:match => hostgroup_match).where(:lookup_key_id => class_parameters.map(&:id)).each do |value|
|
31
|
+
key = class_parameters.detect{|k| k.id == value.lookup_key_id }
|
32
|
+
Rails.logger.debug "ForemanEncHostgrouponlyPatch: detect host group parameters (#{key.to_s})"
|
33
|
+
klass_id = key.environment_classes.first.puppetclass_id
|
34
|
+
h[klass_id] ||= []
|
35
|
+
h[klass_id] << key
|
36
|
+
end
|
37
|
+
end
|
38
|
+
h
|
39
|
+
rescue => e
|
40
|
+
Rails.logger.error "ForemanEncHostgrouponly: skipping engine hook (#{e.to_s})"
|
41
|
+
end
|
45
42
|
end
|
46
43
|
|
47
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_enc_hostgrouponly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: deface
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
12
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
30
14
|
description: get hostgroup param only
|
31
15
|
email:
|
32
16
|
- huajiang@ebay.com
|