Documentation ¶
Overview ¶
Package osutils provides methods to perform os specific operations
Index ¶
- Constants
- type Device
- type NodePublishParams
- type NodeStageParams
- type OsUtils
- func (osUtils *OsUtils) CleanupPublishPath(ctx context.Context, target string, volID string) error
- func (osUtils *OsUtils) CleanupStagePath(ctx context.Context, stagingTarget string, volID string) error
- func (osUtils *OsUtils) ConvertUUID(uuid string) (string, error)
- func (osUtils *OsUtils) EnsureMountVol(ctx context.Context, volCap *csi.VolumeCapability) (string, []string, error)
- func (osUtils *OsUtils) GetBlockSizeBytes(ctx context.Context, devicePath string) (int64, error)
- func (osUtils *OsUtils) GetDevFromMount(ctx context.Context, target string) (*Device, error)
- func (osUtils *OsUtils) GetDevMounts(ctx context.Context, sysDevice *Device) ([]gofsutil.Info, error)
- func (osUtils *OsUtils) GetDevice(ctx context.Context, path string) (*Device, error)
- func (osUtils *OsUtils) GetDeviceRescanPath(dev *Device) (string, error)
- func (osUtils *OsUtils) GetDiskID(pubCtx map[string]string, log *zap.SugaredLogger) (string, error)
- func (osUtils *OsUtils) GetDiskPath(id string) (string, error)
- func (osUtils *OsUtils) GetMetrics(ctx context.Context, path string) (*k8svol.Metrics, error)
- func (osUtils *OsUtils) GetSystemUUID(ctx context.Context) (string, error)
- func (osUtils *OsUtils) GetVolumeCapabilityFsType(ctx context.Context, capability *csi.VolumeCapability) (string, error)
- func (osUtils *OsUtils) IsBlockDevice(ctx context.Context, volumePath string) (bool, error)
- func (osUtils *OsUtils) IsBlockVolumeMounted(ctx context.Context, volID string, stagingTargetPath string) (bool, error)
- func (osUtils *OsUtils) IsBlockVolumePublished(ctx context.Context, volID string, target string) (bool, error)
- func (osUtils *OsUtils) IsTargetInMounts(ctx context.Context, path string) (bool, error)
- func (osUtils *OsUtils) Mkdir(ctx context.Context, path string) (bool, error)
- func (osUtils *OsUtils) Mkfile(ctx context.Context, path string) (bool, error)
- func (osUtils *OsUtils) NodeStageBlockVolume(ctx context.Context, req *csi.NodeStageVolumeRequest, params NodeStageParams) (*csi.NodeStageVolumeResponse, error)
- func (osUtils *OsUtils) PublishBlockVol(ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, ...) (*csi.NodePublishVolumeResponse, error)
- func (osUtils *OsUtils) PublishFileVol(ctx context.Context, req *csi.NodePublishVolumeRequest, ...) (*csi.NodePublishVolumeResponse, error)
- func (osUtils *OsUtils) PublishMountVol(ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, ...) (*csi.NodePublishVolumeResponse, error)
- func (osUtils *OsUtils) RescanDevice(ctx context.Context, dev *Device) error
- func (osUtils *OsUtils) ResizeVolume(ctx context.Context, devicePath, volumePath string, reqVolSizeBytes int64) error
- func (osUtils *OsUtils) Rmpath(ctx context.Context, target string) error
- func (osUtils *OsUtils) ShouldContinue(ctx context.Context)
- func (osUtils *OsUtils) VerifyTargetDir(ctx context.Context, target string, targetShouldExist bool) (bool, error)
- func (osUtils *OsUtils) VerifyVolumeAttached(ctx context.Context, diskID string) (string, error)
- func (osUtils *OsUtils) VerifyVolumeAttachedAndFillParams(ctx context.Context, pubCtx map[string]string, params *NodePublishParams, ...) error
Constants ¶
const (
UUIDPrefix = "VMware-"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { FullPath string // full path where device is mounted Name string // name of device RealDev string // in windows it represents volumeID and in linux it represents device path }
Device is a struct for holding details about a block device.
type NodePublishParams ¶
type NodePublishParams struct { // volID is the identifier for the underlying volume. VolID string // Target path is used to bind-mount a staged volume to the pod. Target string // Staging Target path is used to mount the volume to the node. StagingTarget string // diskID is the identifier for the disk. DiskID string // volumePath represents the sym-linked block volume full path. VolumePath string // device represents the actual path of the block volume. Device string // Read-only flag. Ro bool }
struct to hold params required for NodePublish operation
type NodeStageParams ¶
type NodeStageParams struct { // volID is the identifier for the underlying volume. VolID string // fsType is the file system type - ext3, ext4, nfs, nfs4. FsType string // Staging Target path is used to mount the volume to the node. StagingTarget string // Mount flags/options intended to be used while running the mount command. MntFlags []string // Read-only flag. Ro bool }
struct to hold params required for NodeStage operation
type OsUtils ¶
type OsUtils struct {
Mounter *mount.SafeFormatAndMount
}
func NewOsUtils ¶
NewOsUtils creates OsUtils with a linux specific mounter
func (*OsUtils) CleanupPublishPath ¶
CleanupPublishPath will unmount and remove publish path
func (*OsUtils) CleanupStagePath ¶
func (osUtils *OsUtils) CleanupStagePath(ctx context.Context, stagingTarget string, volID string) error
CleanupStagePath will unmount the volume from node and remove the stage directory
func (*OsUtils) ConvertUUID ¶
convertUUID helps convert UUID to vSphere format, for example, Input uuid: 6B8C2042-0DD1-D037-156F-435F999D94C1 Returned uuid: 42208c6b-d10d-37d0-156f-435f999d94c1
func (*OsUtils) EnsureMountVol ¶
func (osUtils *OsUtils) EnsureMountVol(ctx context.Context, volCap *csi.VolumeCapability) (string, []string, error)
EnsureMountVol ensures that VolumeCapability has mount option and returns fstype, mount flags
func (*OsUtils) GetBlockSizeBytes ¶
GetBlockSizeBytes returns the Block size in bytes
func (*OsUtils) GetDevFromMount ¶
GetDevFromMount returns device info mounted on the target dir
func (*OsUtils) GetDevMounts ¶
func (osUtils *OsUtils) GetDevMounts(ctx context.Context, sysDevice *Device) ([]gofsutil.Info, error)
A wrapper around gofsutil.GetMounts that handles bind mounts.
func (*OsUtils) GetDevice ¶
GetDevice returns a Device struct with info about the given device, or an error if it doesn't exist or is not a block device.
func (*OsUtils) GetDeviceRescanPath ¶
GetDeviceRescanPath is used to rescan the device
func (*OsUtils) GetDiskPath ¶
GetDiskPath return the full DiskPath for diskID
func (*OsUtils) GetMetrics ¶
GetMetrics helps get volume metrics using k8s fsInfo strategy.
func (*OsUtils) GetSystemUUID ¶
GetSystemUUID returns the UUID used to identify node vm
func (*OsUtils) GetVolumeCapabilityFsType ¶
func (osUtils *OsUtils) GetVolumeCapabilityFsType(ctx context.Context, capability *csi.VolumeCapability) (string, error)
GetVolumeCapabilityFsType retrieves fstype from VolumeCapability. Defaults to nfs4 for file volume and ext4 for block volume when empty string is observed. This function also ignores default ext4 fstype supplied by external-provisioner when none is specified in the StorageClass
func (*OsUtils) IsBlockDevice ¶
Check if device at given path is block device or not
func (*OsUtils) IsBlockVolumeMounted ¶
func (osUtils *OsUtils) IsBlockVolumeMounted( ctx context.Context, volID string, stagingTargetPath string) ( bool, error)
IsBlockVolumeMounted checks if the block volume is properly mounted or not. If yes, then the calling function proceeds to unmount the volume.
func (*OsUtils) IsBlockVolumePublished ¶
func (osUtils *OsUtils) IsBlockVolumePublished(ctx context.Context, volID string, target string) (bool, error)
IsBlockVolumePublished checks if the device backing block volume exists.
func (*OsUtils) IsTargetInMounts ¶
IsTargetInMounts checks if a path exists in the mounts
func (*OsUtils) Mkdir ¶
Mkdir creates the directory specified by path if needed. Return pair is a bool flag of whether dir was created, and an error.
func (*OsUtils) Mkfile ¶
Mkfile creates a file specified by the path if needed. Return pair is a bool flag of whether file was created, and an error.
func (*OsUtils) NodeStageBlockVolume ¶
func (osUtils *OsUtils) NodeStageBlockVolume( ctx context.Context, req *csi.NodeStageVolumeRequest, params NodeStageParams) ( *csi.NodeStageVolumeResponse, error)
NodeStageBlockVolume mounts mount volume or file volume to staging target
func (*OsUtils) PublishBlockVol ¶
func (osUtils *OsUtils) PublishBlockVol( ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, params NodePublishParams) ( *csi.NodePublishVolumeResponse, error)
PublishBlockVol mounts raw block device to publish target
func (*OsUtils) PublishFileVol ¶
func (osUtils *OsUtils) PublishFileVol( ctx context.Context, req *csi.NodePublishVolumeRequest, params NodePublishParams) ( *csi.NodePublishVolumeResponse, error)
PublishBlockVol mounts file volume to publish target
func (*OsUtils) PublishMountVol ¶
func (osUtils *OsUtils) PublishMountVol( ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, params NodePublishParams) ( *csi.NodePublishVolumeResponse, error)
PublishBlockVol mounts block volume to publish target
func (*OsUtils) RescanDevice ¶
RescanDevice rescans the device
func (*OsUtils) ResizeVolume ¶
func (osUtils *OsUtils) ResizeVolume(ctx context.Context, devicePath, volumePath string, reqVolSizeBytes int64) error
ResizeVolume resizes the volume
func (*OsUtils) Rmpath ¶
Rmpath removes the given target path, whether it is a file or a directory. For directories, an error is returned if the dir is not empty.
func (*OsUtils) ShouldContinue ¶
decides if node should continue
func (*OsUtils) VerifyTargetDir ¶
func (osUtils *OsUtils) VerifyTargetDir(ctx context.Context, target string, targetShouldExist bool) (bool, error)
VerifyTargetDir checks if the target path is not empty, exists and is a directory. If targetShouldExist is set to false, then verifyTargetDir returns (false, nil) if the path does not exist. If targetShouldExist is set to true, then verifyTargetDir returns (false, err) if the path does not exist.
func (*OsUtils) VerifyVolumeAttached ¶
VerifyVolumeAttached verifies if the volume path exist for diskID