Using DictReader for getting core info from 'list caches' command output
Signed-off-by: Karolina Rogowska <karolina.rogowska@intel.com>
This commit is contained in:
parent
6792c1b455
commit
5951e5996f
@ -2,6 +2,8 @@
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||
#
|
||||
import csv
|
||||
import io
|
||||
from datetime import timedelta
|
||||
from typing import List
|
||||
|
||||
@ -46,14 +48,13 @@ class Core(Device):
|
||||
|
||||
def __get_core_info(self):
|
||||
output = casadm.list_caches(OutputFormat.csv, by_id_path=True)
|
||||
split_line = next(
|
||||
line.split(',') for line in output.stdout.splitlines()
|
||||
if line.startswith("core") and self.core_device.path in line
|
||||
)
|
||||
return {"core_id": split_line[1],
|
||||
"core_device": split_line[2],
|
||||
"status": split_line[3],
|
||||
"exp_obj": split_line[5]}
|
||||
reader = csv.DictReader(io.StringIO(output.stdout))
|
||||
for row in reader:
|
||||
if row['type'] == "core" and row['disk'] == self.core_device.path:
|
||||
return {"core_id": row['id'],
|
||||
"core_device": row['disk'],
|
||||
"status": row['status'],
|
||||
"exp_obj": row['device']}
|
||||
|
||||
def create_filesystem(self, fs_type: disk_utils.Filesystem, force=True, blocksize=None):
|
||||
super().create_filesystem(fs_type, force, blocksize)
|
||||
|
Loading…
Reference in New Issue
Block a user