#!/usr/bin/python3
-import json
import mmap
import os
import subprocess
-
-def get_data_pool():
- cmd = ['ceph', 'fs', 'ls', '--format=json-pretty']
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- out = proc.communicate()[0]
- return json.loads(out)[0]['data_pools'][0]
-
-
def main():
- fd = os.open("testfile", os.O_RDWR | os.O_CREAT | os.O_TRUNC | os.O_DIRECT, 0o644)
+ path = "testfile"
+ fd = os.open(path, os.O_RDWR | os.O_CREAT | os.O_TRUNC | os.O_DIRECT, 0o644)
ino = os.fstat(fd).st_ino
obj_name = "{ino:x}.00000000".format(ino=ino)
- pool_name = get_data_pool()
+ pool_name = os.getxattr(path, "ceph.file.layout.pool")
buf = mmap.mmap(-1, 1)
buf.write(b'1')