In case you need that, here is the draft:
git branch --merged master | sed -n 's,^ \+\(.*\)$,\1,p' | xargs git branch -d
Saturday, 29 April 2017
Wednesday, 26 April 2017
Tmate cheatsheet
If you detached tmate, you might want to re-attach by:
tmate -S /tmp/tmate-0/DpfNjI attach
tmate -S /tmp/tmate-0/DpfNjI attach
Tuesday, 25 April 2017
iptables - deny connecting to a host
I would like to test a scenario where server A cannot reach server B. To establish this, I will add iptables rules on server A so ssh connections fail. After some research (basically reading this article) I managed to come up with the rules I need. Before doing anything it is good to know the state of the system. Use
iptables -S
to find out existing rules on your system. To block connections to ssh, use:
iptables -A OUTPUT -p tcp --dport ssh -d 192.168.124.82 -j REJECT
removing the rule is simple, list the rules with iptables -S and replace -A with -D:
iptables -D OUTPUT -d 192.168.124.82/32 -p tcp -m tcp --dport 22 -j REJECT --reject-with icmp-port-unreachable
iptables -S
to find out existing rules on your system. To block connections to ssh, use:
iptables -A OUTPUT -p tcp --dport ssh -d 192.168.124.82 -j REJECT
removing the rule is simple, list the rules with iptables -S and replace -A with -D:
iptables -D OUTPUT -d 192.168.124.82/32 -p tcp -m tcp --dport 22 -j REJECT --reject-with icmp-port-unreachable
Friday, 10 March 2017
Running Cinder Migration Unit Tests
Cinder has some unit tests for migration. If you want to run them on your computer, you'll need to set up database administrator accounts for your backends, and export an environment variable before running the test:
One-liner:
MySQL
PostgreSQL
SQLite
One-liner:
for backend in \
mysql+pymysql://root:secret@localhost/mysql \
postgresql://postgres:secret@localhost/cinder \
sqlite:///somefile.db \
; do
OS_TEST_DBAPI_ADMIN_CONNECTION=$backend \
python -m subunit.run cinder.tests.unit.test_migrations |
subunit2pyunit
done
MySQL
OS_TEST_DBAPI_ADMIN_CONNECTION='mysql+pymysql://root:secret@localhost/mysql'\ python -m subunit.run cinder.tests.unit.test_migrations | subunit2pyunit
PostgreSQL
OS_TEST_DBAPI_ADMIN_CONNECTION='postgresql://postgres:secret@localhost/cinder'\ python -m subunit.run cinder.tests.unit.test_migrations | subunit2pyunit
SQLite
OS_TEST_DBAPI_ADMIN_CONNECTION='sqlite:///somefile.db'\ python -m subunit.run cinder.tests.unit.test_migrations | subunit2pyunit
Labels:
cinder,
migrations,
openstack,
sqlalchemy,
test,
unit
Friday, 24 February 2017
PostgreSQL Notes
Backup a Database
sudo -u postgres --format=custom --file=<file name> <database name>
Restore a Database
First, create an empty database:
create database <database name> with encoding='utf-8';
Then grant all permissions to your user:
grant all on database <database name> to <user name>;
Then restore the dump:
sudo -u postgres pg_restore \
--schema=public \
--dbname=<database name> \
--no-owner \
--no-privileges \
--role=<user name> \
<file name>
Saturday, 25 July 2015
System backup
Transfer all the files to the new partition
rsync -aAXvHS --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/data"} /* /mnt/backup/Get the UUID for the new partition
[root@archie /]# blkid /dev/sda2 /dev/sda2: UUID="ca2f7146-122f-4746-8725-7aeb4ca792e6" TYPE="ext4" PARTUUID="48c724bf-02"
Edit mountpoints
[root@archie /]# vim /etc/fstab
Edit the new system's boot configuration
[root@archie /]# vim /mnt/backup/boot/syslinux/syslinux.cfg
Enter the new system and fix booting
[root@archie /]# arch-chroot /mnt/backup/ sh-4.3# syslinux-install_update -i -a -m Syslinux BIOS install successful Boot Flag Set - /dev/sda2 Installed MBR (/usr/lib/syslinux/bios/mbr.bin) to /dev/sda
Sunday, 5 July 2015
Burning Blu Ray Discs
Look at this blog
For mkudffs, see arch: udftools
For mkudffs, see arch: udftools
What I get is
24712708096/25000000000 (98.9%) @0.9x, remaining 1:08 RBU 100.0% UBU 76.6% 24726929408/25000000000 (98.9%) @0.9x, remaining 1:04 RBU 100.0% UBU 79.7% 24741150720/25000000000 (99.0%) @0.9x, remaining 1:01 RBU 100.0% UBU 85.9% 24755372032/25000000000 (99.0%) @0.9x, remaining 0:58 RBU 100.0% UBU 73.4% :-[ WRITE@LBA=b87400h failed with SK=5h/END OF USER AREA ENCOUNTERED ON THIS TRACK]: Input/output error :-( write failed: Input/output error /dev/sr2: flushing cache /dev/sr2: closing track /dev/sr2: closing session :-[ CLOSE SESSION failed with SK=5h/INVALID FIELD IN CDB]: Input/output error /dev/sr2: reloading tray
Subscribe to:
Posts (Atom)