Skip to content

Instantly share code, notes, and snippets.

View ljjjustin's full-sized avatar

Jiajun Liu ljjjustin

View GitHub Profile
@ljjjustin
ljjjustin / _INSTALL.md
Created October 15, 2019 07:23 — forked from robinsmidsrod/_INSTALL.md
Bootstrapping full iPXE native menu with customizable default option with timeout (also includes working Ubuntu 12.04 preseed install)

Add the following chunk to your existing ISC dhcpd.conf file.

if exists user-class and ( option user-class = "iPXE" ) {
    filename "http://boot.smidsrod.lan/boot.ipxe";
}
else {
    filename "undionly.kpxe";
}

(or see https://gist.github.com/4008017 for a more elaborate setup

@ljjjustin
ljjjustin / migrate-vm.sh
Created June 27, 2019 06:11
migrate vm in openstack env
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 <vm uuid or name>"
exit
fi
vm=$1
wait_status() {
#!/usr/bin/env python
import math
import sys
if __name__ == '__main__':
if len(sys.argv) != 2:
print "usage: %s <osd amount>" % sys.argv[0]
osd_num = int(sys.argv[1])
@ljjjustin
ljjjustin / cpu_flags_comp.py
Created March 21, 2019 08:05
compare cpu flags to check if we can live migration virtual machine
#!/usr/bin/env python
import sys
def compare_cpu_flags(cpu1, cpu2):
with open(cpu1, "r") as f:
cpu1_flags = f.read()
with open(cpu2, "r") as f:
cpu2_flags = f.read()
@ljjjustin
ljjjustin / ssh-copy-id.sh
Created March 21, 2019 07:22
copy ssh id
#!/bin/bash
ssh_copy_id() {
host=$1
pass=$2
expect <<-EOF
spawn ssh-copy-id root@${host}
expect {
@ljjjustin
ljjjustin / upload-image.sh
Last active May 5, 2019 06:22
upload image to ceph
#!/bin/bash
set -x
if [ $# -ne 1 ]; then
echo "usage: $0 <image file path>"
exit
fi
image_path=$1
if [ ! -r "${image_path}" ]; then
@ljjjustin
ljjjustin / add-vdb.sh
Created March 1, 2019 12:14
add vdb to vm
#!/bin/bash
pushd /var/lib/libvirt/images &> /dev/null
for vm in $(virsh list --all | grep win2008 | awk '{print $2}')
do
disk_path="${vm}-vdb.qcow2"
if [ ! -e ${disk_path} ]; then
qemu-img create -f qcow2 ${disk_path} 200G
fi
@ljjjustin
ljjjustin / joinstr.sh
Created December 7, 2018 07:44
join string in bash
#!/bin/bash
function join {
local IFS="$1"; shift; echo "$*";
}
arr=( 1 a 2 b c d e 3 )
result=$(join , ${arr[@]})
echo $result
@ljjjustin
ljjjustin / makeiso.sh
Created September 13, 2018 04:04
make bootable centos
#!/bin/bash
mkisofs -joliet-long -R -T -v \
-V CentOS \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-no-emul-boot \
-boot-info-table \
-o centos-bootable.iso iso
@ljjjustin
ljjjustin / synclog.sh
Created September 3, 2018 14:55
synclog
#!/bin/bash
control_hosts="TX-LNSZF-MANAGE-01 TX-LNSZF-MANAGE-04 TX-LNSZF-MANAGE-07"
compute_hosts=$(cat /etc/hosts | grep COMPUTE | awk '{print $2}')
all_hosts="${control_hosts} ${compute_hosts}"
sync_logfiles() {
local host=$1