nfs

package
v0.0.0-...-1c5d739 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 22 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidExportedName is returned when an exported name is not a valid single directory name
	ErrInvalidExportedName = errors.New("nfs server: invalid exported name")
	// ErrInvalidBasePath is returned when the local path to export is invalid
	ErrInvalidBasePath = errors.New("nfs server: invalid base path")
	// ErrBasePathNotDir is returned when the base path is not a directory
	ErrBasePathNotDir = errors.New("nfs server: base path not a directory")
	// ErrInvalidNetwork is returned when the network specifier does not parse in CIDR format
	ErrInvalidNetwork = errors.New("nfs server: the network value is not CIDR")
)
View Source
var ErrMalformedNFSMountpoint = errors.New("malformed nfs mountpoint")

ErrMalformedNFSMountpoint is returned when the nfs mountpoint string is malformed

View Source
var ErrNfsMountingUnsupported = errors.New("nfs mounting not supported; install nfs-common")

ErrNfsMountingUnsupported is returned when the mount.nfs4 binary is not found

Functions

func Mount

func Mount(driver Driver, remotePath, localPath string) error

Mount attempts to mount the nfsPath to the localPath

func Unmount

func Unmount(driver Driver, localPath string) error

Unmount attempts to unmount the localPath

Types

type Driver

type Driver interface {
	// Installed determines if the driver is installed on the system
	Installed() error
	// Info provides information about the mounted drive
	// TODO: make output more universal
	Info(localPath string, info *proc.NFSMountInfo) error
	// Mount mounts the remote path to local
	Mount(remotePath, localPath string, timeout time.Duration) error
	// Unmount force unmounts a volume
	Unmount(localPath string) error
}

type NFSDriver

type NFSDriver struct{}

func (*NFSDriver) Info

func (d *NFSDriver) Info(localPath string, info *proc.NFSMountInfo) error

func (*NFSDriver) Installed

func (d *NFSDriver) Installed() error

func (*NFSDriver) Mount

func (d *NFSDriver) Mount(remotePath, localPath string, timeout time.Duration) error

func (*NFSDriver) Unmount

func (d *NFSDriver) Unmount(localPath string) error

type NfsClientValidator

type NfsClientValidator interface {
	ValidateClient(string) bool
}

Refine facade.DfsValidator to avoid circular dependencies

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server manages exporting an NFS mount.

func NewServer

func NewServer(basePath, exportedName, network string) (*Server, error)

NewServer returns a nfs.Server object that manages the given nfs mounts to configured clients; basePath is the path for volumes, exportedName is the container dir to hold exported volumes

func (*Server) AddVolume

func (c *Server) AddVolume(volumePath string) error

VolumeCreated set that path of a volume that should be exported

func (*Server) Clients

func (c *Server) Clients() []string

Clients returns the IP Addresses of the current clients

func (*Server) ExportNamePath

func (c *Server) ExportNamePath() string

Returns the export path name; a combination of the exportsDir and ExportPath

func (*Server) ExportPath

func (c *Server) ExportPath() string

ExportPath returns the external export name; foo for nfs export /exports/foo

func (*Server) GetDevice

func (c *Server) GetDevice(path string) (uint64, error)

Returns the backing device for a given path. Set on the Driver object to make the mount device check testable.

func (*Server) RemoveVolume

func (c *Server) RemoveVolume(volumePath string) error

VolumeCreated set that path of a volume that should be exported

func (*Server) Restart

func (c *Server) Restart() error

Restart restarts the nfs subsystem

func (*Server) SetClientValidator

func (c *Server) SetClientValidator(validator NfsClientValidator)

func (*Server) SetClients

func (c *Server) SetClients(clients ...string)

SetClients replaces the existing clients with the new clients

func (*Server) Stop

func (c *Server) Stop() error

Stop stops the nfs subsystem

func (*Server) Sync

func (c *Server) Sync() error

Sync ensures that the nfs exports are visible to all clients

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL