Skip to content

Instantly share code, notes, and snippets.

View smurugap's full-sized avatar

Senthilnathan Murugappan smurugap

View GitHub Profile
@smurugap
smurugap / haproxy container
Last active April 27, 2020 01:53
sample haproxy container
Create /tmp/haproxy.cfg file:
global
daemon
defaults
log global
frontend contrail_webui_external
bind 10.87.69.7:8143
mode tcp
@smurugap
smurugap / ansible command line
Created June 28, 2018 04:35
ansible command line to exec command on multiple hosts
ansible all -i 10.0.0.5,10.0.0.6,10.0.0.7,10.0.0.8,10.0.0.9 -m shell -e 'ansible_ssh_pass=c0ntrail123' -a 'uname -a'
@smurugap
smurugap / nova-delete-db
Created April 9, 2018 22:22
DB changes to delete a VM stuck in ‘error’ or ‘deleting’ state
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM security_group_instance_association WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM block_device_mapping WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_info_caches WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_system_metadata WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_faults WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE
@smurugap
smurugap / heat-stack-delete-db
Created April 9, 2018 22:16
DB Changes to delete a heat stack manually.
mysql -hlocalhost -uroot -p$(cat /etc/contrail/mysql.token) -e "
use heat;
delete from resource_data where resource_id in (select id from resource where stack_id in (select id from stack where name = \"$project\"));
delete from resource where stack_id in (select id from stack where name = \"$project\");
delete from event where stack_id in (select id from stack where name = \"$project\");
delete from stack where name = \"$project\";
@smurugap
smurugap / increase-disk-host
Last active January 25, 2020 01:09
Increase disk size of host
Add a new physical disk to existing lvpartition:
104 vgdisplay
105 pvdisplay
106 vgextend a2s39-vg00 /dev/sdb1
107 df -h
108 lvextend /dev/a2s39-vg00/lv_var /dev/sdb1
109 resize2fs /dev/a2s39-vg00/lv_var
Remove a lvpartition and extend the other lvpartition:
umount /home
@smurugap
smurugap / virt-install
Created March 11, 2018 21:04
Virt Install to start a VM with macvtap interface
virt-install \
--name=centos-compute-$i \
--ram=32768 \
--vcpus=16 \
--cpu host-model-only \
--os-type linux \
--os-variant centos7.0 \
--import \
--disk path=/var/lib/libvirt/images/centos74-compute-$i.qcow2,bus=virtio,cache=none,format=qcow2,bus=virtio \
--network type=direct,source=enp6s0f0,source_mode=bridge,model=virtio \
@smurugap
smurugap / virsh-dump-xml
Last active September 17, 2020 06:05
Virsh dump XML file to launch a VM with virsh
virsh net-define <below xml>
<network>
<name>macvtap-net</name>
<forward mode="bridge">
<interface dev="eth1"/>
</forward>
</network>
<domain type='kvm'>
@smurugap
smurugap / virt-manager_vnc-server.md
Last active March 11, 2018 19:07
Setup Virt-Manager + xVncServer

Install packages

###install epel repo, yum install epel-release

yum install -y tigervnc-server qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer vim screen git net-tools

yum -y groupinstall X11 Xfce

Disable firewalld

systemctl disable firewalld

@smurugap
smurugap / VirtualBox
Created February 9, 2018 00:25
VirtualBox
sh-3.2# VBoxManage hostonlyif create
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interface 'vboxnet0' was successfully created
Set the VM network adapter type to hostonly mode and select the created vboxnet0 interface
@smurugap
smurugap / Remote python debugging
Last active February 1, 2018 22:36
Remote python debugging
#pip install remote_pdb
import remote_pdb
remote_pdb.set_trace() # you'll see the port number in the logs
remote_pdb.RemotePdb('127.0.0.1', 4444).set_trace()