Skip to content

Instantly share code, notes, and snippets.

@orimanabu
orimanabu / tmp
Created November 8, 2019 05:28
tmp
tmp
@orimanabu
orimanabu / hostname2nodetag.sh
Created October 15, 2019 13:33
Convert OpenShift4 internal hostname to AWS node tag
#!/bin/bash
if [ x"$#" != x"1" ]; then
echo "$0 hostname"
exit 1
fi
hostname=$1; shift
json=$(aws ec2 describe-instances)
echo "${json}" | jq -r '.Reservations[].Instances[] | select(.PrivateDnsName == "'${hostname}'") | .Tags | from_entries | .Name'
@orimanabu
orimanabu / xxx.py
Created September 13, 2019 14:59
xxx
#!/usr/bin/python
import json
import sys
input_path = sys.argv[1]
print("* " + input_path)
f = open(input_path, 'r')
data = json.load(f)
esc=$(printf '\033'); tail -f /var/log/containers/nova/nova-compute.log | sed -e "s/d7ed6fe9-e0fb-4ccb-8d80-85bd80cf367a/${esc}[33md7ed6fe9-e0fb-4ccb-8d80-85bd80cf367a${esc}[0m/g"
@orimanabu
orimanabu / errata_bugzilla.py
Last active April 22, 2019 09:15
Obtain Errata Advisory and Bugzilla URLs for RHOSP
#!/usr/bin/env python
import csv
import sys
import requests
import subprocess
import urllib.parse
from pprint import pprint
from lxml import html
from argparse import ArgumentParser
@orimanabu
orimanabu / openstack_curl_example.sh
Last active November 28, 2018 04:55
OpenStack Rest API call with cURL
#!/bin/bash
# This script is an example for calling OpenStack Rest API with cURL.
# First, gets project-scoped token, then gets instance information with the token.
# Prereq: jq
# Note that before running this script, ensure to set some environment variables.
# e.g.
# source ~/keystonerc_admin
# or
@orimanabu
orimanabu / decode_s_addr.py
Created November 21, 2018 05:06
Decode sin_addr.s_addr in Python
#!/usr/bin/python
import socket
import struct
import sys
#value = 191041708
def to_ipaddr(value):
packed = socket.ntohl(value)
x = struct.pack('!I', packed)
@orimanabu
orimanabu / dnsmasq_dump_servers.gdb
Created November 21, 2018 04:23
dump servers value from dnsmasq using gdb
define server_list
set var $s = (*dnsmasq_daemon)->servers
echo \n
echo struct server *:\n
print $s
while $s
echo .domain:\n
print $s.domain
@orimanabu
orimanabu / decrypt_saml_response.py
Last active December 12, 2023 07:58
SAML Response Decrypter
#!/usr/bin/env python
# Prereq: PyCrypto
# Validation: https://www.samltool.com/decrypt.php
# Usage: ./decrypt_saml_response.py --key PRIVATE_KEY --pretty-print RESPONSE_XML
import sys
import optparse
import base64
@orimanabu
orimanabu / openshift_personal_cheat_sheat.md
Created December 4, 2017 02:51
OpenShift personal cheat sheat

obtain docker tags

curl -s -S 'https://registry.access.redhat.com/v1/repositories/openshift3/postgresql-apb/tags' | jq '.'
curl -s -S 'https://registry.access.redhat.com/v1/repositories/rhel7/tags'| jq '.'