disk

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ISCSIDEVICE is the map key to get or save iscci device
	ISCSIDEVICE = "iscsi_device"
	// ISCSIIQN is the map key to get or save iSCSI IQN
	ISCSIIQN = "iscci_iqn"
	// ISCSIIP is the map key to get or save iSCSI IP
	ISCSIIP = "iscsi_ip"
	// ISCSIPORT is the map key to get or save iSCSI Port
	ISCSIPORT = "iscsi_port"

	LIST_PATHS_COMMAND  = "ls -f /dev/disk/by-path"
	DISK_BY_PATH_FOLDER = "/dev/disk/by-path/"
)
View Source
const (
	EncryptedUmountCommand = "encrypt-umount"

	EncryptionMountCommand = "encrypt-mount"
)
View Source
const (
	CHROOT_BASH_COMMAND = "chroot-bash"
)

Variables

View Source
var ErrMountPointNotFound = errors.New("mount point not found")

ErrMountPointNotFound is returned when a given path does not appear to be a mount point.

Functions

func FindFromDevicePath

func FindFromDevicePath(logger *zap.SugaredLogger, mountDevice string) ([]string, error)

FindFromDevicePath extracts the IQN, IPv4 address, and port from a iSCSI mount device path. i.e. /dev/disk/by-path/ip-<ip>:<port>-iscsi-<IQN>-lun-1

func FindFromMountPointPath

func FindFromMountPointPath(logger *zap.SugaredLogger, diskByPaths []string) ([]string, error)

FindFromMountPointPath gets /dev/disk/by-path/ip-<ip>:<port>-iscsi-<IQN>-lun-1 from the given mount point path.

func GetDiskPathFromMountPath

func GetDiskPathFromMountPath(logger *zap.SugaredLogger, mountPath string) ([]string, error)

GetDiskPathFromMountPath resolves a directory to a block device

func GetIscsiDevicePath added in v1.26.3

func GetIscsiDevicePath(disk *Disk) (string, error)

func GetMultipathFriendlyName added in v1.26.3

func GetMultipathFriendlyName(consistentDevicePath string, logger *zap.SugaredLogger) (string, error)

func GetMultipathIscsiDevicePath added in v1.26.3

func GetMultipathIscsiDevicePath(ctx context.Context, consistentDevicePath string, logger *zap.SugaredLogger) (string, error)

func MakeMountArgs added in v1.25.2

func MakeMountArgs(source, target, fstype string, options []string) (mountArgs []string, mountArgsLogStr string)

func MountWithEncrypt added in v1.25.2

func MountWithEncrypt(logger *zap.SugaredLogger, source string, target string, fstype string, options []string) error
func ReadLink(symbolicLink string, logger *zap.SugaredLogger) (string, error)

func Rescan added in v1.26.3

func Rescan(logger *zap.SugaredLogger, devicePath string) error

func UnmountPath added in v1.24.0

func UnmountPath(logger *zap.SugaredLogger, mountPath string, mounter mount.Interface) error

UnmountPath is a common unmount routine that unmounts the given path and deletes the remaining directory if successful.

func UnmountWithEncrypt added in v1.24.0

func UnmountWithEncrypt(logger *zap.SugaredLogger, target string) error

Unmount the target that is in-transit encryption enabled

func WaitForDevicePathToExist added in v1.26.3

func WaitForDevicePathToExist(ctx context.Context, disk *Disk, logger *zap.SugaredLogger) (string, error)

func WaitForDirectoryDeletion added in v1.24.0

func WaitForDirectoryDeletion(logger *zap.SugaredLogger, mountPath string) error

Types

type Disk

type Disk struct {
	IQN  string
	IPv4 string
	Port int
}

Disk interface

func GetScsiInfo added in v1.26.3

func GetScsiInfo(mountDevice string) (*Disk, error)

func (*Disk) String

func (sd *Disk) String() string

func (*Disk) Target

func (sd *Disk) Target() string

Target returns the target to connect to in the format ip:port.

type Interface

type Interface interface {
	// AddToDB adds the iSCSI node record for the target.
	AddToDB() error
	// FormatAndMount formats the given disk, if needed, and mounts it.  That is
	// if the disk is not formatted and it is not being mounted as read-only it
	// will format it first then mount it. Otherwise, if the disk is already
	// formatted or it is being mounted as read-only, it will be mounted without
	// formatting.
	FormatAndMount(source string, target string, fstype string, options []string) error

	//Mount only mounts the disk. In case if formatting is handled by different functionality.
	// This function doesn't bother for checking the format again.
	Mount(source string, target string, fstype string, options []string) error

	// Login logs into the iSCSI target.
	Login() error

	// Logout logs out the iSCSI target.
	Logout() error

	DeviceOpened(pathname string) (bool, error)
	// updates the queue depth for iSCSI target
	UpdateQueueDepth() error

	// RemoveFromDB removes the iSCSI target from the database.
	RemoveFromDB() error

	// SetAutomaticLogin sets the iSCSI node to automatically login at machine
	// start-up.
	SetAutomaticLogin() error

	// UnmountPath is a common unmount routine that unmounts the given path and
	// deletes the remaining directory if successful.
	UnmountPath(path string) error

	Rescan(devicePath string) error

	Resize(devicePath string, volumePath string) (bool, error)

	WaitForVolumeLoginOrTimeout(ctx context.Context, multipathDevices []core.MultipathDevice) error

	GetDiskFormat(devicePath string) (string, error)

	WaitForPathToExist(path string, maxRetries int) bool
}

Interface mounts iSCSI volumes.

func New

func New(logger *zap.SugaredLogger, iqn, ipv4 string, port int) Interface

New creates a new iSCSI handler.

func NewFromDevicePath

func NewFromDevicePath(logger *zap.SugaredLogger, mountDevice string) (Interface, error)

NewFromDevicePath extracts the IQN, IPv4 address, and port from a iSCSI mount device path. i.e. /dev/disk/by-path/ip-<ip>:<port>-iscsi-<IQN>-lun-1

func NewFromISCSIDisk

func NewFromISCSIDisk(logger *zap.SugaredLogger, sd *Disk) Interface

NewFromISCSIDisk creates a new iSCSI handler from ISCSIDisk.

func NewFromMountPointPath

func NewFromMountPointPath(logger *zap.SugaredLogger, mountPath string) (Interface, error)

NewFromMountPointPath gets /dev/disk/by-path/ip-<ip>:<port>-iscsi-<IQN>-lun-1 from the given mount point path.

func NewFromPVDisk

func NewFromPVDisk(logger *zap.SugaredLogger) Interface

NewFromPVDisk creates a new PV handler from PVDisk.

func NewISCSIUHPMounter added in v1.26.3

func NewISCSIUHPMounter(logger *zap.SugaredLogger) Interface

Jump to

Keyboard shortcuts

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