Initial import of the existing CephFS subvolume migration prototype, including the native libcephfs transport, rsync backend, local Ceph lab environment and integration tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Read-only lab probe: compare native snapshot identity across two clusters."""
|
|
import argparse
|
|
import json
|
|
import subprocess
|
|
|
|
import cephfs
|
|
|
|
|
|
def snapshot_identity(endpoint, name):
|
|
args = ["ceph", "--conf", endpoint["config"], "--keyring", endpoint["keyring"]]
|
|
user = endpoint.get("user", "client.admin")
|
|
if user:
|
|
args += ["--name", user]
|
|
args += ["fs", "subvolume", "snapshot", "getpath",
|
|
endpoint["filesystem"], endpoint["subvolume"], name]
|
|
if endpoint.get("group"):
|
|
args += ["--group_name", endpoint["group"]]
|
|
path = subprocess.check_output(args, text=True, timeout=30).strip()
|
|
fs = cephfs.LibCephFS(conffile=endpoint["config"],
|
|
auth_id=user.removeprefix("client."))
|
|
try:
|
|
fs.conf_set("keyring", endpoint["keyring"])
|
|
fs.conf_set("client_fs", endpoint["filesystem"])
|
|
fs.mount()
|
|
info = fs.snap_info(path)
|
|
birthtime = fs.getxattr(path, "ceph.snap.btime").decode("ascii")
|
|
return {"id": info["id"], "birthtime": birthtime}
|
|
finally:
|
|
fs.shutdown()
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--config", required=True)
|
|
parser.add_argument("--snapshot", required=True)
|
|
args = parser.parse_args()
|
|
with open(args.config) as f:
|
|
config = json.load(f)
|
|
source = snapshot_identity(config["source"], args.snapshot)
|
|
target = snapshot_identity(config["target"], args.snapshot)
|
|
print(json.dumps({"snapshot": args.snapshot, "source": source, "target": target,
|
|
"native_ids_equal": source["id"] == target["id"],
|
|
"native_birthtimes_equal": source["birthtime"] == target["birthtime"]}))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|