utils

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Darwin = "darwin"

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

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 ConvertSizeToBytes64

func ConvertSizeToBytes64(s string) (string, error)

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

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, key string, defaultValue string) string

GetV takes a map, key, and a defaultValue; will return the value of the key or defaultValue none set

func IscsiDisableDelete

func IscsiDisableDelete(tgt *IscsiTargetInfo) (err error)

IscsiDisableDelete logout from the supplied target and remove the iscsi device

func IscsiDiscovery

func IscsiDiscovery(portal string) (targets []string, err error)

IscsiDiscovery uses the 'iscsiadm' command to perform discovery

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 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 MultipathFlush

func MultipathFlush() (err error)

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

func Pow

func Pow(x, y int) int

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

func Pow64

func Pow64(x int64, y int) int64

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

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, 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 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