utils

package
v0.0.0-...-2596de7 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var P4rtMutex sync.Mutex

Functions

func CompareBinary

func CompareBinary(imcPath string, vspPath string, client *ssh.Client) (bool, string)

compares(using md5sum) binary on IMC, with equivalent binary built-into ipu-plugin(VSP) image. returns true, if binary checksum matches, false otherwise.

func CompareFile

func CompareFile(inputFile string, remoteFilePath string, client *ssh.Client) (bool, string)

compares(using md5sum) file on IMC, with equivalent file-content(in string format) as expected by ipu-plugin(VSP). returns true, if file checksum matches, false otherwise.

func CopyBinary

func CopyBinary(imcPath string, vspPath string, sftpClient *sftp.Client) error

copies binary part of ipu-plugin(VSP) image onto IMC(to the path provided)

func CopyFile

func CopyFile(inputFile string, remoteFilePath string, sftpClient *sftp.Client) error

copies file content(in string) onto IMC(to the path provided)

func ExecOsCommand

func ExecOsCommand(cmdBin string, params ...string) error

func ExecuteScript

func ExecuteScript(script string) (string, error)

func ExtractVsiVportInfo

func ExtractVsiVportInfo(macAddr string) (int, int, error)

func GetAccApfMacList

func GetAccApfMacList() ([]string, error)

func GetAvailableAccVsiList

func GetAvailableAccVsiList() ([]string, error)

skips ACC interfaces D0 to D3, which are used internally. So, not available for other usages. $2 == 4 is to get ACC entries, and $10 check is to make sure, we skip rows that has vportIDs from D0 to D3.

func GetMacAsByteArray

func GetMacAsByteArray(macAddr string) ([]byte, error)

func GetMacIntValueFromBytes

func GetMacIntValueFromBytes(macAddr []byte) uint64

func GetVfMacList

func GetVfMacList() ([]string, error)

func GetVportForVsi

func GetVportForVsi(vsi int) int

func GetVsiVportInfo

func GetVsiVportInfo(macAddr string) (int, int, error)

func ImcQueryfindVsiGivenMacAddr

func ImcQueryfindVsiGivenMacAddr(mode string, mac string) (string, error)

func RestoreRHPrimaryNetwork

func RestoreRHPrimaryNetwork()

func RunCliCmdOnImc

func RunCliCmdOnImc(cliCmd, subCmd string) ([]byte, error)

Note: Added retry logic, since ipumgmtd is single-threaded, so concurrent usage, of cli-client errors out. we retry 5 times, with sleep(0.5s) between retries. If it exceeds max attempts, we quit retry. retry logic is a best-effort attempt. WARNING: Even if ipumgmtd throws error, cli_client tool still returns success. Also this code(for retry) can break, if error string or error code gets changed.

func RunP4rtCtlCommand

func RunP4rtCtlCommand(p4rtBin string, p4rtIpPort string, params ...string) (string, string, error)

func VerifiedFilePath

func VerifiedFilePath(fileName string, allowedDir string) (string, error)

Taken from the IPDK k8s-infra-offload project instead of including the full project as a module https://github.com/ipdk-io/k8s-infra-offload/blob/30f0efb483d177df7ce052d014593c1a17def8bc/pkg/utils/utils.go#L659

VerifiedFilePath validates a file for potential file path traversal attacks. It returns the real filepath after cleaning and evaluiating any symlinks in the path. It returns error if the "fileName" is not within the "allowedDir", point to a non-privileged location or "fileName" points to a file outside of allowed dir.

Types

This section is empty.

Jump to

Keyboard shortcuts

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