foreman_info.patch

The *right* version of the patch - Brian Gallew, 10/26/2010 12:30 AM

Download (1.89 KB)

View differences:

app/models/report.rb 2010-10-25 15:12:09.000000000 -0700
105 105
      # save our report time
106 106
      host.last_report = report.time.utc if host.last_report.nil? or host.last_report.utc < report.time.utc
107 107

  
108
      # If we are running TheForeman strictly for reporting purposes we should
109
      # collect a little more information from the client.
110
      if SETTINGS[:reportonly].to_s == "true"
111

  
112
        # Update the environment, creating a new one if necessary.
113
        v = Environment.find_by_name(host.fv(:environment))
114
        if v
115
          host.environment = v
116
        else
117
          host.environment = Environment.create({:name => host.fv(:environment)})
118
        end
119

  
120
        # Update the model, creating a new one if necessary.  Will also
121
        # differentiate various virtual hosts.
122
        val = host.fv(:productname) 
123
        val = host.fv(:virtual) if val == nil # Use the virtual info
124
        logger.info "chose produce '#{val}' for #{report.host}"
125
        v = Model.find_by_name(val)
126
        if v
127
          host.model = v
128
        else
129
          host.model = Model.create({:name => val})
130
        end
131

  
132
        # Update the OS, creating a new one if necessary.  This is a rather 
133
        # naive way to set up the OS.  Sorry.
134
        major, minor = host.fv(:operatingsystemrelease).split(".",2)
135
        v = Operatingsystem.first(:conditions => "name = \"#{host.fv(:operatingsystem)}\" and major = \"#{major}\" and minor = \"#{minor}\"")
136
        if v
137
          host.os = v
138
        else
139
          host.os = Operatingsystem.create({:name => host.fv(:operatingsystem),
140
                                             :major => major,
141
                                             :minor => minor})
142
        end
143
      end
144

  
108 145
      # we save the raw bit status value in our host too.
109 146
      host.puppet_status = st
110 147