Skip to content

Instantly share code, notes, and snippets.

View iNecas's full-sized avatar
💭
Happy hacking 👨 ⌨️ 💻

Ivan Necas iNecas

💭
Happy hacking 👨 ⌨️ 💻
View GitHub Profile
@iNecas
iNecas / convention-foreign-keys.php
Created February 10, 2011 22:37
Convention foreign keys: plugin for Adminer (http://www.adminer.org)
<?php
/** Convention foreign keys: plugin for Adminer
* Links for foreign keys by convention user_id => users.id. Useful for Ruby On Rails like standard schema conventions.
* @author Ivan Nečas, @inecas
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class ConventionForeignKeys {
@iNecas
iNecas / dynflow_throughput_monitor.rb
Last active August 23, 2017 13:54
dynflow message throughput monitor
# usage
#
# 1) copy the monitory to be loaded by satellite
#
# cp dynflow_throughput_monitor.rb /usr/share/foreman/config/initializers
# service foreman-tasks restart
#
# 2) grab the collected data to be shared with engineering:
#
# tar cvf dynflow_thoughput_monitor.tar /var/log/foreman/dynflow_throughput_monitor.log*
@iNecas
iNecas / pry-remote-setup.txt
Created July 31, 2017 12:27
pry-remote-setup
scl enable tfm bash
gem install pry-remote
setenforce 0
# in code:
# require 'pry-remote'; binding.remote_pry
$(dirname $(gem which pry-remote))/../bin/pry-remote
@iNecas
iNecas / foreman_tasks_extract_data.rb
Created June 26, 2017 15:13
Get raw action data from task in JSON format.
# Get raw action data from task in JSON format.
#
# usage:
#
# TASK_IDS="TASK_ID_1,TASK_ID_2" \
# foreman-rake console 2>/dev/null < foreman_tasks_extract_data.rb | \
# grep "^OUT: " | sed "s/^OUT: //g"
task_ids = ENV['TASK_IDS'].split(',').map(&:strip)
@iNecas
iNecas / dynflow_increase_workers.sh
Last active May 10, 2017 19:06
Increase number of workers for dynflow in Foreman
cat <<EOF > /usr/share/foreman/config/initializers/foreman_tasks_workers_bump.rb
workers_count = 10
Rails.logger.info("Bumping the number of dynflow worksers to #{workers_count}")
ForemanTasks.dynflow.config.pool_size = workers_count
ForemanTasks.dynflow.config.db_pool_size = workers_count + 5
EOF
service foreman-tasks restart
@iNecas
iNecas / sat61_tasks_cleaner.rb
Created March 8, 2017 11:52
sat61_tasks_cleaner.rb
# Usage:
# 1. edit the TASK_SEARCH and AFTER values
# 2. run `foreman-rake console < sat61_tasks_cleaner.rb`
TASK_SEARCH=''
AFTER='30d'
module ForemanTasks
# Represents the cleanup mechanism for tasks
class Cleaner
diff --git a/lib/dynflow/action/with_bulk_sub_plans.rb b/lib/dynflow/action/with_bulk_sub_plans.rb
index dbff3a2..9dae0e2 100644
--- a/lib/dynflow/action/with_bulk_sub_plans.rb
+++ b/lib/dynflow/action/with_bulk_sub_plans.rb
@@ -9,6 +9,17 @@ module Dynflow
raise NotImplementedError
end
+ PlanNextBatch = Algebrick.atom
+
@iNecas
iNecas / rex-in-batch.patch
Created February 24, 2017 00:01
rex-in-batch.patch
diff --git a/app/lib/actions/remote_execution/run_hosts_job.rb b/app/lib/actions/remote_execution/run_hosts_job.rb
index 40dd320..c146ea8 100644
--- a/app/lib/actions/remote_execution/run_hosts_job.rb
+++ b/app/lib/actions/remote_execution/run_hosts_job.rb
@@ -25,7 +25,7 @@ module Actions
job_invocation = JobInvocation.find(input[:job_invocation_id])
proxy_selector = RemoteExecutionProxySelector.new
- ::Host.where(:id => current_batch).map do |host|
+ current_batch.map do |host|
@iNecas
iNecas / bundler.d-Gemfile.local.rb
Last active September 6, 2016 20:14
smart-proxy-ansible devel setup
gem 'smart_proxy_dynflow', :git => 'git@github.com:iNecas/smart_proxy_dynflow.git', :branch => 'integrate-foreman-tasks-core'
gem 'smart_proxy_dynflow_core', :git => 'git@github.com:iNecas/smart_proxy_dynflow.git', :branch => 'integrate-foreman-tasks-core'
gem 'foreman-tasks-core', :git => 'git@github.com:iNecas/foreman-tasks.git', :branch => 'foreman-tasks-core'
gem 'smart_proxy_ansible', :git => 'git@github.com:iNecas/smart_proxy_ansible.git', :branch => 'ansible-run-rebase'
gem 'foreman_ansible_core', :git => 'git@github.com:iNecas/foreman_ansible.git', :branch => 'run-via-proxy'
@iNecas
iNecas / resume_missing_pulp_task.rb
Created May 5, 2016 15:34
resume_missing_pulp_task.rb
cat <<EOF | foreman-rake console
@world = ForemanTasks.dynflow.world
@persistence = @world.persistence
def reset_pulp_task(uuid)
execution_plan = @persistence.load_execution_plan(uuid)
raise 'execution plan #{execution_plan} is not paused' unless execution_plan.state == :paused
active_steps = execution_plan.steps_in_state(:running, :suspended, :error)
active_steps.each do |step|
action = step.action(execution_plan)