backend

package
v4.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package backend get is related with storage backend get operation

Index

Constants

View Source
const (
	// Topology constant for topology filter function
	Topology = "topology"

	// NoAvailablePool message of no available poll error
	NoAvailablePool = "no storage pool meets the requirements"
)

Variables

View Source
var (
	// ValidateFilterFuncs validate filters' function map
	ValidateFilterFuncs = [][]interface{}{
		{"backend", validateBackendName},
		{"volumeType", validateVolumeType},
	}

	// PrimaryFilterFuncs primary filters' function map
	PrimaryFilterFuncs = [][]interface{}{
		{"backend", filterByBackendName},
		{"pool", filterByStoragePool},
		{"volumeType", filterByVolumeType},
		{"allocType", filterByAllocType},
		{"qos", filterByQos},
		{"hyperMetro", filterByMetro},
		{"replication", filterByReplication},
		{"applicationType", filterByApplicationType},
		{"storageQuota", filterByStorageQuota},
		{"sourceVolumeName", filterBySupportClone},
		{"sourceSnapshotName", filterBySupportClone},
		{"nfsProtocol", filterByNFSProtocol},
	}

	// SecondaryFilterFuncs secondary filters' function map
	SecondaryFilterFuncs = [][]interface{}{
		{"volumeType", filterByVolumeType},
		{"allocType", filterByAllocType},
		{"qos", filterByQos},
		{"replication", filterByReplication},
		{"applicationType", filterByApplicationType},
	}
)
View Source
var ValidateBackend = func(ctx context.Context, selectBackend *model.Backend, parameters map[string]interface{}) error {
	for _, i := range ValidateFilterFuncs {
		key, validator := i[0].(string), i[1].(func(context.Context, string, *model.Backend) error)
		value, _ := parameters[key].(string)
		if err := validator(ctx, value, selectBackend); err != nil {
			return fmt.Errorf("validate backend %s error for manage Volume. "+
				"the final validator field: %s, validator function: %s, parameters %v. Reason: %v",
				selectBackend.Name, key, runtime.FuncForPC(reflect.ValueOf(validator).Pointer()).Name(), parameters, err)
		}
	}

	return nil
}

ValidateBackend valid the backend basic info, such as: volumeType(authClient if nfs)

Functions

func BuildBackend

func BuildBackend(ctx context.Context, content v1.StorageBackendContent) (*model.Backend, error)

BuildBackend build a valid backend

func ConvertConfigmapToMap

func ConvertConfigmapToMap(ctx context.Context, configmap *coreV1.ConfigMap) (map[string]interface{}, error)

ConvertConfigmapToMap converts a configmap to a map object

func FilterByCapability

func FilterByCapability(ctx context.Context, parameters map[string]interface{}, candidatePools []*model.StoragePool,
	filterFuncs [][]interface{}) ([]*model.StoragePool, error)

FilterByCapability filter backend by capability

func FilterByCapacity

func FilterByCapacity(requestSize int64, allocType string, candidatePools []*model.StoragePool) []*model.StoragePool

FilterByCapacity filter backend by capacity

func FilterByTopology

func FilterByTopology(parameters map[string]interface{}, candidatePools []*model.StoragePool) ([]*model.StoragePool,
	error)

FilterByTopology returns a subset of the provided pools that can support any of the topology requirement.

func FilterStoragePool

func FilterStoragePool(ctx context.Context, requestSize int64, parameters map[string]interface{},
	candidatePools []*model.StoragePool, filterFuncs [][]interface{}) ([]*model.StoragePool, error)

FilterStoragePool filter storage pool by capability, topology and capacity.

func GetAccountName

func GetAccountName(backendName string) string

GetAccountName get account name of backend

func GetBackendConfigmap

func GetBackendConfigmap(ctx context.Context, configmapMeta string) (*coreV1.ConfigMap, error)

GetBackendConfigmap used to get Configmap

func GetBackendConfigmapMap

func GetBackendConfigmapMap(ctx context.Context, configmapMeta string) (map[string]interface{}, error)

GetBackendConfigmapMap used to get backend info by configmapMeta

func GetMetroDomain

func GetMetroDomain(backendName string) string

GetMetroDomain get metro domain of backend

func GetMetrovStorePairID

func GetMetrovStorePairID(backendName string) string

GetMetrovStorePairID get MetrovStorePairID of backend

func GetStorageBackendInfo

func GetStorageBackendInfo(ctx context.Context, backendID, configmapMeta, secretMeta, certSecret string,
	useCert bool) (map[string]interface{}, error)

GetStorageBackendInfo used to get storage config info

func NewBackend

func NewBackend(backendName string, config map[string]interface{}) (*model.Backend, error)

NewBackend constructs an object of Kubernetes backend resource

func RemoveOneBackend

func RemoveOneBackend(ctx context.Context, storageBackendId string)

RemoveOneBackend remove a storage backend from plugin

func SelectRemotePool

func SelectRemotePool(ctx context.Context, requestSize int64, parameters map[string]interface{},
	localBackendName string) (*model.StoragePool, error)

SelectRemotePool select the optimal remote storage pool based on the free capacity.

func WeightPools

func WeightPools(ctx context.Context, requestSize int64, parameters map[string]interface{},
	localPools []*model.StoragePool, poolPairs []model.SelectPoolPair) (*model.StoragePool, *model.StoragePool, error)

WeightPools select the optimal local and remote storage pool based on the free capacity.

func WeightSinglePools

func WeightSinglePools(
	ctx context.Context,
	requestSize int64,
	parameters map[string]interface{},
	filterPools []*model.StoragePool) (*model.StoragePool, error)

WeightSinglePools select the optimal storage pool based on the free capacity.

Types

type AccessibleTopology

type AccessibleTopology struct {
	RequisiteTopologies []map[string]string
	PreferredTopologies []map[string]string
}

AccessibleTopology represents selected node topology

type CSIConfig

type CSIConfig struct {
	Backends map[string]interface{} `json:"backends"`
}

CSIConfig holds the CSI config of backend resources

Directories

Path Synopsis
Package cache for backend cache
Package cache for backend cache
Package handler contains all helper functions with backend process
Package handler contains all helper functions with backend process
Package job contains all scheduled task
Package job contains all scheduled task
Package model package for backend model
Package model package for backend model
Package plugin provide storage function
Package plugin provide storage function

Jump to

Keyboard shortcuts

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