Skip to content

Instantly share code, notes, and snippets.

View 4383's full-sized avatar
🏠
Working from home

Hervé Beraud 4383

🏠
Working from home
View GitHub Profile
@4383
4383 / docker_vs_podman_run.sh
Created February 1, 2019 10:54 — forked from bogdando/docker_vs_podman_run.sh
Comparing the time it takes to launch containers concurrently for docker and podman runtimes
#!/bin/bash
set -e
containers_total=${1:-100}
containers_concur=${2:-10}
container_image=${3:-docker.io/library/busybox}
podman pull $container_image
docker pull $container_image
rm -f bench-jobs.txt
generated from /usr/share/openstack-tripleo-heat-templates *and* /usr/share/openstack-puppet/modules/tripleo
edit this file /usr/share/openstack-puppet/modules/tripleo/manifests/profile/base/nova.pp
you will see the class '::nova::cache' just change the hardcoded backend there
@4383
4383 / introspect.py
Last active March 4, 2019 18:23
Generate a function parameters (args, kwargs) from strings by converting it with called function signature
from inspect import signature
import copy
def expected(key, sign):
for el in sign.parameters.values():
if key in el.name:
return True
return False
@4383
4383 / kill-ctrl0.sh
Created April 3, 2019 14:57
kill controler-0 by using ipmi example
#!/bin/sh
ipmitool -I lanplus -H 172.16.0.1 -L ADMINISTRATOR -p 6232 -U admin -R 12 -N 5 -Ppassword power status
ipmitool -I lanplus -H 172.16.0.1 -L ADMINISTRATOR -p 6232 -U admin -R 12 -N 5 -Ppassword power off
sleep 2
ipmitool -I lanplus -H 172.16.0.1 -L ADMINISTRATOR -p 6232 -U admin -R 12 -N 5 -Ppassword power status
@4383
4383 / log.py
Created April 4, 2019 15:56
log with python
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
logging.getLogger('foo').debug('bah')
logging.getLogger().setLevel(logging.INFO)
logging.getLogger('foo').debug('debug')
logging.getLogger('foo').info('info')
logging.getLogger('foo').warn('warn')
@4383
4383 / nova-restart.sh
Created April 17, 2019 16:06
restart all nova containers
# On controllers
# ssh heat-admin@<controller-ip>
for el in $(sudo docker ps | grep nova | awk '{print $1}'); do sudo docker restart $el; done
@4383
4383 / patch.sh
Last active April 24, 2019 16:24
patch code from review
for el in $(ls /var/log/containers); do cp -v /var/log/containers/nova/impl_rabbit.py /var/log/containers/${el}; done
for el in $(infect_who_use_oslo messaging); do \
name=$(echo $el | awk -F "_" '{print $1}'); \
echo -e "patch ${name}\n"; \
docker exec -it --user root ${el} cp /var/log/${name}/impl_rabbit.py /usr/lib/python2.7/site-packages/oslo_messaging/_drivers; \
docker restart ${el}; \
done
curl -4 https://review.opendev.org/changes/643056/revisions/current/patch?download | base64 -d | sudo patch -p1
@4383
4383 / scan.sh
Last active May 3, 2019 17:36
scan python dependencies
cd /tmp
mkdir keystone
pipenv shell
pip install keystone
pypath=$(dirname $(which python) | sed 's/bin/lib/g')
grep -ri ${mypath} -e subprocess -exclude-dir="*/__pycache__" | grep import | more
@4383
4383 / padding.py
Last active May 4, 2019 16:03
Test padding implementation
threads = [
"",
"1111111111111-thread1-base ",
"1111111111111-thread2-base ",
"1111111111111-thread3-very-long ",
"1111111111111-short ",
"1111111111111-thread4-base ",
"1111111111111-thread3-very-long-long ",
"1111111111111-short ",
"1111111111111-thread5-base ",
@4383
4383 / trigger-zuul-periodic-job.sh
Created May 15, 2019 12:16 — forked from mgagne/trigger-zuul-periodic-job.sh
Trigger a Zuul periodic job
./tools/trigger-job.py --job periodic-foobar-proposal --project dev/foobar --pipeline periodic --url https://zuul.example.org/p --logpath /dev/null --newrev refs/heads/master --refname refs/heads/master