Skip to content

Instantly share code, notes, and snippets.

View zhanghui9700's full-sized avatar
🎯
Focusing

pysharp zhanghui9700

🎯
Focusing
  • beijing
View GitHub Profile
@zhanghui9700
zhanghui9700 / nova-resize-workflow-folsom.sh
Created April 29, 2014 10:05
nova-resize-workflow-folsom
mv /var/lib/nova/instances/instance-00000026 /var/lib/nova/instances/instance-00000026_resize
mkdir -p /var/lib/nova/instances/instance-00000026
qemu-img convert -f qcow2 -O qcow2 /var/lib/nova/instances/instance-00000026_resize/disk /var/lib/nova/instances/instance-00000026_resize/disk_rbase
mv /var/lib/nova/instances/instance-00000026_resize/disk_rbase /var/lib/nova/instances/instance-00000026/disk
qemu-img convert -f qcow2 -O qcow2 /var/lib/nova/instances/instance-00000026_resize/disk.local /var/lib/nova/instances/instance-00000026_resize/disk.local_rbase
mv /var/lib/nova/instances/instance-00000026_resize/disk.local_rbase /var/lib/nova/instances/instance-00000026/disk.local
finish_resize:
@zhanghui9700
zhanghui9700 / image-in-base-uuid.py
Created April 29, 2014 14:49
nova _base image uuid
#!/usr/bin/env python
#-*-coding=utf-8-*-
import hashlib
import sys
def chunkreadable(iter, chunk_size=65536):
"""
@zhanghui9700
zhanghui9700 / fio_tutorial.sh
Created May 20, 2014 02:44
use fio to test disk io
#fio 是测试磁盘性能的最佳工具:
#1、测试顺序读性能
fio --filename=/home/test -iodepth=64 -ioengine=libaio --direct=1 --rw=read --bs=1m --size=2g --numjobs=4 --runtime=10 --group_reporting --name=test-read
#2、测试顺序写性能
fio -filename=/home/test -iodepth=64 -ioengine=libaio -direct=1 -rw=write -bs=1m -size=2g -numjobs=4 -runtime=20 -group_reporting -name=test-write
#3、测试随机读性能
fio -filename=/home/test -iodepth=64 -ioengine=libaio -direct=1 -rw=randread -bs=4k -size=2G -numjobs=64 -runtime=20 -group_reporting -name=test-rand-read
@zhanghui9700
zhanghui9700 / resize-cinder-volumes.txt
Created May 30, 2014 03:07
resize cinder volume pv
关于lvremove删除openstack cinder volume所对应的逻辑卷的方法
按照我的理解,openstack里的cinder volume创建、管理磁盘实际是用tgtadm管理的来自网络中的lvm磁盘。
有时cinder volume一直处于creating状态或者deleting状态,下层磁盘用不了也删不掉,占了很大的磁盘空间。既然它是用lvm管理的所以可以用lvm相关的工具来删除它。
先找到要删除的volume的lvm路径lvdisplay,我的是:/dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798
直接lvremove /dev/cinder-vol/volume-725230c0-558a-422a-b9aa-5f309ed42798
@zhanghui9700
zhanghui9700 / curl-openstack-api.sh
Created June 10, 2014 02:30
use curl to test openstack api
curl test for openstack api
; change token when you run the command.
; glance
; glance image-list
curl -i -X GET -H 'X-Auth-Token: XXXXXXXXXXXXX-TODO' -H 'Content-Type: application/json' -H 'User-Agent: python-glanceclient' http://192.168.14.80:9292/v1/images/detail?sort_key=nam e&sort_dir=asc&limit=20
@zhanghui9700
zhanghui9700 / nova-passwordless-ssh-login.sh
Created June 11, 2014 08:58
passwordless ssh host by nova
; allow nova login
usermod -s /bin/bash nova
su - nova
; ssh key
ssh-keygen
; scp key to compute host
scp /var/lib/nova/.ssh/id_rsa.pub root@ComputeHost:/var/lib/nova/.ssh/authorized_keys
@zhanghui9700
zhanghui9700 / devstack-mitaka-local.conf
Created May 25, 2016 01:55
devstack+trystack+mitaka
[[local|localrc]]
MYSQL_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_TOKEN=password
ADMIN_PASSWORD=password
SERVICE_PASSWORD=password
SWIFT_HASH=password
LOGFILE=/opt/stack/logs/stack.sh.log
@zhanghui9700
zhanghui9700 / openstack-neutron-api-response.md
Last active June 1, 2016 02:42
openstack neutron api response

neutron

neutronclient(request).list_networks(**params).get('networks')

{                                                                           
  "networks": [                                                             
    {                                                                       
      "status": "ACTIVE",                                                   
      "subnets": [                                                          

"a9c9fdd5-6491-4611-9ad2-97ac01622a52"

servers

{
  "servers": [
    {
      "status": "ACTIVE",
      "OS-EXT-SRV-ATTR:ramdisk_id": "",
      "updated": "2016-06-30T06:47:06Z",

"hostId": "3239ae9bf2efa4792633c8c2b9db92feac00868cd4055b5b5e924719",

@zhanghui9700
zhanghui9700 / ceilometer-cli-helper.md
Last active September 26, 2016 16:40
ceilometer cli helper

openstack ceilometer cli helper

通常云,特别是公有云在计费方面有三个层次:
计量 (Metering): 收集资源的使用数据,其数据信息主要包括:使用对象(what), 使用者(who), 使用时间(when)和 用量(how much)。
计费 (Rating):将资源使用数据按照商务规则转化为可计费项目并计算费用
结算 (Billing):收钱开票
Ceilometer 的目标是 计量 Metering 方面,为上层的计费、结算或者监控应用提供统一的资源使用数据收集功能。
"To provide an infrastructure to collect any information needed within all OpenStack projects so that rating engines could use this single point to transform events into bill items, which we tagged “metering“."

Meter(计量项)