INNER CODE UNIT · Python

write_file

LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:320

def write_file(path, content):
    print("+ write " + path, flush=True)
    os.makedirs(os.path.dirname(path), exist_ok=True)
    with open(path, "w") as fh:
        fh.write(content)


def drbd_kernel_version():
    """(major, minor) of the loaded DRBD kernel module, or None when no module
    is loaded. /proc/drbd only exists once the module is in."""
    try:
        with open("/proc/drbd") as fh:
            # "version: 9.3.2 (api:2/proto:118-124)"
            parts = fh.readline().split()
        major, minor = parts[1].split(".")[:2]
        return int(major), int(minor)
    except (OSError, IndexError, ValueError):
        return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…