Skip to content

Instantly share code, notes, and snippets.

shundezhang /
Last active March 2, 2021 04:03
import pyudev
# install pyudev
# apt install python3-pyudev
context = pyudev.Context()
for device in context.list_devices(subsystem="block"):
if device.device_type == u"disk":
property_dict = dict(device.items())
if ('ID_MODEL' in property_dict):
shundezhang / 0-charmed-k8s-docker-calico-openstack
Last active July 20, 2020 06:55
use juju to deploy charmed k8s with docker, calico and openstack integration
juju deploy ./bundle.yaml --overlay openstack-overlay.yaml --trust --overlay calico-overlay.yaml
# Generated by iptables-save v1.4.21 on Mon Feb 6 13:03:28 2017
-A INPUT -s -p tcp -m multiport --dports 5671,5672,15672 -m comment --comment "001 amqp incoming amqp_10.10.10.51" -j ACCEPT
-A INPUT -p tcp -m multiport --dports 8042 -m comment --comment "001 aodh-api incoming aodh_api" -j ACCEPT
-A INPUT -p tcp -m multiport --dports 8777 -m comment --comment "001 ceilometer-api incoming ceilometer_api" -j ACCEPT
-A INPUT -s -p tcp -m multiport --dports 3260 -m comment --comment "001 cinder incoming cinder_10.10.10.53" -j ACCEPT
-A INPUT -p tcp -m multiport --dports 8776 -m comment --comment "001 cinder-api incoming cinder_api" -j ACCEPT
shundezhang /
Created July 9, 2019 01:57
ceph disk list for ceph nautilus
# run "ceph-volume simple scan" to generate OSD json files, these files will be placed in /etc/ceph/osd/
for i in `ls $JSON_PATH`; do
OSD_ID=`cat $JSON_PATH$i | jq '.whoami'`
DATA_PATH=`cat $JSON_PATH$i | jq -r '.data.path'`
DB_PATH=`cat $JSON_PATH$i | jq -r '."block.db".path'`
WAL_PATH=`cat $JSON_PATH$i | jq -r '."block.wal".path'`
shundezhang / gist:322743e77e0ebaa65d6f
Last active December 23, 2015 06:06
openstack puppet all-in-one on centos 7
yum upgrade -y centos-release
yum install -y git gcc-c++ python-devel
git clone git://
cd puppet-openstack-integration

download and compile pam-python-1.0.4 ( on CentOS

(python-pam is a pam client, NOT to write pam modules)

Put everything under /lib64/security, such as, and python pam scripts, e.g.

Here is a test script. It allows you to log in as test1 with password '11'. (User test1 needs to exist on the host.) Some output will be written to /var/log/secure.

# Duplicates pam_permit.c