mirror of
https://github.com/gluster/glusterfs.git
synced 2026-02-05 15:48:40 +01:00
see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, https://review.gluster.org/#/c/20207/, https://review.gluster.org/#/c/20227/, https://review.gluster.org/#/c/20307/, https://review.gluster.org/#/c/20320/, https://review.gluster.org/#/c/20332/, https://review.gluster.org/#/c/20364/, https://review.gluster.org/#/c/20441/, and https://review.gluster.org/#/c/20484 shebangs changed from /usr/bin/python2 to /usr/bin/python3. (Reminder, various distribution packaging guidelines require use of explicit python version and don't allow '#!/usr/bin/env python', regardless of how handy that idiom may be.) glusterfs.spec(.in) package python{2,3}-gluster and python2 or python3 dependencies as appropriate. configure(.ac): + test for and use python2 or python3 as appropriate. If build machine has python2 and python3, use python3. Override by setting PYTHON=/usr/bin/python2 when running configure. + PYTHONDEV_CPPFLAGS from python[23]-config --includes is a better match to the original python sysconfig.get_python_inc(). All those other extraneous flags breaks the build. + Only change the shebangs once. Changing them over and over again, e.g., during a `make glusterrpms` in extras/LinuxRPM just sends make (is it really make that's looping?) into an infinite loop. If you figure out why, let me know. + Oldest python2 is python2.6 on CentOS 6 and Debian 8 (Jessie). Everything else has 2.7 or 3.x + logic from https://review.gluster.org/c/glusterfs/+/21050, which needs to be removed/merged after that patch is merged. Builds on CentOS 6, CentOS 7, Fedora 28, Fedora rawhide, and the mysterious RHEL > 7. Change-Id: Idae21d3b6f58b32372e1daa0d234e491e563198f updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
46 lines
1.3 KiB
Python
Executable File
46 lines
1.3 KiB
Python
Executable File
#!/usr/bin/python3
|
|
|
|
from __future__ import print_function
|
|
import ctypes
|
|
import ctypes.util
|
|
|
|
api = ctypes.CDLL("libgfapi.so")
|
|
api.glfs_get_volfile.argtypes = [ctypes.c_void_p,
|
|
ctypes.c_void_p,
|
|
ctypes.c_ulong]
|
|
api.glfs_get_volfile.restype = ctypes.c_long
|
|
|
|
|
|
def get_volfile(host, volume):
|
|
# This is set to a large value to exercise the "buffer not big enough"
|
|
# path. More realistically, you'd just start with a huge buffer.
|
|
BUF_LEN = 0
|
|
fs = api.glfs_new(volume)
|
|
# api.glfs_set_logging(fs,"/dev/stderr",7)
|
|
api.glfs_set_volfile_server(fs, "tcp", host, 24007)
|
|
api.glfs_init(fs)
|
|
vbuf = ctypes.create_string_buffer(BUF_LEN)
|
|
vlen = api.glfs_get_volfile(fs, vbuf, BUF_LEN)
|
|
if vlen < 0:
|
|
vlen = BUF_LEN - vlen
|
|
vbuf = ctypes.create_string_buffer(vlen)
|
|
vlen = api.glfs_get_volfile(fs, vbuf, vlen)
|
|
api.glfs_fini(fs)
|
|
if vlen <= 0:
|
|
return vlen
|
|
return vbuf.value[:vlen]
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
|
|
try:
|
|
res = get_volfile(*sys.argv[1:3])
|
|
except:
|
|
print("fetching volfile failed (volume not started?)")
|
|
|
|
try:
|
|
for line in res.split('\n'):
|
|
print(line)
|
|
except:
|
|
print("bad return value %s" % res)
|