| Server IP : 199.250.200.62 / Your IP : 216.73.216.15 Web Server : Apache System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : jasonp18 ( 1000) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/proc/3/task/3/cwd/opt/imh-python/lib/python3.9/site-packages/mdstat/ |
Upload File : |
# Copyright 2015-2016, Truveris Inc. All Rights Reserved.
from __future__ import absolute_import
from .disk import parse_device_disks
def parse_device_header(line):
tokens = line.split()
name = tokens.pop(0)
if not name.startswith("md"):
raise ValueError("invalid device header line: {0}"
.format(line))
if tokens.pop(0) != ":":
raise ValueError("invalid device header format (missing ':'): {0}"
.format(line))
active = (tokens.pop(0) == "active")
if tokens[0] in ["(read-only)", "(auto-read-only)"]:
tokens.pop(0)
read_only = True
else:
read_only = False
if "[" not in tokens[0]:
personality = tokens.pop(0)
else:
personality = None
# If the list of disk is empty, the status line is merged with the header,
# return it so we can parse it as such.
if "[" not in tokens[0]:
status_line = " 0 blocks " + " ".join(tokens)
disks = {}
else:
status_line = None
disks = parse_device_disks(tokens)
return name, status_line, {
"active": active,
"read_only": read_only,
"personality": personality,
"disks": disks,
}