Documentation
¶
Index ¶
- Constants
- func AttachISCSIVolume(name, mountpoint string, publishInfo *VolumePublishInfo) error
- func AttachNFSVolume(name, mountpoint string, publishInfo *VolumePublishInfo) error
- func ConsistentRead(filename string, attempts int) ([]byte, error)
- func ConvertSizeToBytes(s string) (string, error)
- func EnsureISCSISession(hostDataIP string) error
- func EnsureISCSISessions(hostDataIPs []string) error
- func GetDeviceNameFromMount(mountpath string) (string, int, error)
- func GetInitiatorIqns() ([]string, error)
- func GetV(opts map[string]string, keys string, defaultValue string) string
- func GetVolumeSizeBytes(opts map[string]string, defaultVolumeSize string) (uint64, error)
- func ISCSIDisableDelete(targetIQN, targetPortal string) error
- func ISCSISupported() bool
- func ISCSITargetHasMountedDevice(targetIQN string) (bool, error)
- func IsLikelyNotMountPoint(mountpoint string) (bool, error)
- func Lock(ctx, lockID string)
- func LogHTTPRequest(request *http.Request, requestBody []byte)
- func LogHTTPResponse(response *http.Response, responseBody []byte)
- func MountDevice(device, mountpoint, options string) (err error)
- func PathExists(path string) bool
- func Pow(x int64, y int) int64
- func PrepareDeviceAtMountPathForRemoval(mountpoint string, unmount bool) error
- func PrepareDeviceForRemoval(lunID int, iSCSINodeName string)
- func RandomString(strSize int) string
- func Umount(mountpoint string) (err error)
- func Unlock(ctx, lockID string)
- func VolumeSizeWithinTolerance(requestedSize int64, currentSize int64, delta int64) (bool, error)
- type DFInfo
- type HTTPError
- type ISCSIDiscoveryInfo
- type ISCSISessionInfo
- type IscsiAccessInfo
- type MountPoint
- type NfsAccessInfo
- type ScsiDeviceInfo
- type Version
- func (v *Version) AtLeast(min *Version) bool
- func (v *Version) BuildMetadata() string
- func (v *Version) Compare(other string) (int, error)
- func (v *Version) LessThan(other *Version) bool
- func (v *Version) MajorVersion() uint
- func (v *Version) MajorVersionString() string
- func (v *Version) MinorVersion() uint
- func (v *Version) MinorVersionString() string
- func (v *Version) PatchVersion() uint
- func (v *Version) PreRelease() string
- func (v *Version) ShortString() string
- func (v *Version) String() string
- func (v *Version) ToMajorMinorVersion() *Version
- type VolumeAccessInfo
- type VolumePublishInfo
Constants ¶
const Darwin = "darwin"
Darwin is a constant value for the runtime.GOOS that represents Apple MacOS
const Linux = "linux"
Linux is a constant value for the runtime.GOOS that represents the Linux OS
const Windows = "windows"
Windows is a constant value for the runtime.GOOS that represents the Windows OS
Variables ¶
This section is empty.
Functions ¶
func AttachISCSIVolume ¶
func AttachISCSIVolume(name, mountpoint string, publishInfo *VolumePublishInfo) error
Attach the volume to the local host. This method must be able to accomplish its task using only the data passed in. It may be assumed that this method always runs on the host to which the volume will be attached. If the mountpoint parameter is specified, the volume will be mounted. The device path is set on the in-out publishInfo parameter so that it may be mounted later instead.
func AttachNFSVolume ¶
func AttachNFSVolume(name, mountpoint string, publishInfo *VolumePublishInfo) error
Attach the volume to the local host. This method must be able to accomplish its task using only the data passed in. It may be assumed that this method always runs on the host to which the volume will be attached.
func ConsistentRead ¶
ConsistentRead repeatedly reads a file until it gets the same content twice. This is useful when reading files in /proc that are larger than page size and kernel may modify them between individual read() syscalls.
func ConvertSizeToBytes ¶
ConvertSizeToBytes converts size to bytes; see also https://en.wikipedia.org/wiki/Kilobyte
func EnsureISCSISession ¶
func EnsureISCSISessions ¶
func GetInitiatorIqns ¶
GetInitiatorIqns returns parsed contents of /etc/iscsi/initiatorname.iscsi
func GetV ¶
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 ¶
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 ¶
ISCSIDisableDelete logs out from the supplied target and removes the iSCSI device.
func ISCSISupported ¶
func ISCSISupported() bool
ISCSISupported returns true if iscsiadm is installed and in the PATH.
func ISCSITargetHasMountedDevice ¶
ISCSITargetHasMountedDevice returns true if this host has any mounted devices on the specified target.
func IsLikelyNotMountPoint ¶
IsLikelyNotMountPoint determines if a directory is not a mountpoint.
func Lock ¶
func Lock(ctx, lockID string)
Lock acquires a mutex with the specified ID. The mutex does not need to exist before calling this method. The semantics of this method are intentionally identical to sync.Mutex.Lock().
func LogHTTPRequest ¶
func LogHTTPResponse ¶
func MountDevice ¶
MountDevice attaches the supplied device at the supplied location. Use this for iSCSI devices.
func PathExists ¶
PathExists returns true if the file/directory at the specified path exists, false otherwise or if an error occurs.
func Pow ¶
Pow is an integer version of exponentiation; existing builtin is float, we needed an int version.
func PrepareDeviceAtMountPathForRemoval ¶
PrepareDeviceAtMountPathForRemoval informs Linux that a device will be removed.
func PrepareDeviceForRemoval ¶
PrepareDeviceForRemoval informs Linux that a device will be removed.
func RandomString ¶
RandomString returns a string of the specified length consisting only of alphabetic characters.
func Unlock ¶
func Unlock(ctx, lockID string)
Unlock releases a mutex with the specified ID. The semantics of this method are intentionally identical to sync.Mutex.Unlock().
func VolumeSizeWithinTolerance ¶
VolumeSizeWithinTolerance checks to see if requestedSize is within the delta of the currentSize. If within the delta true is returned. If not within the delta and requestedSize is less than the currentSize false is returned.
Types ¶
type HTTPError ¶
func NewHTTPError ¶
type ISCSIDiscoveryInfo ¶
ISCSIDiscoveryInfo contains information about discovered iSCSI targets.
type ISCSISessionInfo ¶
ISCSISessionInfo contains information about iSCSI sessions.
type IscsiAccessInfo ¶
type IscsiAccessInfo struct { IscsiTargetPortal string `json:"iscsiTargetPortal,omitempty"` IscsiPortals []string `json:"iscsiPortals,omitempty"` IscsiTargetIQN string `json:"iscsiTargetIqn,omitempty"` IscsiLunNumber int32 `json:"iscsiLunNumber,omitempty"` IscsiInterface string `json:"iscsiInterface,omitempty"` IscsiIgroup string `json:"iscsiIgroup,omitempty"` IscsiVAGs []int64 `json:"iscsiVags,omitempty"` IscsiUsername string `json:"iscsiUsername,omitempty"` IscsiInitiatorSecret string `json:"iscsiInitiatorSecret,omitempty"` IscsiTargetSecret string `json:"iscsiTargetSecret,omitempty"` }
type MountPoint ¶
This represents a single line in /proc/mounts or /etc/fstab.
type NfsAccessInfo ¶
type ScsiDeviceInfo ¶
type ScsiDeviceInfo struct { Host string Channel string Target string LUN string Devices []string MultipathDevice string Filesystem string IQN string HostSessionMap map[int]int }
ScsiDeviceInfo contains information about SCSI devices
func GetISCSIDevices ¶
func GetISCSIDevices() ([]*ScsiDeviceInfo, error)
GetISCSIDevices returns a list of iSCSI devices that are attached to (but not necessarily mounted on) this host.
func GetMountedISCSIDevices ¶
func GetMountedISCSIDevices() ([]*ScsiDeviceInfo, error)
GetMountedISCSIDevices returns a list of iSCSI devices that are *mounted* on this host.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version is an opaque representation of a version number
func MustParseDate ¶
MustParseDate is like ParseDate except that it panics on error
func MustParseGeneric ¶
MustParseGeneric is like ParseGeneric except that it panics on error
func MustParseSemantic ¶
MustParseSemantic is like ParseSemantic except that it panics on error
func ParseDate ¶
ParseDate parses a version string that mostly obeys the syntax and semantics of the "Semantic Versioning" specification (http://semver.org/) (although it ignores leading and trailing whitespace, and allows the version to be preceded by "v"). Furthermore, it allows leading zeroes on the second numerical component so that the version may represent a two-digit month (i.e. 17.07.1). A date-based version string must be of the form <year>.<month>.<rev>[-preRelease][+buildMetadata], where the year/month/rev values are numerical, and the month must be in the range 1..12.
func ParseGeneric ¶
ParseGeneric parses a "generic" version string. The version string must consist of two or more dot-separated numeric fields (the first of which can't have leading zeroes), followed by arbitrary uninterpreted data (which need not be separated from the final numeric field by punctuation). For convenience, leading and trailing whitespace is ignored, and the version can be preceded by the letter "v". See also ParseSemantic.
func ParseSemantic ¶
ParseSemantic parses a version string that exactly obeys the syntax and semantics of the "Semantic Versioning" specification (http://semver.org/) (although it ignores leading and trailing whitespace, and allows the version to be preceded by "v"). For version strings that are not guaranteed to obey the Semantic Versioning syntax, use ParseGeneric.
func (*Version) AtLeast ¶
AtLeast tests if a version is at least equal to a given minimum version. If both Versions are Semantic Versions, this will use the Semantic Version comparison algorithm. Otherwise, it will compare only the numeric components, with non-present components being considered "0" (ie, "1.4" is equal to "1.4.0").
func (*Version) BuildMetadata ¶
BuildMetadata returns the build metadata, if v is a Semantic Version, or ""
func (*Version) Compare ¶
Compare compares v against a version string (which will be parsed as either Semantic or non-Semantic depending on v). On success it returns -1 if v is less than other, 1 if it is greater than other, or 0 if they are equal.
func (*Version) LessThan ¶
LessThan tests if a version is less than a given version. (It is exactly the opposite of AtLeast, for situations where asking "is v too old?" makes more sense than asking "is v new enough?".)
func (*Version) MajorVersion ¶
func (*Version) MajorVersionString ¶
func (*Version) MinorVersion ¶
func (*Version) MinorVersionString ¶
func (*Version) PatchVersion ¶
func (*Version) PreRelease ¶
func (*Version) ShortString ¶
ShortString converts a Version back to a string, including only the major/minor/patch components.
func (*Version) String ¶
String converts a Version back to a string; note that for versions parsed with ParseGeneric, this will not include the trailing uninterpreted portion of the version number.
func (*Version) ToMajorMinorVersion ¶
type VolumeAccessInfo ¶
type VolumeAccessInfo struct { IscsiAccessInfo NfsAccessInfo }
type VolumePublishInfo ¶
type VolumePublishInfo struct { Localhost bool `json:"localhost,omitempty"` HostIQN []string `json:"hostIQN,omitempty"` HostIP []string `json:"hostIP,omitempty"` HostName string `json:"hostName,omitempty"` FilesystemType string `json:"fstype,omitempty"` MountOptions string `json:"mountOptions,omitempty"` UseCHAP bool `json:"useCHAP,omitempty"` DevicePath string `json:"devicePath,omitempty"` VolumeAccessInfo }