iscsi

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(c *Connector) (string, error)

Connect attempts to connect a volume to this node using the provided Connector info

func CreateDBEntry

func CreateDBEntry(tgtIQN, portal, iFace string, discoverySecrets, sessionSecrets Secrets) error

CreateDBEntry sets up a node entry for the specified tgt in the nodes iscsi nodes db

func DeleteDBEntry

func DeleteDBEntry(tgtIQN string) error

DeleteDBEntry deletes the iscsi db entry fo rthe specified target

func DeleteIFace

func DeleteIFace(iface string) error

DeleteIFace delete the iface

func Disconnect

func Disconnect(tgtIqn string, portals []string) error

Disconnect performs a disconnect operation on a volume

func DisconnectVolume

func DisconnectVolume(c Connector) error

DisconnectVolume removes a volume from a Linux host.

func Discoverydb

func Discoverydb(tp, iface string, discoverySecrets Secrets, chapDiscovery bool) error

Discoverydb discovers the iscsi target

func EnableDebugLogging

func EnableDebugLogging(writer io.Writer)

EnableDebugLogging provides a mechanism to turn on debug logging for this package output is written to the provided io.Writer

func ExecWithTimeout

func ExecWithTimeout(command string, args []string, timeout time.Duration) ([]byte, error)

func FlushMultipathDevice

func FlushMultipathDevice(device string) error

FlushMultipathDevice flushes a multipath device dm-x with command multipath -f /dev/dm-x

func GetSessions

func GetSessions() (string, error)

GetSessions retrieves a list of current iscsi sessions on the node

func GetSysDevicesFromMultipathDevice

func GetSysDevicesFromMultipathDevice(device string) ([]string, error)

GetSysDevicesFromMultipathDevice gets all slaves for multipath device dm-x in /sys/block/dm-x/slaves/

func ISCSIRescan added in v1.1.0

func ISCSIRescan(tgtIQN string, lun int) error

ISCSIRescan takes a target iqn and lun and writes to the scan file in the scsi subsystem We do this manually instead of relying on iscsiadm -R. This prevents a race condition in which devices that are in the process of being removed can be re-discovered and left behind.

func ListInterfaces

func ListInterfaces() ([]string, error)

ListInterfaces returns a list of all iscsi interfaces configured on the node along with the raw output in Response.StdOut we add the convenience of returning a list of entries found

func Login

func Login(tgtIQN, portal string) error

Login performs an iscsi login for the specified target

func Logout

func Logout(tgtIQN string, portals []string) error

Logout logs out the specified target, if the target is not logged in it's not considered an error

func PersistConnector

func PersistConnector(c *Connector, filePath string) error

PersistConnector persists the provided Connector to the specified file (ie /var/lib/pfile/myConnector.json)

func RemoveAndClear added in v1.0.2

func RemoveAndClear(device string) error

RemoveAndClear calls 'dmsetup' to remove and clear a device entry

func RemovePhysicalDevice

func RemovePhysicalDevice(devices ...string) error

RemovePhysicalDevice removes device(s) sdx from a Linux host.

func RescanISCSIDevices added in v1.1.0

func RescanISCSIDevices(hctls []HCTL) error

func ResizeMultipathDevice

func ResizeMultipathDevice(device string) error

ResizeMultipathDevice resize a multipath device based on its underlying devices

func ShowInterface

func ShowInterface(iface string) (string, error)

ShowInterface retrieves the details for the specified iscsi interface caller should inspect r.Err and use r.StdOut for interface details

Types

type CmdError

type CmdError struct {
	CMD      string
	StdErr   string
	ExitCode int
}

CmdError is a custom error to provide details including the command, stderr output and exit code. iscsiadm in some cases requires all of this info to determine success or failure

func (*CmdError) Error

func (e *CmdError) Error() string

type Connector

type Connector struct {
	VolumeName       string       `json:"volume_name"`
	Targets          []TargetInfo `json:"targets"`
	Lun              int32        `json:"lun"`
	AuthType         string       `json:"auth_type"`
	DiscoverySecrets Secrets      `json:"discovery_secrets"`
	SessionSecrets   Secrets      `json:"session_secrets"`
	Interface        string       `json:"interface"`
	Multipath        bool         `json:"multipath"`
	DevicePath       string       `json:"device_path"` // DevicePath is dm-x for a multipath device, and sdx for a normal device.
	RetryCount       int32        `json:"retry_count"`
	CheckInterval    int32        `json:"check_interval"`
	DoDiscovery      bool         `json:"do_discovery"`
	DoCHAPDiscovery  bool         `json:"do_chap_discovery"`
	TargetIqn        string       `json:"target_iqn"`
	TargetPortals    []string     `json:"target_portals"`
}

Connector provides a struct to hold all of the needed parameters to make our iscsi connection

func GetConnectorFromFile

func GetConnectorFromFile(filePath string) (*Connector, error)

GetConnectorFromFile attempts to create a Connector using the specified json file (ie /var/lib/pfile/myConnector.json)

type HCTL added in v1.1.0

type HCTL struct {
	HBA     int
	Channel int
	Target  int
	LUN     int
}

type Secrets

type Secrets struct {
	// SecretsType is the type of Secrets being utilized (currently we only impleemnent "chap"
	SecretsType string `json:"secretsType,omitempty"`
	// UserName is the configured iscsi user login
	UserName string `json:"userName"`
	// Password is the configured iscsi password
	Password string `json:"password"`
	// UserNameIn provides a specific input login for directional CHAP configurations
	UserNameIn string `json:"userNameIn,omitempty"`
	// PasswordIn provides a specific input password for directional CHAP configurations
	PasswordIn string `json:"passwordIn,omitempty"`
}

Secrets provides optional iscsi security credentials (CHAP settings)

type TargetInfo

type TargetInfo struct {
	Iqn    string `json:"iqn"`
	Portal string `json:"portal"`
	Port   string `json:"port"`
}

Jump to

Keyboard shortcuts

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