class FirewalldFacts(Model): """The model contains firewalld configuration.""" topic = SystemInfoTopic firewall_config_command = fields.String(default='') ebtablesTablesInUse = fields.List(fields.String(), default=[]) ipsetTypesInUse = fields.List(fields.String(), default=[])
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())
class RpmTransactionTasks(Model): topic = TransactionTopic local_rpms = fields.List(fields.String(), default=[]) to_install = fields.List(fields.String(), default=[]) to_keep = fields.List(fields.String(), default=[]) to_remove = fields.List(fields.String(), default=[])
class RootSubdirectory(Model): """ Representation of a single root subdirectory. Can be expanded as needed. """ topic = SystemFactsTopic name = fields.String() target = fields.Nullable(fields.String()) # if it's a link
class RPM(Model): topic = SystemInfoTopic name = fields.String(required=True) epoch = fields.String(required=True) version = fields.String(required=True) release = fields.String(required=True) arch = fields.String(required=True)
class PartitionEntry(Model): topic = SystemInfoTopic major = fields.String() minor = fields.String() blocks = fields.String() name = fields.String()
class Module(Model): """ A single DNF module indentified by its name and stream. """ topic = SystemFactsTopic name = fields.String() stream = fields.String()
def test_not_required_field_types(): fields.Nullable(fields.String())._validate_model_value(None, 'test-value') fields.Nullable(fields.String())._validate_model_value(None, 'test-value') fields.Nullable(fields.String())._validate_builtin_value( None, 'test-value') fields.Nullable(fields.String())._validate_builtin_value( None, 'test-value')
class CheckOutput(Model): topic = CheckOutputTopic check_actor = fields.String(required=True) check_action = fields.String() status = fields.String(required=True) summary = fields.String(required=True) params = fields.List(fields.String(), required=True)
class MountEntry(Model): topic = SystemInfoTopic name = fields.String() mount = fields.String() tp = fields.String() options = fields.String()
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. """
class DialogModel(Model): topic = DialogTopic answerfile_sections = fields.JSON() actor = fields.String() details = fields.Nullable(fields.String()) key = fields.Nullable(fields.String())
class TargetUserSpaceInfo(Model): """ Information about the target userspace container to be able to use it The target userspace container contains the most crucial part of the target system to be able to proceed the inplace upgrade process (let's simplify it, and call it bootstrap of the target system). It contains (e.g.) the package manager of the target system, so we can calculate and process the RPM transaction. Additionally, it is used to create the upgrade initramfs (see the UpgradeInitramfsTasks model for more information). See the TargetUserSpaceTasks model for possibilities to influence content of the container automatically. """ topic = TransactionTopic path = fields.String() """ Path to the created target userspace directory It could be used as a container. It contains top level rootfs directories (bin, usr, var, ...). """ scratch = fields.String() """ Path to the directory with stored xfs-ftype workaround files It's not possible to create overlayfs over XFS without the ftype attribute. To workaround this problem, we are creating these files with EXT4 FS inside. """ mounts = fields.String() """
class User(Model): topic = SystemFactsTopic name = fields.String() uid = fields.Integer() gid = fields.Integer() home = fields.String()
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')
class RepoMapEntry(Model): topic = TransactionTopic source = fields.String() """The source PES id.""" target = fields.List(fields.String()) """List of target PES ids"""
class KernelCmdlineArg(Model): """ Single kernel command line argument to include to RHEL-8 kernel cmdline """ topic = SystemInfoTopic key = fields.String() value = fields.String()
class RenamedInterface(Model): """ Provide original and new name of the network interface when renamed """ topic = SystemInfoTopic rhel7_name = fields.String() rhel8_name = fields.String()
class EnvVar(Model): topic = SystemInfoTopic name = fields.String() """Name of the environment variable.""" value = fields.String() """Value of the environment variable."""
class Version(Model): topic = SystemInfoTopic source = fields.String() """Version of the source (current) system. E.g.: '7.8'.""" target = fields.String() """Version of the target system. E.g. '8.2.'."""
class SELinuxModule(Model): """SELinux module in cil including priority""" topic = SystemInfoTopic name = fields.String() priority = fields.Integer() content = fields.String() # lines removed due to content invalid on RHEL 8 removed = fields.List(fields.String())
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 UsedRepository(Model): """ Describe list of current packages installed from a specific repository """ topic = SystemInfoTopic repository = fields.String() packages = fields.List(fields.String(), default=[])
class RepositoryData(Model): topic = SystemInfoTopic name = fields.String() baseurl = fields.Nullable(fields.String()) metalink = fields.Nullable(fields.String()) mirrorlist = fields.Nullable(fields.String()) enabled = fields.Boolean(default=True) additional_fields = fields.Nullable(fields.String())
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)
class KernelCmdlineArg(Model): """ Single kernel command line parameter with/without a value When produced alone, represents a parameter to include in RHEL-8 kernel cmdline. """ topic = SystemInfoTopic key = fields.String() value = fields.Nullable(fields.String())
class PCIAddress(Model): """ TODO: tbd """ topic = SystemInfoTopic domain = fields.String() bus = fields.String() function = fields.String() device = fields.String()
class SkippedRepositories(Model): """ Message that contains all skipped repositories and the packages that will not be upgraded as a result of those repositories being skipped. """ topic = TransactionTopic repos = fields.List(fields.String(), default=[]) """ List of repositories ids that are going to be skipped for the upgrade """ packages = fields.List(fields.String(), default=[]) """ List of packages that are not going to be upgraded because of skipped repositories """
class RpmTransactionTasks(Model): topic = TransactionTopic local_rpms = fields.List(fields.String(), default=[]) to_install = fields.List(fields.String(), default=[]) to_keep = fields.List(fields.String(), default=[]) to_remove = fields.List(fields.String(), default=[]) to_upgrade = fields.List(fields.String(), default=[]) modules_to_enable = fields.List(fields.Model(Module), default=[]) modules_to_reset = fields.List(fields.Model(Module), default=[])
class AllFieldTypesModel(Model): topic = ModelTestTopic float_field = fields.Float(default=3.14, required=True) number_int_field = fields.Number(default=1.2, required=True) number_float_field = fields.Number(default=2, required=True) integer_field = fields.Integer(default=1, required=True) str_field = fields.String(default='string', required=True) unicode_field = fields.String(default=u'Unicode string', required=True) date_field = fields.DateTime(default=datetime.utcnow(), required=True) bool_field = fields.Boolean(default=True, required=True)