util

package
v0.0.0-...-9e299b5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NsenterCmd is the nsenter command
	NsenterCmd = "nsenter --mount=/proc/1/ns/mnt"

	// LinearType linear type
	LinearType = "linear"
	// StripingType striping type
	StripingType = "striping"
)

Variables

This section is empty.

Functions

func CheckVolumeInNode

func CheckVolumeInNode(vgName string, volumeid string) bool

func CreateVolume

func CreateVolume(ctx context.Context, volumeID, vgName, lvmType string, poolname string) error

create lvm volume

func DeleteHostpathVolume

func DeleteHostpathVolume(ctx context.Context, volID string) error

deleteVolume deletes the directory for the hostpath volume.

func DeleteSnap

func DeleteSnap(ctx context.Context, snapid string) error

func FormatFSForDevice

func FormatFSForDevice(devicePath, fstype string) error

func FsCheck

func FsCheck(devicePath string) (string, error)

func GetAllLThinsVGS

func GetAllLThinsVGS() map[string]string

func GetAllLvms

func GetAllLvms() []string

func GetDevicePathForVolumue

func GetDevicePathForVolumue(ctx context.Context, volumeID string) (string, string, string, string, error)

func UpdatePVForNodeAffinity(ctx context.Context, volumeID string, nodename string) error {

	pv := GetPV(ctx, volumeID)
	if pv == nil {
		return fmt.Errorf("cant got pv for setnodeaddress")
	}

	var terms []v1.NodeSelectorTerm

	var expressions []v1.NodeSelectorRequirement

	expressions = append(expressions, v1.NodeSelectorRequirement{
		Key:      "kubernetes.io/hostname",
		Operator: v1.NodeSelectorOpIn,
		Values:   []string{nodename},
	})

	terms = append(terms, v1.NodeSelectorTerm{
		MatchExpressions: expressions,
	})

	na := v1.VolumeNodeAffinity{
		Required: &v1.NodeSelector{
			NodeSelectorTerms: terms,
		},
	}

    _, err := kubeClient.CoreV1().PersistentVolumes().Delete(pv.Name, &metav1.DeleteOptions{})

    pv.ResourceVersion=""
	pv.Spec.NodeAffinity = &na

	_, err := kubeClient.CoreV1().PersistentVolumes().Create(pv)
	if err != nil {
		log.Errorf("update Node Affir: fail to update pv, err: %v", err)
		return err
	}
	return nil

}

func GetFreeForLVM

func GetFreeForLVM(vgName string) (string, error)

func GetNodeAddress

func GetNodeAddress(ctx context.Context, volumeID string) (string, error)

func GetNodeName

func GetNodeName() string

func GetPV

func GetPV(ctx context.Context, volumeID string) *v1.PersistentVolume

func GetPvSize

func GetPvSize(ctx context.Context, volumeID string) (int64, string)

func GetS3ENSForSnapID

func GetS3ENSForSnapID(ctx context.Context, snapid string) (string, error)

func GetS3ENV

func GetS3ENV(ctx context.Context, name string, namespace string, s3endpoint string) (string, error)

****************************

func GetSizeForPool

func GetSizeForPool(size string) int64

func GetSnap

func GetSnap(ctx context.Context, snapid string) (string, error)

func GetTotalForLVM

func GetTotalForLVM(vgName string) (string, error)

func GetVgnameForVolume

func GetVgnameForVolume(ctx context.Context, volumeID string) (string, string, error)

*********

func GetVolContentsource

func GetVolContentsource(ctx context.Context, volumeID string) (snapid string, s3env string, err error)

func GetpvnumberForVG

func GetpvnumberForVG(vgName string) (int, error)

func LoadFromSnapshot

func LoadFromSnapshot(ctx context.Context, snapshotId, devicePath, mountpath string, s3env string) error

loadFromSnapshot populates the given destPath with data from the snapshotID

func MirrorDevicetoS3

func MirrorDevicetoS3(ctx context.Context, targetPath string, snapid string, s3env string) error

func MirrorS3toDevice

func MirrorS3toDevice(ctx context.Context, targetPath string, snapid string, s3env string) error

func MountVolforDevice

func MountVolforDevice(ctx context.Context, devicepath, targetPath string, fs string) error

func MountVolforDeviceForSnap

func MountVolforDeviceForSnap(ctx context.Context, devicepath, targetPath string, fs string) error

func Runcmd

func Runcmd(cmd string) (string, error)

Run run shell command

func SetNodeAddressForPV

func SetNodeAddressForPV(ctx context.Context, node string, volumeID string) error

*************

func SetNodeId

func SetNodeId(id string)

func UpdateNode

func UpdateNode(nodename string, lablename string, add bool, updatesize int64) error

func UpdateNodeLab

func UpdateNodeLab(nodeobj *v1.Node, lablename string, lablevalue string) bool

func UpdateThinForNode

func UpdateThinForNode() error

func Updatenodeslabs

func Updatenodeslabs() error

Types

This section is empty.

Jump to

Keyboard shortcuts

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