Skip to content

Instantly share code, notes, and snippets.

View jrafanie's full-sized avatar

Joe Rafaniello jrafanie

  • New Jersey
View GitHub Profile
@jrafanie
jrafanie / debug_faraday_manageiq_api_client_request_in_workers.rb
Last active April 26, 2018 14:25
Debug faraday requests in ManageIQ
# put me in config/initializers
# restart your appliances and it should now log all the net/http interactions
# ***** WARNING *****
# do not run in production, set_debug_output has this warning in ruby docs:
# WARNING This method opens a serious security hole. Never use this method in production code.
require 'manageiq-api-client'
require 'faraday'
require 'faraday/adapter/net_http'
@jrafanie
jrafanie / vcr-webmock-2.rb
Created October 26, 2017 13:22 — forked from glaszig/vcr-webmock-2.rb
converts vcr cassettes to webmock 2.0-compatible format
# converts URIs in vcr cassettes from uri-based basic auth
# to header-based basic auth to be compatible with webmock 2.0.
# it will create a basic auth header with an ERB tag
# to keep user and password be editable.
#
# Authorization: Basic <%= Base64.encode64("user:password").chomp %>
#
# may not work if using VCR's filter_sensitive_data.
# in that case use https://gist.github.com/ujh/594c99385b6cbe92e32b1bbfa8578a45
#
@jrafanie
jrafanie / sexp_processor_4_9_0_vs_4_10_0.diff
Created October 2, 2017 15:15
Diff of sexp_processor 4.9.0 vs 4.10.0
diff --git a/sexp_processor-4.9.0/History.txt b/sexp_processor-4.10.0/History.txt
index b8e355f..23c21e2 100644
--- a/sexp_processor-4.9.0/History.txt
+++ b/sexp_processor-4.10.0/History.txt
@@ -1,3 +1,52 @@
+=== 4.10.0 / 2017-07-17
+
+* 2 major enhancements:
+
+ * Added experimental pattern matcher to Sexp. Forked from sexp_path.
@jrafanie
jrafanie / pgbouncer_setup.txt
Created July 7, 2017 16:17
initial setup of pgbouncer with manageiq
yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install pgbouncer
vim /etc/pgbouncer/pgbouncer.ini
[databases]
...
@jrafanie
jrafanie / update_settings.rb
Last active June 15, 2017 15:58
Change ManageIQ server settings from a single location
# 1) you'll need https://github.com/ManageIQ/manageiq/blob/master/tools/configure_server_settings.rb
# 2) copy this file to /var/www/miq/vmdb/tools
# 3) Then cd to vmdb via the 'vmdb' command alias
# 4) Create a list of miq_servers table ids for all of the target servers. I use 1000000000001 here.
# Or just do them all:
# ids = MiqServer.pluck(:id)
# 5) run this script in bin/rails console (if copy/paste works) or put this script into a file, update_settings.rb, in vmdb and run it using bin/rails r 'update_settings.rb'
# 6) Repeat this process for each region/database.
ids = %w(
@jrafanie
jrafanie / loaded_features.txt
Created June 12, 2017 19:32
$LOADED_FEATURES in generic worker after for do_work loop
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-automation_engine-0f8c8a48f536/lib/manageiq-automation_engine.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-content-706f32ca26b7/lib/manageiq-content.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/miq-xml.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/xml/miq_rexml.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/xml/xml_diff.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/xml/xml_hash.rb
@jrafanie
jrafanie / worker_creation
Created May 12, 2017 19:05
ManageIQ worker creation and start
...
MiqServer.start
...
server.start [1]
...
server.monitor_loop [2]
[1] server.start
deactivate/activate roles
monitor_servers and roles
# Logfile created on 2017-03-06 17:12:44 -0300 by logger.rb/56504
[----] D, [2017-03-06T17:12:44.556723 #19943:2afa865b1980] DEBUG -- : PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
[----] D, [2017-03-06T17:12:44.680628 #19943:2afa865b1980] DEBUG -- : MiqServer Load (0.6ms) SELECT "miq_servers".* FROM "miq_servers" WHERE "miq_servers"."guid" = $1 LIMIT $2 [["guid", "dc4343be-02a7-11e7-a1b2-0242a89f1cd9"], ["LIMIT", 1]]
[----] D, [2017-03-06T17:12:44.750165 #19943:2afa865b1980] DEBUG -- :  (0.2ms) SELECT last_value FROM miq_databases_id_seq
[----] D, [2017-03-06T17:12:44.755576 #19943:2afa865b1980] DEBUG -- : MiqRegion Load (0.4ms) SELECT "miq_regions".* FROM "miq_regions" WHERE "miq_regions"."region" = $1 LIMIT $2 [["region", 0], ["LIMIT", 1]]
[----] D, [2017-03-06T17:12:44.789966 #19943:2afa865b1980] DEBUG -- : SettingsChange Load (0.4ms)
@jrafanie
jrafanie / AAA_output.log
Last active March 24, 2017 17:30
bundler 1.14.x issue resolving correct sys-proctable platform
01:28:55 ~/Code/new_project (2.4.1) + ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin15]
01:28:58 ~/Code/new_project (2.4.1) + bundle --version
Bundler version 1.14.6
01:29:00 ~/Code/new_project (2.4.1) + gem list sys-proctable
*** LOCAL GEMS ***
# ~/.rubies/ruby-compact/lib/ruby/gems/2.5.0/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb
def fork(nakayoshi: true, cow_friendly: true, &b)
if nakayoshi && cow_friendly
h = {}
4.times{ # maximum 4 times
GC.stat(h)
live_slots = h[:heap_live_slots] || h[:heap_live_slot]
old_objects = h[:old_objects] || h[:old_object]
remwb_unprotects = h[:remembered_wb_unprotected_objects] || h[:remembered_shady_object]
young_objects = live_slots - old_objects - remwb_unprotects