utils

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: Apache-2.0 Imports: 23 Imported by: 22

Documentation

Index

Constants

View Source
const MultipathTimeout = 10 * 1000
View Source
const (
	STALE_LOCK_TIMEOUT = 600 //in seconds
)
View Source
const WarningNoTargetPortGroup = "couldn't get target port group"

Variables

This section is empty.

Functions

func ConvertToBytes added in v0.4.0

func ConvertToBytes(logger logs.Logger, inputStr string) (uint64, error)

func ExcludeNoTargetPortGroupMessagesFromMultipathOutput

func ExcludeNoTargetPortGroupMessagesFromMultipathOutput(mpathOutput string, logger logs.Logger) string

func Exists

func Exists(path string) bool

func ExtractErrorResponse

func ExtractErrorResponse(response *http.Response) error

func ExtractVarsFromRequest

func ExtractVarsFromRequest(r *http.Request, varName string) string

func FormatURL

func FormatURL(url string, entries ...string) string

func GetEnv added in v1.1.0

func GetEnv(envName string, defaultValue string) string

func GetMultipathOutputAndDeviceMapperAndDevice

func GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn string, exec Executor) ([]byte, string, []string, error)

GetMultipathOutputAndDeviceMapperAndDevice analysises the output of command "multipath -ll", and find the device mapper and device names according to the given WWN.

For example: Input: 6005076306ffd69d0000000000001004

Multipath output: mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active

|- 29:0:1:1 sde 8:64 active ready running
|- 29:0:6:1 sdf 8:80 active ready running
`- 29:0:7:1 sdg 8:96 active ready running

mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=enabled

|- 29:0:1:0 sdb 8:16 active ready running
|- 29:0:6:0 sdc 8:32 active ready running
`- 29:0:7:0 sdd 8:48 active ready running

Output: fullOutput, mpathg, [sde, sdf, sdg], nil

func GetPath

func GetPath(paths []string) string

func HttpExecute

func HttpExecute(httpClient *http.Client, requestType string, requestURL string, rawPayload interface{}, request_context resources.RequestContext) (*http.Response, error)

func HttpExecuteUserAuth

func HttpExecuteUserAuth(httpClient *http.Client, requestType string, requestURL string, user string, password string, rawPayload interface{}) (*http.Response, error)

func InitUbiquityServerLogger added in v1.2.0

func InitUbiquityServerLogger() func()

func InitUbiquityServerTestLogger added in v1.2.0

func InitUbiquityServerTestLogger() func()

func LoadConfig added in v1.0.0

func LoadConfig() (resources.UbiquityServerConfig, error)

func MarshalAndRecord

func MarshalAndRecord(object interface{}, dir string, fileName string) error

func MkDir

func MkDir(path string) error

func PrintResponse

func PrintResponse(f resources.FlexVolumeResponse) error

func ReadAndUnmarshal

func ReadAndUnmarshal(object interface{}, dir string, fileName string) error

func ReadFile

func ReadFile(path string) (content []byte, err error)

func SetupConfigDirectory

func SetupConfigDirectory(executor Executor, configPath string) (string, error)

func SetupOldLogger added in v1.0.0

func SetupOldLogger(loggerName string) *log.Logger

func StringInSlice

func StringInSlice(a string, list []string) bool

func Unmarshal

func Unmarshal(r *http.Request, object interface{}) error

func UnmarshalDataFromRequest

func UnmarshalDataFromRequest(r *http.Request, object interface{}) error

func UnmarshalResponse

func UnmarshalResponse(r *http.Response, object interface{}) error

func WriteFile

func WriteFile(path string, content []byte) error

func WriteResponse

func WriteResponse(w http.ResponseWriter, code int, object interface{})

Types

type CommandExecuteError

type CommandExecuteError struct {
	Cmd string
	Err error
}

func (*CommandExecuteError) Error

func (e *CommandExecuteError) Error() string

type CommandNotFoundError

type CommandNotFoundError struct {
	Cmd string
	Err error
}

func (*CommandNotFoundError) Error

func (e *CommandNotFoundError) Error() string

type Executor

type Executor interface {
	Execute(command string, args []string) ([]byte, error)
	Stat(string) (os.FileInfo, error)
	Mkdir(string, os.FileMode) error
	MkdirAll(string, os.FileMode) error
	RemoveAll(string) error
	Remove(string) error
	Hostname() (string, error)
	IsExecutable(string) error
	IsNotExist(error) bool
	EvalSymlinks(path string) (string, error)
	ExecuteWithTimeout(mSeconds int, command string, args []string) ([]byte, error)
	Lstat(path string) (os.FileInfo, error)
	IsDir(fInfo os.FileInfo) bool
	Symlink(target string, slink string) error
	IsSlink(fInfo os.FileInfo) bool
	GetGlobFiles(file_pattern string) (matches []string, err error)
	IsSameFile(file1 os.FileInfo, file2 os.FileInfo) bool
	IsDirEmpty(dir string) (bool, error)
	GetDeviceForFileStat(os.FileInfo) uint64
}

func NewExecutor

func NewExecutor() Executor

type Heartbeat

type Heartbeat interface {
	Exists() (bool, error)
	Create() error
	Update() error
	GetLastUpdateTimestamp() (time.Time, error)
}

func NewHeartbeat

func NewHeartbeat(mountpoint string) Heartbeat

type Locker

type Locker interface {
	WriteLock(name string)
	WriteUnlock(name string)
	ReadLock(name string)
	ReadUnlock(name string)
}

func NewLocker

func NewLocker() Locker

type NoENVKeyError added in v1.2.0

type NoENVKeyError struct {
	EnvKeyName string
}

func (*NoENVKeyError) Error added in v1.2.0

func (e *NoENVKeyError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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