Skip to content

Instantly share code, notes, and snippets.

View mbruzek's full-sized avatar

Matt Bruzek mbruzek

View GitHub Profile
#!/usr/bin/env python3
"""
A Python3 tool that uses the NASA-Acronym data to find similar expansions.
This code uses the Levenshtein Distance to calculate the difference between
sequences of characters in the expansions field of the data.
This file relies on thefuzz python package: https://github.com/seatgeek/thefuzz
@mbruzek
mbruzek / find_similar.py
Last active November 19, 2021 19:49
A duplicate expansion finding tool not yet ready for primetime.
#!/usr/bin/env python3
"""
A Python3 tool that uses the NASA-Acronym data to find similar expansions.
This code uses the Levenshtein Distance to calculate the difference between
sequences of characters in the expansions field of the data.
This file relies on thefuzz python package: https://github.com/seatgeek/thefuzz
hosts.ini
[ios]
sg250a ansible_host=192.168.1.254
[ios:vars]
ansible_become=yes
ansible_become_method=enable
ansible_connection=ansible.netcommon.network_cli
ansible_network_os=cisco.ios.ios
@mbruzek
mbruzek / sparsify_method1.sh
Last active April 7, 2020 22:15
Sparsify a qemu disk with backing file.
#!/bin/bash
# Implement method 1 to compress the VM differencing disks.
LIBVIRT_IMAGES=/var/lib/libvirt/images
TARGET_DOMAIN=${1}
function sparsify {
local TARGET_DISK=${1}
# Print the size of the differencing disk.
@mbruzek
mbruzek / pty_ssh.py
Created February 4, 2020 15:54
Automating an un-automatable network switch required some creative programming. Create an SSH session inside a pseudo terminal (pty), then read and write the file descriptor.
#!/usr/bin/python3
import argparse
import getpass
import os
import pty
import re
import sys
import time
---
- name: mbruzek test
hosts: localhost
vars:
glusterfs_nodes:
- cns-1.scale-ci.example.com
- cns-2.scale-ci.example.com
- cns-0.scale-ci.example.com
l_glusterfs_count: "{{ glusterfs_count | default(glusterfs_nodes | count) }}"
tasks:
@mbruzek
mbruzek / openstack_ironic_clean.sh
Created July 6, 2018 18:48
The instructions to clean OpenShift nodes between deploys
for ironic_id in $(ironic node-list | awk {'print $2'} | grep -v UUID | egrep -v '^$'); do
ironic node-set-provision-state $ironic_id manage;
done
# Check ironic node-list for managemable
for ironic_id in $(ironic node-list | awk {'print $2'} | grep -v UUID | egrep -v '^$'); do
openstack baremetal node clean $ironic_id --clean-steps '[{"interface": "deploy", "step": "erase_devices_metadata"}]';
done
# watch ironic node list until all cleaned
---
- name: test the instackenv logic
hosts: localhost
vars:
num_controllers: 3
num_storage: 5
vars_prompt:
- name: "instack_url"
prompt: "What is th instackenv url?"
private: false
@mbruzek
mbruzek / curl_file_to_jenkins.sh
Created August 11, 2017 15:07
A script to kick off a parameterized build for Jenkins
#!/bin/bash
# Send a file to a Jenkins build using curl.
# The first parameter must be the URL of the Jenkins job to build.
# The second parameter must be the local file to send to Jenkins.
url=$1
local_file=$2
# curl $JENKINS_URL/job/$JOB_NAME/build -F file_key=@file_path -F json='{"parameter": [{"name": "param_name", "file": "file_key"}]}'
#!/bin/bash
# This script uploads e2e results from a Jenkins run using gcloud.
set -o errexit
set -o xtrace
set -o nounset
set -o pipefail
source logging.sh