Skip to content

Instantly share code, notes, and snippets.

@sferich888
sferich888 / README.md
Created December 31, 2019 05:40
libvirt dynamic inventory

This asumes that your VM's in your libvirt network, have functioning DNS, using dnsmasq provided by libvirt and your host.

@sferich888
sferich888 / client.py
Last active July 26, 2018 00:51
Mock API Server (flask) and Simply 'requests' Client (with threading)
import requests, argparse, timeit
from concurrent.futures import ThreadPoolExecutor
### Globals
""" These are simply defined, and the values are not used.
The values are set by argparse at the start of the script.
"""
server = ''
port = 0
@sferich888
sferich888 / requests-saml.py
Last active January 13, 2023 06:59
Example SAML implementation using Python Requests
from requests.auth import AuthBase
class SAML(AuthBase):
from bs4 import BeautifulSoup
"""Implemeents SSO with RH auth.redhat.com"""
def __init__(self, username, password):
# setup any auth-related data here
self.username = username
self.password = password
@sferich888
sferich888 / virt-install_ks
Last active December 13, 2017 23:17
Using virt-install to test kickstart files (without a webserver).
sudo virt-install -n test -r 2048 --disk path=/var/lib/libvirt/images/test.img,size=25,format=qcow2,sparse=false --location="https://mirrors.rit.edu/fedora/fedora/linux/releases/27/Workstation/x86_64/os/" --initrd-inject=fedora.ks -x "ks=file:/fedora.ks" --noautoconsole
@sferich888
sferich888 / keystonerc_user
Created November 13, 2015 16:25
Keystonerc for multple users. It allows multiple users to have the same keystonerc and prompt them for there password just like you would if you used the UI.
unset OS_SERVICE_TOKEN
if [[ -z $1 ]]; then
echo -n "Please enter your OpenStack Username: "
read OS_USERNAME_INPUT
export OS_USERNAME=$OS_USERNAME_INPUT
else
export OS_USERNAME=$1
fi
@sferich888
sferich888 / signed_test_certs.sh
Created August 28, 2015 19:50
A Certificate Signing Script for testing.
#!/bin/bash
# Description: Simple Script to Create an NSS Certificat Authority (CA), and client / server certificats that can be used for testing.
# Usage: Simply run the script with out options. Be sure to set the Configuration settings below
# Opetions: are positional
# 1: -i - This option activates intermediate mode, and will issue and intermediate CA certificate, clients and servers will be signed by the intermediat and not the CA.
# 2: -j - This option activates Java, and will issue java keystores for
# -- Configuration -------------------------------------------------------
# Testing Varables
@sferich888
sferich888 / restore_repos
Created April 24, 2014 20:18
script to restore save repositories for save_repo script.
DIR=/tmp/test
FLAG=1
mkdir -p $DIR
START=$(pwd) && cd $DIR
while read line; do
if [[ -z $line ]]; then
FLAG=1
else
if [[ $FLAG == 0 ]]; then
@sferich888
sferich888 / save_repos
Created April 24, 2014 20:16
bash script to save a directory of repositories with 1 or two sub-directories in side them that are SVN repositories.
DEBUG=TRUE
SAVE_FILE=/tmp/REPOS
REPO_DIR="$HOME/Repositories/" && cd $REPO_DIR
echo "Moved into Repository Directory: $(pwd)"
for repo in $(ls); do
echo "Saving: $repo"
cd $repo; git remote -v | grep -e push | awk '{print $2}' >> $SAVE_FILE
for cdir in $(ls -d */ | grep -v "\."); do
if [[ $DEBUG == "TRUE" ]]; then echo "Checking for SVN repos at $cdir"; fi
if [[ -e $cdir/.svn ]]; then
@sferich888
sferich888 / OpenShift SSL Assurance + Flask
Last active August 29, 2015 14:00
This can be used to ensure that the client using your application connected to OpenShift's SSL port prior to getting routed to your application.
@app.route('/endpoint')
def endpoint():
# Check for SSL on OpenShift, that is used to force SSL for your endpoint.
## You have to check for the X-Forwarded-Proto because of the OpenShift Node Router terminating the SSL.
if request.headers.get('X-Forwarded-Proto', 'http') != 'https':
return redirect(request.url.replace("http://", "https://"))
@sferich888
sferich888 / can_o_virt
Last active April 5, 2017 15:45
While working with some of my KVM vm's I needed the ability to take snapshots quickly as well as revert back to a desired point. The following shell functions are used in my bashrc to make it simple for me to accomplish these task. NOTE: These snapshots are only for the file system and require qcow2 disk images for the backing storage.
#!/bin/bash
wake(){ # Start your VM
sudo virsh start $1
}
slay(){ # Stop your VM
sd_time=20
sudo virsh shutdown $1
if [[ $? ]]; then