Documentation ¶
Index ¶
- Constants
- Variables
- func AreFsOptionsCompatible(fsOpts *model.FilesystemOpts, existingFsOptions *model.FilesystemOpts) (bool, error)
- func BindMount(path, mountPoint string, rbind bool) error
- func BindUnmount(mountPoint string) error
- func ChangeMode(devicePath, fsMode string) (err error)
- func ChangeOwner(mountPoint, user, group string) (err error)
- func Chcon(context, path string) error
- func CheckFsCreationInProgress(device model.Device) (inProgress bool, err error)
- func CreateFileSystem(devPath string, fsType string) (err error)
- func CreateFileSystemOnDevice(serialnumber string, fileSystemType string) (dev *model.Device, err error)
- func CreateFileSystemWithOptions(devPath string, fsType string, options []string) (err error)
- func CreateLinuxDevices(vols []*model.Volume) (devs []*model.Device, err error)
- func CreateMountDir(mountPoint string) (isDir bool, err error)
- func DeleteDevice(dev *model.Device) (err error)
- func EnableService(serviceType string) (err error)
- func ExcludeMountDirFromUpdateDb(mountDir string) (err error)
- func ExpandDevice(targetPath string, volAccessType model.VolumeAccessType) error
- func ExpandFilesystem(devPath, mountPath, fsType string) (err error)
- func GetAllFcHostPortWWN() (portWWNs []string, err error)
- func GetAllFcHostPorts() (hostPorts []*model.FcHostPort, err error)
- func GetChapInfo() (chapInfo *model.ChapInfo, err error)
- func GetDeviceBySerial(serialNumber string) (device *model.Device, err error)
- func GetDeviceFromMountPoint(mountPoint string) (string, error)
- func GetDeviceFromVolume(vol *model.Volume) (*model.Device, error)
- func GetDmDeviceFromSerial(serial string) (*model.Device, error)
- func GetFilesystemOptions(device *model.Device, mountPoint string) (*model.FilesystemOpts, error)
- func GetFilesystemType(devPath string) (string, error)
- func GetFsType(mount model.Mount) (fsType string, err error)
- func GetHostNameAndDomain() ([]string, error)
- func GetHostPort(hostNumber string) (hostPort *model.FcHostPort, err error)
- func GetIPV4NetworkAddress(ipv4Address, netMask string) (networkAddress string, err error)
- func GetIfaces() (ifaces []*model.Iface, err error)
- func GetInitiators() ([]*model.Initiator, error)
- func GetIscsiIfacesPath() (ifacesPath string, err error)
- func GetIscsiTargets() (a model.IscsiTargets, err error)
- func GetLinuxDmDevices(needActivePath bool, serialNumber, lunID string) (a []*model.Device, err error)
- func GetLoggedInIscsiTargets() (targets []string, err error)
- func GetManufacturer() (manufacturer string, err error)
- func GetMountOptions(device *model.Device, mountPoint string) (options []string, err error)
- func GetMountOptionsForDevice(device *model.Device) (options []string, err error)
- func GetMountPointFromDevice(devPath string) (string, error)
- func GetMountPointsForDevices(devices []*model.Device) ([]*model.Mount, error)
- func GetNetworkInterfaces() ([]*model.NetworkInterface, error)
- func GetPartitionInfo(dev *model.Device) (partInfo []model.DevicePartition, err error)
- func GetProductName() (productName string, err error)
- func GetScsiHosts() ([]string, error)
- func GetUserFriendlyNameBySerial(serial string) (mapname string, err error)
- func HandleIscsiDiscovery(volume *model.Volume) (err error)
- func HashMountID(s string) string
- func InstallPackage(packageType string) error
- func IsFsOwnerMatch(fsOwner string, existingFsOwner string) (bool, error)
- func IsPackageInstalled(packageType string) (bool, error)
- func IsVirtualMachine() (isVM bool, err error)
- func MountDevice(device *model.Device, mountPoint string, options []string) (*model.Mount, error)
- func MountDeviceWithFileSystem(devPath string, mountPoint string, options []string) (*model.Mount, error)
- func MultipathdReconfigure() (out string, err error)
- func MultipathdShowMaps(serialNumber string) (a []string, err error)
- func MultipathdShowPaths(serialNumber string) (a []string, err error)
- func OfflineDevice(dev *model.Device) (err error)
- func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error)
- func RemountWithOptions(mountPoint string, options []string) error
- func RescanFcTarget(lunID string) (err error)
- func RescanForCapacityUpdates(devicePath string) error
- func RescanIscsi(lunID string) error
- func RescanScsiHosts(scsiHosts []string, lunID string) (err error)
- func RetryBindMount(path, mountPoint string, rbind bool) error
- func RetryBindUnmount(mountPoint string) error
- func RetryCreateFileSystem(devPath string, fsType string) (err error)
- func RetryCreateFileSystemWithOptions(devPath string, fsType string, options []string) (err error)
- func SelinuxEnabled() bool
- func ServiceCommand(serviceType string, operationType string) (err error)
- func SetFilesystemOptions(devPath string, fsOpts *model.FilesystemOpts) error
- func SetMountOptions(device *model.Device, mountPoint string, options []string) error
- func SetupFilesystem(device *model.Device, filesystemType string) error
- func SetupFilesystemWithOptions(device *model.Device, filesystemType string, options []string) error
- func SetupMount(device *model.Device, mountPoint string, mountOptions []string) (*model.Mount, error)
- func UdevadmReloadRules() (err error)
- func UdevadmTrigger() (err error)
- func UnmountDevice(device *model.Device, mountPoint string) (*model.Mount, error)
- func UnmountFileSystem(mountPoint string) (*model.Mount, error)
- func VmdkAttachDevices(vols []*model.Volume) (devs []*model.Device, err error)
- func VmdkDeleteDevice(dev *model.Device) (err error)
- type DeletingDevices
- type FsType
- type Mount
- type OsInfo
Constants ¶
const ( // IscsiConf is configuration file for iscsid daemon IscsiConf = "/etc/iscsi/iscsid.conf" PingCount = 5 PingInterval = 10 * time.Millisecond PingTimeout = 5 * time.Second DefaultIscsiPort = 3260 )
const ( // VolumeScope scope of the device is volume VolumeScope targetScope = 1 // GroupScope scope of the device is group GroupScope targetScope = 2 )
const ( // MultipathConf configuration file for multipathd MultipathConf = "/etc/multipath.conf" // MultipathBindings bindings file for multipathd MultipathBindings = "/etc/multipath/bindings" )
const ( // OsTypeRedhat represents RedHat OS OsTypeRedhat = "redhat" // OsTypeCentos represents CentOS OS OsTypeCentos = "centos" // OsTypeOracle represents Oracle Linux OS OsTypeOracle = "oracle" // OsTypeUbuntu represents Ubuntu OS OsTypeUbuntu = "ubuntu" // OsTypeSuse represents SuSE OS OsTypeSuse = "suse" // OsTypeAmazon represents Amazon OS OsTypeAmazon = "amazon" )
const ( // ScsiHostPathFormat ScsiHostPathFormat = "/sys/class/scsi_host/" // ScsiHostScanPathFormat ScsiHostScanPathFormat = "/sys/class/scsi_host/%s/scan" )
const FcHostLIPNameFormat = "/sys/class/fc_host/host%s/issue_lip"
FcHostLIPNameFormat :
const Udevadm = "udevadm"
Udevadm udev manager
Variables ¶
var OsIscsiPackageMap = map[string]string{ OsTypeUbuntu: openIscsi, OsTypeSuse: openIscsi, OsTypeRedhat: iscsiInitiatorUtils, OsTypeCentos: iscsiInitiatorUtils, OsTypeOracle: iscsiInitiatorUtils, OsTypeAmazon: iscsiInitiatorUtils, }
OsIscsiPackageMap provides mapping of os distribution to iscsi package name
var OsIscsiServiceMap = map[string]string{ OsTypeUbuntu: iscsid, OsTypeSuse: iscsid, OsTypeRedhat: iscsid, OsTypeCentos: iscsid, OsTypeOracle: iscsid, OsTypeAmazon: iscsid, }
OsIscsiServiceMap provides mapping of os distribution to iscsi service name
var OsMultipathPackageMap = map[string]string{ OsTypeUbuntu: multipathTools, OsTypeSuse: multipathTools, OsTypeRedhat: deviceMapperMultipath, OsTypeCentos: deviceMapperMultipath, OsTypeOracle: deviceMapperMultipath, OsTypeAmazon: deviceMapperMultipath, }
OsMultipathPackageMap provides mapping of os distribution to multipath package name
Functions ¶
func AreFsOptionsCompatible ¶
func AreFsOptionsCompatible(fsOpts *model.FilesystemOpts, existingFsOptions *model.FilesystemOpts) (bool, error)
AreFsOptionsCompatible returns true if the FS options are compatible
func BindMount ¶
BindMount mounts a path to a mountPoint. The rbind flag controls recursive binding.
func ChangeMode ¶
ChangeMode on the device with fsMode string
func ChangeOwner ¶
ChangeOwner on the mountpoint to user:group
func CheckFsCreationInProgress ¶
CheckFsCreationInProgress checks if mkfs process is using the device using lsof
func CreateFileSystem ¶
CreateFileSystem : creates file system on the device
func CreateFileSystemOnDevice ¶
func CreateFileSystemOnDevice(serialnumber string, fileSystemType string) (dev *model.Device, err error)
CreateFileSystemOnDevice : create filesystem on device with serialnumber :serialnumber nolint: gocyclo
func CreateFileSystemWithOptions ¶
CreateFileSystemWithOptions : creates file system on the device with creation options
func CreateLinuxDevices ¶
CreateLinuxDevices : attached and creates linux devices to host
func CreateMountDir ¶
CreateMountDir creates new directory if not exists
func DeleteDevice ¶
DeleteDevice : delete the multipath device
func EnableService ¶
EnableService enables given service type on the system, only iscsi and multipath service types are supported
func ExcludeMountDirFromUpdateDb ¶
ExcludeMountDirFromUpdateDb add mountDir to PRUNEPATHS in updatedb.conf to let mlocate ignore mountDir during file search
func ExpandDevice ¶
func ExpandDevice(targetPath string, volAccessType model.VolumeAccessType) error
ExpandDevice expands device and filesystem at given targetPath to underlying volume size targetPath is /dev/dm-* for block device and mountpoint for filesystem based device
func ExpandFilesystem ¶
ExpandFilesystem : expands filesystem size to underlying device size
func GetAllFcHostPortWWN ¶
GetAllFcHostPortWWN get all FC host port WWN's on the host
func GetAllFcHostPorts ¶
func GetAllFcHostPorts() (hostPorts []*model.FcHostPort, err error)
GetAllFcHostPorts get all the FC host port details on the host
func GetChapInfo ¶
GetChapInfo gets the chap user
func GetDeviceBySerial ¶
GetNimbleDmDevices : get the scsi device by specified serial
func GetDeviceFromMountPoint ¶
GetDeviceFromMountPoint returns the device path from /proc/mounts for the mountpoint provided. For example /dev/mapper/mpathd might be returned for /mnt.
func GetDeviceFromVolume ¶
GetDeviceFromVolume returns Linux device for given volume info
func GetDmDeviceFromSerial ¶
GetDmDeviceFromSerial returns populated multipath device object for given serial
func GetFilesystemOptions ¶
GetFilesystemOptions applies the FS options on the filesystem of the device
func GetFilesystemType ¶
GetFilesystemType returns the filesystem type if present else empty string
func GetHostNameAndDomain ¶
GetHostNameAndDomain : get host name and domain
func GetHostPort ¶
func GetHostPort(hostNumber string) (hostPort *model.FcHostPort, err error)
GetHostPort get the host port details for given host number from H:C:T:L of device
func GetIPV4NetworkAddress ¶
GetIPV4NetworkAddress returns network address for given ipv4 address and netmask
func GetInitiators ¶
GetInitiators : get the host initiators
func GetIscsiIfacesPath ¶
GetIscsiIfacesPath returns actual path for iscsi ifaces db
func GetIscsiTargets ¶
func GetIscsiTargets() (a model.IscsiTargets, err error)
GetIscsiTargets gets targets connected on host from /dev/disk/by-path entries NOTE: this will fetch only targets with at-least one device discovered
func GetLinuxDmDevices ¶
func GetLinuxDmDevices(needActivePath bool, serialNumber, lunID string) (a []*model.Device, err error)
GetLinuxDmDevices : Gets the list of Linux Multipath Devices nolint : gocyclo
func GetLoggedInIscsiTargets ¶
GetLoggedInIscsiTargets returns currently logged-in iscsi targets
func GetManufacturer ¶
GetManufacturer return manufacturer name of the system
func GetMountOptions ¶
GetMountOptions : get options used for mount point for the Device
func GetMountOptionsForDevice ¶
GetMountOptionsForDevice : get options used for mount point for the Device
func GetMountPointFromDevice ¶
GetMountPointFromDevice returns the FIRST mountpoint listed in /proc/mounts matching the device. Note that /proc/mounts lists device paths using the device mapper format. For example: /dev/mapper/mpathd
func GetMountPointsForDevices ¶
GetMountPointsForDevices : get the mount point for the Device nolint : gocyclo
func GetNetworkInterfaces ¶
func GetNetworkInterfaces() ([]*model.NetworkInterface, error)
GetNetworkInterfaces : get the array of network interfaces
func GetPartitionInfo ¶
func GetPartitionInfo(dev *model.Device) (partInfo []model.DevicePartition, err error)
GetPartitionInfo for the Device dev
func GetProductName ¶
GetProductName return product name of the system
func GetScsiHosts ¶
GetScsiHosts returns all SCSI adapter host objects
func GetUserFriendlyNameBySerial ¶
GetUserFriendlyNameBySerial returns user_friendly_name for given serial
func HandleIscsiDiscovery ¶
HandleIscsiDiscovery performs iscsi target discovery and create sessions as required.
func InstallPackage ¶
InstallPackage installs provided package type on the host based on OS distro
func IsFsOwnerMatch ¶
IsFsOwnerMatch checks if the fsOwner matches with the existing FsOwner info
func IsPackageInstalled ¶
IsPackageInstalled returns true if specified package type is installed on host
func IsVirtualMachine ¶
IsVirtualMachine returns true if system is running as a guest on hypervisor
func MountDevice ¶
MountDevice : mount device on host
func MountDeviceWithFileSystem ¶
func MountDeviceWithFileSystem(devPath string, mountPoint string, options []string) (*model.Mount, error)
MountDeviceWithFileSystem : Mount device with filesystem at the mountPoint, if partitions are present, then largest partition will be mounted
func MultipathdReconfigure ¶
MultipathdReconfigure reconfigure multipathd settings
func MultipathdShowMaps ¶
MultipathdShowMaps output
func MultipathdShowPaths ¶
MultipathdShowPaths output from Linux
func OfflineDevice ¶
OfflineDevice : offline all the scsi paths for the multipath device
func PerformDiscovery ¶
func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error)
PerformDiscovery : adds iscsi targets to iscsi database after performing send targets
func RemountWithOptions ¶
RemountWithOptions : Remount mountpoint with options nolint : dupl
func RescanFcTarget ¶
RescanFcTarget rescans host ports for new Fibre Channel devices nolint: dupl
func RescanForCapacityUpdates ¶
RescanSize performs size rescan of all scsi devices on host and updates applicable multipath devices TODO: replace rescan-scsi-bus.sh dependency with manual rescan of scsi devices
func RescanIscsi ¶
RescanIscsi perform SCSI rescan on iSCSI host ports
func RescanScsiHosts ¶
RescanScsiHosts rescan's all SCSI host adapters
func RetryBindMount ¶
RetryBindMount :
func RetryCreateFileSystem ¶
RetryCreateFileSystem : retry file system create
func RetryCreateFileSystemWithOptions ¶
RetryCreateFileSystemWithOptions : retry file system create
func SelinuxEnabled ¶
func SelinuxEnabled() bool
SelinuxEnabled runs selinuxenabled if found and returns the result. If its not found, false is returned. From man - It exits with status 0 if SELinux is enabled and 1 if it is not enabled.
func ServiceCommand ¶
ServiceCommand runs service command on given service, valid service types are iscsi and multipath nolint : gocyclo
func SetFilesystemOptions ¶
func SetFilesystemOptions(devPath string, fsOpts *model.FilesystemOpts) error
SetFilesystemOptions applies the FS options on the filesystem of the device
func SetMountOptions ¶
SetMountOptions : get options used for mount point for the Device
func SetupFilesystem ¶
SetupFilesystem writes the given filesystem on the given device. If the requested FS already exists on the device, then it returns success.
func SetupFilesystemWithOptions ¶
func SetupFilesystemWithOptions(device *model.Device, filesystemType string, options []string) error
SetupFilesystemWithOptions writes the given filesystem on the given device using the given options. If the requested FS already exists on the device, then it returns success.
func SetupMount ¶
func SetupMount(device *model.Device, mountPoint string, mountOptions []string) (*model.Mount, error)
SetupMount creates the mountpoint with mount options
func UdevadmReloadRules ¶
func UdevadmReloadRules() (err error)
UdevadmReloadRules trigger udev rules
func UnmountDevice ¶
UnmountDevice : unmount device from host
func UnmountFileSystem ¶
UnmountFileSystem : unmount the filesystem nolint: gocyclo
func VmdkAttachDevices ¶
AttachDevices : attached and creates scsi devices to host
func VmdkDeleteDevice ¶
DeleteDevice : delete the multipath device
Types ¶
type DeletingDevices ¶
type DeletingDevices struct { Devices []string `json:"devices,omitempty"` // contains filtered or unexported fields }
DeletingDevices represents serial numbers of devices being deleted
func GetDeletingDevices ¶
func GetDeletingDevices() (dd *DeletingDevices)
GetDeletingDevices returns device serial numbers in deletion state
type Mount ¶
type Mount struct { ID uint64 `json:"id,omitempty"` Mountpoint string `json:"mount_point,omitempty"` Device *model.Device `json:"device,omitempty"` }
Mount struct
type OsInfo ¶
type OsInfo struct {
// contains filtered or unexported fields
}
OsInfo represents OS information
func (*OsInfo) GetKernelVersion ¶
GetKernelVersion returns OS kernel version
func (*OsInfo) GetOsDistro ¶
GetOsDistro will return OS distribution
func (*OsInfo) GetOsMajorVersion ¶
GetOsMajorVersion returns OS major version
func (*OsInfo) GetOsMinorVersion ¶
GetOsMinorVersion returns OS minor version
func (*OsInfo) GetOsVersion ¶
GetOsVersion returns OS release version in major.minor format
func (*OsInfo) IsSystemdSupported ¶
IsSystemdSupported returns true if systmed is used as service manager on the system
func (*OsInfo) IsUekKernel ¶
IsUekKernel returns true if Oracle Linux is running with UEK kernel