Permalink
Browse files

Merge branch 'next'

* next: (25 commits)
  maint: Move inventory section lower on the node page
  (#4403) Do timezone arithmetic outside of the DB in the Status model
  Remove dead code from Status model
  Validate the user supplied daily_run_history_length
  (#6656) Inventory service is no longer experimental.
  (#6601) Inventory search uses the new inventory URL
  (#5711) Change license from GPLv3 to GPLv2
  (#5234) Source of silk icons attributed, per author's license
  Maint: Moved logic for identifying inspect reports into a callback.
  Maint: removed bogus comments from _report.html.haml
  Maint: Moved elements of the report "show" view into callbacks.
  Maint: Moved elements of the node "show" view into callbacks.
  Maint: Forbid uninstalled plugins from adding themselves to hooks.
  Maint: Add plug-in install and uninstall rake tasks
  Maint: removed db/schema.rb
  Maint: Removed some private methods in the report model that are part of baseline functionality.
  Maint: remove code that belongs in the "baseline" module.
  maint: Added log dir to version control
  Maint: Add puppet plugins to .gitignore
  Bug fix: renamed each_hook and find_first_hook to *_callback
  ...
  • Loading branch information...
2 parents 875f5a4 + b80b12c commit e5fd77d9e8c3de410a249e537cf3a177edaadbeb Matt Robinson committed Mar 16, 2011
Showing with 1,082 additions and 1,799 deletions.
  1. +4 −0 .gitignore
  2. +282 −617 LICENSE
  3. +10 −1 README.markdown
  4. +0 −40 app/controllers/node_groups_controller.rb
  5. +0 −42 app/controllers/reports_controller.rb
  6. +1 −2 app/models/node.rb
  7. +0 −55 app/models/report.rb
  8. +32 −31 app/models/status.rb
  9. +0 −36 app/views/node_groups/diff.html.haml
  10. +2 −2 app/views/node_groups/show.html.haml
  11. +8 −0 app/views/nodes/_activity.html.haml
  12. +2 −0 app/views/nodes/_description.html.haml
  13. +26 −0 app/views/nodes/_inspections.html.haml
  14. +9 −0 app/views/nodes/_inventory_service.html.haml
  15. +6 −0 app/views/nodes/_node_classification.html.haml
  16. +35 −0 app/views/nodes/_reports.html.haml
  17. +2 −95 app/views/nodes/show.html.haml
  18. +0 −13 app/views/reports/_baseline_selector.html.haml
  19. +0 −41 app/views/reports/_diff.html.haml
  20. +18 −0 app/views/reports/_log.html.haml
  21. +10 −0 app/views/reports/_metrics.html.haml
  22. +4 −58 app/views/reports/_report.html.haml
  23. +1 −6 app/views/reports/_report_status_icon.html.haml
  24. +25 −0 app/views/reports/_resource_statuses.html.haml
  25. +0 −17 app/views/reports/diff.html.haml
  26. +1 −1 app/views/shared/_node_manager_sidebar.html.haml
  27. +4 −0 config/environment.rb
  28. +0 −5 config/routes.rb
  29. +3 −0 config/settings.yml.example
  30. +9 −0 db/migrate/20110130010154_remove_column_baseline_report_id_from_nodes.rb
  31. +0 −166 db/schema.rb
  32. +4 −0 ext/packaging/debian/copyright
  33. +44 −0 lib/core_callbacks.rb
  34. +64 −0 lib/registry.rb
  35. +6 −0 lib/settings_reader.rb
  36. +43 −0 lib/tasks/plugins.rake
  37. 0 log/.gitignore
  38. BIN public/images/icons/baseline.png
  39. +2 −2 public/javascripts/application.js
  40. +0 −14 public/javascripts/baseline_selector.js
  41. +12 −12 public/stylesheets/tables.css
  42. +0 −197 spec/controllers/node_groups_controller_spec.rb
  43. +0 −78 spec/controllers/reports_controller_spec.rb
  44. +0 −4 spec/factories.rb
  45. +123 −0 spec/lib/registry_spec.rb
  46. +29 −4 spec/lib/settings_reader_spec.rb
  47. +0 −177 spec/models/report_spec.rb
  48. +261 −39 spec/models/status_spec.rb
  49. +0 −44 spec/views/node_groups/diff.html.haml_spec.rb
View
@@ -26,3 +26,7 @@ tags
tmp/*
results/*
certs
+vendor/plugins/puppet_*
+db/schema.rb
+db/migrate/*_plugin__*.rb
+config/installed_plugins
View
899 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -99,7 +99,7 @@ Installation
3. Download the most recent release of Puppet Dashboard, extract it and move it to your install location (this may be different on your system). This options makes upgrading more difficult since you'll have to manually manage files when upgrading, but may be a good option if you want to avoid repository setup or using git and just want to try out dashboard.
- wget --no-check-certificate https://github.com/puppetlabs/puppet-dashboard/tarball/v1.0.4
+ wget --no-check-certificate https://github.com/puppetlabs/puppet-dashboard/tarball/v1.0.4
tar -xzvf puppetlabs-puppet-dashboard-v1.0.4-0-g071acf4.tar.gz
mv puppetlabs-puppet-dashboard-071acf4 /usr/share/puppet-dashboard
@@ -422,6 +422,15 @@ In order to connect to the inventory service you will need to configure auth.con
method search
allow dashboard
+Icons
+-----
+
+Puppet Dashboard uses Mark James' fine [Silk icons](http://www.famfamfam.com/lab/icons/silk/).
+
+Thanks, Mark!
+
+
+
Contributors
------------
@@ -4,44 +4,4 @@ class NodeGroupsController < InheritedResources::Base
before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :create, :update, :destroy]
include SearchableIndex
-
- def diff
- @node_group = NodeGroup.find(params[:id])
- unless params[:baseline_type] == "self"
- node = Node.find_by_name(params[:baseline_host])
-
- if node
- @baseline = node.baseline_report
- @diff_error_message = "Node '#{params[:baseline_host]}' does not have a baseline report set." unless @baseline
- else
- @diff_error_message = "Node '#{params[:baseline_host]}' does not exist."
- end
- end
-
- unless @diff_error_message
- @nodes_without_latest_inspect_reports = []
- @nodes_without_baselines = []
- @nodes_without_differences = []
- @nodes_with_differences = []
- @node_group.all_nodes.sort_by(&:name).each do |node|
- baseline = @baseline || node.baseline_report
- @nodes_without_latest_inspect_reports << node and next unless node.last_inspect_report
- @nodes_without_baselines << node and next unless baseline
-
- report_diff = baseline.diff(node.last_inspect_report)
- resource_statuses = Report.divide_diff_into_pass_and_fail(report_diff)
-
- if resource_statuses[:failure].empty?
- @nodes_without_differences << node
- else
- @nodes_with_differences << {
- :baseline_report => baseline,
- :last_inspect_report => node.last_inspect_report,
- :report_diff => report_diff,
- :resource_statuses => resource_statuses,
- }
- end
- end
- end
- end
end
@@ -37,35 +37,6 @@ def upload
end
end
- def diff
- @my_report = Report.find(params[:id])
-
- if params[:baseline_type] == "self"
- @baseline_report = @my_report.node.baseline_report
- @diff_error_message = "Node '#{@my_report.node.name}' does not have a baseline report set." unless @baseline_report
- else
- node = Node.find_by_name(params[:baseline_host])
-
- if node
- @baseline_report = node.baseline_report
- @diff_error_message = "Node '#{params[:baseline_host]}' does not have a baseline report set." unless @baseline_report
- else
- @diff_error_message = "Node '#{params[:baseline_host]}' does not exist."
- end
- end
-
- unless @diff_error_message
- @diff = @baseline_report.diff(@my_report)
- @resource_statuses = Report.divide_diff_into_pass_and_fail(@diff)
- end
- end
-
- def make_baseline
- report = Report.find( params[:id] )
- report.baseline!
- redirect_to report
- end
-
def search
flash[:errors] = []
inspected_resources = ResourceStatus.latest_inspections.order("nodes.name")
@@ -91,19 +62,6 @@ def search
end
end
- def baselines
- if request.format == :json
- limit = params[:limit].to_i
- search_term = params[:term].gsub(/([\\%_])/, "\\\\\\1")
- prefix_matches = Report.baselines.where(["host LIKE ?", "#{search_term}%"]).order("host ASC").limit(limit).map(&:host)
- substring_matches = Report.baselines.where(["host LIKE ?", "%#{search_term}%"]).order("host ASC").limit(limit).map(&:host)
- matches = (prefix_matches + substring_matches).uniq[0,limit]
- render :text => matches.to_json, :content_type => 'application/json'
- else
- render :status => 406
- end
- end
-
private
def collection
View
@@ -16,7 +16,6 @@ def self.per_page; 20 end # Pagination
has_many :reports, :dependent => :destroy
belongs_to :last_apply_report, :class_name => 'Report'
belongs_to :last_inspect_report, :class_name => 'Report'
- belongs_to :baseline_report, :class_name => 'Report'
named_scope :with_last_report, :include => :last_apply_report
named_scope :by_report_date, :order => 'reported_at DESC'
@@ -79,7 +78,7 @@ def self.find_from_inventory_search(search_params)
map {|param| "facts.#{CGI::escape param["fact"]}.#{param["comparator"]}=#{CGI::escape param["value"]}" }.
join("&")
- url = "https://#{SETTINGS.inventory_server}:#{SETTINGS.inventory_port}/production/inventory/search?#{query_string}"
+ url = "https://#{SETTINGS.inventory_server}:#{SETTINGS.inventory_port}/production/facts_search/search?#{query_string}"
matches = JSON.parse(PuppetHttps.get(url, 'pson'))
nodes = Node.find_all_by_name(matches)
found = nodes.map(&:name).map(&:downcase)
View
@@ -19,7 +19,6 @@ def self.per_page; 20 end # Pagination
named_scope :inspections, :conditions => {:kind => "inspect"}, :include => :metrics
named_scope :applies, :conditions => {:kind => "apply" }, :include => :metrics
- named_scope :baselines, :include => :node, :conditions => ['nodes.baseline_report_id = reports.id']
def total_resources
metric_value("resources", "total")
@@ -56,35 +55,6 @@ def metric_value(category, name)
(metric and metric.value) or 0
end
- def diff(comparison_report)
- diff_stuff = {}
- comparison_resources = resources_to_hash(comparison_report.resource_statuses)
- our_resources = resources_to_hash(resource_statuses)
- (comparison_resources.keys | our_resources.keys).each do |resource_name|
- comparison_resource = comparison_resources[resource_name] || {}
- our_resource = our_resources[resource_name] || {}
- (comparison_resource.keys | our_resource.keys).each do |property|
- diff_stuff[resource_name] ||= {}
- if our_resource[property] != comparison_resource[property]
- diff_stuff[resource_name][property.to_sym] = [ our_resource[property], comparison_resource[property] ]
- end
- end
- end
- diff_stuff
- end
-
- def self.divide_diff_into_pass_and_fail(diff)
- divided_diff = {:failure => [], :pass => []}
- diff.each do |resource, differences|
- if ! differences.empty?
- divided_diff[:failure] << resource
- else
- divided_diff[:pass] << resource
- end
- end
- divided_diff
- end
-
def self.attribute_hash_from(report_hash)
attribute_hash = report_hash.dup
attribute_hash["logs_attributes"] = attribute_hash.delete("logs")
@@ -135,33 +105,8 @@ def long_name
"#{node.name} at #{time}"
end
- def baseline?
- self.node.baseline_report_id == self.id
- end
-
- def baseline!
- raise IncorrectReportKind.new("expected 'inspect', got '#{self.kind}'") unless self.kind == "inspect"
- self.node.baseline_report = self
- self.node.save!
- end
-
private
- def resources_to_hash(resources)
- hash = {}
- resources.each do |resource_status|
- hash[resource_status.name] = events_to_hash(resource_status.events)
- end
- hash
- end
-
- def events_to_hash(events)
- events.inject({}) do |hash, event|
- hash[event.property] = event.previous_value
- hash
- end
- end
-
def replace_last_report
return unless node
View
@@ -8,55 +8,56 @@ def initialize(datum)
@start = Time.zone.parse(datum["start"])
end
- def self.latest(options={})
- by_interval(options.merge(:limit => 1)).first
- end
-
- def self.recent(options={})
- by_interval options.merge(:start => 1.hour.ago)
- end
-
# Returns an array of Statuses by date for either a :node, or :nodes or all nodes in the system.
#
# Options:
- # * :node => Node to return Statuses for.
+ # * :node => Node to return Statuses for.
# * :nodes => Nodes to return Statuses for.
- # * :start => Start Time of the range to query.
- # * :limit => Limit the number of records to return.
- def self.by_interval(options={})
+ def self.within_daily_run_history(options={})
return [] if options[:nodes] && options[:nodes].empty?
- interval = 1.day
- # WARNING: This uses the local server time, regardless of what is set in the Rails config.
- # This should be changed once we have a user-friendly settings file, or can get the browser
- # time zone to this method.
- offset = Time.zone.now.utc_offset
- offset_timestamp = "UNIX_TIMESTAMP(time) + #{offset}"
- date = "DATE(FROM_UNIXTIME(#{offset_timestamp}))"
+ last_day = Time.zone.now + 1.day # Last full day to include (ignores time).
+ limit = SETTINGS.daily_run_history_length # Limit the number of days to return (includes "last_day").
+
+ utc_date_boundaries = get_utc_boundaries_ending(last_day, limit + 1)
+ newest_accepatable_data = utc_date_boundaries.first
+
+ boundary_groupings = "CASE\n"
+ utc_date_boundaries.each do |boundary|
+ # We use the '%Y-%m-%d %H:%M:%S %z' strftime to get something parse-able
+ # by Time.zone.parse and lexically sortable.
+ boundary_groupings << "WHEN time >= '#{boundary.utc.to_s(:db)}' THEN '#{boundary.strftime("%Y-%m-%d %H:%M:%S %z")}'\n"
+ end
+ boundary_groupings << "ELSE null\n"
+ boundary_groupings << "END"
sql = <<-SQL
SELECT
- COUNT(*) as total,
+ COUNT(*) as total,
SUM(CASE status when "unchanged" then 1 else 0 end) as unchanged,
- SUM(CASE status when "changed" then 1 else 0 end) as changed,
- SUM(CASE status when "failed" then 1 else 0 end) as failed,
- #{date} as start
+ SUM(CASE status when "changed" then 1 else 0 end) as changed,
+ SUM(CASE status when "failed" then 1 else 0 end) as failed,
+ #{boundary_groupings} as start
FROM reports
SQL
- sql << "WHERE kind = 'apply' "
- sql << "AND time >= \"#{options[:start].getutc.to_s(:db)}\"\n" if options[:start]
- sql << "AND node_id = #{options[:node].id} " if options[:node]
+ sql << "WHERE kind = 'apply'\n"
+ sql << "AND time < \"#{newest_accepatable_data.utc.to_s(:db)}\"\n"
+ sql << "AND time >= \"#{utc_date_boundaries.last.utc.to_s(:db)}\"\n"
+ sql << "AND node_id = #{options[:node].id}\n" if options[:node]
sql << "AND node_id IN (#{options[:nodes].map(&:id).join(',')})\n" if options[:nodes].present?
- sql << "GROUP BY #{date}\n"
- sql << "ORDER BY time ASC\n"
- sql << "LIMIT #{options[:limit]}" if options[:limit]
+ sql << "GROUP BY start\n"
+ sql << "ORDER BY start ASC\n"
+ sql << "LIMIT #{limit}\n"
return execute(sql)
end
- def self.within_daily_run_history(options={})
- self.by_interval( options.merge( :start => SETTINGS.daily_run_history_length.days.ago, :limit => SETTINGS.daily_run_history_length ) )
+ def self.get_utc_boundaries_ending(date, num_days)
+ (0..(num_days-1)).collect do |offset|
+ x = date - offset.days
+ Time.zone.local(x.year, x.month, x.day, 0, 0, 0)
+ end
end
def self.runtime
@@ -1,36 +0,0 @@
-#sidebar= render 'shared/node_manager_sidebar'
-#main
- .header
- %h2
- Diff Report for
- = @node_group.name
- - if @diff_error_message
- .item
- .section.error
- %h3 No baseline available to compare.
- %p
- = h @diff_error_message
- - else
- - unless @nodes_without_latest_inspect_reports.empty?
- .item
- %h2 No latest inspect report
- = @nodes_without_latest_inspect_reports.sort_by(&:name).map {|node| link_to node.name, node_path(node)}.join(", ")
- - unless @nodes_without_baselines.empty?
- .item
- %h2 No baseline
- = @nodes_without_baselines.sort_by(&:name).map {|node| link_to node.name, node_path(node)}.join(", ")
- - unless @nodes_without_differences.empty?
- .item
- %h2 No differences from baseline
- = @nodes_without_differences.sort_by(&:name).map {|node| link_to node.name, node_path(node)}.join(", ")
- - unless @nodes_with_differences.empty?
- .item
- %h2 Nodes with difference from baseline
- %a{ :href => '#', :class => ['expand-all', 'button'] } expand all
- %br
- - @nodes_with_differences.each do |diff_information|
- = render 'reports/diff', |
- :baseline_report => diff_information[:baseline_report], |
- :my_report => diff_information[:last_inspect_report], |
- :resource_statuses => diff_information[:resource_statuses], |
- :diff => diff_information[:report_diff]
@@ -42,8 +42,8 @@
.section
.header
%h2 Nodes for this group
- - if Report.baselines.any?
- = render 'reports/baseline_selector', :diffee => @node_group
+ - Registry.each_callback :core, :node_group_view_widgets do |thing|
+ = thing.call self, @node_group
- if @node_group.all_nodes.present?
= render 'nodes/nodes', :nodes => @node_group.all_nodes, :container => @node_group
- else
@@ -0,0 +1,8 @@
+.section
+ %h3 Dashboard activity
+ - unless node.timeline_events.empty?
+ %ol.timeline= render node.timeline_events.recent(10)
+ - else
+ = describe_no_matches_for :activity
+
+%br.clear
@@ -0,0 +1,2 @@
+- unless node.description.blank?
+ .description= simple_format h(node.description)
Oops, something went wrong.

0 comments on commit e5fd77d

Please sign in to comment.