Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Michele Baldessari mbaldessari

🏠
Working from home
View GitHub Profile
View ovn-commands.txt
export SBDB=$(sudo ovs-vsctl get open . external_ids:ovn-remote | sed -e 's/\"//g') ; export NBDB=$(sudo ovs-vsctl get open . external_ids:ovn-remote
| sed -e 's/\"//g' | sed -e 's/6642/6641/g') ; alias ovn-sbctl='sudo podman exec ovn_controller ovn-sbctl --db=$SBDB' ; alias ovn-nbctl='sudo podman
exec ovn_controller ovn-nbctl --db=$NBDB' ; alias ovn-trace='sudo podman exec ovn_controller ovn-trace --db=$SBDB'
ovn-sbctl list chassis
ovs-vsctl get open . external_ids:ovn-bridge-mappings
ovn-nbctl --db="ssl:172.17.1.122:6641" -p /etc/pki/tls/private/ovn_controller.key -c /etc/pki/tls/certs/ovn_controller.crt -C /etc/ipa/ca.crt show
View standalone-cleanup.sh
#!/bin/bash
set -x
source /etc/os-release
sudo systemctl stop tripleo_\*
sudo systemctl stop ceph\*
sudo pcs cluster destroy
if [ $VERSION_ID == "7" ]; then
sudo docker ps -a -q | xargs docker rm -f
else
View ospgrep.sh
ospgrep() {
echo "$*"
grep -E "\s\b(E[rR]{2}:?|alert|Traceback|TRACE|crit|fatal|HANDLER|TASK|PLAY|Unexpected|FAIL|[Ff]ail|denied|non-zero|[Tt]ime[d\s]?out|UNCAUGHT|EXCEPTION|Unknown|[Aa]ssertion|inuse)" $*
}
View facter-cleanup.sh
rm /opt/puppetlabs/facter/cache/ -rf
rm -fr /var/lib/container-puppet/puppetlabs/
mkdir /var/lib/container-puppet/puppetlabs/
cat > /var/lib/container-puppet/puppetlabs/facter.conf <<EOF
facts : {
ttls: [
{ "kernel" : 98 hour },
{ "memory" : 98 hour },
{ "networking" : 98 hour },
{ "operating system" : 98 hour },
View sos-collect.sh
#!/bin/bash
set -e
cd /home/stack
source ./stackrc
if [ ! -f inv.yml ]; then
tripleo-ansible-inventory --static-yaml-inventory inv.yml
fi
cat > /tmp/sosreport.yml <<EOF
@mbaldessari
mbaldessari / sos-collect.sh
Created Oct 1, 2020
sosreport collection in parallel
View sos-collect.sh
#!/bin/bash
set -ex
mkdir sosreports || /bin/true
declare -A pids
nodes=$(openstack --os-cloud undercloud server list -f value -c Networks |cut -f2 -d\=)
for i in $nodes; do
echo "Collecting for $i"
ssh $i 'sudo sosreport --quiet --batch; sudo chmod 644 /var/tmp/sos*xz' &
pids["$i"]="$!"
@mbaldessari
mbaldessari / gist:d356ef76d68ff8636a3d73b1cd968269
Last active Mar 17, 2020
Clean freeipa from spurious hosts
View gist:d356ef76d68ff8636a3d73b1cd968269
# To delete all hosts that are not freeipa and undercloud
# Go to freeipa-0 and open /tmp/freeipa-setup.env
# look for AdminPassword
kinit admin
# Type in AdminPassword
D='redhat.local'
for i in $(ipa host-find |grep 'Host name:' | awk '{ print $3 }' | grep -v -e freeipa-0 -e undercloud-0 -e "ctlplane.$D" -e "$D" -e "internalapi.$D" -e "storage.$D" -e "storagemgmt.$D"); do ipa host-del "$i"; done
@mbaldessari
mbaldessari / disable-haproxy-backends.sh
Created Sep 18, 2019
Disables other controller haproxy backends on osp ctlplane
View disable-haproxy-backends.sh
#!/bin/bash
set -e
# Before running this script it would be best to disable haproxy on the other nodes
# via: for i in controller-1 controller-2; do pcs resource ban haproxy-bundle $i; done
# To clear the bans: for i in controller-1 controller-2; do pcs resource clear haproxy-bundle $i; done
# Run this script as root on the single controller you want to stay active
CONF="/var/lib/config-data/puppet-generated/haproxy/etc/haproxy/haproxy.cfg"
HOST=$(hostname)
# Enable admin access to the haproxy stat socket
@mbaldessari
mbaldessari / debug
Last active Apr 17, 2019
quick debug function
View debug
def lol(self, msg):
import datetime
f = open('/tmp/lol.txt', 'a+')
f.write('[LOL] %s %s\n' % (str(datetime.datetime.now()), msg))
f.flush()
f.close()
View nuke-uc.sh
# stop active systemd
for i in $(systemctl list-units |grep -e 'tripleo.*active' -e 'tripleo.*timer'|awk '{ print $1}'); do
echo $i;
sudo systemctl stop $i;
done
sudo podman ps -q -a |xargs -n1 sudo podman rm -f
sudo podman images -q -a |xargs -n1 sudo podman rmi -f
sudo rm -rf /var/lib/mysql/*