NFS Backend#
NFSBackend configuration schema for OpenFactory applications.
This module defines the NFSBackendConfig class, which extends
BaseBackendConfig to configure NFS (POSIX filesystem) backends.
The NFSBackend allows OpenFactory services to mount a network-shared directory from an NFS server into Docker containers, providing a standard FileBackend interface for file operations.
Note
Server addresses are validated as hostnames, IPv4, or IPv6 (IPv6 must be in brackets).
Remote paths and container mount points are validated to be absolute, normalized, and safe.
Optional mount options can be specified for fine-tuning NFS mounts.
This module only provides configuration and validation; it does not perform actual file operations.
Usage Example
To use the NFS Storage Backend, add a storage entry to your OpenFactory YAML configuration file:
storage:
type: nfs
server: nfs.server.openfactory.org
remote_path: /nfs/data
mount_point: /mnt
mount_options:
- rw
- noatime
See also
The runtime class of the NFS Backend is openfactory.filelayer.nfs_backend.NFSBackend.
- class openfactory.schemas.filelayer.nfs_backend.NFSBackendConfig(**data)[source]#
Bases:
BaseBackendConfigConfiguration schema for NFSBackend.
This schema is used by the deployment tool to mount an NFS share into OpenFactory service containers. It validates paths, server addresses, and optional mount options.
- classmethod clean_mount_options(value)[source]#
Cleans the mount_options list by stripping whitespace and removing empty strings.
- Parameters:
value (Optional[List[str]]) – List of mount options.
- Returns:
Optional[List[str]] – Cleaned list of mount options or None.
- create_backend_instance()[source]#
Instantiate the runtime NFSBackend using this configuration.
- Return type:
openfactory.filelayer.nfs_backend.NFSBackend
- Returns:
NFSBackend – Runtime backend instance.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'str_strip_whitespace': True, 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod validate_export_path(value)[source]#
Validates and normalizes the remote_path.
- Return type:
- Parameters:
value (str) – Remote path on the NFS server.
- Returns:
str – Normalized absolute path.
- Raises:
ValueError – If the path is not absolute.
- classmethod validate_mount_point(value)[source]#
Validates and normalizes the mount point inside the container.
- Return type:
- Parameters:
value (str) – Mount point path.
- Returns:
str – Normalized absolute path.
- Raises:
ValueError – If the path is invalid (relative, contains ‘..’, invalid chars, or too long).
- classmethod validate_server(value)[source]#
Validates that the server is a non-empty string representing a valid hostname, IPv4 address, or IPv6 address (IPv6 must be in brackets).
- Return type:
- Parameters:
value (str) – Server string to validate.
- Returns:
str – Cleaned server string.
- Raises:
ValueError – If the server string is empty or invalid.