iscsi

package
v0.0.0-...-dd26709 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(c Connector) (string, error)

Connect is for backward-compatibility with c.Connect()

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 for the specified target

func DeleteIFace

func DeleteIFace(iface string) error

DeleteIFace delete the iface

func Disconnect

func Disconnect(targetIqn string, targets []string)

Disconnect is for backward-compatibility with c.Disconnect()

func Discoverydb

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

Discoverydb discovers the iscsi target

func ExecWithTimeout

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

ExecWithTimeout execute a command with a timeout and returns an error if timeout is exceeded

func FlushMultipathDevice

func FlushMultipathDevice(device *Device) 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 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, portal string) error

Logout logs out the specified target

func PersistConnector

func PersistConnector(c *Connector, filePath string) error

PersistConnector is for backward-compatibility with c.Persist()

func RemoveSCSIDevices

func RemoveSCSIDevices(devices ...Device) error

RemoveSCSIDevices removes SCSI device(s) from a Linux host.

func ResizeMultipathDevice

func ResizeMultipathDevice(device *Device) 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 Connector

type Connector struct {
	VolumeName        string   `json:"volume_name"`
	TargetIqn         string   `json:"target_iqn"`
	TargetPortals     []string `json:"target_portal"`
	Lun               int32    `json:"lun"`
	AuthType          string   `json:"auth_type"`
	DiscoverySecrets  Secrets  `json:"discovery_secrets"`
	SessionSecrets    Secrets  `json:"session_secrets"`
	Interface         string   `json:"interface"`
	MountTargetDevice *Device  `json:"mount_target_device"`
	Devices           []Device `json:"devices"`
	RetryCount        uint     `json:"retry_count"`
	CheckInterval     uint     `json:"check_interval"`
	DoDiscovery       bool     `json:"do_discovery"`
	DoCHAPDiscovery   bool     `json:"do_chap_discovery"`
}

Connector provides a struct to hold all 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)

func (*Connector) Connect

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

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

func (*Connector) Disconnect

func (c *Connector) Disconnect()

Disconnect performs a disconnect operation from an appliance. Be sure to disconnect all devices properly before doing this as it can result in data loss.

func (*Connector) DisconnectVolume

func (c *Connector) DisconnectVolume() error

DisconnectVolume removes a volume from a Linux host.

func (*Connector) IsMultipathConsistent

func (c *Connector) IsMultipathConsistent() error

IsMultipathConsistent check if the currently used device is using a consistent multipath mapping

func (*Connector) IsMultipathEnabled

func (c *Connector) IsMultipathEnabled() bool

IsMultipathEnabled check if multipath is enabled on devices handled by this connector

func (*Connector) Persist

func (c *Connector) Persist(filePath string) error

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

type Device

type Device struct {
	Name      string   `json:"name"`
	Hctl      string   `json:"hctl"`
	Children  []Device `json:"children"`
	Type      string   `json:"type"`
	Transport string   `json:"tran"`
	Size      string   `json:"size,omitempty"`
}

Device contains information about a device

func GetISCSIDevices

func GetISCSIDevices(devicePaths []string, strict bool) (devices []Device, err error)

GetISCSIDevices get iSCSI devices from device paths It will returns all iSCSI devices if no paths are given

func GetSCSIDevices

func GetSCSIDevices(devicePaths []string, strict bool) ([]Device, error)

GetSCSIDevices get SCSI devices from device paths It will returns all SCSI devices if no paths are given

func (*Device) Delete

func (d *Device) Delete() error

Delete detach an SCSI device by writing 1 in /sys/class/scsi_device/h:c:t:l/device/delete

func (*Device) Exists

func (d *Device) Exists() error

Exists check if the device exists at its path and returns an error otherwise

func (*Device) GetPath

func (d *Device) GetPath() string

GetPath returns the path of a device

func (*Device) HCTL

func (d *Device) HCTL() (*HCTL, error)

HCTL returns the HCTL of a device

func (*Device) Rescan

func (d *Device) Rescan() error

Rescan does a rescan of SCSI device by writing 1 in /sys/class/scsi_device/h:c:t:l/device/rescan

func (*Device) Shutdown

func (d *Device) Shutdown() error

Shutdown turn off an SCSI device by writing offline\n in /sys/class/scsi_device/h:c:t:l/device/state

func (*Device) WWID

func (d *Device) WWID() (string, error)

WWID returns the WWID of a device

func (*Device) WriteDeviceFile

func (d *Device) WriteDeviceFile(name string, content string) error

WriteDeviceFile write in a device file

type HCTL

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)

Jump to

Keyboard shortcuts

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