foreman_discovery 1.0.2 → 1.1.1
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 +12 -26
- data/app/controllers/discovers_controller.rb +7 -6
- data/app/models/host/discovered.rb +12 -25
- data/lib/foreman_discovery/version.rb +1 -1
- data/lib/tasks.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 321fccd57e6e597e9d144fbdfed50b2ebf31060a
|
|
4
|
+
data.tar.gz: d51274ca2f006f8c2ceb300a1cb7690c80eb4aeb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 397579ca7a041155026bfdd6d1bd4ff189319e4f980c41a9ae706dc1e7c1444eefbc70c05eeed8bf3ea812dbf394d0206850f5a91303636b5e10f064003b174b
|
|
7
|
+
data.tar.gz: bcb39a17222301d169f9b06ec1dadf281bfe528683370d64ae2abe5fc7260fa4f6268ce1ade4641b9f26edab3323edf55e3279fff3a085297df84661418c586b
|
data/README.md
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
# foreman\_discovery
|
|
2
2
|
|
|
3
|
-
This plugin
|
|
4
|
-
right now ;)
|
|
3
|
+
This plugin enables MaaS hardware discovery in Foreman.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Installation
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
|
8
|
+
for how to install Foreman plugins
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Compatibility
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
SCL-based OSes (i.e. EL6) will want to avoid a large number of dependencies by doing this:
|
|
17
|
-
|
|
18
|
-
yum -y install ruby193-rubygem-nokogiri && scl enable ruby193 'gem install foreman_discovery'
|
|
19
|
-
|
|
20
|
-
Other OSes should run:
|
|
21
|
-
|
|
22
|
-
bundle update
|
|
23
|
-
|
|
24
|
-
Lastly, restart Foreman.
|
|
12
|
+
| Foreman Version | Plugin Version |
|
|
13
|
+
| --------------- | --------------:|
|
|
14
|
+
| <= 1.2 | 1.0.2 |
|
|
15
|
+
| >= 1.3 | 1.1.0 |
|
|
25
16
|
|
|
26
17
|
## Latest code
|
|
27
18
|
|
|
28
|
-
You can get the develop branch of the plugin this way:
|
|
19
|
+
You can get the develop branch of the plugin by specifying your Gemfile in this way:
|
|
29
20
|
|
|
30
21
|
gem 'foreman_discovery', :git => "https://github.com/theforeman/foreman_discovery.git"
|
|
31
22
|
|
|
@@ -35,14 +26,9 @@ There is a rake task for the discovery image. It requires Ruby 1.8, but should
|
|
|
35
26
|
appropriately detect and use ruby1.8 even if the system default is 1.9. If you
|
|
36
27
|
have trouble building it, try a ruby1.8-only system.
|
|
37
28
|
|
|
38
|
-
Run this
|
|
39
|
-
|
|
40
|
-
rake discovery:build_image
|
|
41
|
-
|
|
42
|
-
Note: If you are using RHEL6 or clones, make sure you run the above command
|
|
43
|
-
with the SCL Ruby:
|
|
29
|
+
Run this rake task to create the image:
|
|
44
30
|
|
|
45
|
-
|
|
31
|
+
foreman-rake discovery:build_image
|
|
46
32
|
|
|
47
33
|
You image will be in ./discovery\_image. Run the rake task as root, or with passwordless
|
|
48
34
|
sudo, as the password prompts may get lost in the ruby->bash forking process.
|
|
@@ -8,7 +8,7 @@ class DiscoversController < ::ApplicationController
|
|
|
8
8
|
|
|
9
9
|
before_filter :find_by_name, :only => %w[show edit update destroy refresh_facts convert]
|
|
10
10
|
before_filter :find_multiple, :only => [:multiple_destroy, :submit_multiple_destroy]
|
|
11
|
-
before_filter :taxonomy_scope, :only => [:edit]
|
|
11
|
+
before_filter :taxonomy_scope, :only => [:edit]
|
|
12
12
|
|
|
13
13
|
helper :hosts
|
|
14
14
|
|
|
@@ -26,20 +26,20 @@ class DiscoversController < ::ApplicationController
|
|
|
26
26
|
# as a parameter and use refresh_facts to get the rest
|
|
27
27
|
def create
|
|
28
28
|
Taxonomy.no_taxonomy_scope do
|
|
29
|
-
imported = Host::Discovered.new(:ip => get_ip_from_env).refresh_facts
|
|
29
|
+
host, imported = Host::Discovered.new(:ip => get_ip_from_env).refresh_facts
|
|
30
30
|
respond_to do |format|
|
|
31
31
|
format.yml {
|
|
32
32
|
if imported
|
|
33
|
-
render :text => _("Imported
|
|
33
|
+
render :text => _("Imported Host::Discovered"), :status => 200 and return
|
|
34
34
|
else
|
|
35
|
-
render :text => _("Failed to import facts"), :status => 400
|
|
35
|
+
render :text => _("Failed to import facts for Host::Discovered"), :status => 400
|
|
36
36
|
end
|
|
37
37
|
}
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
rescue Exception => e
|
|
41
|
-
logger.warn "Failed to import facts: #{e}"
|
|
42
|
-
render :text => _("Failed to import facts: %s") % (e), :status => 400
|
|
41
|
+
logger.warn "Failed to import facts for Host::Discovered: #{e}"
|
|
42
|
+
render :text => _("Failed to import facts for Host::Discovered: %s") % (e), :status => 400
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def show
|
|
@@ -72,6 +72,7 @@ class DiscoversController < ::ApplicationController
|
|
|
72
72
|
if @host.update_attributes(params[:host])
|
|
73
73
|
process_success :success_redirect => host_path(@host), :redirect_xhr => request.xhr?
|
|
74
74
|
else
|
|
75
|
+
taxonomy_scope
|
|
75
76
|
load_vars_for_ajax
|
|
76
77
|
offer_to_overwrite_conflicts
|
|
77
78
|
process_error :object => @host, :render => 'hosts/edit'
|
|
@@ -21,32 +21,18 @@ class Host::Discovered < ::Host::Base
|
|
|
21
21
|
# this seems like a rails bug, TODO: figure out whats really wrong here
|
|
22
22
|
scope :list, lambda { where(:type => "Host::Discovered").includes(:model, :location, :organization) }
|
|
23
23
|
|
|
24
|
-
def self.importHostAndFacts
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# Discovered hosts don't have a name yet - use MAC for now
|
|
29
|
-
# TODO: make this more intelligent, we might not have an eth0...
|
|
30
|
-
when Puppet::Node::Facts
|
|
31
|
-
name = facts.values["macaddress_eth0"].downcase.gsub(/:/,'')
|
|
32
|
-
values = facts.values
|
|
33
|
-
when Hash
|
|
34
|
-
name = facts["macaddress_eth0"].downcase.gsub(/:/,'')
|
|
35
|
-
values = facts
|
|
36
|
-
return raise("invalid facts hash") unless name and values
|
|
37
|
-
else
|
|
38
|
-
return raise("Invalid Facts, much be a Puppet::Node::Facts or a Hash")
|
|
39
|
-
end
|
|
24
|
+
def self.importHostAndFacts facts
|
|
25
|
+
raise(::Foreman::Exception.new("Invalid Facts, must be a Hash")) unless facts.is_a?(Hash)
|
|
26
|
+
hostname = facts["macaddress_eth0"].try(:downcase).try(:gsub,/:/,'')
|
|
27
|
+
raise(::Foreman::Exception.new("Invalid facts: hash does not contain macaddress_eth0 to use as hostname")) unless hostname
|
|
40
28
|
|
|
41
29
|
# filter facts
|
|
42
|
-
|
|
30
|
+
facts.reject!{|k,v| k =~ /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|filesystem|version/i }
|
|
43
31
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
h ||= Host.new :name => name, :type => "Host::Discovered"
|
|
32
|
+
h = ::Host::Discovered.find_by_name hostname
|
|
33
|
+
h ||= Host.new :name => hostname, :type => "Host::Discovered"
|
|
48
34
|
h.type = "Host::Discovered"
|
|
49
|
-
h.mac =
|
|
35
|
+
h.mac = facts["macaddress_eth0"].try(:downcase)
|
|
50
36
|
|
|
51
37
|
if SETTINGS[:locations_enabled]
|
|
52
38
|
begin
|
|
@@ -63,11 +49,12 @@ class Host::Discovered < ::Host::Base
|
|
|
63
49
|
end
|
|
64
50
|
end
|
|
65
51
|
|
|
66
|
-
h.save if h.new_record?
|
|
67
|
-
h.importFacts(
|
|
52
|
+
h.save(:validate => false) if h.new_record?
|
|
53
|
+
state = h.importFacts(facts)
|
|
54
|
+
return h, state
|
|
68
55
|
end
|
|
69
56
|
|
|
70
|
-
def importFacts
|
|
57
|
+
def importFacts facts
|
|
71
58
|
# Discovered Hosts won't report in via puppet, so we can use that field to
|
|
72
59
|
# record the last time it sent facts...
|
|
73
60
|
self.last_report = Time.now
|
data/lib/tasks.rake
CHANGED
|
@@ -43,7 +43,7 @@ namespace :discovery do
|
|
|
43
43
|
exit 1
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
script
|
|
46
|
+
script = File.join(File.dirname(__FILE__), '..', 'extra', 'build_iso.sh')
|
|
47
47
|
builddir=''
|
|
48
48
|
begin
|
|
49
49
|
status = Open4::popen4("#{prefix} #{script} #{mode}") do |pid, stdin, stdout, stderr|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_discovery
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
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-
|
|
11
|
+
date: 2013-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: open4
|