Skip to content

Instantly share code, notes, and snippets.

Setup the OS for provisioning
1) Hosts -> Operating Systems
Create a new operating system ->
Name: Centos-Atomic
Major: 7
Arch: x86_64
Family: Redhat
import itertools
def sargam(notes):
return ["".join(notes[index] for index in combi) for combi in itertools.permutations(range(len(notes)), len(notes))]
#usage
#print sargam("SRGM")
# ['SRGM', 'SRMG', 'SGRM', 'SGMR', 'SMRG', 'SMGR', 'RSGM', 'RSMG', 'RGSM', 'RGMS', 'RMSG', 'RMGS', 'GSRM', 'GSMR', 'GRSM', 'GRMS', 'GMSR', 'GMRS', 'MSRG', 'MSGR', 'MRSG', 'MRGS', 'MGSR', 'MGRS']
[atomic7-testing]
name=atomic7-testing
baseurl=http://buildlogs.centos.org/centos/7/atomic/x86_64/Packages/
gpgcheck=0
enabled=1
#!/usr/bin/env bash
for file in $@
do
echo $file,`sha256sum $file | awk '{ print $1 }'`,`stat -c '%s' $file`
done
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
CONTENTS = <<-EOS
Listen %{port} https
<VirtualHost *:%{port}>
ProxyPass / https://%{ip_address}/
<Location />
ProxyPassReverse https://%{ip_address}/
#!/usr/bin/env ruby
require 'libvirt'
conn = Libvirt::open("qemu:///system")
networks = conn.list_all_networks
puts networks.map {|net| net.dhcp_leases.first["ipaddr"] unless net.dhcp_leases.empty?}.compact
@parthaa
parthaa / mongo-tasks
Created July 3, 2017 19:09
mongo-tasks
mongo pulp_database --eval 'printjson(db.task_status.find({"start_time": {"$gt": "2017-06-27"}}).toArray())' > mongo.out
require_relative '../test_helper'
require 'hammer_cli_katello/sync_plan'
require_relative 'sync_plan_helpers'
require_relative '../organization/organization_helpers'
module HammerCLIKatello
describe SyncPlan::InfoCommand do
include OrganizationHelpers
include SyncPlanHelpers
it 'by ID' do
namespace :csv_dump do
desc "export db tables to csv used for debugging and exporting tables from production.\
Run with tables=\"katello_repositories, taxonomies\" to export tables .\
Note: you can use regexs like, tables='katelllo.*, dynflow.*, foreman_tas.*'
destination= /tmp/export.tgz, optional default =/tmp/tables.tgz\
Note: foreman user should have the right permission to write files"
task :export=> :environment do
def dump_csv(table, dir = "/tmp")
system("/usr/bin/psql -c \"COPY #{table} to STDOUT DELIMITER ',' CSV HEADER;\" > '#{dir}/#{table}.csv'")
end
@parthaa
parthaa / foreman-tasks.rb
Last active August 25, 2017 14:15
handy foreman tasks rails console methods for perf/pattern analysis
def pulp_sorted_by_execution_plan(task)
pulp_steps(task).sort {|s1, s2| s2.execution_time <=> s1.execution_time}
end
def worst_pulp_sorted_by_execution_plan(task, limit = 10)
pulp_sorted_by_execution_plan(task)[0..limit].map {|step| step_metrics(step)}
end
def sorted_steps(task)
execplan = task.execution_plan