Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F1969836
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 17, 10:50 AM
Size
16 KB
Mime Type
text/x-diff
Expires
Tue, May 19, 10:50 AM (21 h, 45 m)
Engine
blob
Format
Raw Data
Handle
385281
Attached To
rWEBDNS WebDNS (edet4)
View Options
diff --git a/Gemfile b/Gemfile
index c233588..c912921 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,61 +1,62 @@
source 'https://rubygems.org'
group :development, :test do
gem 'pry-byebug'
end
group :development do
gem 'rubocop', '0.35', require: false
gem 'yard'
gem 'yard-tomdoc'
gem 'guard-yard'
gem 'guard-minitest', require: false
gem 'guard', require: false
gem 'capistrano', '3.2.1', require: false # pkg:capistrano
end
group :production do
gem 'unicorn' # pkg:unicorn
end
group :assets do
gem 'coffee-rails', '4.0.1' # pkg: ryby-coffee-rails
end
# Lock jessie versions
#
gem 'rails', '4.1.8' # pkg:rails
gem 'i18n', '0.6.9'
gem 'json', '1.8.1'
gem 'mail', '2.6.1'
gem 'mime-types', '1.25'
gem 'minitest', '5.4.2'
gem 'rack', '1.5.2'
gem 'rack-test', '0.6.2'
gem 'rake', '10.3.2'
gem 'sprockets', '2.12.3'
gem 'sprockets-rails', '2.1.3'
gem 'thread_safe', '0.3.3'
gem 'tzinfo', '1.1.0'
+gem 'will_paginate', '3.0.5'
gem 'mysql2', '0.3.16' # pkg:ruby-mysql2
gem 'jquery-rails', '3.1.2' # pkg:ruby-jquery-rails
gem 'state_machine', '1.2.0' # pkg: ruby-state-machine
gem 'nokogiri', '1.6.3'
# Worker
gem 'faraday', '0.9.0'
gem 'faraday_middleware', '0.9.1'
# Devise & dependencies
gem 'devise', '3.5.2' # pkg:ruby-devise
gem 'warden', '1.2.3'
gem 'bcrypt', '3.1.7'
gem 'orm_adapter', '0.5.0'
gem 'responders', '1.1.2'
group :test do
gem 'factory_girl_rails', '4.4.1'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index ccc4bf9..a8a4e1c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,232 +1,234 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.1.8)
actionpack (= 4.1.8)
actionview (= 4.1.8)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.8)
actionview (= 4.1.8)
activesupport (= 4.1.8)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.8)
activesupport (= 4.1.8)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.8)
activesupport (= 4.1.8)
builder (~> 3.1)
activerecord (4.1.8)
activemodel (= 4.1.8)
activesupport (= 4.1.8)
arel (~> 5.0.0)
activesupport (4.1.8)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
ast (2.1.0)
astrolabe (1.3.1)
parser (~> 2.2)
bcrypt (3.1.7)
builder (3.2.2)
byebug (4.0.5)
columnize (= 0.9.0)
capistrano (3.2.1)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
colorize (0.7.7)
columnize (0.9.0)
devise (3.5.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.6.0)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.4.1)
factory_girl (~> 4.4.0)
railties (>= 3.0.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.10)
formatador (0.2.5)
guard (2.13.0)
formatador (>= 0.2.4)
listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-minitest (2.4.4)
guard-compat (~> 1.2)
minitest (>= 3.0)
guard-yard (2.1.4)
guard (>= 1.1.0)
yard (>= 0.7.0)
hike (1.2.3)
i18n (0.6.9)
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
kgio (2.9.3)
listen (3.0.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
mail (2.6.1)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (1.25)
mini_portile (0.6.0)
minitest (5.4.2)
multi_json (1.11.2)
multipart-post (2.0.0)
mysql2 (0.3.16)
nenv (0.2.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
nokogiri (1.6.3)
mini_portile (= 0.6.0)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0)
parser (2.2.3.0)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.1.0)
byebug (~> 4.0)
pry (~> 0.10)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.1.8)
actionmailer (= 4.1.8)
actionpack (= 4.1.8)
actionview (= 4.1.8)
activemodel (= 4.1.8)
activerecord (= 4.1.8)
activesupport (= 4.1.8)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.8)
sprockets-rails (~> 2.0)
railties (4.1.8)
actionpack (= 4.1.8)
activesupport (= 4.1.8)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
raindrops (0.15.0)
rake (10.3.2)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
rubocop (0.35.0)
astrolabe (~> 1.3)
parser (>= 2.2.3.0, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
ruby-progressbar (1.7.5)
shellany (0.0.1)
slop (3.6.0)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
state_machine (1.2.0)
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
tomparse (0.4.2)
tzinfo (1.1.0)
thread_safe (~> 0.1)
unicorn (4.9.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
warden (1.2.3)
rack (>= 1.0)
+ will_paginate (3.0.5)
yard (0.8.7.6)
yard-tomdoc (0.7.1)
tomparse (>= 0.4.0)
yard
PLATFORMS
ruby
DEPENDENCIES
bcrypt (= 3.1.7)
capistrano (= 3.2.1)
coffee-rails (= 4.0.1)
devise (= 3.5.2)
factory_girl_rails (= 4.4.1)
faraday (= 0.9.0)
faraday_middleware (= 0.9.1)
guard
guard-minitest
guard-yard
i18n (= 0.6.9)
jquery-rails (= 3.1.2)
json (= 1.8.1)
mail (= 2.6.1)
mime-types (= 1.25)
minitest (= 5.4.2)
mysql2 (= 0.3.16)
nokogiri (= 1.6.3)
orm_adapter (= 0.5.0)
pry-byebug
rack (= 1.5.2)
rack-test (= 0.6.2)
rails (= 4.1.8)
rake (= 10.3.2)
responders (= 1.1.2)
rubocop (= 0.35)
sprockets (= 2.12.3)
sprockets-rails (= 2.1.3)
state_machine (= 1.2.0)
thread_safe (= 0.3.3)
tzinfo (= 1.1.0)
unicorn
warden (= 1.2.3)
+ will_paginate (= 3.0.5)
yard
yard-tomdoc
diff --git a/app/controllers/admin/jobs_controller.rb b/app/controllers/admin/jobs_controller.rb
index 486203d..7a00a10 100644
--- a/app/controllers/admin/jobs_controller.rb
+++ b/app/controllers/admin/jobs_controller.rb
@@ -1,43 +1,43 @@
module Admin
class JobsController < ApplicationController
before_action :authenticate_user!
before_action :admin_only!
before_action :job, only: [:destroy, :update]
# GET /jobs
def index
@job_categories = {
- 'Pending' => Job.includes(:domain).pending,
- 'Completed' => Job.includes(:domain).completed.order('id desc')
+ 'Pending' => Job.includes(:domain).pending.page(params[:page]),
+ 'Completed' => Job.includes(:domain).completed.order('id desc').page(params[:page])
}
@category = params[:category] || 'pending'
end
# DELETE /jobs/1
def destroy
@job.destroy
redirect_to admin_jobs_url, notice: "#{@job.id} was successfully destroyed."
end
# PUT /jobs/1
def update
if @job.update(job_params)
redirect_to admin_jobs_url, notice: 'Job was successfully updated.'
else
render :edit
end
end
private
def job
@job = Job.find(params[:id])
end
def job_params
params.require(:job).permit(:status)
end
end
end
diff --git a/app/models/job.rb b/app/models/job.rb
index 5aa81cd..6ebd99c 100644
--- a/app/models/job.rb
+++ b/app/models/job.rb
@@ -1,145 +1,147 @@
class Job < ActiveRecord::Base
belongs_to :domain
scope :pending, -> { where(status: 0) }
scope :failed, -> { where(status: 2) }
scope :completed, -> { where(status: [1, 2]) }
+ self.per_page = 100
+
def failed?
status == 2
end
def done?
status == 1
end
def pending?
status == 0
end
def arguments
JSON.parse(args)
end
def zone
return domain.name if domain
arguments['zone']
end
def run_event!
args = arguments
raise 'Not an event!' unless args['event']
Domain
.find_by_name(args['zone'])
.fire_state_event(args['event'])
self.status = 1
self.save!
end
class << self
def add_domain(domain)
ActiveRecord::Base.transaction do
jobs_for_domain(domain, :add_domain)
trigger_event(domain, :installed)
end
end
def shutdown_domain(domain)
ActiveRecord::Base.transaction do
job_for_domain(domain, :remove_domain)
job_for_domain(domain, :opendnssec_remove) if domain.dnssec?
trigger_event(domain, :cleaned_up)
end
end
def dnssec_sign(domain)
ActiveRecord::Base.transaction do
job_for_domain(domain, :opendnssec_add, policy: domain.dnssec_policy.name)
job_for_domain(domain, :bind_convert_to_dnssec)
trigger_event(domain, :signed)
end
end
def wait_for_ready(domain)
jobs_for_domain(domain,
:wait_for_ready_to_push_ds)
end
def dnssec_push_ds(domain, dss)
opts = Hash[:dnssec_parent, domain.dnssec_parent,
:dnssec_parent_authority, domain.dnssec_parent_authority,
:dss, dss]
keytag = dss.map { |ds| ds.split.first }.first # Both records should have the same keytag
ActiveRecord::Base.transaction do
job_for_domain(domain, :publish_ds, opts)
job_for_domain(domain, :wait_for_active, keytag: keytag)
trigger_event(domain, :converted)
end
end
def dnssec_rollover_ds(domain, dss)
opts = Hash[:dnssec_parent, domain.dnssec_parent,
:dnssec_parent_authority, domain.dnssec_parent_authority,
:dss, dss]
keytag = dss.map { |ds| ds.split.first }.first # Both records should have the same keytag
ActiveRecord::Base.transaction do
job_for_domain(domain, :publish_ds, opts)
job_for_domain(domain, :wait_for_active, keytag: keytag)
trigger_event(domain, :complete_rollover)
end
end
def dnssec_drop_ds(domain)
opts = Hash[:dnssec_parent, domain.dnssec_parent,
:dnssec_parent_authority, domain.dnssec_parent_authority,
:dss, []]
ActiveRecord::Base.transaction do
job_for_domain(domain, :publish_ds, opts)
# Wait for the change to propagate
job_for_domain(domain, :wait_until, until: Time.now.to_i + WebDNS.settings[:dnssec_ds_removal_sleep])
trigger_event(domain, :remove)
end
end
def convert_to_plain(domain)
ActiveRecord::Base.transaction do
jobs_for_domain(domain,
:remove_domain,
:add_domain,
:opendnssec_remove)
trigger_event(domain, :converted)
end
end
private
def trigger_event(domain, event)
job_for_domain(domain, :trigger_event, event: event)
end
def jobs_for_domain(domain, *job_names)
job_names.each { |job_name| job_for_domain(domain, job_name) }
end
def job_for_domain(domain, job_name, args = {})
args = { zone: domain.name }.merge!(args)
create!(domain: domain, job_type: job_name, args: args.to_json)
end
end
end
diff --git a/app/views/admin/jobs/index.html.erb b/app/views/admin/jobs/index.html.erb
index d2b4434..ea93984 100644
--- a/app/views/admin/jobs/index.html.erb
+++ b/app/views/admin/jobs/index.html.erb
@@ -1,55 +1,57 @@
<ul class="nav nav-tabs">
<% @job_categories.each_with_index do |pair, idx| %>
<% title, jobs = pair %>
<% active = title.downcase == @category.try(:to_s) %>
<li role="presentation" class="<%= 'active' if active %>"><a data-toggle="tab" href="#<%= title.downcase %>"><%= title %></a></li>
<% end %>
</ul>
<div class="tab-content">
<% @job_categories.each_with_index do |pair, idx| %>
<% title, jobs = pair %>
<% active = title.downcase == @category.try(:to_s) %>
<div role="tabpanel" class="tab-pane <%= 'active' if active %>" id="<%= title.downcase %>">
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Created at</th>
<th>Domain</th>
<th>Type</th>
<th>Args</th>
<th>Retries</th>
<th colspan="2">Controls</th>
</tr>
</thead>
<tbody>
<% jobs.each do |job| %>
<tr class="<%= 'danger' if job.failed? %>">
<td><%= job.id %></td>
<td><%= job.created_at %></td>
<% if job.domain %>
<td><%= link_to job.domain.name, domain_path(job.domain) %></td>
<% else %>
<td><%= job.arguments['zone'] %></td>
<% end %>
<td><%= job.job_type %></td>
<% if job.args.size > 70 %>
<td data-toggle="tooltip" data-placement="right" title="<%= job.args %>"><%= truncate(job.args, length: 70) %></td>
<% else %>
<td><%= job.args %></td>
<% end %>
<td><%= job.retries %></td>
<td>
<%= link_to('done', done_admin_job_path(job), method: :put) unless job.done? %>
<%= link_to('pending', pending_admin_job_path(job), method: :put) if job.failed? %>
</td>
<td><%= link_to_destroy admin_job_path(job), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
+ <%= will_paginate jobs, params: { category: title.downcase } %>
</div>
+
<% end %>
</div>
diff --git a/config/application.rb b/config/application.rb
index b79d38a..79d9556 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,42 +1,43 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Production doesn't use bundler
# you've limited to :test, :development, or :production.
if ENV['RAILS_ENV'] != 'production'
Bundler.require(*Rails.groups)
else
# Dependencies to load before starting rails in production
require 'devise'
require 'jquery-rails'
require 'coffee-rails'
require 'state_machine'
require 'nokogiri'
+ require 'will_paginate'
end
module WebDNS
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.time_zone = 'Europe/Athens'
# Store/Read localtime from the database
config.active_record.default_timezone = :local
config.active_record.schema_format = :sql
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.autoload_paths << Rails.root.join('lib')
config.x = {}
end
def self.settings
Application.config.x
end
end
Event Timeline
Log In to Comment