From bb668ea9a9b44ca7334b58b4299c10d1a08c911e Mon Sep 17 00:00:00 2001 From: "Joshua B. Bussdieker" Date: Thu, 22 May 2014 12:16:45 -0700 Subject: [PATCH 01/16] Make it Moovweb compliant --- Gemfile | 7 ++- Gemfile.lock | 15 +++++ VERSION | 1 + app/controllers/home_controller.rb | 11 ++++ config/database.yml | 2 +- config/environments/prod.rb | 76 ++++++++++++++++++++++++++ config/environments/stage.rb | 41 ++++++++++++++ config/initializers/00_enc_settings.rb | 2 + config/routes.rb | 1 + enc_dashboard.gemspec | 24 ++++++++ lib/enc_dashboard/version.rb | 10 ++++ public/moov_check.txt | 1 + 12 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 VERSION create mode 100644 app/controllers/home_controller.rb create mode 100644 config/environments/prod.rb create mode 100644 config/environments/stage.rb create mode 100644 enc_dashboard.gemspec create mode 100644 lib/enc_dashboard/version.rb create mode 100644 public/moov_check.txt diff --git a/Gemfile b/Gemfile index 0ec6715..446a575 100644 --- a/Gemfile +++ b/Gemfile @@ -5,14 +5,15 @@ gem 'rails', '3.2.18' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -db = ENV["DB"] || "pg" -gem db +gem 'mysql2' gem 'puppet' gem 'mcollective-client' gem 'chartkick' gem 'groupdate' gem 'rails-bootstrap', '~> 3.0.0' gem 'kaminari' +gem 'unicorn' + # Gems used only for assets and not required # in production environments by default. @@ -55,3 +56,5 @@ gem 'jquery-rails' # To use debugger # gem 'debugger' + +gem 'syslogger', git: 'https://github.com/jbussdieker/syslogger.git', :branch => 'implement_log_formatter' diff --git a/Gemfile.lock b/Gemfile.lock index af6c860..2d2545d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +GIT + remote: https://github.com/jbussdieker/syslogger.git + revision: e9749cdedee9d99e07eb20065dafd1f73e78affe + branch: implement_log_formatter + specs: + syslogger (1.6.0) + GEM remote: https://rubygems.org/ specs: @@ -83,6 +90,7 @@ GEM kaminari (0.15.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) + kgio (2.9.2) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -125,6 +133,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) + raindrops (0.13.0) rake (10.3.1) rdoc (3.12.2) json (~> 1.4) @@ -178,6 +187,10 @@ GEM uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) + unicorn (4.8.3) + kgio (~> 2.6) + rack + raindrops (~> 0.7) websocket (1.0.7) xpath (2.0.0) nokogiri (~> 1.3) @@ -204,4 +217,6 @@ DEPENDENCIES rspec-rails sass-rails (~> 3.2.3) selenium-webdriver + syslogger! uglifier (>= 1.0.3) + unicorn diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..49d5957 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..9b63905 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,11 @@ +class HomeController < ApplicationController + def moov_check + if File.exists? File.join(Rails.root, "/public/moov_check.txt") + render json: { message: "OK" } + else + error_msg = "moov_check disabled by user. '/public/moov_check.txt' does not exist." + Rails.logger.error(error_msg) + render json: { message: error_msg }, status: 500 + end + end +end diff --git a/config/database.yml b/config/database.yml index ff7fe08..0f2eeb1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -19,7 +19,7 @@ defaults: &defaults pool: 16 timeout: 5000 host: localhost - <<: *<%= ENV['DB'] || "pg" %> + <<: *<%= ENV['DB'] || "mysql2" %> development: <<: *defaults diff --git a/config/environments/prod.rb b/config/environments/prod.rb new file mode 100644 index 0000000..3f68241 --- /dev/null +++ b/config/environments/prod.rb @@ -0,0 +1,76 @@ +Enc::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 + + config.serve_static_assets = true + config.assets.compile = false + config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' + + # Setup custom logger to syslog + config.logger = Syslogger.new("enc_dashboard", Syslog::LOG_PID | Syslog::LOG_CONS, Syslog::LOG_LOCAL5) + config.logger.level = Logger::ERROR + config.logger.level = Logger::DEBUG if File.exists?"/tmp/moov_debug_prod" +end diff --git a/config/environments/stage.rb b/config/environments/stage.rb new file mode 100644 index 0000000..e9efcd4 --- /dev/null +++ b/config/environments/stage.rb @@ -0,0 +1,41 @@ +Enc::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true + + config.serve_static_assets = true + config.assets.compile = false + config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' +end diff --git a/config/initializers/00_enc_settings.rb b/config/initializers/00_enc_settings.rb index 9f2629c..d826860 100644 --- a/config/initializers/00_enc_settings.rb +++ b/config/initializers/00_enc_settings.rb @@ -1,5 +1,7 @@ if File.exists? "config/settings.yml" ENC_CONFIG = YAML.load_file("#{Rails.root}/config/settings.yml")[Rails.env].with_indifferent_access +elsif File.exists? "/etc/enc_dashboard/settings.yml" + ENC_CONFIG = YAML.load_file("/etc/enc_dashboard/settings.yml")[Rails.env].with_indifferent_access else puts "WARNING: No config/settings.yml file found" ENC_CONFIG = {} diff --git a/config/routes.rb b/config/routes.rb index 6d4f834..d9dee89 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,4 +32,5 @@ end resources :parameters, only: [:index, :new, :create] root :to => 'nodes#index' + match 'moov_check' => "home#moov_check" end diff --git a/enc_dashboard.gemspec b/enc_dashboard.gemspec new file mode 100644 index 0000000..0ea8095 --- /dev/null +++ b/enc_dashboard.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +require 'enc_dashboard/version' + +Gem::Specification.new do |gem| + gem.name = "enc_dashboard" + gem.version = EncDashboard::VERSION + gem.authors = ["Joshua B. Bussdieker"] + gem.email = ["josh.bussdieker@moovweb.com"] + gem.description = %q{Puppet dashboard replacement} + gem.summary = %q{Puppet dashboard replacement} + gem.homepage = "" + + gem.files = `git ls-files`.split($/) + gem.files << Dir[".bundle/**/*"] + gem.files << Dir["vendor/**/*"] + gem.files << Dir["public/**/*"] + gem.files << "JENKINS" + gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.require_paths = ["lib"] +end diff --git a/lib/enc_dashboard/version.rb b/lib/enc_dashboard/version.rb new file mode 100644 index 0000000..870a31e --- /dev/null +++ b/lib/enc_dashboard/version.rb @@ -0,0 +1,10 @@ +module EncDashboard + VERSION = lambda { + version = File.read("VERSION").strip + if File.exists?("JENKINS") + version += "." + version += File.read("JENKINS").strip + end + version + }.yield +end diff --git a/public/moov_check.txt b/public/moov_check.txt new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/public/moov_check.txt @@ -0,0 +1 @@ +OK From b26a32ab00ae43460fd69ca516e17cb92f3fce9b Mon Sep 17 00:00:00 2001 From: Ted Hanson Date: Thu, 18 Jun 2015 15:44:21 -0700 Subject: [PATCH 02/16] Update nodes_controller.rb --- app/controllers/nodes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index f8b131c..5133e8d 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -4,7 +4,7 @@ class NodesController < ApplicationController def index @nodes = Node.order(sort_column + " " + sort_direction) - render_collection(@nodes) + render_collection(@nodes, 'index') end def show From 471c496947be36dfd0e170b738a3c772f74da45e Mon Sep 17 00:00:00 2001 From: Ted Hanson Date: Thu, 18 Jun 2015 16:08:45 -0700 Subject: [PATCH 03/16] remove gitkeep files --- vendor/assets/javascripts/.gitkeep | 0 vendor/assets/stylesheets/.gitkeep | 0 vendor/plugins/.gitkeep | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 vendor/assets/javascripts/.gitkeep delete mode 100644 vendor/assets/stylesheets/.gitkeep delete mode 100644 vendor/plugins/.gitkeep diff --git a/vendor/assets/javascripts/.gitkeep b/vendor/assets/javascripts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/assets/stylesheets/.gitkeep b/vendor/assets/stylesheets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/plugins/.gitkeep b/vendor/plugins/.gitkeep deleted file mode 100644 index e69de29..0000000 From 07f7348fec415073704ecef933d6e994603c1417 Mon Sep 17 00:00:00 2001 From: Ted Hanson Date: Thu, 6 Aug 2015 18:08:09 -0700 Subject: [PATCH 04/16] lets keep cache the node controller for 1 hour (we can clear with a varnish restart) --- app/controllers/nodes_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 5133e8d..73a9593 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -9,6 +9,7 @@ def index def show @reports = @node.reports.order("time DESC").page params[:page] + expires_in 61.minutes, :public => true respond_to do |format| format.html # show.html.erb From 447f803e1fb4ab200a624af78fa311cd36f48d10 Mon Sep 17 00:00:00 2001 From: Bo Huang Date: Tue, 3 May 2016 14:45:10 -0700 Subject: [PATCH 05/16] Add index to node group memberships --- .../20160503213802_add_index_to_node_group_memberships.rb | 5 +++++ db/schema.rb | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160503213802_add_index_to_node_group_memberships.rb diff --git a/db/migrate/20160503213802_add_index_to_node_group_memberships.rb b/db/migrate/20160503213802_add_index_to_node_group_memberships.rb new file mode 100644 index 0000000..e01ebea --- /dev/null +++ b/db/migrate/20160503213802_add_index_to_node_group_memberships.rb @@ -0,0 +1,5 @@ +class AddIndexToNodeGroupMemberships < ActiveRecord::Migration + def change + add_index :node_group_memberships, :node_group_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 8ccfa99..0ccfedf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140509184854) do +ActiveRecord::Schema.define(:version => 20160503213802) do create_table "metrics", :force => true do |t| t.integer "report_id", :null => false @@ -46,6 +46,8 @@ t.datetime "updated_at", :null => false end + add_index "node_group_memberships", ["node_group_id"], :name => "index_node_group_memberships_on_node_group_id" + create_table "node_groups", :force => true do |t| t.string "name", :null => false t.datetime "created_at", :null => false From 2a6fc306d8e43074956493802f2835c8ba6b95f7 Mon Sep 17 00:00:00 2001 From: Paul Dunham Date: Thu, 15 Sep 2016 15:11:17 -0700 Subject: [PATCH 06/16] change 61 minute cache to 5 minutes --- app/controllers/nodes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 73a9593..97a165d 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -9,7 +9,7 @@ def index def show @reports = @node.reports.order("time DESC").page params[:page] - expires_in 61.minutes, :public => true + expires_in 5.minutes, :public => true respond_to do |format| format.html # show.html.erb From 30562f34f74035732cbeeabd8883d0b1e5e2f9d6 Mon Sep 17 00:00:00 2001 From: LujiaZ Date: Thu, 19 Jan 2017 15:26:17 -0800 Subject: [PATCH 07/16] [PFST-1492] Upgrade Rails and Ruby version - Upgrade Ruby from 1.9.3 to 2.3.3 - Upgrade Rails from 3.2.18 to 4.0.6 --- Gemfile | 37 ++-- Gemfile.lock | 280 +++++++++++++------------ app/services/report_processing.rb | 2 +- app/views/node_classes/show.html.erb | 2 +- app/views/node_groups/show.html.erb | 2 +- app/views/nodes/show.html.erb | 2 +- app/views/reports/show.html.erb | 2 +- config/application.rb | 2 +- config/database.yml | 18 +- config/environments/development.rb | 13 +- config/environments/prod.rb | 8 +- config/environments/production.rb | 8 +- config/environments/stage.rb | 13 +- config/environments/test.rb | 3 +- config/initializers/00_enc_settings.rb | 6 +- config/initializers/secret_token.rb | 5 +- config/initializers/wrap_parameters.rb | 5 - config/routes.rb | 4 +- config/settings.yml.sample | 10 - db/schema.rb | 92 ++++---- db/seeds.rb | 10 +- spec/lib/puppetdb_spec.rb | 2 +- 22 files changed, 248 insertions(+), 278 deletions(-) delete mode 100644 config/settings.yml.sample diff --git a/Gemfile b/Gemfile index 446a575..3442c17 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,8 @@ source 'https://rubygems.org' -gem 'rails', '3.2.18' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'mysql2' +gem 'rails', '4.0.6' +gem 'mysql2', '0.3.17' +gem 'syslogger', git: 'https://github.com/jbussdieker/syslogger.git', :branch => 'implement_log_formatter' gem 'puppet' gem 'mcollective-client' gem 'chartkick' @@ -14,18 +11,19 @@ gem 'rails-bootstrap', '~> 3.0.0' gem 'kaminari' gem 'unicorn' +gem 'sass-rails', '~> 4.0.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'uglifier', '>= 1.0.3' +gem 'jquery-rails' +gem 'awesome_print', require:"ap" -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer', :platforms => :ruby +# attr_accessible` is extracted out of Rails into a gem. +# Please use new recommended protection model for params(strong_parameters) +# or add `protected_attributes` to your Gemfile to use old one +gem 'protected_attributes' - gem 'uglifier', '>= 1.0.3' -end +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +# gem 'therubyracer', :platforms => :ruby group :development, :test do gem 'rspec-rails' @@ -40,11 +38,6 @@ group :test do gem 'database_cleaner' end -gem 'jquery-rails' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - # To use Jbuilder templates for JSON # gem 'jbuilder' @@ -56,5 +49,3 @@ gem 'jquery-rails' # To use debugger # gem 'debugger' - -gem 'syslogger', git: 'https://github.com/jbussdieker/syslogger.git', :branch => 'implement_log_formatter' diff --git a/Gemfile.lock b/Gemfile.lock index 2d2545d..80efd9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,189 +9,189 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.2.8) - actionmailer (3.2.18) - actionpack (= 3.2.18) + actionmailer (4.0.6) + actionpack (= 4.0.6) mail (~> 2.5.4) - actionpack (3.2.18) - activemodel (= 3.2.18) - activesupport (= 3.2.18) - builder (~> 3.0.0) + actionpack (4.0.6) + activesupport (= 4.0.6) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.18) - activesupport (= 3.2.18) - builder (~> 3.0.0) - activerecord (3.2.18) - activemodel (= 3.2.18) - activesupport (= 3.2.18) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.18) - activemodel (= 3.2.18) - activesupport (= 3.2.18) - activesupport (3.2.18) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - arel (3.0.3) - builder (3.0.4) - capybara (2.2.1) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.6) + activesupport (= 4.0.6) + builder (~> 3.1.0) + activerecord (4.0.6) + activemodel (= 4.0.6) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.6) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.4) + activesupport (4.0.6) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) + arel (4.0.2) + awesome_print (1.7.0) + builder (3.1.4) + capybara (2.11.0) + addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - chartkick (1.2.4) - childprocess (0.5.3) + chartkick (2.2.2) + childprocess (0.5.9) ffi (~> 1.0, >= 1.0.11) - coffee-rails (3.2.2) + coffee-rails (4.0.1) coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.7.0) - coveralls (0.7.0) - multi_json (~> 1.3) - rest-client - simplecov (>= 0.7) - term-ansicolor - thor - database_cleaner (1.2.0) + coffee-script-source (1.12.2) + coveralls (0.8.17) + json (>= 1.8, < 3) + simplecov (~> 0.12.0) + term-ansicolor (~> 1.3) + thor (~> 0.19.1) + tins (~> 1.6) + database_cleaner (1.5.3) diff-lcs (1.2.5) - docile (1.1.3) + docile (1.1.5) erubis (2.7.0) - execjs (2.0.2) - facter (2.0.1) + execjs (2.7.0) + facter (2.4.6) CFPropertyList (~> 2.2.6) - factory_girl (4.4.0) + factory_girl (4.8.0) activesupport (>= 3.0.0) - factory_girl_rails (4.4.1) - factory_girl (~> 4.4.0) + factory_girl_rails (4.8.0) + factory_girl (~> 4.8.0) railties (>= 3.0.0) - faker (1.3.0) + faker (1.7.2) i18n (~> 0.5) - ffi (1.9.3) - groupdate (2.1.0) - activerecord (>= 3.0.0) - hiera (1.3.2) - json_pure + ffi (1.9.17) + groupdate (3.1.1) + activesupport (>= 3) + hiera (3.2.2) hike (1.2.3) - i18n (0.6.9) - journey (1.0.4) - jquery-rails (3.1.0) + i18n (0.7.0) + jquery-rails (3.1.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.8.1) - json_pure (1.8.1) - kaminari (0.15.1) + json (2.0.3) + json_pure (1.8.6) + kaminari (0.17.0) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - kgio (2.9.2) + kgio (2.11.0) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - mcollective-client (2.5.1) + mcollective-client (2.9.1) json stomp systemu mime-types (1.25.1) - mini_portile (0.5.3) - multi_json (1.10.0) - mysql2 (0.3.16) - nokogiri (1.6.2) - mini_portile (~> 0.5.2) - polyglot (0.3.4) - puppet (3.5.1) - facter (> 1.6, < 3) - hiera (~> 1.0) - json_pure - rgen (~> 0.6.5) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.4) - rack - rack-test (0.6.2) + mini_portile2 (2.1.0) + minitest (4.7.5) + multi_json (1.12.1) + mysql2 (0.3.17) + nokogiri (1.7.0.1) + mini_portile2 (~> 2.1.0) + polyglot (0.3.5) + protected_attributes (1.1.3) + activemodel (>= 4.0.1, < 5.0) + public_suffix (2.0.5) + puppet (4.8.1) + CFPropertyList (~> 2.2.6) + facter (> 2.0, < 4) + hiera (>= 2.0, < 4) + json_pure (~> 1.8) + rack (1.5.5) + rack-test (0.6.3) rack (>= 1.0) - rails (3.2.18) - actionmailer (= 3.2.18) - actionpack (= 3.2.18) - activerecord (= 3.2.18) - activeresource (= 3.2.18) - activesupport (= 3.2.18) - bundler (~> 1.0) - railties (= 3.2.18) + rails (4.0.6) + actionmailer (= 4.0.6) + actionpack (= 4.0.6) + activerecord (= 4.0.6) + activesupport (= 4.0.6) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.6) + sprockets-rails (~> 2.0) rails-bootstrap (3.0.0.4) - railties (3.2.18) - actionpack (= 3.2.18) - activesupport (= 3.2.18) - rack-ssl (~> 1.3.2) + railties (4.0.6) + actionpack (= 4.0.6) + activesupport (= 4.0.6) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - raindrops (0.13.0) - rake (10.3.1) - rdoc (3.12.2) - json (~> 1.4) - rest-client (1.6.7) - mime-types (>= 1.16) - rgen (0.6.6) - rspec-core (2.14.8) - rspec-expectations (2.14.5) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.6) - rspec-rails (2.14.2) + thor (>= 0.18.1, < 2.0) + raindrops (0.17.0) + rake (12.0.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-rails (3.5.2) actionpack (>= 3.0) - activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rubyzip (1.1.3) - sass (3.3.7) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - selenium-webdriver (2.41.0) - childprocess (>= 0.5.0) - multi_json (~> 1.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + rubyzip (1.2.0) + sass (3.2.19) + sass-rails (4.0.5) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.2) + sprockets (~> 2.8, < 3.0) + sprockets-rails (~> 2.0) + selenium-webdriver (3.0.5) + childprocess (~> 0.5) rubyzip (~> 1.0) - websocket (~> 1.0.4) - simplecov (0.8.2) + websocket (~> 1.0) + simplecov (0.12.0) docile (~> 1.1.0) - multi_json - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) - sprockets (2.2.2) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) + sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - stomp (1.3.2) - systemu (2.6.4) - term-ansicolor (1.3.0) + sprockets-rails (2.3.3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + stomp (1.4.3) + systemu (2.6.5) + term-ansicolor (1.4.0) tins (~> 1.0) - thor (0.19.1) + thor (0.19.4) + thread_safe (0.3.5) tilt (1.4.1) - tins (1.2.0) + tins (1.13.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.39) - uglifier (2.5.0) - execjs (>= 0.3.0) - json (>= 1.8.0) - unicorn (4.8.3) + tzinfo (0.3.52) + uglifier (3.0.4) + execjs (>= 0.3.0, < 3) + unicorn (5.2.0) kgio (~> 2.6) - rack raindrops (~> 0.7) - websocket (1.0.7) + websocket (1.2.3) xpath (2.0.0) nokogiri (~> 1.3) @@ -199,9 +199,10 @@ PLATFORMS ruby DEPENDENCIES + awesome_print capybara chartkick - coffee-rails (~> 3.2.1) + coffee-rails (~> 4.0.0) coveralls database_cleaner factory_girl_rails @@ -210,12 +211,13 @@ DEPENDENCIES jquery-rails kaminari mcollective-client - mysql2 + mysql2 (= 0.3.17) + protected_attributes puppet - rails (= 3.2.18) + rails (= 4.0.6) rails-bootstrap (~> 3.0.0) rspec-rails - sass-rails (~> 3.2.3) + sass-rails (~> 4.0.0) selenium-webdriver syslogger! uglifier (>= 1.0.3) diff --git a/app/services/report_processing.rb b/app/services/report_processing.rb index a6401e0..95bb324 100644 --- a/app/services/report_processing.rb +++ b/app/services/report_processing.rb @@ -80,7 +80,7 @@ def parse_status def parse node_name = parsed.name - @report.node = Node.find_or_create_by_name(node_name) + @report.node = Node.find_or_create_by(name: node_name) @report.report_logs.create(parse_logs) @report.metrics.create(parse_metrics) @report.resource_statuses.create(parse_resource_statuses) diff --git a/app/views/node_classes/show.html.erb b/app/views/node_classes/show.html.erb index 7d0e8b4..a032d28 100644 --- a/app/views/node_classes/show.html.erb +++ b/app/views/node_classes/show.html.erb @@ -5,7 +5,7 @@
<%= link_to "Back", node_classes_path, :class => 'btn btn-sm btn-default' %> <%= link_to "Edit", edit_node_class_path(@node_class), :class => 'btn btn-sm btn-primary' %> - <%= link_to "Delete", @node_class, :method => :delete, :confirm => "Are you sure?", :class => 'btn btn-sm btn-danger pull-right' %> + <%= link_to "Delete", @node_class, :method => :delete, :data => { :confirm => "Are you sure?" }, :class => 'btn btn-sm btn-danger pull-right' %>

Nodes

diff --git a/app/views/node_groups/show.html.erb b/app/views/node_groups/show.html.erb index 6fb4d34..528cbe8 100644 --- a/app/views/node_groups/show.html.erb +++ b/app/views/node_groups/show.html.erb @@ -5,7 +5,7 @@
<%= link_to "Back", node_groups_path, :class => 'btn btn-sm btn-default' %> <%= link_to "Edit", edit_node_group_path(@node_group), :class => 'btn btn-sm btn-primary' %> - <%= link_to "Delete", @node_group, :method => :delete, :confirm => "Are you sure?", :class => 'btn btn-sm btn-danger pull-right' %> + <%= link_to "Delete", @node_group, :method => :delete, :data => { :confirm => "Are you sure?" }, :class => 'btn btn-sm btn-danger pull-right' %>

Parameters

diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index d54d7f3..a96adcd 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb @@ -17,7 +17,7 @@
<%= puppet_agent_node_status(@node) %>
- <%= link_to "Delete", @node, :method => :delete, :confirm => "Are you sure?", :class => 'btn btn-sm btn-danger pull-right' %> + <%= link_to "Delete", @node, :method => :delete, :data => { :confirm => "Are you sure?" }, :class => 'btn btn-sm btn-danger pull-right' %>

Parameters

diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb index 639edd7..96cf41c 100644 --- a/app/views/reports/show.html.erb +++ b/app/views/reports/show.html.erb @@ -4,7 +4,7 @@
<%= link_to "Back", @report.node ? node_path(@report.node) : reports_path, :class => 'btn btn-sm btn-default' %> - <%= link_to "Delete", @report, :method => :delete, :confirm => "Are you sure?", :class => 'btn btn-sm btn-danger pull-right' %> + <%= link_to "Delete", @report, :method => :delete, :data => { :confirm => "Are you sure?" }, :class => 'btn btn-sm btn-danger pull-right' %>

diff --git a/config/application.rb b/config/application.rb index 38fdd57..f1c8963 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,7 +4,7 @@ if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) + Bundler.require(*Rails.groups) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end diff --git a/config/database.yml b/config/database.yml index 0f2eeb1..dd5c7fd 100644 --- a/config/database.yml +++ b/config/database.yml @@ -18,15 +18,27 @@ postgresql: &pg defaults: &defaults pool: 16 timeout: 5000 - host: localhost <<: *<%= ENV['DB'] || "mysql2" %> development: - <<: *defaults + adapter: mysql2 + encoding: utf8 + host: enc-dashboard.c1phlpd5jvwq.us-west-2.rds.amazonaws.com + port: 3306 + database: dashboard_development + username: dashboard + password: d4aca968 test: <<: *defaults + host: localhost production: - <<: *defaults + # <<: *defaults # presumably, we'd erb-echo the production password from /etc/something here. + adapter: mysql2 + encoding: utf8 + host: enc-dashboard + database: dashboard_production + username: dashboard + password: d4aca968 diff --git a/config/environments/development.rb b/config/environments/development.rb index 0335c29..a5bf402 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,8 +6,7 @@ # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + config.eager_load = false # Show full error reports and disable caching config.consider_all_requests_local = true @@ -19,19 +18,9 @@ # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 - - # Do not compress assets - config.assets.compress = false - # Expands the lines which load the assets config.assets.debug = true end diff --git a/config/environments/prod.rb b/config/environments/prod.rb index 3f68241..76c4bb1 100644 --- a/config/environments/prod.rb +++ b/config/environments/prod.rb @@ -4,6 +4,8 @@ # Code is not reloaded between requests config.cache_classes = true + config.eager_load = true + # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true @@ -12,7 +14,7 @@ config.serve_static_assets = false # Compress JavaScripts and CSS - config.assets.compress = true + config.assets.js_compressor = :uglifier # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false @@ -61,10 +63,6 @@ # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 - config.serve_static_assets = true config.assets.compile = false config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' diff --git a/config/environments/production.rb b/config/environments/production.rb index 4c19acd..d100d72 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,6 +4,8 @@ # Code is not reloaded between requests config.cache_classes = true + config.eager_load = true + # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true @@ -12,7 +14,7 @@ config.serve_static_assets = false # Compress JavaScripts and CSS - config.assets.compress = true + config.assets.js_compressor = :uglifier # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false @@ -60,8 +62,4 @@ # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 end diff --git a/config/environments/stage.rb b/config/environments/stage.rb index e9efcd4..cb39d68 100644 --- a/config/environments/stage.rb +++ b/config/environments/stage.rb @@ -6,8 +6,7 @@ # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + config.eager_load = false # Show full error reports and disable caching config.consider_all_requests_local = true @@ -19,19 +18,9 @@ # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 - - # Do not compress assets - config.assets.compress = false - # Expands the lines which load the assets config.assets.debug = true diff --git a/config/environments/test.rb b/config/environments/test.rb index b365299..69f771b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -11,8 +11,7 @@ config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true + config.eager_load = false # Show full error reports and disable caching config.consider_all_requests_local = true diff --git a/config/initializers/00_enc_settings.rb b/config/initializers/00_enc_settings.rb index d826860..db4811f 100644 --- a/config/initializers/00_enc_settings.rb +++ b/config/initializers/00_enc_settings.rb @@ -1,7 +1,9 @@ if File.exists? "config/settings.yml" - ENC_CONFIG = YAML.load_file("#{Rails.root}/config/settings.yml")[Rails.env].with_indifferent_access + ENC_CONFIG = HashWithIndifferentAccess.new(YAML.load(File.read("#{Rails.root}/config/settings.yml"))[Rails.env]) + puts "=> Config file(settings.yml) loaded. \n ENC_CONFIG: #{ENC_CONFIG}" elsif File.exists? "/etc/enc_dashboard/settings.yml" - ENC_CONFIG = YAML.load_file("/etc/enc_dashboard/settings.yml")[Rails.env].with_indifferent_access + ENC_CONFIG = HashWithIndifferentAccess.new(YAML.load(File.read("/etc/enc_dashboard/settings.yml"))[Rails.env]) + puts "=> Config file(settings.yml) loaded. \n ENC_CONFIG: #{ENC_CONFIG}" else puts "WARNING: No config/settings.yml file found" ENC_CONFIG = {} diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index be058f1..6cb96ce 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -2,6 +2,9 @@ # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! + # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -Enc::Application.config.secret_token = '920e97b1d36c9c3f92c6fb9ba9c2ff72e3dccea603965445d2e8e1ce0e003e55ac084008a9841940bb3173ed6269e412ffecb23b20598c730e2fe85f8ac5ce60' +# You can use `rake secret` to generate a secure secret key. + +Enc::Application.config.secret_key_base = '5c82fd92241d77979577a72754fbe29de81e14a7343814aa9b9486147920bbdf2f71e7dc271e33c1a7037e8d1c1b487b7209ff4ba7820278069d6e02992ee38e' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df20..c2f744d 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -7,8 +7,3 @@ ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end - -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end diff --git a/config/routes.rb b/config/routes.rb index d9dee89..c413289 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,5 +32,7 @@ end resources :parameters, only: [:index, :new, :create] root :to => 'nodes#index' - match 'moov_check' => "home#moov_check" + # Rails 4.0 requires that routes using match must specify the request method + # match 'moov_check' => "home#moov_check" + get 'moov_check' => 'home#moov_check' end diff --git a/config/settings.yml.sample b/config/settings.yml.sample deleted file mode 100644 index 355a6ed..0000000 --- a/config/settings.yml.sample +++ /dev/null @@ -1,10 +0,0 @@ -development: -# spool_path: /tmp/enc_spool - puppetdb: - host: hostname - port: port -production: -# spool_path: /tmp/enc_spool - puppetdb: - host: hostname - port: port diff --git a/db/schema.rb b/db/schema.rb index 0ccfedf..2c42a1c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,110 +9,110 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160503213802) do +ActiveRecord::Schema.define(version: 20160503213802) do - create_table "metrics", :force => true do |t| - t.integer "report_id", :null => false + create_table "metrics", force: true do |t| + t.integer "report_id", null: false t.string "category" t.string "name" - t.decimal "value", :precision => 12, :scale => 6 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.decimal "value", precision: 12, scale: 6 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "metrics", ["report_id"], :name => "index_metrics_on_report_id" + add_index "metrics", ["report_id"], name: "index_metrics_on_report_id", using: :btree - create_table "node_class_memberships", :force => true do |t| + create_table "node_class_memberships", force: true do |t| t.integer "node_id" t.integer "node_class_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "node_classes", :force => true do |t| - t.string "name", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "node_classes", force: true do |t| + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "node_classes", ["name"], :name => "index_node_classes_on_name", :unique => true + add_index "node_classes", ["name"], name: "index_node_classes_on_name", unique: true, using: :btree - create_table "node_group_memberships", :force => true do |t| + create_table "node_group_memberships", force: true do |t| t.integer "node_id" t.integer "node_group_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "node_group_memberships", ["node_group_id"], :name => "index_node_group_memberships_on_node_group_id" + add_index "node_group_memberships", ["node_group_id"], name: "index_node_group_memberships_on_node_group_id", using: :btree - create_table "node_groups", :force => true do |t| - t.string "name", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "node_groups", force: true do |t| + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "node_groups", ["name"], :name => "index_node_groups_on_name", :unique => true + add_index "node_groups", ["name"], name: "index_node_groups_on_name", unique: true, using: :btree - create_table "nodes", :force => true do |t| - t.string "name", :null => false + create_table "nodes", force: true do |t| + t.string "name", null: false t.text "description" t.datetime "reported_at" t.integer "last_apply_report_id" t.string "status" - t.boolean "hidden", :default => false + t.boolean "hidden", default: false t.integer "last_inspect_report_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "environment" end - add_index "nodes", ["name"], :name => "index_nodes_on_name", :unique => true + add_index "nodes", ["name"], name: "index_nodes_on_name", unique: true, using: :btree - create_table "parameters", :force => true do |t| + create_table "parameters", force: true do |t| t.string "key" t.text "value" t.integer "parameterable_id" t.string "parameterable_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "report_logs", :force => true do |t| + create_table "report_logs", force: true do |t| t.integer "report_id" t.string "level" t.text "message" t.datetime "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "source" end - add_index "report_logs", ["report_id"], :name => "index_report_logs_on_report_id" + add_index "report_logs", ["report_id"], name: "index_report_logs_on_report_id", using: :btree - create_table "reports", :force => true do |t| + create_table "reports", force: true do |t| t.integer "node_id" t.string "status" t.string "environment" t.datetime "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "reports", ["node_id"], :name => "index_reports_on_node_id" + add_index "reports", ["node_id"], name: "index_reports_on_node_id", using: :btree - create_table "resource_statuses", :force => true do |t| + create_table "resource_statuses", force: true do |t| t.integer "report_id" t.boolean "failed" t.boolean "skipped" t.boolean "is_changed" t.text "title" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "resource_statuses", ["report_id"], :name => "index_resource_statuses_on_report_id" + add_index "resource_statuses", ["report_id"], name: "index_resource_statuses_on_report_id", using: :btree end diff --git a/db/seeds.rb b/db/seeds.rb index 6c82759..fb5384d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,12 +5,12 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -node1 = Node.find_or_create_by_name("node1") +node1 = Node.find_or_create_by(name: "node1") node1.status = "unchanged" node1.save -node2 = Node.find_or_create_by_name("node2") +node2 = Node.find_or_create_by(name: "node2") node2.status = "changed" node2.save -group1 = NodeGroup.find_or_create_by_name("group1") -group2 = NodeGroup.find_or_create_by_name("group2") -group3 = NodeGroup.find_or_create_by_name("group3") +group1 = NodeGroup.find_or_create_by(name: "group1") +group2 = NodeGroup.find_or_create_by(name: "group2") +group3 = NodeGroup.find_or_create_by(name: "group3") diff --git a/spec/lib/puppetdb_spec.rb b/spec/lib/puppetdb_spec.rb index 69c97c2..9392624 100644 --- a/spec/lib/puppetdb_spec.rb +++ b/spec/lib/puppetdb_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe PuppetDB do - its(:options) { should be_kind_of Hash } + it(:options) { should be_kind_of Hash } end From ca550397b613dbb4895d3bfc949765c3198ff5cc Mon Sep 17 00:00:00 2001 From: LujiaZ Date: Mon, 23 Jan 2017 11:46:09 -0800 Subject: [PATCH 08/16] Update .ruby-version config file --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 3e3c2f1..0bee604 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.1.1 +2.3.3 From bc1e5a0c8882e5bcb8c5ecdb4ab51bb3824ce1ea Mon Sep 17 00:00:00 2001 From: LujiaZ Date: Mon, 20 Mar 2017 15:41:00 -0700 Subject: [PATCH 09/16] Upgrade rails to 4.2.5 --- Gemfile | 9 +- Gemfile.lock | 171 +++++++++++++++-------- app/controllers/nodes_controller.rb | 2 +- app/controllers/parameters_controller.rb | 2 +- app/helpers/application_helper.rb | 10 ++ app/views/layouts/application.html.erb | 10 ++ config/application.rb | 12 +- config/environments/development.rb | 11 +- config/environments/prod.rb | 1 - config/environments/stage.rb | 3 +- config/environments/test.rb | 3 - config/routes.rb | 1 + db/schema.rb | 120 ++++++++-------- spec/factories/node.rb | 2 +- spec/factories/report.rb | 2 +- 15 files changed, 213 insertions(+), 146 deletions(-) diff --git a/Gemfile b/Gemfile index 3442c17..70b2995 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'https://rubygems.org' -gem 'rails', '4.0.6' -gem 'mysql2', '0.3.17' gem 'syslogger', git: 'https://github.com/jbussdieker/syslogger.git', :branch => 'implement_log_formatter' +gem 'rails', '4.2.5' +gem 'mysql2', '0.3.18' gem 'puppet' gem 'mcollective-client' gem 'chartkick' @@ -15,13 +15,15 @@ gem 'sass-rails', '~> 4.0.0' gem 'coffee-rails', '~> 4.0.0' gem 'uglifier', '>= 1.0.3' gem 'jquery-rails' -gem 'awesome_print', require:"ap" +gem 'awesome_print' # attr_accessible` is extracted out of Rails into a gem. # Please use new recommended protection model for params(strong_parameters) # or add `protected_attributes` to your Gemfile to use old one gem 'protected_attributes' +gem 'responders', '~> 2.0' + # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby @@ -29,6 +31,7 @@ group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails' gem 'coveralls', require: false + gem 'web-console', '~> 2.0' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 80efd9d..0f9bd4c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,35 +9,47 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.2.8) - actionmailer (4.0.6) - actionpack (= 4.0.6) - mail (~> 2.5.4) - actionpack (4.0.6) - activesupport (= 4.0.6) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) + actionmailer (4.2.5) + actionpack (= 4.2.5) + actionview (= 4.2.5) + activejob (= 4.2.5) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.5) + actionview (= 4.2.5) + activesupport (= 4.2.5) + rack (~> 1.6) rack-test (~> 0.6.2) - activemodel (4.0.6) - activesupport (= 4.0.6) - builder (~> 3.1.0) - activerecord (4.0.6) - activemodel (= 4.0.6) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.6) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.4) - activesupport (4.0.6) - i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.5) + activesupport (= 4.2.5) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (4.2.5) + activesupport (= 4.2.5) + globalid (>= 0.3.0) + activemodel (4.2.5) + activesupport (= 4.2.5) + builder (~> 3.1) + activerecord (4.2.5) + activemodel (= 4.2.5) + activesupport (= 4.2.5) + arel (~> 6.0) + activesupport (4.2.5) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) addressable (2.5.0) public_suffix (~> 2.0, >= 2.0.2) - arel (4.0.2) - awesome_print (1.7.0) - builder (3.1.4) + arel (6.0.4) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + builder (3.2.3) capybara (2.11.0) addressable mime-types (>= 1.16) @@ -62,6 +74,7 @@ GEM thor (~> 0.19.1) tins (~> 1.6) database_cleaner (1.5.3) + debug_inspector (0.0.2) diff-lcs (1.2.5) docile (1.1.5) erubis (2.7.0) @@ -73,38 +86,52 @@ GEM factory_girl_rails (4.8.0) factory_girl (~> 4.8.0) railties (>= 3.0.0) - faker (1.7.2) + faker (1.7.3) i18n (~> 0.5) ffi (1.9.17) - groupdate (3.1.1) + globalid (0.3.7) + activesupport (>= 4.1.0) + groupdate (3.2.0) activesupport (>= 3) - hiera (3.2.2) + hiera (3.3.1) hike (1.2.3) - i18n (0.7.0) - jquery-rails (3.1.4) - railties (>= 3.0, < 5.0) + i18n (0.8.1) + jquery-rails (4.2.2) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.0.3) + json (1.8.6) json_pure (1.8.6) - kaminari (0.17.0) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) kgio (2.11.0) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mcollective-client (2.9.1) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.4) + mime-types (>= 1.16, < 4) + mcollective-client (2.10.2) json stomp systemu - mime-types (1.25.1) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (4.7.5) + minitest (5.10.1) multi_json (1.12.1) - mysql2 (0.3.17) - nokogiri (1.7.0.1) + mysql2 (0.3.18) + nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - polyglot (0.3.5) protected_attributes (1.1.3) activemodel (>= 4.0.1, < 5.0) public_suffix (2.0.5) @@ -113,25 +140,38 @@ GEM facter (> 2.0, < 4) hiera (>= 2.0, < 4) json_pure (~> 1.8) - rack (1.5.5) + rack (1.6.5) rack-test (0.6.3) rack (>= 1.0) - rails (4.0.6) - actionmailer (= 4.0.6) - actionpack (= 4.0.6) - activerecord (= 4.0.6) - activesupport (= 4.0.6) + rails (4.2.5) + actionmailer (= 4.2.5) + actionpack (= 4.2.5) + actionview (= 4.2.5) + activejob (= 4.2.5) + activemodel (= 4.2.5) + activerecord (= 4.2.5) + activesupport (= 4.2.5) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.6) - sprockets-rails (~> 2.0) + railties (= 4.2.5) + sprockets-rails rails-bootstrap (3.0.0.4) - railties (4.0.6) - actionpack (= 4.0.6) - activesupport (= 4.0.6) + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.8) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (4.2.5) + actionpack (= 4.2.5) + activesupport (= 4.2.5) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.17.0) rake (12.0.0) + responders (2.3.0) + railties (>= 4.2.0, < 5.1) rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) @@ -182,16 +222,18 @@ GEM thread_safe (0.3.5) tilt (1.4.1) tins (1.13.0) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) tzinfo (0.3.52) uglifier (3.0.4) execjs (>= 0.3.0, < 3) unicorn (5.2.0) kgio (~> 2.6) raindrops (~> 0.7) - websocket (1.2.3) + web-console (2.3.0) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) + websocket (1.2.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -211,14 +253,19 @@ DEPENDENCIES jquery-rails kaminari mcollective-client - mysql2 (= 0.3.17) + mysql2 (= 0.3.18) protected_attributes puppet - rails (= 4.0.6) + rails (= 4.2.5) rails-bootstrap (~> 3.0.0) + responders (~> 2.0) rspec-rails sass-rails (~> 4.0.0) selenium-webdriver syslogger! uglifier (>= 1.0.3) unicorn + web-console (~> 2.0) + +BUNDLED WITH + 1.13.6 diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 97a165d..fa03b58 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -87,7 +87,7 @@ def status_history def resource_times @report = @node.reports.order("time DESC").first if @report - @metrics = @report.metrics.where(:category => "Time") + @metrics = @report.metrics.where(:category => "Time").to_a @metrics.reject! {|n| n.name == "Total"} @metrics = @metrics.collect {|n| [n.name, n.value]} else diff --git a/app/controllers/parameters_controller.rb b/app/controllers/parameters_controller.rb index da2f72f..658d3ba 100644 --- a/app/controllers/parameters_controller.rb +++ b/app/controllers/parameters_controller.rb @@ -2,7 +2,7 @@ class ParametersController < ApplicationController helper_method :sort_column, :sort_direction def index - @parameters = Parameter.where(parameterable_id: nil).order(sort_column + " " + sort_direction) + @parameters = Parameter.where(parameterable_id: nil).order(sort_column + " " + sort_direction).to_a render_collection(@parameters) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8f0b166..e06ab59 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -24,4 +24,14 @@ def current_url(new_params) string = options.map{ |k,v| "#{k}=#{v}" }.join("&") request.fullpath.split("?")[0] + "?" + string end + + def link_to_function(name, *args, &block) + html_options = args.extract_options!.symbolize_keys + + function = block_given? ? update_page(&block) : args[0] || '' + onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;" + href = html_options[:href] || '#' + + content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick)) + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 613eaeb..518e781 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -29,6 +29,16 @@
  • <%= link_to "Parameters", parameters_path %>
  • <%= link_to "Reports", reports_path %>
  • + +
    diff --git a/config/application.rb b/config/application.rb index f1c8963..c749f66 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,9 +4,7 @@ if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) + Bundler.require(:default, Rails.env) end module Enc @@ -47,16 +45,12 @@ class Application < Rails::Application # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = true - # Enable the asset pipeline config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + + config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/environments/development.rb b/config/environments/development.rb index a5bf402..d602256 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,15 +12,22 @@ config.consider_all_requests_local = true config.action_controller.perform_caching = false + # Compress JavaScripts and CSS + config.assets.js_compressor = :uglifier + # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load # Expands the lines which load the assets config.assets.debug = true + + config.logger = Logger.new(STDOUT) + config.logger.level = :debug + config.log_level = :debug end diff --git a/config/environments/prod.rb b/config/environments/prod.rb index 76c4bb1..077c81b 100644 --- a/config/environments/prod.rb +++ b/config/environments/prod.rb @@ -64,7 +64,6 @@ config.active_support.deprecation = :notify config.serve_static_assets = true - config.assets.compile = false config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' # Setup custom logger to syslog diff --git a/config/environments/stage.rb b/config/environments/stage.rb index cb39d68..b37caf9 100644 --- a/config/environments/stage.rb +++ b/config/environments/stage.rb @@ -18,8 +18,7 @@ # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + config.assets.js_compressor = :uglifier # Expands the lines which load the assets config.assets.debug = true diff --git a/config/environments/test.rb b/config/environments/test.rb index 69f771b..3f37da3 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -28,9 +28,6 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end diff --git a/config/routes.rb b/config/routes.rb index c413289..db6793e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,7 @@ end resources :parameters, only: [:index, :new, :create] root :to => 'nodes#index' + # Rails 4.0 requires that routes using match must specify the request method # match 'moov_check' => "home#moov_check" get 'moov_check' => 'home#moov_check' diff --git a/db/schema.rb b/db/schema.rb index 2c42a1c..ab58670 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,104 +13,104 @@ ActiveRecord::Schema.define(version: 20160503213802) do - create_table "metrics", force: true do |t| - t.integer "report_id", null: false - t.string "category" - t.string "name" - t.decimal "value", precision: 12, scale: 6 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "metrics", force: :cascade do |t| + t.integer "report_id", limit: 4, null: false + t.string "category", limit: 255 + t.string "name", limit: 255 + t.decimal "value", precision: 12, scale: 6 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "metrics", ["report_id"], name: "index_metrics_on_report_id", using: :btree - create_table "node_class_memberships", force: true do |t| - t.integer "node_id" - t.integer "node_class_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "node_class_memberships", force: :cascade do |t| + t.integer "node_id", limit: 4 + t.integer "node_class_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "node_classes", force: true do |t| - t.string "name", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "node_classes", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "node_classes", ["name"], name: "index_node_classes_on_name", unique: true, using: :btree - create_table "node_group_memberships", force: true do |t| - t.integer "node_id" - t.integer "node_group_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "node_group_memberships", force: :cascade do |t| + t.integer "node_id", limit: 4 + t.integer "node_group_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "node_group_memberships", ["node_group_id"], name: "index_node_group_memberships_on_node_group_id", using: :btree - create_table "node_groups", force: true do |t| - t.string "name", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "node_groups", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "node_groups", ["name"], name: "index_node_groups_on_name", unique: true, using: :btree - create_table "nodes", force: true do |t| - t.string "name", null: false - t.text "description" + create_table "nodes", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.text "description", limit: 65535 t.datetime "reported_at" - t.integer "last_apply_report_id" - t.string "status" - t.boolean "hidden", default: false - t.integer "last_inspect_report_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "environment" + t.integer "last_apply_report_id", limit: 4 + t.string "status", limit: 255 + t.boolean "hidden", default: false + t.integer "last_inspect_report_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "environment", limit: 255 end add_index "nodes", ["name"], name: "index_nodes_on_name", unique: true, using: :btree - create_table "parameters", force: true do |t| - t.string "key" - t.text "value" - t.integer "parameterable_id" - t.string "parameterable_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "parameters", force: :cascade do |t| + t.string "key", limit: 255 + t.text "value", limit: 65535 + t.integer "parameterable_id", limit: 4 + t.string "parameterable_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "report_logs", force: true do |t| - t.integer "report_id" - t.string "level" - t.text "message" + create_table "report_logs", force: :cascade do |t| + t.integer "report_id", limit: 4 + t.string "level", limit: 255 + t.text "message", limit: 65535 t.datetime "time" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "source" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "source", limit: 255 end add_index "report_logs", ["report_id"], name: "index_report_logs_on_report_id", using: :btree - create_table "reports", force: true do |t| - t.integer "node_id" - t.string "status" - t.string "environment" + create_table "reports", force: :cascade do |t| + t.integer "node_id", limit: 4 + t.string "status", limit: 255 + t.string "environment", limit: 255 t.datetime "time" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "reports", ["node_id"], name: "index_reports_on_node_id", using: :btree - create_table "resource_statuses", force: true do |t| - t.integer "report_id" + create_table "resource_statuses", force: :cascade do |t| + t.integer "report_id", limit: 4 t.boolean "failed" t.boolean "skipped" t.boolean "is_changed" - t.text "title" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.text "title", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "resource_statuses", ["report_id"], name: "index_resource_statuses_on_report_id", using: :btree diff --git a/spec/factories/node.rb b/spec/factories/node.rb index 39405cb..b56326a 100644 --- a/spec/factories/node.rb +++ b/spec/factories/node.rb @@ -37,7 +37,7 @@ end factory :node_with_reports, parent: :node do - ignore do + ransient do report_count 5 end diff --git a/spec/factories/report.rb b/spec/factories/report.rb index 8f31bf2..0fde8a9 100644 --- a/spec/factories/report.rb +++ b/spec/factories/report.rb @@ -9,7 +9,7 @@ end factory :report_with_dependents, parent: :full_report do - ignore do + ransient do metric_count 5 report_log_count 5 resource_status_count 5 From 1badc236d638ce79bdf9d594958f6dab5604fd3f Mon Sep 17 00:00:00 2001 From: LujiaZ Date: Thu, 23 Mar 2017 15:53:01 -0700 Subject: [PATCH 10/16] Update config files --- config/application.rb | 8 -------- config/environments/prod.rb | 10 +++++----- config/environments/production.rb | 7 ++++++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/config/application.rb b/config/application.rb index c749f66..39773ae 100644 --- a/config/application.rb +++ b/config/application.rb @@ -40,14 +40,6 @@ class Application < Rails::Application # Enable escaping HTML in JSON. config.active_support.escape_html_entities_in_json = true - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Enable the asset pipeline - config.assets.enabled = true - # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' diff --git a/config/environments/prod.rb b/config/environments/prod.rb index 077c81b..d5ab2cd 100644 --- a/config/environments/prod.rb +++ b/config/environments/prod.rb @@ -11,7 +11,7 @@ config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + config.serve_static_assets = true # Compress JavaScripts and CSS config.assets.js_compressor = :uglifier @@ -66,8 +66,8 @@ config.serve_static_assets = true config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' - # Setup custom logger to syslog - config.logger = Syslogger.new("enc_dashboard", Syslog::LOG_PID | Syslog::LOG_CONS, Syslog::LOG_LOCAL5) - config.logger.level = Logger::ERROR - config.logger.level = Logger::DEBUG if File.exists?"/tmp/moov_debug_prod" + # Setup custom logger to stdout and log level to debug + config.logger = Logger.new(STDOUT) + config.logger.level = :debug + config.log_level = :debug end diff --git a/config/environments/production.rb b/config/environments/production.rb index d100d72..704ffbe 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -11,7 +11,7 @@ config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + config.serve_static_assets = true # Compress JavaScripts and CSS config.assets.js_compressor = :uglifier @@ -62,4 +62,9 @@ # Send deprecation notices to registered listeners config.active_support.deprecation = :notify + + # Setup custom logger to stdout and log level to debug + config.logger = Logger.new(STDOUT) + config.logger.level = :debug + config.log_level = :debug end From 2244e117817be4d4c3d2eb97d872ff509eee4231 Mon Sep 17 00:00:00 2001 From: LujiaZ Date: Thu, 20 Jul 2017 16:34:35 -0700 Subject: [PATCH 11/16] [PFST-1820] Fix the DEPRECATION WARNING --- config/environments/prod.rb | 4 ++-- config/environments/production.rb | 2 +- config/environments/stage.rb | 2 +- config/environments/test.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/environments/prod.rb b/config/environments/prod.rb index d5ab2cd..59cfca2 100644 --- a/config/environments/prod.rb +++ b/config/environments/prod.rb @@ -11,7 +11,7 @@ config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + config.serve_static_files = true # Compress JavaScripts and CSS config.assets.js_compressor = :uglifier @@ -63,7 +63,7 @@ # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - config.serve_static_assets = true + config.serve_static_files = true config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' # Setup custom logger to stdout and log level to debug diff --git a/config/environments/production.rb b/config/environments/production.rb index 704ffbe..8ff1ada 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -11,7 +11,7 @@ config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + config.serve_static_files = true # Compress JavaScripts and CSS config.assets.js_compressor = :uglifier diff --git a/config/environments/stage.rb b/config/environments/stage.rb index b37caf9..984f13f 100644 --- a/config/environments/stage.rb +++ b/config/environments/stage.rb @@ -23,7 +23,7 @@ # Expands the lines which load the assets config.assets.debug = true - config.serve_static_assets = true + config.serve_static_files = true config.assets.compile = false config.paths['config/database'] = '/etc/enc_dashboard/database.yml' if File.exists? '/etc/enc_dashboard/database.yml' end diff --git a/config/environments/test.rb b/config/environments/test.rb index 3f37da3..11a3562 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,7 +8,7 @@ config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = "public, max-age=3600" config.eager_load = false From 4e5f30cb362635394d97751a69871e5c40f5ddcd Mon Sep 17 00:00:00 2001 From: Glennon Ng Date: Thu, 12 Oct 2017 13:57:24 -0700 Subject: [PATCH 12/16] try to bundle on jenkins --- Gemfile | 2 ++ Gemfile.lock | 8 ++++++-- newrelic.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 newrelic.yml diff --git a/Gemfile b/Gemfile index 70b2995..31443e9 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,8 @@ gem 'protected_attributes' gem 'responders', '~> 2.0' +gem 'newrelic_rpm' + # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby diff --git a/Gemfile.lock b/Gemfile.lock index 0f9bd4c..513b172 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,6 +38,7 @@ GEM activemodel (= 4.2.5) activesupport (= 4.2.5) arel (~> 6.0) + awesome_print (1.8.0) activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) @@ -47,6 +48,7 @@ GEM addressable (2.5.0) public_suffix (~> 2.0, >= 2.0.2) arel (6.0.4) + awesome_print (1.8.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.3) @@ -73,6 +75,7 @@ GEM term-ansicolor (~> 1.3) thor (~> 0.19.1) tins (~> 1.6) + tzinfo (0.3.52) database_cleaner (1.5.3) debug_inspector (0.0.2) diff-lcs (1.2.5) @@ -130,6 +133,7 @@ GEM minitest (5.10.1) multi_json (1.12.1) mysql2 (0.3.18) + newrelic_rpm (4.5.0.337) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) protected_attributes (1.1.3) @@ -222,7 +226,6 @@ GEM thread_safe (0.3.5) tilt (1.4.1) tins (1.13.0) - tzinfo (0.3.52) uglifier (3.0.4) execjs (>= 0.3.0, < 3) unicorn (5.2.0) @@ -254,6 +257,7 @@ DEPENDENCIES kaminari mcollective-client mysql2 (= 0.3.18) + newrelic_rpm protected_attributes puppet rails (= 4.2.5) @@ -268,4 +272,4 @@ DEPENDENCIES web-console (~> 2.0) BUNDLED WITH - 1.13.6 + 1.16.0.pre.3 diff --git a/newrelic.yml b/newrelic.yml new file mode 100644 index 0000000..fab996e --- /dev/null +++ b/newrelic.yml @@ -0,0 +1,46 @@ +# +# This file configures the New Relic Agent. New Relic monitors Ruby, Java, +# .NET, PHP, Python and Node applications with deep visibility and low +# overhead. For more information, visit www.newrelic.com. +# +# Generated October 12, 2017 +# +# This configuration file is custom generated for Moovweb_8 +# +# For full documentation of agent configuration options, please refer to +# https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration + +common: &default_settings + # Required license key associated with your New Relic account. + license_key: cd79ec6532df89596bf61c9187e488db7891266b + + # Your application name. Renaming here affects where data displays in New + # Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications + app_name: ENC Dashboard + + # To disable the agent regardless of other settings, uncomment the following: + # agent_enabled: false + + # Logging level for log/newrelic_agent.log + log_level: info + + +# Environment-specific settings are in this section. +# RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment. +# If your application has other named environments, configure them here. +development: + <<: *default_settings + app_name: ENC Dashboard (Development) + +test: + <<: *default_settings + # It doesn't make sense to report to New Relic from automated test runs. + monitor_mode: false + +staging: + <<: *default_settings + app_name: ENC Dashboard (Staging) + +production: + <<: *default_settings + From 7b52cae42cb1959d404cc0e8f3c51fbb01a75b66 Mon Sep 17 00:00:00 2001 From: Glennon Ng Date: Thu, 12 Oct 2017 14:06:44 -0700 Subject: [PATCH 13/16] add newrelic and use new Gemfile.lock --- Gemfile.lock | 149 +++++++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 70 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 513b172..b5a7020 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,6 @@ GIT GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.2.8) actionmailer (4.2.5) actionpack (= 4.2.5) actionview (= 4.2.5) @@ -38,29 +37,28 @@ GEM activemodel (= 4.2.5) activesupport (= 4.2.5) arel (~> 6.0) - awesome_print (1.8.0) activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.0) - public_suffix (~> 2.0, >= 2.0.2) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) arel (6.0.4) awesome_print (1.8.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.3) - capybara (2.11.0) + capybara (2.15.4) addressable - mime-types (>= 1.16) + mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - chartkick (2.2.2) - childprocess (0.5.9) + chartkick (2.2.4) + childprocess (0.8.0) ffi (~> 1.0, >= 1.0.11) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -69,42 +67,48 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - coveralls (0.8.17) + coveralls (0.8.21) json (>= 1.8, < 3) - simplecov (~> 0.12.0) + simplecov (~> 0.14.1) term-ansicolor (~> 1.3) - thor (~> 0.19.1) + thor (~> 0.19.4) tins (~> 1.6) - tzinfo (0.3.52) - database_cleaner (1.5.3) - debug_inspector (0.0.2) - diff-lcs (1.2.5) + crass (1.0.2) + database_cleaner (1.6.1) + debug_inspector (0.0.3) + diff-lcs (1.3) docile (1.1.5) erubis (2.7.0) execjs (2.7.0) - facter (2.4.6) - CFPropertyList (~> 2.2.6) - factory_girl (4.8.0) + facter (2.5.1) + factory_girl (4.8.1) activesupport (>= 3.0.0) factory_girl_rails (4.8.0) factory_girl (~> 4.8.0) railties (>= 3.0.0) - faker (1.7.3) + faker (1.8.4) i18n (~> 0.5) - ffi (1.9.17) - globalid (0.3.7) - activesupport (>= 4.1.0) + fast_gettext (1.1.0) + ffi (1.9.18) + gettext (3.2.4) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.28) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + globalid (0.4.0) + activesupport (>= 4.2.0) groupdate (3.2.0) activesupport (>= 3) - hiera (3.3.1) + hiera (3.4.2) hike (1.2.3) - i18n (0.8.1) - jquery-rails (4.2.2) + i18n (0.8.6) + jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.6) - json_pure (1.8.6) kaminari (1.0.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.0.1) @@ -118,33 +122,36 @@ GEM kaminari-core (= 1.0.1) kaminari-core (1.0.1) kgio (2.11.0) - loofah (2.0.3) + locale (2.1.2) + loofah (2.1.1) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.4) + mail (2.6.6) mime-types (>= 1.16, < 4) - mcollective-client (2.10.2) + mcollective-client (2.11.3) json stomp systemu mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) - minitest (5.10.1) - multi_json (1.12.1) + mini_mime (0.1.4) + mini_portile2 (2.3.0) + minitest (5.10.3) + multi_json (1.12.2) mysql2 (0.3.18) newrelic_rpm (4.5.0.337) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) - protected_attributes (1.1.3) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) + protected_attributes (1.1.4) activemodel (>= 4.0.1, < 5.0) - public_suffix (2.0.5) - puppet (4.8.1) - CFPropertyList (~> 2.2.6) + public_suffix (3.0.0) + puppet (5.3.2) facter (> 2.0, < 4) - hiera (>= 2.0, < 4) - json_pure (~> 1.8) - rack (1.6.5) + gettext-setup (>= 0.10, < 1) + hiera (>= 3.2.1, < 4) + locale (~> 2.1) + rack (1.6.8) rack-test (0.6.3) rack (>= 1.0) rails (4.2.5) @@ -172,43 +179,43 @@ GEM activesupport (= 4.2.5) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.17.0) - rake (12.0.0) - responders (2.3.0) - railties (>= 4.2.0, < 5.1) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + raindrops (0.19.0) + rake (12.1.0) + responders (2.4.0) + actionpack (>= 4.2.0, < 5.3) + railties (>= 4.2.0, < 5.3) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-rails (3.5.2) + rspec-support (~> 3.6.0) + rspec-rails (3.6.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) - rubyzip (1.2.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) + rubyzip (1.2.1) sass (3.2.19) sass-rails (4.0.5) railties (>= 4.0.0, < 5.0) sass (~> 3.2.2) sprockets (~> 2.8, < 3.0) sprockets-rails (~> 2.0) - selenium-webdriver (3.0.5) + selenium-webdriver (3.6.0) childprocess (~> 0.5) rubyzip (~> 1.0) - websocket (~> 1.0) - simplecov (0.12.0) + simplecov (0.14.1) docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.2) sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) @@ -218,17 +225,20 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - stomp (1.4.3) + stomp (1.4.4) systemu (2.6.5) - term-ansicolor (1.4.0) + term-ansicolor (1.6.0) tins (~> 1.0) + text (1.3.1) thor (0.19.4) - thread_safe (0.3.5) + thread_safe (0.3.6) tilt (1.4.1) - tins (1.13.0) - uglifier (3.0.4) + tins (1.15.0) + tzinfo (1.2.3) + thread_safe (~> 0.1) + uglifier (3.2.0) execjs (>= 0.3.0, < 3) - unicorn (5.2.0) + unicorn (5.3.1) kgio (~> 2.6) raindrops (~> 0.7) web-console (2.3.0) @@ -236,8 +246,7 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - websocket (1.2.4) - xpath (2.0.0) + xpath (2.1.0) nokogiri (~> 1.3) PLATFORMS From 86ae428513a58a84cd5f651341bd3e31d3512747 Mon Sep 17 00:00:00 2001 From: Glennon Ng Date: Thu, 12 Oct 2017 14:56:19 -0700 Subject: [PATCH 14/16] move newrelic.yml --- newrelic.yml => config/newrelic.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename newrelic.yml => config/newrelic.yml (100%) diff --git a/newrelic.yml b/config/newrelic.yml similarity index 100% rename from newrelic.yml rename to config/newrelic.yml From 833e609e56b3021ed4929836e185a7bca773db8a Mon Sep 17 00:00:00 2001 From: Brad Jewell Date: Mon, 27 Nov 2017 16:57:48 -0600 Subject: [PATCH 15/16] add circleci, docker, gemfile --- .circleci/config.yml | 44 +++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 8 ++++++++ bin/build.sh | 8 ++++++++ enc_dashboard.gemspec | 13 ++++++++++--- 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 Dockerfile create mode 100755 bin/build.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0b495dd --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,44 @@ +version: 2 +jobs: + build: + docker: + - image: docker:git + + working_directory: /usr/src/app + + steps: + - checkout + - setup_remote_docker + - restore_cache: + keys: + - v1-{{ .Branch }} + paths: + - /caches/docker-image.tar + - run: + name: Load Docker image layer cache + command: | + set +o pipefail + docker load -i /caches/docker-image.tar | true + - run: + name: Build app Docker image + command: | + docker build --cache-from=ruby-enc -t ruby-enc --build-arg BUNDLE_GEM__FURY__IO=$BUNDLE_GEM__FURY__IO . + - run: + name: Save Docker image layer cache + command: | + mkdir -p /caches + docker save -o /caches/docker-image.tar ruby-enc + - save_cache: + key: v1-{{ .Branch }}-{{ epoch }} + paths: + - /caches/docker-image.tar + - run: + name: Build and upload gem + command: | + docker run \ + -e CIRCLE_BRANCH=${CIRCLE_BRANCH} \ + -e CIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM} \ + -e BUNDLE_GEM__FURY__IO=${BUNDLE_GEM__FURY__IO} \ + -e MAJOR_VERSION=${MAJOR_VERSION} \ + -e MINOR_VERSION=${MINOR_VERSION} \ + -it ruby-enc bin/build.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0f5a36 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ruby:2.3 + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +ARG BUNDLE_GEM__FURY__IO= + +COPY . /usr/src/app \ No newline at end of file diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..be89214 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e +set -x + +gem install fury +gem build end_dashboard.gemspec +fury push --as=moovweb --api-token=$BUNDLE_GEM__FURY__IO *.gem \ No newline at end of file diff --git a/enc_dashboard.gemspec b/enc_dashboard.gemspec index 0ea8095..02218c2 100644 --- a/enc_dashboard.gemspec +++ b/enc_dashboard.gemspec @@ -2,11 +2,19 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'enc_dashboard/version' +version_prefix = "#{ENV['MAJOR_VERSION']}.#{ENV['MINOR_VERSION']}." Gem::Specification.new do |gem| gem.name = "enc_dashboard" - gem.version = EncDashboard::VERSION + gem.version = if !ENV['CIRCLE_BUILD_NUM'].nil? && (ENV['CIRCLE_BUILD_NUM'] != '') + if ENV["CIRCLE_BRANCH"] != "master" + version_prefix + ENV["CIRCLE_BUILD_NUM"] + ".pre" + else + version_prefix + ENV["CIRCLE_BUILD_NUM"] + end + else + version_prefix + ENV.fetch("BUILD_NUMBER", "dev") + end gem.authors = ["Joshua B. Bussdieker"] gem.email = ["josh.bussdieker@moovweb.com"] gem.description = %q{Puppet dashboard replacement} @@ -17,7 +25,6 @@ Gem::Specification.new do |gem| gem.files << Dir[".bundle/**/*"] gem.files << Dir["vendor/**/*"] gem.files << Dir["public/**/*"] - gem.files << "JENKINS" gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] From ee2caf192e3da8f77dd1b453ff49e5cca798801b Mon Sep 17 00:00:00 2001 From: Brad Jewell Date: Mon, 27 Nov 2017 17:10:01 -0600 Subject: [PATCH 16/16] fix typo --- bin/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build.sh b/bin/build.sh index be89214..e6e9e8b 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -4,5 +4,5 @@ set -e set -x gem install fury -gem build end_dashboard.gemspec +gem build enc_dashboard.gemspec fury push --as=moovweb --api-token=$BUNDLE_GEM__FURY__IO *.gem \ No newline at end of file