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
|
# Copyright(c) 2019-2021 Intel Corporation
|
||||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
#
|
#
|
||||||
|
import csv
|
||||||
|
import io
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
@ -46,14 +48,13 @@ class Core(Device):
|
|||||||
|
|
||||||
def __get_core_info(self):
|
def __get_core_info(self):
|
||||||
output = casadm.list_caches(OutputFormat.csv, by_id_path=True)
|
output = casadm.list_caches(OutputFormat.csv, by_id_path=True)
|
||||||
split_line = next(
|
reader = csv.DictReader(io.StringIO(output.stdout))
|
||||||
line.split(',') for line in output.stdout.splitlines()
|
for row in reader:
|
||||||
if line.startswith("core") and self.core_device.path in line
|
if row['type'] == "core" and row['disk'] == self.core_device.path:
|
||||||
)
|
return {"core_id": row['id'],
|
||||||
return {"core_id": split_line[1],
|
"core_device": row['disk'],
|
||||||
"core_device": split_line[2],
|
"status": row['status'],
|
||||||
"status": split_line[3],
|
"exp_obj": row['device']}
|
||||||
"exp_obj": split_line[5]}
|
|
||||||
|
|
||||||
def create_filesystem(self, fs_type: disk_utils.Filesystem, force=True, blocksize=None):
|
def create_filesystem(self, fs_type: disk_utils.Filesystem, force=True, blocksize=None):
|
||||||
super().create_filesystem(fs_type, force, blocksize)
|
super().create_filesystem(fs_type, force, blocksize)
|
||||||
|
Loading…
Reference in New Issue
Block a user