Feature #335 » foreman_info.patch
app/models/report.rb 2010-10-25 15:12:09.000000000 -0700 | ||
---|---|---|
# save our report time
|
||
host.last_report = report.time.utc if host.last_report.nil? or host.last_report.utc < report.time.utc
|
||
# If we are running TheForeman strictly for reporting purposes we should
|
||
# collect a little more information from the client.
|
||
if SETTINGS[:reportonly].to_s == "true"
|
||
# Update the environment, creating a new one if necessary.
|
||
v = Environment.find_by_name(host.fv(:environment))
|
||
if v
|
||
host.environment = v
|
||
else
|
||
host.environment = Environment.create({:name => host.fv(:environment)})
|
||
end
|
||
# Update the model, creating a new one if necessary. Will also
|
||
# differentiate various virtual hosts.
|
||
val = host.fv(:productname)
|
||
val = host.fv(:virtual) if val == nil # Use the virtual info
|
||
logger.info "chose produce '#{val}' for #{report.host}"
|
||
v = Model.find_by_name(val)
|
||
if v
|
||
host.model = v
|
||
else
|
||
host.model = Model.create({:name => val})
|
||
end
|
||
# Update the OS, creating a new one if necessary. This is a rather
|
||
# naive way to set up the OS. Sorry.
|
||
major, minor = host.fv(:operatingsystemrelease).split(".",2)
|
||
v = Operatingsystem.first(:conditions => "name = \"#{host.fv(:operatingsystem)}\" and major = \"#{major}\" and minor = \"#{minor}\"")
|
||
if v
|
||
host.os = v
|
||
else
|
||
host.os = Operatingsystem.create({:name => host.fv(:operatingsystem),
|
||
:major => major,
|
||
:minor => minor})
|
||
end
|
||
end
|
||
# we save the raw bit status value in our host too.
|
||
host.puppet_status = st
|
||
- « Previous
- 1
- 2
- 3
- 4
- Next »