utils

package
v17.10.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Darwin = "darwin"

Darwin is a constant value for the runtime.GOOS that represents Apple MacOS

View Source
const ISCSI_ERR_NO_OBJS_FOUND int = 21
View Source
const Linux = "linux"

Linux is a constant value for the runtime.GOOS that represents the Linux OS

View Source
const Windows = "windows"

Windows is a constant value for the runtime.GOOS that represents the Windows OS

Variables

This section is empty.

Functions

func ConvertSizeToBytes

func ConvertSizeToBytes(s string) (string, error)

ConvertSizeToBytes converts size to bytes; see also https://en.wikipedia.org/wiki/Kilobyte

func EnsureIscsiSession added in v1.4.0

func EnsureIscsiSession(hostDataIP string) error

func FormatVolume

func FormatVolume(device, fstype string) error

FormatVolume creates a filesystem for the supplied device of the supplied type

func GetDeviceFileFromIscsiPath

func GetDeviceFileFromIscsiPath(iscsiPath string) (devFile string)

GetDeviceFileFromIscsiPath returns the /dev device for the supplied iscsiPath

func GetFSType

func GetFSType(device string) string

GetFSType returns the filesystem for the supplied device

func GetInitiatorIqns

func GetInitiatorIqns() ([]string, error)

GetInitiatorIqns returns parsed contents of /etc/iscsi/initiatorname.iscsi

func GetV

func GetV(opts map[string]string, keys string, defaultValue string) string

GetV takes a map, key(s), and a defaultValue; will return the value of the key or defaultValue if none is set. If keys is a string of key values separated by "|", then each key is tried in turn. This allows compatibility with deprecated values, i.e. "fstype|fileSystemType".

func GetVolumeSizeBytes

func GetVolumeSizeBytes(opts map[string]string, defaultVolumeSize string) (uint64, error)

GetVolumeSizeBytes determines the size, in bytes, of a volume from the "size" opt value. If "size" has a units suffix, that is handled here. If there are no units, the default is GiB. If size is not in opts, the specified default value is parsed identically and used instead.

func IscsiDisableDelete

func IscsiDisableDelete(tgt *IscsiTargetInfo) (err error)

IscsiDisableDelete logout from the supplied target and remove the iSCSI device

func IscsiRescan

func IscsiRescan() (err error)

IscsiRescan uses the 'rescan-scsi-bus' command to perform rescanning of the SCSI bus

func IscsiSessionExists

func IscsiSessionExists(portal string) (bool, error)

IscsiSessionExists checks to see if a session exists to the sepecified portal

func IscsiSupported

func IscsiSupported() bool

IscsiSupported returns true if iscsiadm is installed and in the PATH

func IscsiadmCmd

func IscsiadmCmd(args []string) ([]byte, error)

IscsiadmCmd uses the 'iscsiadm' command to perform operations

func LoginIscsiTarget added in v1.4.0

func LoginIscsiTarget(iqn, portal string) error

Login to iSCSI target

func LoginWithChap

func LoginWithChap(tiqn, portal, username, password, iface string) error

LoginWithChap will login to the iSCSI target with the supplied credentials

func Mount

func Mount(device, mountpoint string) error

Mount attaches the supplied device at the supplied location

func Multipath

func Multipath() (err error)

Multipath invokes the 'multipath' command

func MultipathDetected

func MultipathDetected() bool

MultipathDetected returns true if /sbin/multipath is installed and in the PATH

func MultipathFlush

func MultipathFlush() (err error)

MultipathFlush invokes the 'multipath' commands to flush paths that have been removed

func Pow

func Pow(x int64, y int) int64

Pow is an integer version of exponentiation; existing builtin is float, we needed an int version.

func RandomString

func RandomString(str_size int) string

RandomString returns a string of the specified length consisting only of alphabetic characters.

func Stat added in v1.3.3

func Stat(fileName string) (string, error)

func UdevSettle

func UdevSettle() error

UdevSettle invokes the 'udevadm settle' command

func Umount

func Umount(mountpoint string) error

Umount detaches from the supplied location

func WaitForPathToExist

func WaitForPathToExist(fileName string, numTries int) bool

WaitForPathToExist retries every second, up to numTries times, with increasing backoff, for the specified fileName to show up

Types

type DFInfo

type DFInfo struct {
	Target string
	Source string
}

DFInfo data structure for wrapping the parsed output from the 'df' command

func GetDFOutput

func GetDFOutput() ([]DFInfo, error)

GetDFOutput returns parsed DF output

type IscsiDiscoveryInfo added in v1.4.0

type IscsiDiscoveryInfo struct {
	Portal     string
	PortalIP   string
	TargetName string
}

IscsiDiscoveryInfo contains information about discovered iSCSI targets

func IscsiDiscovery

func IscsiDiscovery(portal string) ([]IscsiDiscoveryInfo, error)

IscsiDiscovery uses the 'iscsiadm' command to perform discovery

type IscsiSessionInfo

type IscsiSessionInfo struct {
	SID        string
	Portal     string
	PortalIP   string
	TargetName string
}

IscsiSessionInfo contains information about iSCSI sessions

func GetIscsiSessionInfo

func GetIscsiSessionInfo() ([]IscsiSessionInfo, error)

GetIscsiSessionInfo parses output from 'iscsiadm -m session' and returns the parsed output

type IscsiTargetInfo

type IscsiTargetInfo struct {
	IP        string
	Port      string
	Portal    string
	Iqn       string
	Lun       string
	Device    string
	Discovery string
}

IscsiTargetInfo structure for usage with the iscsiadm command

type ScsiDeviceInfo

type ScsiDeviceInfo struct {
	Host            string
	Channel         string
	Target          string
	LUN             string
	Device          string
	MultipathDevice string
	Filesystem      string
	IQN             string
}

ScsiDeviceInfo contains information about SCSI devices

func GetDeviceInfoForLuns

func GetDeviceInfoForLuns() ([]ScsiDeviceInfo, error)

GetDeviceInfoForLuns parses 'lsscsi' to find NetApp LUNs

func LsscsiCmd

func LsscsiCmd(args []string) ([]ScsiDeviceInfo, error)

LsscsiCmd executes and parses the output from the 'lsscsi' command

Jump to

Keyboard shortcuts

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