Source code for insights.parsers.etc_machine_id

"""
EtcMachineId - file ``/etc/machine-id``
=======================================
"""

from insights.core import Parser
from insights.core.exceptions import SkipComponent
from insights.core.plugins import parser
from insights.parsers import get_active_lines
from insights.specs import Specs


[docs]@parser(Specs.etc_machine_id) class EtcMachineId(Parser): """ Class for parsing the file ``/etc/machine-id`` Sample file content:: 4f3fbfda59ff4aea969255a73342d439 Examples: >>> type(machine_id) <class 'insights.parsers.etc_machine_id.EtcMachineId'> >>> machine_id.machine_id '4f3fbfda59ff4aea969255a73342d439' """
[docs] def parse_content(self, content): content = get_active_lines(content) if not content or len(content) != 1: raise SkipComponent('Invalid Content') self.machine_id = content[0]