Exemplo n.º 1
0
class RestrictedPCIDevice(Model):
    """
    Model to represent known restrictions of the given PCI devices.


    pci_id - unsupported pci_ids. It has the following
        structure: {Vendor}:{Device}:{SVendor}:{SDevice}, where all these 4
        parameters are numeric ids (see shell command spci -vmmkn). If SVendor
        and SDevice fields do not exist, then pci_id has the following structure:
        {Vendor}:{Device}.
    driver_name - the name of restricted driver
    device_name - the name of restricted device
    supported_{rhel_version} - 1 is supported on the given RHEL, 0 - not
        supported
    available_{rhel_version} - 1 is available on the given RHEL, 0 - not
        available. it could be the driver is available, but not supported
    comments - the field for comments
    """
    topic = SystemInfoTopic

    pci_id = fields.Nullable(fields.String())
    driver_name = fields.Nullable(fields.String())
    device_name = fields.Nullable(fields.String())
    available_rhel7 = fields.Integer()
    supported_rhel7 = fields.Integer()
    available_rhel8 = fields.Integer()
    supported_rhel8 = fields.Integer()
    available_rhel9 = fields.Integer()
    supported_rhel9 = fields.Integer()
    comment = fields.Nullable(fields.String())
Exemplo n.º 2
0
class CPUInfo(Model):
    """
    The model represents information about CPUs.

    The model currently doesn't represent all information about cpus could
    provide on the machine. Just part of them, in case any other attributes
    will be neded, the model can be extended.

    The provided info is aggregated - like from lscpu command. Expecting all
    CPUs are same on the machine (at least for now).
    """

    topic = SystemFactsTopic

    machine_type = fields.Nullable(fields.Integer())
    """
Exemplo n.º 3
0
class Group(Model):
    topic = SystemFactsTopic

    name = fields.String()
    gid = fields.Integer()
    members = fields.List(fields.String())
Exemplo n.º 4
0
def test_list_field():
    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.String(), required=True,
                    allow_null=False)._validate_builtin_value(
                        'something', 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.String(), required=True,
                    allow_null=False)._convert_to_model(None, 'test-value')

    fields.List(fields.String(), required=True,
                allow_null=True)._convert_to_model(None, 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.String(), required=True,
                    allow_null=False)._convert_from_model(None, 'test-value')

    fields.List(fields.String(), required=True,
                allow_null=True)._convert_from_model(None, 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.Integer(),
                    minimum=1)._validate_builtin_value([], 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.Integer(),
                    minimum=1)._validate_model_value([], 'test-value')

    fields.List(fields.Integer(),
                minimum=1)._validate_builtin_value([1], 'test-value')
    fields.List(fields.Integer(),
                minimum=1)._validate_builtin_value([1, 2], 'test-value')
    fields.List(fields.Integer(),
                minimum=1)._validate_model_value([1], 'test-value')
    fields.List(fields.Integer(),
                minimum=1)._validate_model_value([1, 2], 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.Integer(), minimum=1,
                    maximum=1)._validate_builtin_value([1, 2], 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.Integer(), minimum=1,
                    maximum=1)._validate_model_value([1, 2], 'test-value')

    fields.List(fields.Integer(),
                maximum=2)._validate_builtin_value([1], 'test-value')
    fields.List(fields.Integer(),
                maximum=2)._validate_builtin_value([1, 2], 'test-value')

    fields.List(fields.Integer(),
                maximum=2)._validate_model_value([1], 'test-value')
    fields.List(fields.Integer(),
                maximum=2)._validate_model_value([1, 2], 'test-value')

    with pytest.raises(fields.ModelViolationError):
        fields.List(fields.Integer(),
                    maximum=3)._validate_builtin_value([1, 2, 3, 4],
                                                       'test-value')
Exemplo n.º 5
0
class MockModel(Model):
    topic = RPM.topic
    list_field = fields.List(fields.Integer(), default=[42])
    list_field_nullable = fields.Nullable(fields.List(fields.String()))
    int_field = fields.Integer(default=42)
Exemplo n.º 6
0
class MockObject(Model):
    topic = RPM.topic
    value = fields.Integer(default=42)
    plan = fields.Nullable(fields.String())