Source code for insights.parsers.rhev_data_center

rhev_data_center - datasource ``rhev_data_center``
import json

from re import compile as re_compile

from insights.core import CommandParser
from insights.core.exceptions import SkipComponent
from insights.core.plugins import parser
from insights.specs import Specs

[docs] @parser(Specs.rhev_data_center) class RhevDataCenter(CommandParser): """Walk through the `/rhev/data-center` directory of RHEV host and return the full path of files not having correct file ownership i.e vdsm:kvm. See the `rhev_data_center` Datasource for more info. Attributes: data(list): A list of the parsed output returned by `rhev_data_center` Datasource. incorrect_volume_ownership(list): Volumes attached to the RHEV VMs in the Data Center having incorrect file ownership. Raises: SkipComponent: If no files are found with incorrect ownership. The following are available in ``data`` and ``incorrect_volume_ownership``: * ``name`` - file owner * ``group`` - file group * ``path`` - full path of a file Examples: >>> assert len( == 4 >>> assert len(rhev_dc.incorrect_volume_ownership) == 1 >>> assert rhev_dc.incorrect_volume_ownership[0]['path'] == '/rhev/data-center/mnt/' >>> assert rhev_dc.incorrect_volume_ownership[0]['name'] == 'root' >>> assert rhev_dc.incorrect_volume_ownership[0]['group'] == 'root' """
[docs] def parse_content(self, content): if not content: raise SkipComponent('No files found with incorrect ownership.') = json.loads(''.join(content)) # Full path of volumes attached to the RHEV VMs in the Data Center not having correct file ownership. _vol_path_pattern = re_compile("/images/[0-9,a-z,-]*/[0-9,a-z,-]*") self.incorrect_volume_ownership = [each for each in if['path'])]