kernel

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

Kernel Package

This package exposes functions used to parse and get parameters passed to the kernel on boot.

Usage

Load kernel parameters:
// params will be used to get any parameter passed to the kernel.
params := kernel.GetParams()
Check if a parameter exist:
if !params.Exists("something") {
    log.Fatal().Msg("`something` is not set")
}
Get values linked to a key:
if values, ok := params.Get("something"); ok {
    if len(values) != 1 {
        log.Fatal().Msg("something values should be of length 1")
    }

    if values[0] != "one thing" {
        log.Fatal().Msg("something value is wrong")
    }
} else {
    log.Fatal().Msg("`something` is not set")
}
Gets a single value for given key:
if value, ok := params.GetOne("something"); !ok {
    log.Fatal().Msg("`something` is not set")
}

Checks if zos-debug is set:
if ok := params.IsDebug(); ok {
   log.Debug().Msg("zos is running in debug mode")
}
Checks if gpu is disabled:
if ok := params.IsGPUDisabled(); ok {
   log.Debug().Msg("GPU is disabled")
}
Checks if zos-debug-vm is set:
if ok := params.IsVirtualMachine(); ok {
   log.Debug().Msg("zos thinks it's running on virtual machine")
}

Documentation

Index

Constants

View Source
const (
	// Debug means zos is running in debug mode
	// applications can handle this flag differently
	Debug = "zos-debug"
	// Light means the node running in light mode
	Light = "light"
	// VirtualMachine forces zos to think it's running
	// on a virtual machine. used mainly for development
	VirtualMachine = "zos-debug-vm"
	// if disable-gpu flag is provided gpu feature will be disabled on that node
	DisableGPU = "disable-gpu"

	// This allows the node to work without ssd disk. If ssd disk is available
	// it will still be preferred for workloads. Otherwise fall back on HDD
	MissingSSD = "missing-ssd"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params map[string][]string

Params represent the parameters passed to the kernel at boot

func GetParams

func GetParams() Params

GetParams Get kernel cmdline arguments

func (Params) Exists

func (k Params) Exists(key string) bool

Exists checks if a key is present in the kernel parameters

func (Params) Get

func (k Params) Get(key string) ([]string, bool)

Get returns the values link to a key and a boolean boolean if true when the key exists in the params or false otherwise a nil list, and a true will be returned if the `key` is set in kernel params, but with no associated value

func (Params) GetOne

func (k Params) GetOne(key string) (string, bool)

GetOne gets a single value for given key. If key is provided multiple times in the cmdline, the last one is used. If key does not exist, or has no associated value, a false is returned

func (Params) IsDebug

func (k Params) IsDebug() bool

IsDebug checks if zos-debug is set

func (Params) IsGPUDisabled

func (k Params) IsGPUDisabled() bool

GPUDisabled checks if gpu is diabled

func (Params) IsVirtualMachine

func (k Params) IsVirtualMachine() bool

IsVirtualMachine checks if zos-debug-vm is set

Jump to

Keyboard shortcuts

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