foreman_default_hostgroup 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80eeeefe5330eb909cbff3b1945df18fd64b5270
|
4
|
+
data.tar.gz: a31c296a3e787879056a7f167f6ae4e31a9ce999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df1e1a9fbf5adefc691245525c284125a3e7f19f29043189e5a0c402dd9468ad860326feee0fb0195fd32d14a809e2abd67f98dac397017f29256df0a873b1f5
|
7
|
+
data.tar.gz: 3d03a685af3174d5ba437330fee1172539b2cdd4961aa4e67bc7dcefadfb4b6228ea7d3e7e9df6595b7b24be17ab3c4d6e8575ca4904d7d5ea6e33a0f4ad3824
|
data/README.md
CHANGED
@@ -5,11 +5,15 @@ a Hostgroup set.
|
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
|
-
|
8
|
+
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
9
|
+
for how to install Foreman plugins
|
9
10
|
|
10
|
-
|
11
|
+
## Compatibility
|
11
12
|
|
12
|
-
|
13
|
+
| Foreman Version | Plugin Version |
|
14
|
+
| --------------- | --------------:|
|
15
|
+
| <= 1.2 | 0.1.0 |
|
16
|
+
| >= 1.3 | 1.0.0 |
|
13
17
|
|
14
18
|
## Usage
|
15
19
|
|
@@ -17,8 +21,8 @@ Go to `Settings -> DefaultHostgroup` and enter the name of the default
|
|
17
21
|
hostgroup. Leaving this blank disables the plugin. Nested Hostgroups should be
|
18
22
|
specified with the full label, e.g. `Base/Level1/Level2`
|
19
23
|
|
20
|
-
Once set, any upload to `/
|
21
|
-
will cause the Hostgroup to be set to the value in the Settings.
|
24
|
+
Once set, any fact upload to `/api/hosts/facts` for a Host with no Hostgroup set
|
25
|
+
will cause the Hostgroup to be set to the value in the Settings. This happens
|
22
26
|
*before* the ENC data is downloaded, meaning it applies for a Host's very first
|
23
27
|
run.
|
24
28
|
|
@@ -28,7 +32,6 @@ reports (i.e new Hosts only).
|
|
28
32
|
## TODO
|
29
33
|
|
30
34
|
* Tests
|
31
|
-
* Rewrite this in a less hacky way
|
32
35
|
|
33
36
|
## Contributing
|
34
37
|
|
@@ -10,36 +10,17 @@ module DefaultHostgroupManagedHostPatch
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
def importHostAndFacts_with_apply_hostgroup
|
14
|
-
|
13
|
+
def importHostAndFacts_with_apply_hostgroup hostname, facts, certname = nil
|
14
|
+
host, result = importHostAndFacts_without_apply_hostgroup(hostname, facts, certname)
|
15
15
|
Rails.logger.debug "DefaultHostgroup: performing Hostgroup check"
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
certname = facts.name
|
23
|
-
name = facts.values["fqdn"].downcase
|
24
|
-
when Hash
|
25
|
-
certname = facts["clientcert"] || facts["certname"]
|
26
|
-
name = facts["fqdn"].downcase
|
27
|
-
end
|
28
|
-
h=nil
|
29
|
-
if name == certname or certname.nil?
|
30
|
-
h = Host.find_by_name name
|
31
|
-
else
|
32
|
-
h = Host.find_by_certname certname
|
33
|
-
h ||= Host.find_by_name name
|
34
|
-
end
|
35
|
-
# Now we can update it
|
36
|
-
if h.hostgroup.nil? and h.reports.empty?
|
37
|
-
h.hostgroup = Hostgroup.find_by_label(Setting[:default_hostgroup])
|
38
|
-
h.save
|
39
|
-
Rails.logger.debug "DefaultHostgroup: added #{h.name} to #{h.hostgroup.label}"
|
40
|
-
end
|
16
|
+
# host.new_record? will only test for the early return in the core method, a real host
|
17
|
+
# will have already been saved at least once.
|
18
|
+
if host.present? && !host.new_record? && host.hostgroup.nil? && host.reports.empty?
|
19
|
+
host.hostgroup = Hostgroup.find_by_label(Setting[:default_hostgroup])
|
20
|
+
host.save(:validate => false)
|
21
|
+
Rails.logger.debug "DefaultHostgroup: added #{host.name} to #{host.hostgroup.label}"
|
41
22
|
end
|
42
|
-
|
23
|
+
return host, result
|
43
24
|
end
|
44
25
|
end
|
45
26
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_default_hostgroup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sutcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: deface
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Adds the option to specify a default hostgroup for new hosts created
|
28
14
|
from facts/reports
|
29
15
|
email: gsutclif@redhat.com
|