Skip to content

intel/mfd-mount

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:

  1. use generic Mount class which will automatically detect OS type based on connected setup and instantiate proper subclass
  2. 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 ✅ Supported ✅ Supported ✅ Not Supported 🔴
NFS Supported ✅ Supported ✅ Supported ✅ Supported ✅
SSHFS Not Supported 🔴 Supported ✅ Not Supported 🔴 Not Supported 🔴
TMPFS Not Supported 🔴 Supported ✅ Not Supported 🔴 Not Supported 🔴
HUGELBFS Not Supported 🔴 Supported ✅ Not Supported 🔴 Not Supported 🔴

Issue reporting

If you encounter any bugs or have suggestions for improvements, you're welcome to contribute directly or open an issue here.

About

No description or website provided.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •