Beispiel #1
0
class SELinuxFacts(Model):
    topic = SystemFactsTopic

    runtime_mode = fields.Nullable(
        fields.StringEnum(['enforcing', 'permissive']))
    static_mode = fields.StringEnum(['enforcing', 'permissive', 'disabled'])
    enabled = fields.Boolean()
    policy = fields.StringEnum(['targeted', 'minimum', 'mls'])
    mls_enabled = fields.Boolean()
Beispiel #2
0
class Report(Model):
    topic = SystemInfoTopic

    severity = fields.StringEnum(choices=['Info', 'Warning', 'Error'])

    result = fields.StringEnum(
        choices=['Not Applicable', 'Fixed', 'Pass', 'Fail'])

    summary = fields.String()
    details = fields.String()
    solutions = fields.Nullable(fields.String())
class SELinux(Model):
    topic = SystemInfoTopic

    # FIXME: fixme properly regarding the issue:
    # # https://github.com/oamg/leapp-repository/issues/20
    runtime_mode = fields.Nullable(
        fields.StringEnum(['enforcing', 'permissive']))
    static_mode = fields.StringEnum(['enforcing', 'permissive', 'disabled'])
    enabled = fields.Boolean()
    policy = fields.String()
    mls_enabled = fields.Boolean()
Beispiel #4
0
def test_choices_wrong_value():
    with pytest.raises(fields.ModelMisuseError):
        fields.StringEnum(choices='abc')
    fields.StringEnum(choices=('abc', ))
    with pytest.raises(fields.ModelMisuseError):
        fields.IntegerEnum(choices=1)
    fields.IntegerEnum(choices=(1, ))
    with pytest.raises(fields.ModelMisuseError):
        fields.FloatEnum(choices=1.2)
    fields.FloatEnum(choices=(1.2, ))
    with pytest.raises(fields.ModelMisuseError):
        fields.NumberEnum(choices=3.14)
    fields.NumberEnum(choices=(3.14, ))
class OpenSshConfig(Model):
    """
    OpenSSH server configuration.

    This model contains the first effective configuration option specified
    in the configuration file or a list of all the options specified
    in all the conditional blocks used throughout the file.
    """
    topic = SystemInfoTopic

    permit_root_login = fields.List(fields.Model(OpenSshPermitRootLogin))
    """ All PermitRootLogin directives. """
    use_privilege_separation = fields.Nullable(fields.StringEnum(['sandbox',
                                                                  'yes',
                                                                  'no']))
    """ Value of the UsePrivilegeSeparation directive, if present. Removed in RHEL 8. """
    protocol = fields.Nullable(fields.String())
    """ Value of the Protocols directive, if present. Removed in RHEL 8. """
    ciphers = fields.Nullable(fields.String())
    """ Value of the Ciphers directive, if present. Ciphers separated by comma. """
    macs = fields.Nullable(fields.String())
    """ Value of the MACs directive, if present. """
    modified = fields.Boolean(default=False)
    """ True if the configuration file was modified. """
    deprecated_directives = fields.List(fields.String())
    """ Configuration directives that were deprecated in the new version of openssh. """
Beispiel #6
0
class ErrorModel(Model):
    topic = ErrorTopic

    message = fields.String()
    severity = fields.StringEnum(choices=ErrorSeverity.ALLOWED_VALUES, default=ErrorSeverity.ERROR)
    details = fields.Nullable(fields.String())
    actor = fields.String()
    time = fields.DateTime()
class OpenSshPermitRootLogin(Model):
    topic = SystemInfoTopic

    value = fields.StringEnum(['yes', 'prohibit-password',
                               'forced-commands-only', 'no'])
    """ Value of a PermitRootLogin directive. """
    in_match = fields.Nullable(fields.List(fields.String()))
    """ Criteria of Match blocks the PermitRootLogin directive occured in, if any. """
Beispiel #8
0
class ErrorModel(Model):
    topic = ErrorTopic

    message = fields.String(required=True)
    severity = fields.StringEnum(required=True,
                                 choices=ErrorSeverity.ALLOWED_VALUES,
                                 default=ErrorSeverity.ERROR)
    details = fields.String(required=True, allow_null=True, default=None)
    actor = fields.String(required=True)
    time = fields.DateTime(required=True)
Beispiel #9
0
class Report(Model):
    """
    Framework model used for reporting and presentation (see "renderers" field) purposes. The report can also carry
    a special meaning using "flags" field.
    """

    __non_inheritable__ = True

    topic = ReportTopic

    severity = fields.StringEnum(choices=['low', 'medium', 'high'])
    """
    Severity of the report entry
    """

    title = fields.String()
    """
    Title of the report entry
    """

    detail = fields.JSON()
    """
    Detail of the report entry as JSON data
    """

    renderers = fields.Model(Renderers)
    """
    :class:`Renderers` describe how to render this report entry
    """

    audience = fields.List(
        fields.StringEnum(choices=['developer', 'sysadmin']))
    """
    Who is the main audience of this report entry
    """

    flags = fields.List(fields.StringEnum(choices=['inhibitor']))
    """
Beispiel #10
0
class RepositoryMap(Model):
    """
    Mapping between repositories to be used during upgrade.

    Mapping of current system repository to target system version repositories to determine which
    ones should be enabled for the correct upgrade process.
    """

    topic = TransactionTopic

    from_id = fields.String()
    to_id = fields.String()
    from_minor_version = fields.String()
    to_minor_version = fields.String()
    arch = fields.String()
    repo_type = fields.StringEnum(choices=['rpm', 'srpm', 'debuginfo'])
Beispiel #11
0
class OpenSshConfig(Model):
    """
    OpenSSH server configuration.

    This model contains the first effective configuration option specified
    in the configuration file or a list of all the options specified
    in all the conditional blocks used throughout the file.
    """
    topic = SystemInfoTopic

    permit_root_login = fields.List(fields.Model(OpenSshPermitRootLogin))
    use_privilege_separation = fields.Nullable(fields.StringEnum(['sandbox',
                                                                  'yes',
                                                                  'no']))
    protocol = fields.Nullable(fields.String())
    ciphers = fields.Nullable(fields.String())
    macs = fields.Nullable(fields.String())

    modified = fields.Nullable(fields.Boolean())
Beispiel #12
0
class IPUConfig(Model):
    """
    IPU workflow configuration model
    """
    topic = SystemInfoTopic

    leapp_env_vars = fields.List(fields.Model(EnvVar), default=[])
    """Environment variables related to the leapp."""

    os_release = fields.Model(OSRelease)
    """Data about the OS get from /etc/os-release."""

    version = fields.Model(Version)
    """Version of the current (source) system and expected target system."""

    architecture = fields.String()
    """Architecture of the system. E.g.: 'x86_64'."""

    kernel = fields.String()
    """Originally booted kernel when on the source system."""

    flavour = fields.StringEnum(('default', 'saphana'), default='default')
    """Flavour of the upgrade - Used to influence changes in supported source/target release"""
class RepositoryMap(Model):
    """
    Mapping between repositories to be used during upgrade.

    Mapping of current system repository to target system version repositories to determine which
    ones should be enabled for the correct upgrade process.
    """

    topic = TransactionTopic

    from_repoid = fields.String()
    """RHEL 7 repoid as present in the Red Hat CDN"""
    to_repoid = fields.String()
    """RHEL 8 repoid as present in the Red Hat CDN"""
    to_pes_repo = fields.String()
    """RHEL 8 repo name as used in the Package Evolution Service database"""
    from_minor_version = fields.String()
    """To which RHEL 7 minor versions the mapping relates to"""
    to_minor_version = fields.String()
    """To which RHEL 8 minor versions the mapping relates to"""
    arch = fields.String()
    """CPU architecture the mapping relates to"""
    repo_type = fields.StringEnum(choices=['rpm', 'srpm', 'debuginfo'])
    """Type of content the mapped repos hold"""
Beispiel #14
0
class FirewallDecisionM(Model):
    topic = SystemInfoTopic

    # Yes, No, Skip
    disable_choice = fields.StringEnum(choices=['Y', 'N', 'S'])
Beispiel #15
0
class OpenSshPermitRootLogin(Model):
    topic = SystemInfoTopic

    value = fields.StringEnum(['yes', 'prohibit-password',
                               'forced-commands-only', 'no'])
    in_match = fields.Nullable(fields.List(fields.String()))
Beispiel #16
0
class FirmwareFacts(Model):
    topic = SystemFactsTopic

    firmware = fields.StringEnum(['bios', 'efi'])
Beispiel #17
0
def test_list_field_default():
    fields.List(fields.StringEnum(choices=('1', '2', '3')), default=['1', '2'])
Beispiel #18
0
class PESIDRepositoryEntry(Model):
    """
    Represent metadata about particular repository.

    The metadata are used to identify purpose and nature of the repository.

    Warning: This model is not expected to be consumed/produced by any actor
    directly. As well, it is not covered by deprecation process and can be
    changed or removed any time.
    """

    topic = TransactionTopic

    pesid = fields.String()
    """
    The PES id of the repository.

    The PES id indicate family of YUM repositories. E.g. rhel8-BaseOS covers
    variants of BaseOS YUM repositories for all channels, architectures,
    RHUI, etc, which have basically same purpose.
    """

    major_version = fields.String()
    """
    The major version of OS.

    E.g. for RHEL 7.9 the major version is 7. Since we work with versions
    as with strings throughout the whole codebase, we keep this data type here too.
    """

    repoid = fields.String()
    """
    The repository ID which identifies the repository from YUM/DNF POV.
    """

    arch = fields.StringEnum(['x86_64', 's390x', 'ppc64le', 'aarch64'])
    """
    The architecture for which the repository is delivered.
    """

    repo_type = fields.StringEnum(['rpm', 'debug', 'srpm'])
    """
    The repository type.

    In our case, we usually map just repositories with the 'rpm' type, so
    usually you can see just this one, but the others are possible to add
    too.
    """

    channel = fields.StringEnum(['ga', 'tuv', 'e4s', 'eus', 'aus', 'beta'])
    """
    The 'channel' of the repository.

    The 'channel' could be a little bit inaccurate term, but let's use it in
    this project. The standard repositories has 'ga' channel. 'beta'
    repositories are unsupported for IPU, however they are useful for testing
    purposes. The other channels indicate premium repositories.
    """

    rhui = fields.StringEnum(['', 'aws', 'azure'])
    """
Beispiel #19
0
 def _fun(**kwargs):
     return fields.StringEnum(choices=choices, **kwargs)