Skip to content

Instantly share code, notes, and snippets.

@mnaser
mnaser / trim-osd-dups.sh
Created February 8, 2023 04:16
Trim all `dups`
#!/bin/bash -xe
OSD_ID=${1}
# Turn off the OSD
systemctl stop ceph-osd@${OSD_ID}
# Loop over all placement groups
for PG in $(ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-${OSD_ID}/ --op list-pgs); do
ceph-objectstore-tool \
@mnaser
mnaser / enable-mlx-uefi.sh
Last active April 15, 2021 22:05
Enable UEFI for Mellanox ConnectX cards
apt -y install mstflint
for i in `lspci | grep Mellanox | cut -d' ' -f1`; do
mstconfig -d $i -y set EXP_ROM_UEFI_x86_ENABLE=1 EXP_ROM_PXE_ENABLE=1 UEFI_HII_EN=1;
mstconfig -d $i q | egrep (EXP_ROM|UEFI);
done;
#!/bin/bash
if ! command -v virsh; then
echo "virsh could not be found"
exit
fi
SECRET_UUID=$(virsh secret-list | grep 'client.cinder' | cut -d' ' -f2)
SECRET_VALUE=$(cat /etc/ceph/ceph.client.cinder.keyring | grep 'key' | cut -d'=' -f2 | cut -d' ' -f2)
#!/bin/bash
if ! command -v virsh; then
echo "virsh could not be found"
exit
fi
SECRET_UUID=$(virsh secret-list | grep 'client.cinder' | cut -d' ' -f2)
SECRET_VALUE=$(virsh secret-get-value ${SECRET_UUID})
#!/bin/bash
if ! command -v virsh; then
echo "virsh could not be found"
exit
fi
SECRET_UUID=$(virsh secret-list | grep 'client.cinder' | cut -d' ' -f2)
SECRET_VALUE=$(virsh secret-get-value ${SECRET_UUID})
#!/bin/bash
SECRET_UUID=$(virsh secret-list | grep 'client.cinder' | cut -d' ' -f2)
SECRET_VALUE=$(virsh secret-get-value ${SECRET_UUID})
virsh secret-undefine ${SECRET_UUID}
virsh secret-define --file /dev/stdin <<EOF
<secret ephemeral='no' private='no'>
<uuid>457eb676-33da-42ec-9a8c-9293d545c337</uuid>
<usage type='ceph'>
DEVICE=br-ex
ONBOOT=yes
DEVICETYPE=ovs
TYPE=OVSBridge
OVSBOOTPROTO="dhcp"
OVSDHCPINTERFACES="bond0"
HOTPLUG=no
@mnaser
mnaser / get_stack_usage.py
Created October 29, 2019 20:05
Get total cost usage for a Heat stack
import argparse
from datetime import datetime
import sys
import urllib.request
import json
import openstack
stack_name = sys.argv[1]
@mnaser
mnaser / cluster-bootstrap.sh
Last active September 4, 2019 23:31
Kubernetes Bootstrap
#!/bin/bash
cat <<EOF > /etc/kubernetes/kubeadm.conf
--
apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
localAPIEndpoint:
bindPort: 16443
---
apiVersion: kubeadm.k8s.io/v1beta2
@mnaser
mnaser / build-beats.sh
Created September 22, 2018 22:53
Script to build ARM64 beats (must run on x86)
#!/bin/bash
sudo add-apt-repository ppa:gophers/archive
sudo apt-get update
sudo apt-get -y install docker.io libpcap-dev python-virtualenv golang-1.10-go git
sudo usermod -aG docker $USER
# logout and login for groups to update
export GOPATH="$HOME/go"