linux

package
v0.0.0-...-9994f1b Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package linux provides utilities for preforming tasks on linux components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurlURL

func CurlURL(ctx context.Context, run components.Runner, timeout time.Duration, downloadURL string, headers map[string]string, extraCurlArgs ...string) (curlOutput string, HTTPErrorResponseCode int, err error)

CurlURL runs the curl command with the provided downloadURL, headers, and extraCurlArgs. Returns the output of the curl command.

If the curl command returns a non-nil error, the HTTP response code (parsed from the error) and the command error is returned along with the output of curl.

func IsPathExist

func IsPathExist(ctx context.Context, run components.Runner, path string) error

IsPathExist checks if a given path exists or not. Raise error if the path does not exist.

func IsPathWritable

func IsPathWritable(ctx context.Context, run components.Runner, testDir string) error

IsPathWritable checks whether a given path is writable.

func MountDrive

func MountDrive(ctx context.Context, run components.Runner, mountPath, srcPath string) error

MountDrive mounts an external drive on host.

func PathHasEnoughValue

func PathHasEnoughValue(ctx context.Context, r components.Runner, dutName string, path string, typeOfSpace SpaceType, minSpaceNeeded float64) error

PathHasEnoughValue is a helper function that checks the given path's free disk space / inodes is no less than the min disk space /indoes specified.

func PathOccupiedSpacePercentage

func PathOccupiedSpacePercentage(ctx context.Context, r components.Runner, path string) (float64, error)

PathOccupiedSpacePercentage will find the percentage indicating the occupied space under the specified path.

func StorageUtilizationReportOfFilesInDir

func StorageUtilizationReportOfFilesInDir(ctx context.Context, runner components.Runner, dirPath string) (string, error)

StorageUtilizationReportOfFilesInDir generates a CSV report of files present in the provided directory and returns it as a string.

func UnmountDrive

func UnmountDrive(ctx context.Context, run components.Runner, mountPath string) error

UnmountDrive unmounts a drive from host.

Types

type SpaceType

type SpaceType string

SpaceType is different types of disk space used in the calculation for storage space.

const (
	SpaceTypeDisk  SpaceType = "disk"
	SpaceTypeInode SpaceType = "inodes"
)

Jump to

Keyboard shortcuts

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