| 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/2/cwd/proc/2/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 .device_header import parse_device_header
from .device_status import parse_device_status
from .device_bitmap import parse_device_bitmap
from .device_resync import (
parse_device_resync_progress,
parse_device_resync_standby,
)
def parse_device(lines):
"""Parse all the lines of a device block.
A device block is composed of a header line with the name of the device and
at least one extra line describing the device and its status. The extra
lines have a varying format depending on the status and personality of the
device (e.g. RAID1 vs RAID5, healthy vs recovery/resync).
"""
name, status_line, device = parse_device_header(lines.pop(0))
# There are edge cases when the device list is empty and the status line is
# merged with the header line, in those cases, the status line is returned
# from parse_device_header(), the rest of the time, it's the next line.
if not status_line:
status_line = lines.pop(0)
status = parse_device_status(status_line, device["personality"])
bitmap = None
resync = None
for line in lines:
if line.startswith(" bitmap:"):
bitmap = parse_device_bitmap(line)
elif line.startswith(" ["):
resync = parse_device_resync_progress(line)
elif line.startswith(" \tresync="):
resync = parse_device_resync_standby(line)
else:
raise NotImplementedError("unknown device line: {0}".format(line))
device.update({
"status": status,
"bitmap": bitmap,
"resync": resync,
})
return (name, device)