engine_config - command engine-config --all

This module provides access to ovirt-engine configuration parameters by parsing output of command engine-config --all.

class insights.parsers.engine_config.EngineConfigAll(context, extra_bad_lines=None)[source]

Bases: CommandParser

Parsing output of command engine-config --all

The parser tries its best to get value & version for specified keyword. At the moment it works well for output which has keyword, value & version in a single line. It ignores keywords where is fails. It skip(rather fails) the keyword having multi-line output.

Typical output of engine-config --all command is:

MaxRerunVmOnVdsCount: 3 version: general
MaxStorageVdsTimeoutCheckSec: 30 version: general
ClusterRequiredRngSourcesDefault:  version: 3.6
ClusterRequiredRngSourcesDefault:  version: 4.0
ClusterRequiredRngSourcesDefault:  version: 4.1
HotUnplugCpuSupported: {"x86":"false","ppc":"false"} version: 3.6
HotUnplugCpuSupported: {"x86":"false","ppc":"false"} version: 4.0
HotUnplugCpuSupported: {"x86":"true","ppc":"true"} version: 4.1

Examples

>>> from insights.parsers.engine_config import EngineConfigAll
>>> from insights.tests import context_wrap
>>> output = EngineConfigAll(context_wrap(OUTPUT))}
>>> 'MaxRerunVmOnVdsCount' in output
True
>>> output['MaxRerunVmOnVdsCount']
['3']
>>> output.get('MaxRerunVmOnVdsCount')
['3']
>>> output['HotUnplugCpuSupported']
['{"x86":"false","ppc":"false"}', '{"x86":"false","ppc":"false"}', '{"x86":"true","ppc":"true"}']
>>> output['ClusterRequiredRngSourcesDefault']
[]
>>> output.head('HotUnplugCpuSupported')
'{"x86":"false","ppc":"false"}'
>>> output.last('HotUnplugCpuSupported')
'{"x86":"true","ppc":"true"}'
>>> output.get_version('HotUnplugCpuSupported')
['3.6', '4.0', '4.1']
>>> 'IDoNotExit' in output
False
>>> output['IDoNotExit']
[]
>>> output.get('IDoNotExit')
[]
>>> output.get_version('IDoNotExit')
[]
>>> output.head('IDoNotExist)
>>> output.last('IDoNotExist)
fields

List of KeyValue namedtupules for each line in the configuration file.

Type:

list

keywords

Set of keywords present in the configuration file, each keyword has been converted to lowercase.

Type:

set

get(keyword)[source]

A get value for keyword specified. A “dictionary like” method.

Example

>>> output.get('MaxStorageVdsTimeoutCheckSec')
['30']
Parameters:

keyword (str) -- A key. For ex. HotUnplugCpuSupported.

Returns:

Values associated with a keyword. Returns an empty list if, all the values are empty or keyword does not exist.

Return type:

list

get_version(keyword)[source]

Get versions associated with a key.

Typical output is engine-config --all command:

MaxStorageVdsTimeoutCheckSec: 30 version: general
HotUnplugCpuSupported: {"x86":"false","ppc":"false"} version: 3.6
HotUnplugCpuSupported: {"x86":"false","ppc":"false"} version: 4.0
HotUnplugCpuSupported: {"x86":"true","ppc":"true"} version: 4.1

Examples

>>> output.get_version('MaxStorageVdsTimeoutCheckSec')
['general']
>>> output.get_version('HotUnplugCpuSupported')
['3.6', '4.0', '4.1']
Parameters:

keyword (str) -- A key. For ex. HotUnplugCpuSupported.

Returns:

Versions associated with a keyword. Returns an empty list if, all the versions are empty or keyword does not exist.

Return type:

list

head(keyword)[source]

Get first element from values(list).

Example

>>> output['HotUnplugCpuSupported']
['{"x86":"false","ppc":"false"}', '{"x86":"false","ppc":"false"}', '{"x86":"true","ppc":"true"}']
>>> output.head('HotUnplugCpuSupported')
'{"x86":"false","ppc":"false"}'
Parameters:

keyword (str) -- A key. For ex. HotUnplugCpuSupported.

Returns:

First element from values(list) associated with a keyword else None

Return type:

str

keyvalue

namedtuple: Represent name value pair as a namedtuple with case.

alias of KeyValue

last(keyword)[source]

Get last element from values(list).

Example

>>> output['HotUnplugCpuSupported']
['{"x86":"false","ppc":"false"}', '{"x86":"false","ppc":"false"}', '{"x86":"true","ppc":"true"}']
>>> output.last('HotUnplugCpuSupported')
'{"x86":"true","ppc":"true"}'
Parameters:

keyword (str) -- A key. For ex. HotUnplugCpuSupported.

Returns:

Last element from values(list) associated with a keyword else None.

Return type:

str

parse_content(content)[source]

Parse each active line for keyword, values & version.

Parameters:

content (list) -- Output of command engine-config --all.