Skip to content

Instantly share code, notes, and snippets.

View 4383's full-sized avatar
🏝️
Vacation

Hervé Beraud 4383

🏝️
Vacation
View GitHub Profile
@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 / 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 / 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 / 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
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 / 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
export OS_PROJECT_DOMAIN_NAME='Default'
export OS_USER_DOMAIN_NAME='Default'
export OS_PROJECT_NAME='admin'
export OS_USERNAME='admin'
export OS_AUTH_URL=http://192.168.24.2:5000/
export OS_AUTH_TYPE='password'
export OS_IDENTITY_API_VERSION='3'
export OS_PASSWORD=$(hiera -c /etc/puppet/hiera.yaml keystone::admin_password)
@4383
4383 / podman.sh
Last active January 23, 2019 18:48
patch openstack stein with podman
#!/bin/bash
# remove old fix container
podman rm -f fix
# patch container with debug changes
podman run --name=fix -u root --net=host -it 192.168.122.1:5000/fedora-binary-nova-api:ospsprint bash -c "curl http://file.cdg.redhat.com/hberaud/context.py -o /tmp/context.py && mv /tmp/context.py /usr/lib/python3.6/site-packages/nova && cat /usr/lib/python3.6/site-packages/nova/context.py"
# commit changes to apply debug changes
podman commit --change CMD='kolla_start' fix 192.168.122.1:5000/fedora-binary-nova-api:ospsprint
# remove fix container generated
podman rm -f fix
# redeploy and catch debug traces
@4383
4383 / openstack.sh
Last active January 28, 2019 17:11
Useful openstack commands
scp memcache.py hberaud@file.cdg.redhat.com:public_html/
@4383
4383 / debug.py
Created November 13, 2018 17:43
debug with kcachegrind
import cProfile
pr = cProfile.Profile()
pr.enable()
# execute python code to profile
print("test")
pr.disable()
pr.dump_stats("/tmp/debug.cprof")