INNER CODE UNIT · Python

unit_exists

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

def unit_exists(unit):
    return _run(["systemctl", "cat", unit + ".service"],
                capture=True).returncode == 0


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)"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…