connector

package
v0.0.0-...-52cd4e6 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package connector provide methods of interacting with the host

Package connector provide methods of interacting with the host

Package connector provide methods of interacting with the host

Package connector provide methods of interacting with the host

Package connector provide methods of interacting with the host

Package connector is a package that used to operate host devices

Index

Constants

View Source
const (
	// FCDriver name string
	FCDriver = "fibreChannel"
	// FCNVMeDriver name string
	FCNVMeDriver = "FC-NVMe"
	// ISCSIDriver name string
	ISCSIDriver = "iSCSI"
	// RoCEDriver name string
	RoCEDriver = "RoCE"
	// LocalDriver name string
	LocalDriver = "Local"
	// NFSDriver name string
	NFSDriver = "NFS"
	// NFSPlusDriver name string
	NFSPlusDriver = "NFS+"

	// MountFSType file system type
	MountFSType = "fs"
	// MountBlockType block type
	MountBlockType = "block"

	// HCTLLength length of HCTL
	HCTLLength = 4

	// UltraPathCommand ultra-path name string
	UltraPathCommand = "ultraPath"
	// UltraPathNVMeCommand ultra-path-NVMe name string
	UltraPathNVMeCommand = "ultraPath-NVMe"

	// DMMultiPath DM-multipath name string
	DMMultiPath = "DM-multipath"
	// HWUltraPath HW-UltraPath name string
	HWUltraPath = "HW-UltraPath"
	// HWUltraPathNVMe HW-UltraPath-NVMe name string
	HWUltraPathNVMe = "HW-UltraPath-NVMe"
	// UnsupportedMultiPathType multi-path type not supported
	UnsupportedMultiPathType = "UnsupportedMultiPathType"

	// VolumeNotFound the message of volume not found error
	VolumeNotFound = "VolumeDeviceNotFound"
	// VolumePathIncomplete the message of volume path incomplete
	VolumePathIncomplete = "VolumePathIncomplete"

	// PingCommand "ping" command format string
	PingCommand = "ping -c 3 -i 0.001 -w 1 %s"
)
View Source
const (
	// Connect field is used for lock
	Connect = "connect"
	// DisConnect field is used for lock
	DisConnect = "disConnect"
	// Extend field is used for lock
	Extend = "extend"
	// VolumeDeviceNotFound field is used for find no volume device
	VolumeDeviceNotFound = "volume device not found"
)
View Source
const (
	// NotUseMultipath means the device does not use multipath service
	NotUseMultipath = iota
	// UseDMMultipath means the device use DM-Multipath service
	UseDMMultipath
	// UseUltraPath means the device use huawei-UltraPath service
	UseUltraPath
	// UseUltraPathNVMe means the device use huawei-UltraPath-NVMe service
	UseUltraPathNVMe
)

Variables

View Source
var (
	// DisconnectVolumeTimeOut defines the timeout period for disconnecting volume
	DisconnectVolumeTimeOut = time.Minute
	// DisconnectVolumeTimeInterval defines the time interval for checking if connected volume
	DisconnectVolumeTimeInterval = time.Second
)
View Source
var DoScanNVMeDevice = func(ctx context.Context, devicePort string) error {
	output, err := utils.ExecShellCmd(ctx, "nvme ns-rescan /dev/%s", devicePort)
	if err != nil {
		log.AddContext(ctx).Errorf("Scan nvme port failed. output:%s, error:%v", output, err)
		return err
	}
	return nil
}

DoScanNVMeDevice used to scan device by command nvme ns-rescan

View Source
var FlushDMDevice = func(ctx context.Context, dm string) error {

	mPath, _ := utils.ExecShellCmd(ctx, "ls -l /dev/mapper/ | grep -w %s | awk '{print $9}'", dm)
	if mPath == "" {
		return fmt.Errorf("get DM device %s", dm)
	}

	var err error
	for i := 0; i < 3; i++ {
		_, err = utils.ExecShellCmd(ctx, "multipath -f %s", mPath)
		if err == nil {
			log.AddContext(ctx).Infof("Flush multipath device %s successful", mPath)
			break
		}
		log.AddContext(ctx).Warningf("Flush multipath device %s error: %v", mPath, err)
		time.Sleep(time.Second * flushMultiPathInternal)
	}

	return err
}

FlushDMDevice is the device of flush DM

View Source
var GetDevNameByLunWWN = func(ctx context.Context, upType, lunWWN string) (string, error) {
	output, err := runUpCommand(ctx, upType, "show vlun | grep -w %s", lunWWN)
	if err != nil {
		return "", err
	}

	ret := utils.GetValueByRegexp(output, `^[\s]*[\d]+[\s]*([\S]+)[\s]+`, 1)
	if ret == "" {
		log.AddContext(ctx).Warningf("Get device by lunWWN:%s failed, output:%s", lunWWN, output)
		return "", nil
	}
	return ret, nil
}

GetDevNameByLunWWN used to get device name by lun wwn

View Source
var GetDeviceSize = func(ctx context.Context, hostDevice string) (int64, error) {

	output, err := utils.ExecShellCmd(ctx, "blockdev --getsize64 %s", hostDevice)
	if err != nil {
		log.AddContext(ctx).Errorf("Failed to get device %s, err is %v", hostDevice, err)
		return 0, err
	}

	outputLines := strings.Split(output, "\n")
	for _, line := range outputLines {
		if line == "" {
			continue
		}
		size, err := strconv.ParseInt(line, 10, 64)
		if err != nil {
			log.AddContext(ctx).Errorf("Failed to get device size %s, err is %v", line, err)
			return 0, err
		}
		return size, nil
	}

	return 0, errors.New("failed to get device size")
}

GetDeviceSize to get the device size in bytes

View Source
var GetDevicesByGUID = func(ctx context.Context, tgtLunGUID string) ([]string, error) {
	var devices []string
	deviceLink, err := getDeviceLink(ctx, tgtLunGUID)
	if err != nil {
		return devices, err
	}

	devices = getDevices(deviceLink)

	return devices, nil
}

GetDevicesByGUID query device from host. If revert connect volume, no need to check device available

View Source
var GetNVMePhysicalDevices = func(ctx context.Context, device string, deviceType int) ([]string, error) {
	switch deviceType {
	case NotUseMultipath:
		return []string{device}, nil
	case UseUltraPathNVMe:
		return GetNVMeDeviceFromUltraPathNVMe(ctx, device)
	default:
		return nil, utils.Errorf(ctx, "Invalid device type %d.", deviceType)
	}
}

GetNVMePhysicalDevices to get NVMe physical devices

View Source
var GetNVMeWwn = func(ctx context.Context, device string) (string, error) {
	cmd := fmt.Sprintf("nvme id-ns %s -o json", device)
	output, err := utils.ExecShellCmdFilterLog(ctx, cmd)
	if err != nil {
		log.AddContext(ctx).Errorf("Failed to get nvme id of device %s, err is %v", device, err)
		return "", err
	}

	var deviceInfo map[string]interface{}
	if err = json.Unmarshal([]byte(output), &deviceInfo); err != nil {
		log.AddContext(ctx).Errorf("Failed to unmarshal input %s", output)
		return "", errors.New("failed to unmarshal device info")
	}

	if uuid, exist := deviceInfo["nguid"]; exist {
		return uuid.(string), nil
	}

	return "", errors.New("there is no nguid in device info")
}

GetNVMeWwn get the unique id of the device

View Source
var GetPhysicalDevices = func(ctx context.Context, device string, deviceType int) ([]string, error) {
	switch deviceType {
	case NotUseMultipath:
		return []string{device}, nil
	case UseDMMultipath:
		return GetPhyDevicesFromDM(device)
	case UseUltraPath:
		return GetDeviceFromUltraPath(ctx, device)
	case UseUltraPathNVMe:
		return GetDeviceFromUltraPathNVMe(ctx, device)
	default:
		return nil, utils.Errorf(ctx, "Invalid device type %d.", deviceType)
	}
}

GetPhysicalDevices to get physical devices

View Source
var GetSCSIWwn = func(ctx context.Context, hostDevice string) (string, error) {
	var wwn string
	var err error
	readable, err := IsDeviceReadable(ctx, hostDevice)
	if readable && err == nil {
		wwn, err = getSCSIWwnByScsiID(ctx, hostDevice)
		if err != nil {
			log.AddContext(ctx).Warningf("get device %s wwn by scsi_id error: %v", hostDevice, err)
		}
	} else {
		if strings.HasPrefix(hostDevice, "/dev/sd") {
			wwn, err = getSCSIWwnByWWid(ctx, hostDevice)
		}
	}

	return wwn, err
}

GetSCSIWwn to get the device wwn

View Source
var GetSubSysInfo = func(ctx context.Context) (map[string]interface{}, error) {
	err := checkNVMeVersion(ctx)
	if err != nil {
		return nil, utils.Errorf(ctx, "Failed to check the NVMe version. err:%v", err)
	}

	output, err := utils.ExecShellCmdFilterLog(ctx, "nvme list-subsys -o json")
	if err != nil {
		log.AddContext(ctx).Errorf("Get exist nvme connect info failed, output:%s, error:%v", output, err)
		return nil, errors.New("get nvme connect port failed")
	}

	var nvmeConnectInfo map[string]interface{}
	if err = json.Unmarshal([]byte(output), &nvmeConnectInfo); err != nil {
		return nil, errors.New("unmarshal nvme connect info failed")
	}

	return nvmeConnectInfo, nil
}

GetSubSysInfo used to get subsys info by command nvme list-subsys

View Source
var GetVirtualDevice = func(ctx context.Context, tgtLunGUID string) (string, int, error) {
	var virtualDevice string
	var deviceType int

	devices, err := GetDevicesByGUID(ctx, tgtLunGUID)
	if err != nil {
		return virtualDevice, 0, err
	}

	var virtualDevices []string
	var phyDevices []string
	for _, device := range devices {
		device = strings.TrimSpace(device)

		partitionDev, err := isPartitionDevice(ctx, device)
		if err != nil {
			return "", 0, utils.Errorf(ctx, "check device: %s is a partition device failed. error: %v", device, err)
		} else if partitionDev {
			log.AddContext(ctx).Infof("Device: %s is a partition device,skip", device)
			continue
		}

		if strings.HasPrefix(device, "ultrapath") {
			deviceType = UseUltraPathNVMe
			virtualDevices = append(virtualDevices, device)
		} else if strings.HasPrefix(device, "dm") {
			deviceType = UseDMMultipath
			virtualDevices = append(virtualDevices, device)
		} else if strings.HasPrefix(device, "sd") && isUltraPathDevice(ctx, device) {
			deviceType = UseUltraPath
			virtualDevices = append(virtualDevices, device)
		} else if strings.HasPrefix(device, "sd") || strings.HasPrefix(device, "nvme") {
			phyDevices = append(phyDevices, device)
		} else {
			log.AddContext(ctx).Warningf("Unknown device link: %s", device)
		}
	}

	log.AddContext(ctx).Infof("Find virtual devices: %v, physical devices: %v", virtualDevices, phyDevices)

	return getVirtualDevice(ctx, virtualDevices, phyDevices, tgtLunGUID, deviceType)
}

GetVirtualDevice used to get virtual device by WWN/GUID

View Source
var IsDeviceAvailable = func(ctx context.Context, device, lunWWN string) (bool, error) {
	var devWWN string
	var err error
	if strings.Contains(device, "sd") {
		devWWN, err = GetSCSIWwn(ctx, device)
	} else if strings.Contains(device, "nvme") {
		devWWN, err = GetNVMeWwn(ctx, device)
	} else {

		devWWN, err = GetSCSIWwn(ctx, device)
	}

	if err != nil {
		return false, err
	}

	if devWWN == "" {
		return false, nil
	}

	if !strings.Contains(devWWN, lunWWN) {
		return false, errors.New("the device WWN is not equal to lun WWN")
	}
	return true, nil
}

IsDeviceAvailable compares the sd device WWN with the lun WWN

View Source
var IsDeviceReadable = func(ctx context.Context, devicePath string) (bool, error) {
	_, err := ReadDevice(ctx, devicePath)
	if err != nil {
		log.AddContext(ctx).Warningf("Device:%s is unreadable.", devicePath)
		return false, err
	}

	return true, nil
}

IsDeviceReadable to check the device is readable or not

View Source
var IsInFormatting = func(ctx context.Context, sourcePath, fsType string) (bool, error) {
	var cmd string
	if fsType != "ext2" && fsType != "ext3" && fsType != "ext4" && fsType != "xfs" {
		return false, utils.Errorf(ctx, "Do not support the type %s.", fsType)
	}

	cmd = fmt.Sprintf("ps -aux | grep mkfs | grep -w %s | wc -l |awk '{if($1>1) print 1; else print 0}'",
		sourcePath)
	output, err := utils.ExecShellCmd(ctx, cmd)
	if err != nil {
		return false, err
	}

	outputSplit := strings.Split(output, "\n")
	return len(outputSplit) != 0 && outputSplit[0] == "1", nil
}

IsInFormatting is to check the device whether in formatting

View Source
var IsUpNVMeResidualPath = func(ctx context.Context, devName, lunWWN string) (bool, error) {
	return isUpNVMeResidualPath(ctx,
		&deviceInfo{deviceName: devName, lunWWN: lunWWN, multipathType: UseUltraPathNVMe,
			deviceFullName: "/dev/" + devName})
}

IsUpNVMeResidualPath used to determine whether the device is residual

View Source
var ReadDevice = func(ctx context.Context, dev string) ([]byte, error) {
	log.AddContext(ctx).Infof("Checking to see if %s is readable.", dev)
	out, err := utils.ExecShellCmdFilterLog(ctx, "dd if=%s bs=1024 count=512 status=none", dev)
	if err != nil {
		return nil, err
	}

	output := []byte(out)
	if len(output) != halfMiDataLength {
		return nil, utils.Errorf(ctx, "can not read 512KiB bytes from the device %s, instead read %d bytes",
			dev, len(output))
	}

	if strings.Contains(out, "0+0 records in") {
		return nil, utils.Errorf(ctx, "the size of %s may be zero, it is abnormal device", dev)
	}

	return output, nil
}

ReadDevice is to check whether the device is readable

View Source
var RemoveAllDevice = func(ctx context.Context,
	virtualDevice string,
	phyDevices []string,
	deviceType int) (string, error) {
	switch deviceType {
	case NotUseMultipath, UseDMMultipath:
		return RemoveDevice(ctx, virtualDevice)
	case UseUltraPath:
		return "", RemoveUltraPathDevice(ctx, virtualDevice, phyDevices)
	case UseUltraPathNVMe:
		return "", RemoveUltraPathNVMeDevice(ctx, virtualDevice, phyDevices)
	default:
		return "", utils.Errorln(ctx, "invalid device type")
	}
}

RemoveAllDevice to remove the device through virtual device and physical device

View Source
var ResizeMountPath = func(ctx context.Context, volumePath string) error {
	output, err := utils.ExecShellCmd(ctx, "findmnt -o source --noheadings --target %s", volumePath)
	if err != nil {
		return fmt.Errorf("findmnt volumePath: %s error: %v", volumePath, err)
	}

	devicePath := strings.TrimSpace(output)
	if len(devicePath) == 0 {
		return fmt.Errorf("could not get valid device for mount path: %s", volumePath)
	}

	fsType, err := GetFsTypeByDevPath(ctx, devicePath)
	if err != nil {
		return err
	}

	if fsType == "" {
		return nil
	}

	switch fsType {
	case "ext2", "ext3", "ext4":
		return extResize(ctx, devicePath)
	case "xfs":
		return xfsResize(ctx, volumePath)
	default:
		return fmt.Errorf("resize of format %s is not supported for device %s", fsType, devicePath)
	}
}

ResizeMountPath Resize the mount point by using the volume path

View Source
var VerifySingleDevice = func(ctx context.Context,
	device, lunWWN, errCode string,
	f func(context.Context, string) error) error {
	log.AddContext(ctx).Infof("Found the dev %s", device)
	_, err := ReadDevice(ctx, device)
	if err != nil {
		return err
	}

	available, err := IsDeviceAvailable(ctx, device, lunWWN)
	if err != nil && err.Error() != "the device WWN is not equal to lun WWN" {
		return err
	}

	if !available {
		err = f(ctx, lunWWN)
		if err != nil {
			log.AddContext(ctx).Errorf("delete device err while revert connect volume. Err is: %v", err)
		}
		return errors.New(errCode)
	}
	return nil
}

VerifySingleDevice check the sd device whether available

Functions

func CheckConnectSuccess

func CheckConnectSuccess(ctx context.Context, device, tgtLunWWN string) bool

CheckConnectSuccess is to check the sd device available

func CheckHostConnectivity

func CheckHostConnectivity(ctx context.Context, portal string) bool

CheckHostConnectivity used to check host connectivity

func CleanDeviceByLunId

func CleanDeviceByLunId(ctx context.Context, lunId string, targets []string) error

CleanDeviceByLunId clean device by Lun id

func ClearResidualPath

func ClearResidualPath(ctx context.Context, lunWWN string, volumeMode interface{}) error

ClearResidualPath used to clear residual path

func ClearUnavailableDevice

func ClearUnavailableDevice(ctx context.Context, device, lunWWN string) string

ClearUnavailableDevice is to check the sd device connect success, otherwise delete the device

func ConnectVolumeCommon

func ConnectVolumeCommon(ctx context.Context,
	conn map[string]interface{},
	tgtLunWWN, protocol string,
	f func(context.Context, map[string]interface{}) (string, error)) (string, error)

ConnectVolumeCommon used for connect volume for all protocol

func ConsistentRead

func ConsistentRead(filename string, attempts int) ([]byte, error)

ConsistentRead repeatedly reads a file until it gets the same content twice. This is useful when reading files in /proc/mount that are larger than page size and kernel may modify them between individual read() syscalls

func DeleteSDDev

func DeleteSDDev(ctx context.Context, sd string) error

DeleteSDDev is used to delete the sd device

func DisConnectVolume

func DisConnectVolume(ctx context.Context, tgtLunWWN string, f func(context.Context, string) error) error

DisConnectVolume delete all devices which match to lunWWN

func DisConnectVolumeCommon

func DisConnectVolumeCommon(ctx context.Context,
	tgtLunWWN, protocol string,
	f func(context.Context, string) error) error

DisConnectVolumeCommon used for disconnect volume for all protocol

func FindAllArrays

func FindAllArrays(ctx context.Context) ([]string, error)

FindAllArrays find all arrays

func FindArrayByTarget

func FindArrayByTarget(ctx context.Context, targets, arrayIds []string) (string, error)

FindArrayByTarget find array by iqn

func FindAvailableMultiPath

func FindAvailableMultiPath(ctx context.Context, foundDevices []string) (string, bool)

FindAvailableMultiPath is to get dm-multipath through sd devices

func GetDeviceFromMountFile

func GetDeviceFromMountFile(ctx context.Context, targetPath string, checkDevRef bool) (string, error)

GetDeviceFromMountFile parse the mount file and get devicePath from targetPath. If a device is associated with multiple paths, an error will be returned

func GetDeviceFromSymLink(targetPath string) (string, error)

GetDeviceFromSymLink returns link path if specified file exists and the type is symbolik link. If file doesn't exist, or file exists but not symbolic link, returns an empty string with error from Lstat().

func GetDeviceFromUltraPath

func GetDeviceFromUltraPath(ctx context.Context, upDevice string) ([]string, error)

GetDeviceFromUltraPath used to get physical device from ultrapath

func GetDeviceFromUltraPathNVMe

func GetDeviceFromUltraPathNVMe(ctx context.Context, upDevice string) ([]string, error)

GetDeviceFromUltraPathNVMe used to get physical device from ultrapath-nvme

func GetDiskNameByWWN

func GetDiskNameByWWN(ctx context.Context, upType, lunWWN string) (string, error)

GetDiskNameByWWN to get the device name based on the LUN WWN

func GetDiskPathAndCheckStatus

func GetDiskPathAndCheckStatus(ctx context.Context, upType, lunWWN string) (string, error)

GetDiskPathAndCheckStatus to get the device path and status based on the LUN WWN.

func GetFsTypeByDevPath

func GetFsTypeByDevPath(ctx context.Context, devicePath string) (string, error)

GetFsTypeByDevPath use blkid to get fsType

func GetLunWWNByDevName

func GetLunWWNByDevName(ctx context.Context, upType, dev string) (string, error)

GetLunWWNByDevName used to get device lun wwn by device name

func GetNVMeDevice

func GetNVMeDevice(ctx context.Context, devicePort string, tgtLunGUID string) (string, error)

GetNVMeDevice used to get device name by channel

func GetNVMeDeviceFromUltraPathNVMe

func GetNVMeDeviceFromUltraPathNVMe(ctx context.Context, upDevice string) ([]string, error)

GetNVMeDeviceFromUltraPathNVMe used to get physical nvme device from ultrapath-nvme

func GetPhyDev

func GetPhyDev(ctx context.Context, upType, vLunID, deviceType string) ([]string, error)

GetPhyDev to get the physical device by using the vLun Id

func GetPhyDevicesFromDM

func GetPhyDevicesFromDM(dm string) ([]string, error)

GetPhyDevicesFromDM used to get physical device from dm-multipath

func GetUltraPathDetailsByPath

func GetUltraPathDetailsByPath(ctx context.Context, upType, device string) (string, error)

GetUltraPathDetailsByPath to get the ultraPath detail info by using device path

func GetUltraPathDetailsByvLunID

func GetUltraPathDetailsByvLunID(ctx context.Context, upType, vLunID string) (string, error)

GetUltraPathDetailsByvLunID to get the ultraPath detail info by using vLun Id

func GetUltraPathIOSuspensionTime

func GetUltraPathIOSuspensionTime(ctx context.Context, upType, vlunID string) (string, error)

GetUltraPathIOSuspensionTime used to get IO suspension time

func GetUltraPathInfoByDevName

func GetUltraPathInfoByDevName(ctx context.Context, upType, devName string) (string, error)

GetUltraPathInfoByDevName to get the ultraPath info by using the device Name

func GetUltraPathInfoByLunWWN

func GetUltraPathInfoByLunWWN(ctx context.Context, upType, targetLunWWN string) (string, error)

GetUltraPathInfoByLunWWN to get the ultraPath info by using the lun wwn

func GetVLunIDByDevName

func GetVLunIDByDevName(ctx context.Context, upType, devName string) (string, error)

GetVLunIDByDevName to get the vLun Id by using device Name

func GetWwnByDevice

func GetWwnByDevice(ctx context.Context, devicePath string) (string, error)

GetWwnByDevice get wwn according to multipath and protocol type

func GetWwnFromTargetPath

func GetWwnFromTargetPath(ctx context.Context, volumeId, targetPath string, checkDevRef bool) (string, error)

GetWwnFromTargetPath get wwn form targetPath

func IsDeviceFormatted

func IsDeviceFormatted(ctx context.Context, dev string) (bool, error)

IsDeviceFormatted reads 2MiBs of the device to check the device formatted or not

func IsMultiPathAvailable

func IsMultiPathAvailable(ctx context.Context, mPath, lunWWN string, devices []string) (bool, error)

IsMultiPathAvailable compares the dm device WWN with the lun WWN

func MountPathIsExist

func MountPathIsExist(ctx context.Context, mountPoint string) (bool, error)

MountPathIsExist if mount point exist in /proc/mounts file, this function will return true

func ReadMountPoints

func ReadMountPoints(ctx context.Context) (map[string]string, error)

ReadMountPoints read mount file mountMap: key means mountPath; value means devicePath.

func ReadNxupFile

func ReadNxupFile(ctx context.Context) (string, error)

ReadNxupFile read nxup file

func ReadNxupMap

func ReadNxupMap(ctx context.Context, lunId string) ([]ultrapathDeviceInfo, error)

ReadNxupMap read nxup map

func RegisterConnector

func RegisterConnector(cType string, cnt Connector) error

RegisterConnector is used to register the specific Connector to the global connector map

func RemoveDevice

func RemoveDevice(ctx context.Context, device string) (string, error)

RemoveDevice is used to remove specified device

func RemoveDevices

func RemoveDevices(ctx context.Context, devices []string) error

RemoveDevices is used to remove devices

func RemoveUltraPathDevice

func RemoveUltraPathDevice(ctx context.Context, virtualDevice string, phyDevices []string) error

RemoveUltraPathDevice to remove the ultrapath device through virtual device and physical device

func RemoveUltraPathNVMeDevice

func RemoveUltraPathNVMeDevice(ctx context.Context, virtualDevice string, phyDevices []string) error

RemoveUltraPathNVMeDevice to remove the ultrapath device through virtual device and physical device

func ResizeBlock

func ResizeBlock(ctx context.Context, tgtLunWWN string, requiredBytes int64) error

ResizeBlock Resize a block device by using the LUN WWN

func SetUltraPathIOSuspensionTime

func SetUltraPathIOSuspensionTime(ctx context.Context, upType, vlunID, time string) error

SetUltraPathIOSuspensionTime used to set IO suspension time

func VerifyDeviceAvailableOfDM

func VerifyDeviceAvailableOfDM(ctx context.Context, tgtLunWWN string, expectPathNumber int,
	foundDevices []string,
	f func(context.Context, string) error) (string, error)

VerifyDeviceAvailableOfDM used to check whether the DM device is available

func VerifyDeviceAvailableOfUltraPath

func VerifyDeviceAvailableOfUltraPath(ctx context.Context, upType, diskName string) (string, error)

VerifyDeviceAvailableOfUltraPath used to check whether the UltraPath device is available

func VerifyMultiPathDevice

func VerifyMultiPathDevice(ctx context.Context,
	mPath, lunWWN, errCode string,
	f func(context.Context, string) error) (string, error)

VerifyMultiPathDevice check the dm device whether available

Types

type ConnectInfo

type ConnectInfo struct {
	Conn        Connector
	MappingInfo map[string]interface{}
}

ConnectInfo defines the fields of connect volume

type Connector

type Connector interface {
	// ConnectVolume to mount the source to target path, the source path can be block or nfs
	// Example:
	//    mount /dev/sdb /<target-path>
	//    mount <source-path> /<target-path>
	ConnectVolume(context.Context, map[string]interface{}) (string, error)
	// DisConnectVolume to unmount the target path
	DisConnectVolume(context.Context, string) error
}

Connector defines the behavior that the connector should have

func GetConnector

func GetConnector(ctx context.Context, cType string) Connector

GetConnector can get a connector by its type from the global connector map

type DMDeviceInfo

type DMDeviceInfo struct {
	// Name device name
	Name string
	// Name device file system
	Sysfs string
	// Devices device list
	Devices []string
}

DMDeviceInfo is the information of DM device

func WatchDMDevice

func WatchDMDevice(ctx context.Context, lunWWN string, expectPathNumber int) (DMDeviceInfo, error)

WatchDMDevice is an aggregate drive letter monitor.

type DisConnectInfo

type DisConnectInfo struct {
	Conn   Connector
	TgtLun string
}

DisConnectInfo defines the fields of disconnect volume

Directories

Path Synopsis
Package fibrechannel provide the way to connect/disconnect volume within FC protocol
Package fibrechannel provide the way to connect/disconnect volume within FC protocol
Package host defines a set of useful methods, which can help Connector to operate host information
Package host defines a set of useful methods, which can help Connector to operate host information
Package iscsi provide the way to connect/disconnect volume within iSCSI protocol
Package iscsi provide the way to connect/disconnect volume within iSCSI protocol
Package local to connect and disconnect local lun
Package local to connect and disconnect local lun
Package nfs to mount or unmount filesystem
Package nfs to mount or unmount filesystem
Package nfs_plus to mount or unmount filesystem
Package nfs_plus to mount or unmount filesystem
Package nvme provide the way to connect/disconnect volume within FC NVMe protocol
Package nvme provide the way to connect/disconnect volume within FC NVMe protocol
Package roce provide the way to connect/disconnect volume within NVMe over RoCE protocol
Package roce provide the way to connect/disconnect volume within NVMe over RoCE protocol
Package utils provides common utils for connector
Package utils provides common utils for connector
lock
Package lock provide Lock and Unlock when manage the disk
Package lock provide Lock and Unlock when manage the disk
models
Package models provides common models for connector
Package models provides common models for connector

Jump to

Keyboard shortcuts

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