[PATCH conductor] BZ#800242 Export events for a single instance display the events of all other instances too.
by Tomas Hrcka
Added restful submit button, controller action and transtalions to enable
selection of instances for event exportation.
---
src/app/controllers/instances_controller.rb | 11 +++++++++++
src/app/views/instances/_list.html.haml | 3 ++-
src/config/locales/en.yml | 2 ++
src/config/routes.rb | 1 +
src/public/javascripts/application.js | 2 +-
5 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/instances_controller.rb b/src/app/controllers/instances_controller.rb
index 7773d81..6d45b39 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -175,6 +175,17 @@ class InstancesController < ApplicationController
:filename => "export.csv")
end
+ def export_selected_events
+ if params[:instance_selected].present?
+ send_data(Instance.csv_export(Instance.find(params[:instance_selected] || [])),
+ :type => 'text/csv; charset=utf-8; header=present',
+ :filename => "export.csv")
+ else
+ flash[:error] = t('instances.none_selected_to_export_events')
+ redirect_to params[:backlink] || pools_path(:view => 'filter', :details_tab => 'instances')
+ end
+ end
+
def stop
if @inaccessible_instances.include?(@instance)
do_operation(:forced_stop)
diff --git a/src/app/views/instances/_list.html.haml b/src/app/views/instances/_list.html.haml
index dac5d69..39276dc 100644
--- a/src/app/views/instances/_list.html.haml
+++ b/src/app/views/instances/_list.html.haml
@@ -1,11 +1,12 @@
- content_for :form_header do
%li= restful_submit_tag t('instances.list.stop_selected_instances'), 'stop', multi_stop_instances_path, 'GET', :class => 'button', :id => 'stop_selected_instances', 'data-none_selected' => t('instances.none_selected')
%li= restful_submit_tag t('instances.list.reboot_selected_instances'), 'reboot', multi_reboot_instances_path, 'GET', :class => 'button', :id => 'reboot_selected_instances', 'data-none_selected' => t('instances.none_selected_to_reboot')
+ %li= restful_submit_tag t('instances.list.export_events'), 'export', export_selected_events_instances_path, 'GET', :class => 'button', :id => 'export_selected_instances_events', 'data-none_selected' => t('instances.none_selected_to_export_events')
%li.more_actions
%span
= image_tag "more_actions_drop.png"
%ul
- %li= link_to "#{t'instances.list.export_events'}", export_events_instances_path(:deployment_id => @deployment)
+ %li= link_to "#{t'instances.list.export_all_events'}", export_events_instances_path(:deployment_id => @deployment)
= hidden_field_tag 'backlink', request.url
- content_for :filter_controls do
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index a3044ad..1154786 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -299,12 +299,14 @@ en:
instance: Instance
none_selected: "You must select one or more instances to stop."
none_selected_to_reboot: "You must select one or more instances to reboot."
+ none_selected_to_export_events: "You must select one or more instances to export events."
tab_captions:
properties: Properties
history: History
permissions: Permissions
list:
export_events: Export events
+ export_all_events: Export all events
stop_selected_instances: Stop selected instances
reboot_selected_instances: Reboot selected instances
stopped_instances_hidden: Stopped instances are hidden
diff --git a/src/config/routes.rb b/src/config/routes.rb
index a95389f..2199911 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -115,6 +115,7 @@ Conductor::Application.routes.draw do
collection do
get 'multi_stop'
get 'multi_reboot'
+ get 'export_selected_events'
get 'remove_failed'
get 'export_events'
post 'filter'
diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js
index f4054fb..6784101 100644
--- a/src/public/javascripts/application.js
+++ b/src/public/javascripts/application.js
@@ -118,7 +118,7 @@ $.extend(Conductor, {
},
multiActionValidation: function() {
- $('#delete_button, #revoke_button, #stop_button, #stop_selected_instances, #reboot_selected_instances').live('click', function(e) {
+ $('#delete_button, #revoke_button, #stop_button, #stop_selected_instances, #reboot_selected_instances, #export_selected_instances_events').live('click', function(e) {
var $checkbox_table = $(this).closest("form.filterable-data").find("table.checkbox_table");
var confirm_message = $checkbox_table.data('confirm');
--
1.7.1
11 years, 11 months
[PATCH configure] RM 3181 - delayed_job support
by Richard Su
Start and stop conductor-delayed_job service with aeolus-configure
and aeolus-cleanup.
---
recipes/aeolus/manifests/conductor.pp | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/recipes/aeolus/manifests/conductor.pp b/recipes/aeolus/manifests/conductor.pp
index f06ae16..528e5ce 100644
--- a/recipes/aeolus/manifests/conductor.pp
+++ b/recipes/aeolus/manifests/conductor.pp
@@ -62,7 +62,8 @@ class aeolus::conductor inherits aeolus {
}
service { ['aeolus-conductor',
- 'conductor-dbomatic' ]:
+ 'conductor-dbomatic',
+ 'conductor-delayed_job']:
ensure => 'running',
enable => true,
hasstatus => true,
@@ -158,7 +159,8 @@ class aeolus::conductor::disabled {
require => Service['aeolus-conductor',
'conductor-dbomatic'] }
service { ['aeolus-conductor',
- 'conductor-dbomatic']:
+ 'conductor-dbomatic',
+ 'conductor-delayed_job']:
ensure => 'stopped',
enable => false,
hasstatus => true }
--
1.7.7.6
11 years, 11 months
[PATCH conductor] RM 3181 - delayed_job support
by Richard Su
Add delayed_job version 2.1.4 back into our environment: db migration,
initializer, and script.
Created systemd configuration file. Spec file installs config file into
/lib/systemd/system.
The service is named conductor-delayed_job and can be controlled through
either of these two commands:
"systemctl start/stop/status conductor-delayed_job.service"
"service conductor-delayed_job start/stop/status"
Service brings up 2 workers to process the queue.
---
aeolus-conductor.spec.in | 28 +++++++++++++++
conf/conductor-delayed_job.systemd | 16 ++++++++
src/Gemfile | 1 +
src/config/initializers/delayed_job.rb | 9 +++++
.../migrate/20110124103216_create_delayed_jobs.rb | 37 --------------------
.../migrate/20120423224618_create_delayed_jobs.rb | 21 +++++++++++
src/script/delayed_job | 5 +++
7 files changed, 80 insertions(+), 37 deletions(-)
create mode 100644 conf/conductor-delayed_job.systemd
create mode 100644 src/config/initializers/delayed_job.rb
delete mode 100644 src/db/migrate/20110124103216_create_delayed_jobs.rb
create mode 100644 src/db/migrate/20120423224618_create_delayed_jobs.rb
create mode 100755 src/script/delayed_job
diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in
index 3008b0c..dcd60f1 100644
--- a/aeolus-conductor.spec.in
+++ b/aeolus-conductor.spec.in
@@ -38,6 +38,7 @@ Requires: rubygem(pg)
Requires: rubygem(ruby-net-ldap)
Requires: rubygem(oauth)
Requires: rubygem(rake)
+Requires: rubygem(delayed_job) >= 2.1.4
Requires: postgresql
Requires: postgresql-server
Requires: system-logos
@@ -63,6 +64,10 @@ Requires: rubygem(thin) >= 1.2.5
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+
%description daemons
The configuration and daemons necessary to run and proxy the Aeolus Conductor.
@@ -137,6 +142,7 @@ getent passwd aeolus >/dev/null || \
%{__mkdir} -p %{buildroot}%{app_root}
%{__mkdir} -p %{buildroot}%{doc_root}
%{__mkdir} -p %{buildroot}%{_initrddir}
+%{__mkdir} -p %{buildroot}%{_unitdir}/systemd/system
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
%{__mkdir} -p %{buildroot}%{_sysconfdir}/httpd/conf.d
%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
@@ -247,6 +253,7 @@ done
# copy over init scripts and various config
%{__cp} conf/aeolus-conductor %{buildroot}%{_initrddir}
%{__cp} conf/conductor-dbomatic %{buildroot}%{_initrddir}
+%{__cp} conf/conductor-delayed_job.systemd %{buildroot}%{_unitdir}/conductor-delayed_job.service
%{__cp} conf/aeolus-conductor-httpd.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/aeolus-conductor.conf
%{__cp} conf/aeolus-conductor.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/aeolus-conductor
%{__cp} conf/aeolus-conductor.sysconf %{buildroot}%{_sysconfdir}/sysconfig/aeolus-conductor
@@ -265,6 +272,10 @@ touch %{buildroot}%{_localstatedir}/log/%{name}/rails.log
touch %{buildroot}%{_localstatedir}/log/%{name}/dbomatic.log
%{__mkdir} -p %{buildroot}%{app_root}/log
+# delayed_job version 2.1.4 forces the log to be in this location
+# we should be able to change this to /var/log/aeolus-conductor/delayed_job.log
+# with version 3.0
+touch %{buildroot}%{app_root}/log/delayed_job.log
# copy script files over
%{__cp} -r src/script %{buildroot}%{app_root}
@@ -304,18 +315,33 @@ if [ ! -d %{app_root}/app ]; then
fi
%post daemons
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1
+fi
# Register the services
/sbin/chkconfig --add aeolus-conductor
/sbin/chkconfig --add conductor-dbomatic
%preun daemons
if [ $1 = 0 ]; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable conductor-delayed_job.service > /dev/null 2>&1
+ /bin/systemctl stop conductor-delayed_job.service > /dev/null 2>&1
/sbin/service aeolus-conductor stop > /dev/null 2>&1
/sbin/chkconfig --del aeolus-conductor
/sbin/service conductor-dbomatic stop > /dev/null 2>&1
/sbin/chkconfig --del conductor-dbomatic
fi
+%postun daemons
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart conductor-delayed_job.service >/dev/null 2>&1
+fi
+
+
%files
%dir %{app_root}
%{app_root}/app
@@ -344,6 +370,7 @@ fi
%files daemons
%{_initrddir}/aeolus-conductor
%{_initrddir}/conductor-dbomatic
+%{_unitdir}/conductor-delayed_job.service
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/aeolus-conductor
%config(noreplace) %{_sysconfdir}/sysconfig/conductor-rails
@@ -351,6 +378,7 @@ fi
%attr(-, aeolus, aeolus) %{_localstatedir}/lib/%{name}
%attr(-, aeolus, aeolus) %{_localstatedir}/run/%{name}
%attr(-, aeolus, aeolus) %{_localstatedir}/log/%{name}
+%attr(-, aeolus, aeolus) %{app_root}/log/delayed_job.log
%doc AUTHORS COPYING
%{_libdir}/../lib/tmpfiles.d/aeolus.conf
diff --git a/conf/conductor-delayed_job.systemd b/conf/conductor-delayed_job.systemd
new file mode 100644
index 0000000..6c1fc55
--- /dev/null
+++ b/conf/conductor-delayed_job.systemd
@@ -0,0 +1,16 @@
+[Unit]
+Description=aeolus delayed_job
+After=syslog.target
+After=postgresql.service
+
+[Service]
+Type=forking
+User=aeolus
+Environment=RAILS_ENV=production
+WorkingDirectory=/usr/share/aeolus-conductor/
+ExecStart=/usr/share/aeolus-conductor/script/delayed_job start -n 2 --pid-dir=/var/run/aeolus-conductor
+ExecStop=/usr/share/aeolus-conductor/script/delayed_job stop --pid-dir=/var/run/aeolus-conductor
+TimeoutSec=120
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/src/Gemfile b/src/Gemfile
index 529d658..ca7eb59 100644
--- a/src/Gemfile
+++ b/src/Gemfile
@@ -23,6 +23,7 @@ gem 'rails_warden'
gem 'ruby-net-ldap'
gem 'aeolus-image'
gem 'oauth'
+gem 'delayed_job'
group :development, :test do
gem 'rspec-rails'
gem 'rspec-core'
diff --git a/src/config/initializers/delayed_job.rb b/src/config/initializers/delayed_job.rb
new file mode 100644
index 0000000..6e0d177
--- /dev/null
+++ b/src/config/initializers/delayed_job.rb
@@ -0,0 +1,9 @@
+require 'delayed_job'
+
+Delayed::Worker.backend = :active_record
+Delayed::Worker.destroy_failed_jobs = false
+#Delayed::Worker.sleep_delay = 60
+Delayed::Worker.max_attempts = 2
+#Delayed::Worker.max_run_time = 5.minutes
+#Delayed::Worker.read_ahead = 10
+#Delayed::Worker.delay_jobs = !Rails.env.test?
diff --git a/src/db/migrate/20110124103216_create_delayed_jobs.rb b/src/db/migrate/20110124103216_create_delayed_jobs.rb
deleted file mode 100644
index d280b57..0000000
--- a/src/db/migrate/20110124103216_create_delayed_jobs.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-class CreateDelayedJobs < ActiveRecord::Migration
- def self.up
- create_table :delayed_jobs, :force => true do |table|
- table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
- table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
- table.text :handler # YAML-encoded string of the object that will do work
- table.text :last_error # reason for last failure (See Note below)
- table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
- table.datetime :locked_at # Set when a client is working on this object
- table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
- table.string :locked_by # Who is working on this object (if locked)
- table.timestamps
- end
-
- add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
- end
-
- def self.down
- drop_table :delayed_jobs
- end
-end
diff --git a/src/db/migrate/20120423224618_create_delayed_jobs.rb b/src/db/migrate/20120423224618_create_delayed_jobs.rb
new file mode 100644
index 0000000..943ff9b
--- /dev/null
+++ b/src/db/migrate/20120423224618_create_delayed_jobs.rb
@@ -0,0 +1,21 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+ def self.up
+ create_table :delayed_jobs, :force => true do |table|
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
+ table.text :handler # YAML-encoded string of the object that will do work
+ table.text :last_error # reason for last failure (See Note below)
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
+ table.datetime :locked_at # Set when a client is working on this object
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
+ table.string :locked_by # Who is working on this object (if locked)
+ table.timestamps
+ end
+
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
+ end
+
+ def self.down
+ drop_table :delayed_jobs
+ end
+end
diff --git a/src/script/delayed_job b/src/script/delayed_job
new file mode 100755
index 0000000..edf1959
--- /dev/null
+++ b/src/script/delayed_job
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require 'delayed/command'
+Delayed::Command.new(ARGV).daemonize
--
1.7.7.6
11 years, 11 months
Working with EC2 when you're behind a corp http proxy...
by Justin Clift
Hi Ian/Steve,
Have either of you looked at using Corkscrew for passing ssh traffic over
a http proxy? (ie to do the initial build setup of vm in EC2)
http://www.agroman.net/corkscrew/
A potential cloud partner, actively looking to add support for their Cloud
platform to Aeolus, is hitting the lack-of-proxy-support problem when trying
things out. (their entire corp environment works from behind a http proxy)
I'm kind of thinking we might be able to get something working using
Corkscrew + some clever coding. Would like your thoughts on this if you've
already been down this path? :)
Regards and best wishes,
Justin Clift
--
Aeolus Community Manager
http://www.aeolusproject.org
11 years, 11 months