util

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VolumeOperationAlreadyExistsFmt string format to return for concerrent operation
	VolumeOperationAlreadyExistsFmt = "an operation with the given Volume ID %s already exists"

	// SnapshotOperationAlreadyExistsFmt string format to return for concerrent operation
	SnapshotOperationAlreadyExistsFmt = "an operation with the given Snapshot ID %s already exists"
)
View Source
const (
	// MiB - MebiByte size
	MiB = 1024 * 1024
	GiB = MiB * 1024
)

remove this once kubernetes v1.14.0 release is done https://github.com/kubernetes/cloud-provider/blob/master/volume/helpers/rounding.go

View Source
const (

	// CephConfigPath ceph configuration file
	CephConfigPath = "/etc/ceph/ceph.conf"
)

Variables

View Source
var (
	// GitCommit tell the latest git commit image is built from
	GitCommit string
	// DriverVersion which will be driver version
	DriverVersion string
)

variables which will be set during the build time

View Source
var Key = contextKey("ID")

Key for context based logging

Functions

func CreateMountPoint added in v1.2.0

func CreateMountPoint(mountPath string) error

CreateMountPoint creates the directory with given path

func CreateObject

func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, objectName string) error

CreateObject creates the object name passed in and returns ErrObjectExists if the provided object is already present in rados

func ExecCommand

func ExecCommand(program string, args ...string) (stdout, stderr []byte, err error)

ExecCommand executes passed in program with args and returns separate stdout and stderr streams

func GenerateVolID

func GenerateVolID(ctx context.Context, monitors string, cr *Credentials, pool, clusterID, objUUID string, volIDVersion uint16) (string, error)

GenerateVolID generates a volume ID based on passed in parameters and version, to be returned to the CO system

func GetK8sNamespace

func GetK8sNamespace() string

GetK8sNamespace returns pod namespace. if pod namespace is empty it returns default namespace

func GetMonValFromSecret

func GetMonValFromSecret(secrets map[string]string) (string, error)

func GetOMapValue

func GetOMapValue(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, oMapName, oMapKey string) (string, error)

GetOMapValue gets the value for the given key from the named omap

func GetPIDLimit added in v1.2.0

func GetPIDLimit() (int, error)

GetPIDLimit returns the current PID limit, or an error. A value of -1 translates to "max".

func GetPoolID

func GetPoolID(ctx context.Context, monitors string, cr *Credentials, poolName string) (int64, error)

GetPoolID searches a list of pools in a cluster and returns the ID of the pool that matches the passed in poolName parameter

func GetPoolName

func GetPoolName(ctx context.Context, monitors string, cr *Credentials, poolID int64) (string, error)

GetPoolName lists all pools in a ceph cluster, and matches the pool whose pool ID is equal to the requested poolID parameter

func IsMountPoint added in v1.2.0

func IsMountPoint(p string) (bool, error)

IsMountPoint checks if the given path is mountpoint or not

func Log added in v1.2.0

func Log(ctx context.Context, format string) string

Log helps in context based logging

func Mons

func Mons(pathToConfig, clusterID string) (string, error)

func Mount added in v1.2.0

func Mount(source, target, fstype string, options []string) error

Mount mounts the source to target path

func NewK8sClient

func NewK8sClient() *k8s.Clientset

NewK8sClient create kubernetes client

func RemoveOMapKey

func RemoveOMapKey(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, oMapName, oMapKey string) error

RemoveOMapKey removes the omap key from the given omap name

func RemoveObject

func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, oMapName string) error

RemoveObject removes the entire omap name passed in and returns ErrObjectNotFound is provided omap is not found in rados

func RoundOffBytes added in v1.2.2

func RoundOffBytes(bytes int64) int64

RoundOffBytes converts roundoff the size 1.1Mib will be round off to 2Mib same for GiB size less than 1MiB will be round off to 1MiB

func RoundOffVolSize added in v1.2.2

func RoundOffVolSize(size int64) int64

RoundOffVolSize rounds up given quantity upto chunks of MiB/GiB

func SetOMapKeyValue

func SetOMapKeyValue(ctx context.Context, monitors string, cr *Credentials, poolName, namespace, oMapName, oMapKey, keyValue string) error

SetOMapKeyValue sets the given key and value into the provided Ceph omap name

func SetPIDLimit