utils

package
v0.0.0-...-83aa6d9 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetadataURL is metadata url
	MetadataURL = "http://100.100.100.200/latest/meta-data/"

	// NsenterCmd use to init resource
	NsenterCmd = "/usr/bin/nsenter --mount=/proc/1/ns/mnt --ipc=/proc/1/ns/ipc --net=/proc/1/ns/net --uts=/proc/1/ns/uts "

	// NodeResourceManager is resource manager
	NodeResourceManager = "node-resource-manager"
)
View Source
const (
	ProtectedTagName = "protected"
)

Variables

View Source
var ErrParse = errors.New("Cannot parse output of blkid")

ErrParse ...

Functions

func ConvertNamespace2LVMDevicePath

func ConvertNamespace2LVMDevicePath(namespace string, regions *model.PmemRegions) string

ConvertNamespace2LVMDevicePath ...

func ConvertRegion2Namespace

func ConvertRegion2Namespace(region string) string

ConvertRegion2Namespace ...

func GetMetaData

func GetMetaData(resource string) (string, error)

GetMetaData get metadata from ecs meta-server

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

IsDirEmpty return status of dir empty or not

func IsPart

func IsPart(largeList, smallList []string) bool

IsPart if smallList is part of or equal to largeList, return true;

func NewEventRecorder

func NewEventRecorder() record.EventRecorder

func NodeFilter

func NodeFilter(configOperator metav1.LabelSelectorOperator, configKey, configValue string, nodeInfo *v1.Node) bool

NodeFilter go through all configmap to find current node config

func Run

func Run(cmd string) (string, error)

Run run shell command

Types

type LVM

type LVM interface {
	ListLV(listSpec string) ([]*model.LV, error)
	CreateLV(vg, name string, size uint64, mirrors uint32, tags []string) (string, error)
	RemoveLV(vg, name string) (string, error)
	CloneLV(src, dest string) (string, error)
	ListVG() ([]*model.VG, error)
	ListPhysicalVolume() ([]*model.PV, error)
	CreateVG(name, physicalVolume string, tags []string) (string, error)
	ExtendVG(name, physicalVolume string) (string, error)
	RemoveVG(name string) (string, error)
	AddTagLV(vg, name string, tags []string) (string, error)
	RemoveTagLV(vg, name string, tags []string) (string, error)
}

LVM ...

type MockLVM

type MockLVM struct {
	// contains filtered or unexported fields
}

MockLVM ...

func NewMockLVM

func NewMockLVM(ctrl *gomock.Controller) *MockLVM

NewMockLVM ...

func (*MockLVM) AddTagLV

func (m *MockLVM) AddTagLV(vg, name string, tags []string) (string, error)

AddTagLV ...

func (*MockLVM) CloneLV

func (m *MockLVM) CloneLV(src, dest string) (string, error)

CloneLV ...

func (*MockLVM) CreateLV

func (m *MockLVM) CreateLV(vg, name string, size uint64, mirrors uint32, tags []string) (string, error)

CreateLV ...

func (*MockLVM) CreateVG

func (m *MockLVM) CreateVG(name, physicalVolume string, tags []string) (string, error)

CreateVG ...

func (*MockLVM) EXPECT

func (m *MockLVM) EXPECT() *MockLVMMockRecorder

EXPECT ...

func (*MockLVM) ExtendVG

func (m *MockLVM) ExtendVG(name, physicalVolume string) (string, error)

ExtendVG ...

func (*MockLVM) ListLV

func (m *MockLVM) ListLV(listSpec string) ([]*model.LV, error)

ListLV ...

func (*MockLVM) ListPhysicalVolume

func (m *MockLVM) ListPhysicalVolume() ([]*model.PV, error)

ListPhysicalVolume ...

func (*MockLVM) ListVG

func (m *MockLVM) ListVG() ([]*model.VG, error)

ListVG ...

func (*MockLVM) RemoveLV

func (m *MockLVM) RemoveLV(vg, name string) (string, error)

RemoveLV ...

func (*MockLVM) RemoveTagLV

func (m *MockLVM) RemoveTagLV(vg, name string, tags []string) (string, error)

RemoveTagLV ...

func (*MockLVM) RemoveVG

func (m *MockLVM) RemoveVG(name string) (string, error)

RemoveVG ...

type MockLVMMockRecorder

type MockLVMMockRecorder struct {
	// contains filtered or unexported fields
}

MockLVMMockRecorder ...

func (*MockLVMMockRecorder) AddTagLV

func (mr *MockLVMMockRecorder) AddTagLV(arg1, arg2, arg3 interface{}) *gomock.Call

AddTagLV ...

func (*MockLVMMockRecorder) CloneLV

func (mr *MockLVMMockRecorder) CloneLV(arg1, arg2 interface{}) *gomock.Call

CloneLV ...

func (*MockLVMMockRecorder) CreateLV

func (mr *MockLVMMockRecorder) CreateLV(arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call

CreateLV ...

func (*MockLVMMockRecorder) CreateVG

func (mr *MockLVMMockRecorder) CreateVG(arg1, arg2, arg3 interface{}) *gomock.Call

CreateVG ...

func (*MockLVMMockRecorder) ExtendVG

func (mr *MockLVMMockRecorder) ExtendVG(arg1, arg2 interface{}) *gomock.Call

ExtendVG ...

func (*MockLVMMockRecorder) ListLV

func (mr *MockLVMMockRecorder) ListLV(arg1 interface{}) *gomock.Call

ListLV ...

func (*MockLVMMockRecorder) ListPhysicalVolume

func (mr *MockLVMMockRecorder) ListPhysicalVolume() *gomock.Call

ListPhysicalVolume ...

func (*MockLVMMockRecorder) ListVG

func (mr *MockLVMMockRecorder) ListVG() *gomock.Call

ListVG ...

func (*MockLVMMockRecorder) RemoveLV

func (mr *MockLVMMockRecorder) RemoveLV(arg1, arg2 interface{}) *gomock.Call

RemoveLV ...

func (*MockLVMMockRecorder) RemoveTagLV

func (mr *MockLVMMockRecorder) RemoveTagLV(arg1, arg2, arg3 interface{}) *gomock.Call

RemoveTagLV ...

func (*MockLVMMockRecorder) RemoveVG

func (mr *MockLVMMockRecorder) RemoveVG(arg1 interface{}) *gomock.Call

RemoveVG ...

type MockMounter

type MockMounter struct {
	k8smount.SafeFormatAndMount
	utilexec.Interface
	// contains filtered or unexported fields
}

MockMounter ...

func NewMockMounter

func NewMockMounter(ctrl *gomock.Controller) *MockMounter

NewMockMounter ...

func (*MockMounter) EXPECT

func (m *MockMounter) EXPECT() *MockMounterMockRecorder

EXPECT ...

func (*MockMounter) EnsureFolder

func (m *MockMounter) EnsureFolder(target string) error

EnsureFolder ...

func (*MockMounter) FileExists

func (m *MockMounter) FileExists(filename string) bool

FileExists ...

func (*MockMounter) FormatAndMount

func (m *MockMounter) FormatAndMount(source, target, fstype string, mkfsOptions []string, mountOptions string) error

FormatAndMount ...

func (*MockMounter) IsMounted

func (m *MockMounter) IsMounted(target string) (bool, error)

IsMounted ...

func (MockMounter) SafePathRemove

func (m MockMounter) SafePathRemove(targetPath string) error

SafePathRemove ...

type MockMounterMockRecorder

type MockMounterMockRecorder struct {
	// contains filtered or unexported fields
}

MockMounterMockRecorder ...

func (MockMounterMockRecorder) EnsureFolder

func (mr MockMounterMockRecorder) EnsureFolder(target interface{}) *gomock.Call

EnsureFolder ...

func (MockMounterMockRecorder) FileExists

func (mr MockMounterMockRecorder) FileExists(filename interface{}) *gomock.Call

EnsureFolder ...

func (MockMounterMockRecorder) FormatAndMount

func (mr MockMounterMockRecorder) FormatAndMount(arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call

FormatAndMount ...

func (MockMounterMockRecorder) IsMounted

func (mr MockMounterMockRecorder) IsMounted(target interface{}) *gomock.Call

IsMounted ...

func (MockMounterMockRecorder) SafePathRemove

func (mr MockMounterMockRecorder) SafePathRemove(target interface{}) *gomock.Call

SafePathRemove ...

type MockPmemer

type MockPmemer struct {
	// contains filtered or unexported fields
}

MockPmemer ..

func NewMockPmemer

func NewMockPmemer(ctrl *gomock.Controller) *MockPmemer

NewMockPmemer ...

func (*MockPmemer) CheckKMEMCreated

func (m *MockPmemer) CheckKMEMCreated(arg1 string) (bool, error)

CheckKMEMCreated ...

func (*MockPmemer) CheckNamespaceUsed

func (m *MockPmemer) CheckNamespaceUsed(arg1 string) bool

CheckNamespaceUsed ...

func (*MockPmemer) CreateNamespace

func (m *MockPmemer) CreateNamespace(arg1, arg2 string) error

CreateNamespace ...

func (*MockPmemer) EXPECT

func (m *MockPmemer) EXPECT() *MockPmemerMockRecorder

EXPECT ...

func (*MockPmemer) GetPmemNamespaceDeivcePath

func (m *MockPmemer) GetPmemNamespaceDeivcePath(arg1, arg2 string) (string, string, error)

GetPmemNamespaceDeivcePath ...

func (*MockPmemer) GetRegions

func (m *MockPmemer) GetRegions() (*model.PmemRegions, error)

GetRegions ...

func (*MockPmemer) MakeNamespaceMemory

func (m *MockPmemer) MakeNamespaceMemory(arg1 string) error

MakeNamespaceMemory ...

type MockPmemerMockRecorder

type MockPmemerMockRecorder struct {
	// contains filtered or unexported fields
}

MockPmemerMockRecorder ...

func (*MockPmemerMockRecorder) CheckKMEMCreated

func (mr *MockPmemerMockRecorder) CheckKMEMCreated(arg1 interface{}) *gomock.Call

CheckKMEMCreated ...

func (*MockPmemerMockRecorder) CheckNamespaceUsed

func (mr *MockPmemerMockRecorder) CheckNamespaceUsed(arg1 interface{}) *gomock.Call

CheckNamespaceUsed ...

func (*MockPmemerMockRecorder) CreateNamespace

func (mr *MockPmemerMockRecorder) CreateNamespace(arg1, arg2 interface{}) *gomock.Call

CreateNamespace ...

func (*MockPmemerMockRecorder) GetPmemNamespaceDeivcePath

func (mr *MockPmemerMockRecorder) GetPmemNamespaceDeivcePath(arg1, arg2 interface{}) *gomock.Call

GetPmemNamespaceDeivcePath ...

func (*MockPmemerMockRecorder) GetRegions

func (mr *MockPmemerMockRecorder) GetRegions() *gomock.Call

GetRegions ...

func (*MockPmemerMockRecorder) MakeNamespaceMemory

func (mr *MockPmemerMockRecorder) MakeNamespaceMemory(arg1 interface{}) *gomock.Call

MakeNamespaceMemory ...

type Mounter

type Mounter interface {
	k8smount.Interface
	utilexec.Interface
	// If the folder doesn't exist, it will call 'mkdir -p'
	EnsureFolder(string) error
	// FormatAndMount ...
	FormatAndMount(string, string, string, []string, string) error

	// IsMounted checks whether the target path is a correct mount (i.e:
	// propagated). It returns true if it's mounted. An error is returned in
	// case of system errors or if it's mounted incorrectly.
	IsMounted(target string) (bool, error)

	SafePathRemove(target string) error

	FileExists(file string) bool
}

Mounter is responsible for formatting and mounting volumes

func NewMounter

func NewMounter() Mounter

NewMounter returns a new mounter instance

type NodeLVM

type NodeLVM struct {
}

NodeLVM ...

func NewNodeLVM

func NewNodeLVM() *NodeLVM

NewNodeLVM ...

func (*NodeLVM) AddTagLV

func (nl *NodeLVM) AddTagLV(vg, name string, tags []string) (string, error)

AddTagLV ...

func (*NodeLVM) CloneLV

func (nl *NodeLVM) CloneLV(src, dest string) (string, error)

CloneLV ...

func (*NodeLVM) CreateLV

func (nl *NodeLVM) CreateLV(vg, name string, size uint64, mirrors uint32, tags []string) (string, error)

CreateLV ...

func (*NodeLVM) CreateVG

func (nl *NodeLVM) CreateVG(name, physicalVolume string, tags []string) (string, error)

CreateVG ...

func (*NodeLVM) ExtendVG

func (nl *NodeLVM) ExtendVG(name, physicalVolume string) (string, error)

ExtendVG ...

func (*NodeLVM) ListLV

func (nl *NodeLVM) ListLV(listSpec string) ([]*model.LV, error)

ListLV ...

func (*NodeLVM) ListPhysicalVolume

func (nl *NodeLVM) ListPhysicalVolume() ([]*model.PV, error)

ListPhysicalVolume ...

func (*NodeLVM) ListVG

func (nl *NodeLVM) ListVG() ([]*model.VG, error)

ListVG ...

func (*NodeLVM) RemoveLV

func (nl *NodeLVM) RemoveLV(vg, name string) (string, error)

RemoveLV ...

func (*NodeLVM) RemoveTagLV

func (nl *NodeLVM) RemoveTagLV(vg, name string, tags []string) (string, error)

RemoveTagLV ....

func (*NodeLVM) RemoveVG

func (nl *NodeLVM) RemoveVG(name string) (string, error)

RemoveVG ...

type NodeMounter

type NodeMounter struct {
	k8smount.SafeFormatAndMount
	utilexec.Interface
}

TODO(arslan): this is Linux only for now. Refactor this into a package with architecture specific code in the future, such as mounter_darwin.go, mounter_linux.go, etc..

func (*NodeMounter) EnsureFolder

func (m *NodeMounter) EnsureFolder(target string) error

EnsureFolder ...

func (*NodeMounter) FileExists

func (m *NodeMounter) FileExists(filename string) bool

FileExists ...

func (*NodeMounter) FormatAndMount

func (m *NodeMounter) FormatAndMount(source, target, fstype string, mkfsOptions []string, mountOptions string) error

FormatAndMount ...

func (*NodeMounter) IsMounted

func (m *NodeMounter) IsMounted(target string) (bool, error)

IsMounted ...

func (*NodeMounter) SafePathRemove

func (m *NodeMounter) SafePathRemove(targetPath string) error

SafePathRemove ...

type NodePmemer

type NodePmemer struct {
}

NodePmemer ...

func NewNodePmemer

func NewNodePmemer() *NodePmemer

NewNodePmemer create new NodePmemer struct

func (*NodePmemer) CheckKMEMCreated

func (np *NodePmemer) CheckKMEMCreated(chardev string) (bool, error)

CheckKMEMCreated ...

func (*NodePmemer) CheckNamespaceUsed

func (np *NodePmemer) CheckNamespaceUsed(devicePath string) bool

CheckNamespaceUsed device used in block

func (*NodePmemer) CreateNamespace

func (np *NodePmemer) CreateNamespace(region, pmemType string) error

CreateNamespace ...

func (*NodePmemer) GetPmemNamespaceDeivcePath

func (np *NodePmemer) GetPmemNamespaceDeivcePath(region, mode string) (devicePath string, namespaceName string, err error)

GetPmemNamespaceDeivcePath ...

func (*NodePmemer) GetRegions

func (np *NodePmemer) GetRegions() (*model.PmemRegions, error)

GetRegions ...

func (*NodePmemer) MakeNamespaceMemory

func (np *NodePmemer) MakeNamespaceMemory(chardev string) error

MakeNamespaceMemory ...

type Pmemer

type Pmemer interface {
	GetRegions() (*model.PmemRegions, error)
	CreateNamespace(string, string) error
	CheckNamespaceUsed(string) bool
	GetPmemNamespaceDeivcePath(string, string) (string, string, error)
	MakeNamespaceMemory(chardev string) error
	CheckKMEMCreated(chardev string) (bool, error)
}

Pmemer ...

Jump to

Keyboard shortcuts

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