Help us shape the future of Go! Take the 2026 Go Developer Survey

storageclass

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterPoolsOnNasType

func FilterPoolsOnNasType(
	ctx context.Context, pools []storage.Pool, scAttributes map[string]storageattribute.Request,
) []storage.Pool

FilterPoolsOnNasType returns pools filtered over nasType SMB. If not found returns the provided pool list as it is.

func FilterPoolsOnTopology

func FilterPoolsOnTopology(
	ctx context.Context, pools []storage.Pool, requisiteTopologies []map[string]string,
) []storage.Pool

FilterPoolsOnTopology returns a subset of the provided pools that can support any of the requisiteTopologies.

func SortPoolsByPreferredTopologies

func SortPoolsByPreferredTopologies(
	ctx context.Context, pools []storage.Pool, preferredTopologies []map[string]string,
) []storage.Pool

SortPoolsByPreferredTopologies returns a list of pools ordered by the pools supportedTopologies field against the provided list of preferredTopologies. If 2 or more pools can support a given preferredTopology, they are shuffled randomly within that segment of the list, in order to prevent hotspots.

Types

type BackendPoolInfo

type BackendPoolInfo struct {
	Pools             []storage.Pool
	PhysicalPoolNames map[string]struct{}
}

type Config

type Config struct {
	// NOTE:  Ensure that any changes made to this data structure are reflected
	// in the Unmarshal method of config.go
	Version         string                              `json:"version" hash:"ignore"`
	Name            string                              `json:"name" hash:"ignore"`
	Attributes      map[string]storageattribute.Request `json:"attributes,omitempty"`
	Pools           map[string][]string                 `json:"storagePools,omitempty"`
	AdditionalPools map[string][]string                 `json:"additionalStoragePools,omitempty"`
	ExcludePools    map[string][]string                 `json:"excludeStoragePools,omitempty"`
}

func (*Config) MarshalJSON

func (c *Config) MarshalJSON() ([]byte, error)

MarshalJSON emits a storage class config struct as a JSON-formatted byte array.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a JSON-formatted byte array into a storage class config struct.

type External

type External struct {
	Config       *Config
	StoragePools map[string][]string `json:"storage"` // Backend -> list of StoragePools
}

func (*External) GetName

func (s *External) GetName() string

type Persistent

type Persistent struct {
	Config *Config `json:"config"`
}

Persistent contains the minimal information needed to persist a StorageClass. This exists to give us some flexibility to evolve the struct; it also avoids overloading the semantics of Config and is consistent with BackendExternal.

func (*Persistent) GetName

func (s *Persistent) GetName() string

type StorageClass

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

func New

func New(c *Config) *StorageClass

func NewForConfig

func NewForConfig(configJSON string) (*StorageClass, error)

func NewFromAttributes

func NewFromAttributes(attributes map[string]storageattribute.Request) *StorageClass

func NewFromPersistent

func NewFromPersistent(persistent *Persistent) *StorageClass

func (*StorageClass) CheckAndAddBackend

func (s *StorageClass) CheckAndAddBackend(ctx context.Context, b storage.Backend) int

CheckAndAddBackend iterates through each of the storage pools for a given backend. If the pool satisfies the storage class, it adds that pool. Returns the number of storage pools added.

func (*StorageClass) ConstructExternal

func (s *StorageClass) ConstructExternal(ctx context.Context) *External

func (*StorageClass) ConstructPersistent

func (s *StorageClass) ConstructPersistent() *Persistent

func (*StorageClass) GetAdditionalStoragePools

func (s *StorageClass) GetAdditionalStoragePools() map[string][]string

func (*StorageClass) GetAttributes

func (s *StorageClass) GetAttributes() map[string]storageattribute.Request

func (*StorageClass) GetName

func (s *StorageClass) GetName() string

func (*StorageClass) GetStoragePools

func (s *StorageClass) GetStoragePools() map[string][]string

func (*StorageClass) GetStoragePoolsForProtocol

func (s *StorageClass) GetStoragePoolsForProtocol(
	ctx context.Context, p config.Protocol, accessMode config.AccessMode,
) []storage.Pool

func (*StorageClass) GetStoragePoolsForProtocolByBackend

func (s *StorageClass) GetStoragePoolsForProtocolByBackend(
	ctx context.Context, p config.Protocol, requisiteTopologies, preferredTopologies []map[string]string,
	accessMode config.AccessMode,
) []storage.Pool

GetStoragePoolsForProtocolByBackend returns an ordered list of pools, where each pool matches the supplied protocol.

func (*StorageClass) IsAddedToBackend

func (s *StorageClass) IsAddedToBackend(backend storage.Backend, storageClassName string) bool

func (*StorageClass) Matches

func (s *StorageClass) Matches(ctx context.Context, storagePool storage.Pool) bool

func (*StorageClass) Pools

func (s *StorageClass) Pools() []storage.Pool

func (*StorageClass) RemovePoolsForBackend

func (s *StorageClass) RemovePoolsForBackend(backend storage.Backend)

Jump to

Keyboard shortcuts

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