Permalink
Browse files

Merge branch 'next'

* next: (59 commits)
  (#5866) Get a consolidated report for baseline diffs in a group
  (#5866) Split dividing diff into pass and fail into a method
  maint: Fixing bad view logic related to enable_read_only_mode
  maint: Remove unused, user related views
  (#5880) Renamed diff_summary to diff now that there is a single view for all diffing.
  (#5880) Redesigned UI for diffing inspect reports
  (#5865) Search for files differing from the expected checksum
  (#5171) Allow Dashboard to contact a file bucket server for file diffs
  Maint: made PuppetHttps.get handle errors
  Maint: check that report deserialization fills in change_count
  (#5900) Added missing migration
  (#5900) Added support for the resource status "failed" attribute in reports.
  (#5889) Add pagination to the file search page
  (#5863) Inspect report search defaults to only searching the most recent report
  (#5863) inspect and apply reports are allowed to happen at the same timestamp
  (#5863) rename latest_report to latest_apply_report
  maint: Add the certs directory to .gitignore
  (#5874) Git rid of unused assignments and services tables and models
  (#5744) Change large columns from string to text
  (#5864) Display "no results" if a file search returns an empty list.
  ...
  • Loading branch information...
2 parents 9d4dc2f + 9831954 commit d41f85dcd06e136b4af54bfa885e008344068e9d Matt Robinson committed Jan 19, 2011
Showing with 2,331 additions and 4,135 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 app/controllers/application_controller.rb
  3. +18 −0 app/controllers/files_controller.rb
  4. +1 −0 app/controllers/node_classes_controller.rb
  5. +28 −0 app/controllers/node_groups_controller.rb
  6. +2 −1 app/controllers/nodes_controller.rb
  7. +47 −12 app/controllers/reports_controller.rb
  8. +6 −5 app/helpers/application_helper.rb
  9. +2 −2 app/helpers/paginate_scope_helper.rb
  10. +0 −6 app/models/assignment.rb
  11. +42 −17 app/models/node.rb
  12. +45 −21 app/models/report.rb
  13. +1 −1 app/models/resource_event.rb
  14. +33 −0 app/models/resource_status.rb
  15. +0 −7 app/models/service.rb
  16. +4 −9 app/models/status.rb
  17. +0 −1 app/views/layouts/application.html.haml
  18. +3 −2 app/views/node_classes/show.html.haml
  19. +29 −0 app/views/node_groups/diff.html.haml
  20. +8 −3 app/views/node_groups/show.html.haml
  21. +1 −1 app/views/nodes/_nodes.html.haml
  22. +30 −30 app/views/nodes/show.html.haml
  23. +37 −0 app/views/reports/_diff.html.haml
  24. +6 −5 app/views/reports/_report.html.haml
  25. +8 −22 app/views/reports/diff.html.haml
  26. +0 −20 app/views/reports/diff_summary.html.haml
  27. +50 −0 app/views/reports/search.html.haml
  28. +3 −1 app/views/shared/_node_manager_sidebar.html.haml
  29. +2 −1 app/views/shared/_node_manager_sidebar_for_type.html.haml
  30. +0 −8 app/views/shared/_secondary_nav.html.haml
  31. +8 −4 config/routes.rb
  32. +13 −1 config/settings.yml.example
  33. +9 −0 db/migrate/20110105015322_add_out_of_sync_count_to_resource_statuses.rb
  34. +9 −0 db/migrate/20110105231637_remove_source_description_from_resource_statuses.rb
  35. +9 −0 db/migrate/20110105231833_remove_source_description_from_resource_events.rb
  36. +9 −0 db/migrate/20110105233543_add_historical_value_to_resource_events.rb
  37. +9 −0 db/migrate/20110105233640_add_audited_to_resource_events.rb
  38. +9 −0 db/migrate/20110105234202_remove_tags_from_resource_events.rb
  39. +9 −0 db/migrate/20110106002514_add_skipped_to_resource_statuses.rb
  40. +9 −0 db/migrate/20110107233911_remove_out_of_sync_column.rb
  41. +45 −0 db/migrate/20110113012919_make_long_string_fields_into_text_fields.rb
  42. +9 −0 db/migrate/20110113013807_add_last_inspect_report_id_to_nodes.rb
  43. +23 −0 db/migrate/20110113183616_remove_unused_tables_and_models.rb
  44. +9 −0 db/migrate/20110113195253_rename_column_last_report_id_to_last_apply_report_id_on_nodes.rb
  45. +9 −0 db/migrate/20110114190814_add_failed_to_resource_statuses.rb
  46. +22 −35 db/schema.rb
  47. +2 −0 lib/incorrect_report_kind.rb
  48. +102 −98 lib/puppet/report.rb
  49. +1 −0 lib/puppet_https.rb
  50. +2 −0 lib/read_only_enabled_error.rb
  51. +92 −6 lib/report_transformer.rb
  52. BIN public/images/icons/bullet_green.png
  53. BIN public/images/icons/bullet_toggle_minus.png
  54. BIN public/images/icons/bullet_toggle_plus.png
  55. +41 −1 public/javascripts/application.js
  56. +41 −0 public/stylesheets/tables.css
  57. +40 −0 spec/controllers/files_controller_spec.rb
  58. +111 −0 spec/controllers/node_groups_controller_spec.rb
  59. +3 −2 spec/controllers/nodes_controller_spec.rb
  60. +85 −1 spec/controllers/reports_controller_spec.rb
  61. +1 −0 spec/exemplars/report_exemplar.rb
  62. +1 −0 spec/fixtures/reports/puppet26/report_ok_service_started_ok.yaml
  63. +453 −0 spec/fixtures/reports/version2/example.yaml
  64. +5 −2 spec/helpers/paginate_scope_helper_spec.rb
  65. +144 −101 spec/lib/puppet/report_spec.rb
  66. +153 −3 spec/lib/report_transformer_spec.rb
  67. +0 −83 spec/models/assignment_spec.rb
  68. +5 −0 spec/models/node_spec.rb
  69. +368 −72 spec/models/report_spec.rb
  70. +54 −0 spec/models/resource_status_spec.rb
  71. +6 −0 spec/models/status_spec.rb
  72. +0 −10 spec/views/nodes/edit.html.haml_spec.rb
  73. +0 −19 spec/views/nodes/index.html.haml_spec.rb
  74. +0 −43 vendor/plugins/will_paginate/.manifest
  75. +0 −110 vendor/plugins/will_paginate/CHANGELOG.rdoc
  76. +0 −18 vendor/plugins/will_paginate/LICENSE
  77. +0 −107 vendor/plugins/will_paginate/README.rdoc
  78. +0 −53 vendor/plugins/will_paginate/Rakefile
  79. BIN vendor/plugins/will_paginate/examples/apple-circle.gif
  80. +0 −69 vendor/plugins/will_paginate/examples/index.haml
  81. +0 −92 vendor/plugins/will_paginate/examples/index.html
  82. +0 −90 vendor/plugins/will_paginate/examples/pagination.css
  83. +0 −91 vendor/plugins/will_paginate/examples/pagination.sass
  84. +0 −1 vendor/plugins/will_paginate/init.rb
  85. +0 −90 vendor/plugins/will_paginate/lib/will_paginate.rb
  86. +0 −16 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  87. +0 −146 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  88. +0 −43 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  89. +0 −264 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  90. +0 −170 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  91. +0 −37 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb
  92. +0 −9 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  93. +0 −404 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  94. +0 −21 vendor/plugins/will_paginate/test/boot.rb
  95. +0 −143 vendor/plugins/will_paginate/test/collection_test.rb
  96. +0 −8 vendor/plugins/will_paginate/test/console
  97. +0 −22 vendor/plugins/will_paginate/test/database.yml
  98. +0 −473 vendor/plugins/will_paginate/test/finder_test.rb
  99. +0 −3 vendor/plugins/will_paginate/test/fixtures/admin.rb
  100. +0 −14 vendor/plugins/will_paginate/test/fixtures/developer.rb
  101. +0 −13 vendor/plugins/will_paginate/test/fixtures/developers_projects.yml
  102. +0 −15 vendor/plugins/will_paginate/test/fixtures/project.rb
  103. +0 −6 vendor/plugins/will_paginate/test/fixtures/projects.yml
  104. +0 −29 vendor/plugins/will_paginate/test/fixtures/replies.yml
  105. +0 −7 vendor/plugins/will_paginate/test/fixtures/reply.rb
  106. +0 −38 vendor/plugins/will_paginate/test/fixtures/schema.rb
  107. +0 −10 vendor/plugins/will_paginate/test/fixtures/topic.rb
  108. +0 −30 vendor/plugins/will_paginate/test/fixtures/topics.yml
  109. +0 −2 vendor/plugins/will_paginate/test/fixtures/user.rb
  110. +0 −35 vendor/plugins/will_paginate/test/fixtures/users.yml
  111. +0 −40 vendor/plugins/will_paginate/test/helper.rb
  112. +0 −43 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb
  113. +0 −75 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb
  114. +0 −11 vendor/plugins/will_paginate/test/lib/load_fixtures.rb
  115. +0 −179 vendor/plugins/will_paginate/test/lib/view_test_process.rb
  116. +0 −59 vendor/plugins/will_paginate/test/tasks.rake
  117. +0 −373 vendor/plugins/will_paginate/test/view_test.rb
  118. +0 −20 vendor/plugins/will_paginate/will_paginate.gemspec
View
@@ -25,3 +25,4 @@ spec/watchr.rb
tags
tmp/*
results/*
+certs
@@ -15,6 +15,10 @@ class ApplicationController < ActionController::Base
private
+ def raise_if_enable_read_only_mode
+ raise ReadOnlyEnabledError.new if SETTINGS.enable_read_only_mode
+ end
+
def raise_unless_using_external_node_classification
raise NodeClassificationDisabledError.new unless SETTINGS.use_external_node_classification
end
@@ -0,0 +1,18 @@
+class FilesController < ApplicationController
+ def diff
+ unless SETTINGS.use_file_bucket_diffs
+ render :text => "File bucket diffs have been disabled", :content_type => 'text/plain', :status => 403
+ return
+ end
+
+ [params[:file1], params[:file2]].each do |md5|
+ unless md5 =~ /^[0-9a-f]{32}$/
+ render :text => "Invalid md5: #{md5.inspect}", :content_type => 'text/plain', :status => 400
+ return
+ end
+ end
+ url = "https://#{SETTINGS.file_bucket_server}:#{SETTINGS.file_bucket_port}/production/file_bucket_file/md5/#{params[:file1]}?diff_with=#{params[:file2]}"
+ diff = PuppetHttps.get(url, 's')
+ render :text => diff, :content_type => 'text/plain'
+ end
+end
@@ -1,6 +1,7 @@
class NodeClassesController < InheritedResources::Base
respond_to :html, :json
before_filter :raise_unless_using_external_node_classification
+ before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :create, :update, :destroy]
include SearchableIndex
end
@@ -1,6 +1,34 @@
class NodeGroupsController < InheritedResources::Base
respond_to :html, :json
before_filter :raise_unless_using_external_node_classification
+ before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :create, :update, :destroy]
include SearchableIndex
+
+ def diff
+ @node_group = NodeGroup.find(params[:id])
+
+ @nodes_without_latest_inspect_reports = []
+ @nodes_without_baselines = []
+ @nodes_without_differences = []
+ @nodes_with_differences = []
+ @node_group.all_nodes.each do |node|
+ @nodes_without_latest_inspect_reports << node and next unless node.last_inspect_report
+ @nodes_without_baselines << node and next unless node.baseline_report
+
+ report_diff = node.baseline_report.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 => node.baseline_report,
+ :last_inspect_report => node.last_inspect_report,
+ :report_diff => report_diff,
+ :resource_statuses => resource_statuses,
+ }
+ end
+ end
+ end
end
@@ -3,6 +3,7 @@ class NodesController < InheritedResources::Base
belongs_to :node_group, :optional => true
respond_to :html, :yaml, :json
before_filter :raise_unless_using_external_node_classification, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :create, :update, :destroy]
layout lambda {|c| c.request.xhr? ? false : 'application' }
@@ -93,7 +94,7 @@ def facts
# requirements
def reports
@node = resource
- @reports = @node.reports
+ @reports = params[:kind] == "inspect" ? @node.reports.inspections : @node.reports.applies
respond_to do |format|
format.html { @reports = paginate_scope(@reports); render 'reports/index' }
end
@@ -2,8 +2,21 @@ class ReportsController < InheritedResources::Base
belongs_to :node, :optional => true, :finder => :find_by_url!
protect_from_forgery :except => [:create, :upload]
+ before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :update, :destroy]
before_filter :handle_raw_post, :only => [:create, :upload]
+ def index
+ index! do |success,failure|
+ success.html do
+ if params[:kind] == "inspect"
+ @reports = paginate_scope Report.inspections
+ else
+ @reports = paginate_scope Report.applies
+ end
+ end
+ end
+ end
+
def create
if SETTINGS.disable_legacy_report_upload_url
render :text => "Access Denied, this url has been disabled, try /reports/upload", :status => 403
@@ -28,18 +41,7 @@ def diff
@my_report = Report.find(params[:id])
@baseline_report = Report.find(params[:baseline_id])
@diff = @baseline_report.diff(@my_report)
- end
-
- def diff_summary
- diff
- @resources = {}
- @diff.each do |resource, differences|
- if ! differences.empty?
- @resources[resource] = :failure
- else
- @resources[resource] = :pass
- end
- end
+ @resource_statuses = Report.divide_diff_into_pass_and_fail(@diff)
end
def make_baseline
@@ -48,6 +50,39 @@ def make_baseline
redirect_to report
end
+ def search
+ if params[:search_all_inspect_reports]
+ inspected_resources = ResourceStatus.inspections
+ else
+ inspected_resources = ResourceStatus.latest_inspections
+ end
+ inspected_resources = inspected_resources.order("reports.time DESC")
+
+ if params[:file_title].present? and params[:file_content].present?
+ @files = inspected_resources.by_file_title(params[:file_title])
+ if params[:content_match] == "negative"
+ @files = @files.without_file_content(params[:file_content])
+ else
+ @files = @files.by_file_content(params[:file_content])
+ end
+
+ elsif params[:file_title].present?
+ @files = inspected_resources.by_file_title(params[:file_title])
+
+ elsif params[:file_content].present?
+ if params[:content_match] == "negative"
+ @files = inspected_resources.in_a_report_without_content(params[:file_content])
+ else
+ @files = inspected_resources.by_file_content(params[:file_content])
+ end
+
+ else
+ @files = nil
+ return
+ end
+ @files = paginate_scope @files
+ end
+
private
def collection
@@ -102,7 +102,7 @@ def header_for(form)
# Return HTML with pagination controls for displaying an ActiveRecord +scope+.
def pagination_for(scope, more_link=nil)
content_tag(:div, :class => 'actionbar') do
- if scope.respond_to?(:total_pages) && scope.total_pages > 1
+ pagination = if scope.respond_to?(:total_pages) && scope.total_pages > 1
[
more_link ? content_tag(:span, :class => 'pagination') { link_to('More &raquo;', more_link) } : will_paginate(scope),
content_tag(:div, :class => 'pagination') do
@@ -111,11 +111,12 @@ def pagination_for(scope, more_link=nil)
]
else
[]
- end +
- [
+ end
+ pagination_sizer = more_link ? [] : [
pagination_sizer_for(scope),
tag(:br, :class=> 'clear')
]
+ pagination + pagination_sizer
end
end
@@ -128,7 +129,7 @@ def pagination_sizer_for(scope)
if (params[:per_page] || scope.per_page.to_s) == n.to_s
content_tag(:span, :class => "current"){ n }
else
- link_to(n, {:per_page => n})
+ link_to(n, params.merge({:per_page => n}))
end
end
end
@@ -140,7 +141,7 @@ def icon(name)
# Return status icon for the +node+.
def node_status_icon(node)
- report_status_icon(node.last_report)
+ report_status_icon(node.last_apply_report)
end
# Return status icon for the +report+.
@@ -2,11 +2,11 @@ module PaginateScopeHelper
# Return a paginated +scope+.
def paginate_scope(scope, opts={})
if ! params[:per_page]
- scope.paginate( opts.reverse_merge(:page => params[:page]) )
+ scope.paginate( opts.reverse_merge(:page => params[:page], :per_page => (scope.first.class.per_page rescue nil)) )
elsif params[:per_page] != "all"
scope.paginate( opts.reverse_merge(:page => params[:page], :per_page => params[:per_page]) )
else
- scope
+ scope.paginate( opts.reverse_merge(:page => 1, :per_page => scope.count) )
end
end
end
View
@@ -1,6 +0,0 @@
-class Assignment < ActiveRecord::Base
- belongs_to :service
- belongs_to :node
- validates_presence_of :service
- validates_presence_of :node
-end
View
@@ -14,10 +14,11 @@ def self.per_page; 20 end # Pagination
has_many :node_groups, :through => :node_group_memberships
has_many :reports, :dependent => :destroy
- belongs_to :last_report, :class_name => 'Report'
+ 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_report
+ named_scope :with_last_report, :include => :last_apply_report
named_scope :by_report_date, :order => 'reported_at DESC'
named_scope :search, lambda{|q| q.blank? ? {} : {:conditions => ['name LIKE ?', "%#{q}%"]} }
@@ -47,10 +48,10 @@ def self.per_page; 20 end # Pagination
named_scope :by_currentness_and_successfulness, lambda {|currentness, successfulness|
operator = successfulness ? '!=' : '='
if currentness
- { :conditions => ["nodes.status #{operator} 'failed' AND nodes.last_report_id is not NULL"] }
+ { :conditions => ["nodes.status #{operator} 'failed' AND nodes.last_apply_report_id is not NULL"] }
else
{
- :conditions => ["reports.status #{operator} 'failed'"],
+ :conditions => ["reports.kind = 'apply' AND reports.status #{operator} 'failed'"],
:joins => :reports,
:group => 'nodes.id',
}
@@ -104,8 +105,8 @@ def environment
end
def status_class
- return 'no reports' unless last_report
- last_report.status
+ return 'no reports' unless last_apply_report
+ last_apply_report.status
end
attr_accessor :node_class_names
@@ -138,23 +139,47 @@ def assign_node_groups
return false
end
- # Assigns the node's :last_report attribute. # FIXME
- def assign_last_report(report=nil)
- report ||= find_last_report
+ def assign_last_apply_report_if_newer(report)
+ raise "wrong report type" unless report.kind == "apply"
- if self.last_report != report
- self.last_report = report
- self.reported_at = report ? report.time : nil
- self.status = report ? report.status : 'unchanged'
+ if reported_at.nil? or reported_at.to_i < report.time.to_i
+ self.last_apply_report = report
+ self.reported_at = report.time
+ self.status = report.status
+ self.save!
+ end
+ end
+
+ def assign_last_inspect_report_if_newer(report)
+ raise "wrong report type" unless report.kind == "inspect"
+
+ if ! self.last_inspect_report or self.last_inspect_report.time.to_i < report.time.to_i
+ self.last_inspect_report = report
+ self.save!
+ end
+ end
- # FIXME #update_without_callbacks doesn't update the object, and #save! is creating unwanted timeline events.
- ### node.send :update_without_callbacks # do not create a timeline event
+ def find_and_assign_last_apply_report
+ report = self.reports.applies.first
+ if report
+ self.reported_at = nil
+ assign_last_apply_report_if_newer(report)
+ else
+ self.last_apply_report = nil
+ self.reported_at = nil
+ self.status = nil
self.save!
end
end
- def find_last_report
- return Report.find_last_for(self)
+ def find_and_assign_last_inspect_report
+ report = self.reports.inspections.first
+ self.last_inspect_report = nil
+ if report
+ assign_last_inspect_report_if_newer(report)
+ else
+ self.save!
+ end
end
def facts
Oops, something went wrong.

0 comments on commit d41f85d

Please sign in to comment.