Skip to content

Instantly share code, notes, and snippets.

View freyes's full-sized avatar
🥑

Felipe Reyes freyes

🥑
View GitHub Profile
def _get_machine_id():
"""Return the machine-id UUID."""
with open('/etc/machine-id', 'r') as f:
# The machine ID is a single newline-terminated, hexadecimal,
# 32-character, lowercase ID.
machine_id_int = int(f.read().strip(), 16)
machine_id_bytes = bytearray(machine_id_int.to_bytes(16, 'big'))
# see manpage machine-id(5)
machine_id_bytes[6] = (machine_id_bytes[6] & 0x0F) | 0x40
machine_id_bytes[8] = (machine_id_bytes[8] & 0x3F) | 0x80
#!/bin/bash -eu
SOSREPORT=$1
shift
FILE_PATH="$@"
SOSREPORT_NAME=$(basename $SOSREPORT)
SOSREPORT_NAME=${SOSREPORT_NAME%.tar.xz}
FILES=""
for F in ${FILE_PATH}; do
#!/bin/bash -u
MODEL=
TIMEOUT=10s
DESTROY_MODEL_OPTS=( )
while true; do
case "$1" in
-t)
shift
#!/bin/bash -eu
#
# Author: Felipe Reyes <[email protected]>
#
# References:
# - "Kubelet api server connection check in health checker" in kubernetes/node-problem-detector
# https://github.com/kubernetes/node-problem-detector/pull/489
# - "(1.17) Kubelet won't reconnect to Apiserver after NIC failure (use of closed network connection)" in kubernetes/kubernetes
# https://github.com/kubernetes/kubernetes/issues/87615
@freyes
freyes / query-etcd.sh
Last active November 30, 2020 20:58 — forked from brettmilford/query-etcd.sh
Query etcd keys
#!/bin/bash -eux
# brettmilford: added etcd /metrics gathering
# This file is based on https://code.launchpad.net/~freyes/+git/experiment
# Modified to use xargs instead of parallel
# 'etcd.etcdctl' is provided by the etcd snap
which etcd.etcdctl
PARALLEL_REQS=20
$ python3 parse-script.py test_script.sh
------
results:
{}
------
parameters:
{}
------
parsed_yaml:
{'description': 'This is something.',
sudo virsh domblklist $MACHINE
# copy the file path to the qcow2 disk that you want to resize
sudo qemu-img resize $QCOW2_PATH +20G # this will add 20G to the disk
sudo virsh start $MACHINE
# ssh into $MACHINE
lsblk # make sure the disk size is the one you want
sudo apt -y install cloud-guest-utils
sudo growpart /dev/vda 1 # change vda is the disk, and '1' is for the partition number as listed by lsblk.
sudo resize2fs /dev/vda1 # resize the filesystem.
df -h | grep /dev/vda # validate the new size is active.
@freyes
freyes / paste-ubuntu-com.el
Last active June 12, 2020 16:30
emacs webpaste support for https://paste.ubuntu.com
(require 'request)
(require 'cl-lib)
(require 'webpaste)
(defun paste-ubuntu-field-lambda ()
"lambda for building post compatible with paste.ubuntu.com."
(cl-function (lambda (&key text
post-field
provider-uri
(post-lang-field-name nil)
(post-data '()))
for PROJECT in $(openstack project list -c Name -f value);do
echo -e "$(openstack quota show -f value -c volumes $PROJECT) \t $PROJECT"
done
#! /bin/sh
#edit by stev-o - find the MTU available for current network
# source: https://www.routertech.org/viewtopic.php?t=1720
#Usage: $0 <exthost>
#
#$0 = Me
#<exthost> = custom host used for test, different from built-in ones, needed if they go down or close: this is optional
#
#P.S.:due to a limitation of busybox "ping" command, make sure the hosts passed reject fragmented packet, otherwise the test will be compromized...