[!IMPORTANT]
This project is under development. All source code and features on the main branch are for the purpose of testing or evaluation and not production ready.
MFD Mount
Module for handling mounting fileshares on OS
Usage
You can create mounter objects in two ways:
- use generic Mount class which will automatically detect OS type based on connected setup and instantiate proper subclass
- use specific subclass e.g. PosixMount if you know beforehand which OS runs on connected setup
from mfd_connect import LocalConnection, RPyCConnection
from mfd_mount import Mount, ESXiMount, PosixMount, WindowsMount, FreeBSDMount
mounter_generic = Mount(connection=LocalConnection()) # will automatically instantiate proper subclass
mounter_windows = WindowsMount(connection=LocalConnection())
mounter_windows.mount_nfs(mount_point="Z:", share_path="10.10.10.10:/shared")
mounter_windows.is_mounted(mount_point="Z:")
mounter_posix = PosixMount(connection=LocalConnection())
mounter_posix.mount_nfs(mount_point="/mnt/shared", share_path="10.10.10.10:/shared")
mounter_posix.mount_cifs(mount_point="/mnt/shared", share_path="//10.10.10.10/shared", username='user', password='pass')
mounter_posix.mount_tmpfs(mount_point="/mnt/shared", share_path="//10.10.10.10/shared", params='-o param')
mounter_posix.mount_hugetlbfs(mount_point="/mnt/shared", share_path="//10.10.10.10/shared", params='-o param')
mounter_posix.is_mounted(mount_point="/mnt/shared")
# or
with mounter_posix.mount_nfs(mount_point="/mnt/shared", share_path="10.10.10.10:/shared"):
mounter_posix.is_mounted(mount_point="/mnt/shared") # will automatically unmount share afterwards
with mounter_posix.mount_cifs(mount_point="/mnt/shared", share_path="//10.10.10.10/shared", username='user', password='pass'):
mounter_posix.is_mounted(mount_point="/mnt/shared") # will automatically unmount share afterwards
with mounter_posix.mount_tmpfs(mount_point="/mnt/shared", share_path="//10.10.10.10/shared", params='-o param'):
mounter_posix.is_mounted(mount_point="/mnt/shared") # will automatically unmount share afterwards
with mounter_posix.mount_hugetlbfs(mount_point="/mnt/shared", share_path="//10.10.10.10/shared", params='-o param'):
mounter_posix.is_mounted(mount_point="/mnt/shared") # will automatically unmount share afterwards
mounter_esxi = ESXiMount(connection=LocalConnection())
mounter_esxi.mount_nfs(mount_point="NFSVolume", share_path="10.10.10.10:/shared")
mounter_esxi.is_mounted(mount_point="NFSVolume")
mounter_posix.umount(mount_point="/mnt/shared")
mounter_freebsd = FreeBSDMount(connection=RPyCConnection(ip='11.11.11.11', port=18813))
mounter_freebsd.mount_cifs(mount_point="/mnt/shared", share_path="10.10.10.10/shared", username='user', password='pass')
# or
with mounter_freebsd.mount_cifs(mount_point="/mnt/shared", share_path="10.10.10.10/shared", username='user', password='pass'):
mounter_freebsd.is_mounted(mount_point="/mnt/shared")
API documentation
Mount NFS share:
mount_nfs(self, *, mount_point: Union[Path, str],
share_path: Union[Path, str],
username: Optional[str],
password: Optional[str]
) -> None:
Mount CIFS share:
mount_cifs(self, *, mount_point: Union[Path, str],
share_path: Union[Path, str],
username: Optional[str],
password: Optional[str]
) -> None:
- Currently only implemented in POSIX class. Mount TMPFS share:
mount_tmpfs(self, *, mount_point: Union[Path, str],
share_path: Union[Path, str],
params: Optional[str]) -> None:
Mount HUGETLBFS share:
mount_hugetlbfs(self, *, mount_point: Union[Path, str],
share_path: Union[Path, str],
params: Optional[str]) -> None:
Check if given mountpoint is mounted:
is_mounted(self, mount_point: Union[Path, str]) -> bool:
Unmount share:
umount(self, mount_point: Union[Path, str]) -> None:
Raises UnmountException on failure
ESXi with NFS
Username and password are unused.
Mount_point is name of new volume.
share_path must be in correct format <host>/<share> or <host>:/<share> eg. 10.10.10.10:/to_share or 10.10.10.10/to_share
SSHFS
SSHFS is not built-in system tool. It requires previous installation.
On POSIX OS'es: <package-manager> install sshfs
OS supported:
- WINDOWS
- LINUX
- FreeBSD
- ESXi
| WINDOWS | LINUX | FreeBSD | ESXi | |
|---|---|---|---|---|
| CIFS | Supported :white_check_mark: | Supported :white_check_mark: | Supported :white_check_mark: | Not Supported :red_circle: |
| NFS | Supported :white_check_mark: | Supported :white_check_mark: | Supported :white_check_mark: | Supported :white_check_mark: |
| SSHFS | Not Supported :red_circle: | Supported :white_check_mark: | Not Supported :red_circle: | Not Supported :red_circle: |
| TMPFS | Not Supported :red_circle: | Supported :white_check_mark: | Not Supported :red_circle: | Not Supported :red_circle: |
| HUGELBFS | Not Supported :red_circle: | Supported :white_check_mark: | Not Supported :red_circle: | Not Supported :red_circle: |
Issue reporting
If you encounter any bugs or have suggestions for improvements, you're welcome to contribute directly or open an issue here.
Metadata
Release files for mfd-mount 1.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mfd_mount-1.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / mfd_mount-1.8.0-py3-none-any.whl
| Download URL | mfd_mount-1.8.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6bad5764ad073583da8f610d7aa863aaff184190a0711c5726219df2a6547fd
|
|
BLAKE2b-256 checksum How to use checksums |
a5c926648e26250363eeaa37bee8d2fa8d22e5b82c8af9e47c05c98d6e054dbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|