datastore

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidClass = errors.New("class is invalid")
View Source
var InvalidExtraProperties = errors.New("extra properties does not match expected format")
View Source
var InvalidNetworkName = errors.New("invalid network name")
View Source
var InvalidNetworkType = errors.New("invalid network type")
View Source
var InvalidXname = errors.New("xname is invalid")
View Source
var InvalidXnameType = errors.New("xname type is invalid")
View Source
var UnknownType = errors.New("type is unknown")
View Source
var UnsupportedType = errors.New("type can not be stored in SLS")

Functions

func ConfigureStorage

func ConfigureStorage(dstype string, connInfo string, args []string) error

ConfigureStorage configures the interface for interacting with the storage module. Args: * dstype (string) - the type of database to use. Always "etcd" * connInfo (string) - the databse-specific connection information * args ([]string) - a list of arguments to pass to teh database engine

func DeleteNetwork

func DeleteNetwork(ctx context.Context, networkName string) error

DeleteNetwork removes a network from the DB.

func DeleteXname

func DeleteXname(ctx context.Context, xname string) error

DeleteXname removes hardware witht he appropriate name from the datastore. It handles updating the parent and any peers.

func GetAllHardware

func GetAllHardware(ctx context.Context) ([]sls_common.GenericHardware, error)

func GetAllNetworks

func GetAllNetworks(ctx context.Context) ([]sls_common.Network, error)

GetAllNetworks returns all the network objects in the DB.

func GetAllXnameObjects

func GetAllXnameObjects(ctx context.Context) ([]sls_common.GenericHardware, error)

GetAllXnameObjects get a list of all stored GenericHardware objects

func GetAllXnames

func GetAllXnames(ctx context.Context) ([]string, error)

GetAllXnames gets a list of names of all stored xnames

func GetNetwork

func GetNetwork(ctx context.Context, name string) (sls_common.Network, error)

GetNetwork returns the network object matching the given name.

func GetXname

func GetXname(ctx context.Context, xname string) (*sls_common.GenericHardware, error)

GetXname retrieves an object by its xname. Objects are returned as GenericHardware objects. Callers should use reflect.GetType if they wish to have this object as a more specific type, then cast as: reflect.ValueOf(GenericHardwareObject).Interface().(Type) Parameters:

  • xname (string): The xname to look up

Returns:

  • *GenericHardware: The object corresponding to that xname or nil if the xname was not found.
  • *error: Any error that occurred during the lookup

func InsertNetwork

func InsertNetwork(ctx context.Context, network sls_common.Network) (validationErr error, dbErr error)

InsertNetwork adds a given network into the database assuming it passes validation.

func NormalizeFields

func NormalizeFields(obj *sls_common.GenericHardware) error

func ReplaceAllNetworks

func ReplaceAllNetworks(ctx context.Context, networks []sls_common.Network) error

func ReplaceGenericHardware

func ReplaceGenericHardware(ctx context.Context, hardware []sls_common.GenericHardware) error

ReplaceGenericHardware will in a single transaction remove all hardware from the database and subsequently insert all of the provided hardware in its place. This make this a safe function to use for any bulk load operations.

func SearchGenericHardware

func SearchGenericHardware(ctx context.Context, searchHardware sls_common.GenericHardware) (returnHardware []sls_common.GenericHardware, validationErr error, dbErr error)

func SearchNetworks

func SearchNetworks(ctx context.Context, network sls_common.Network) (networks []sls_common.Network, err error)

func SetNetwork

func SetNetwork(ctx context.Context, network sls_common.Network) (verificationErr error, dbErr error)

Insert or update a network

func SetXname

func SetXname(ctx context.Context, obj sls_common.GenericHardware) (err error, created bool)

SetXname updates a specified xname with new or updated properties

func UpdateNetwork

func UpdateNetwork(ctx context.Context, network sls_common.Network) error

UpdateNetwork updates all of the fields for a given network in the DB *except* for the name which is read-only. Therefore, this function does no validation on network name.

func ValidateFields

func ValidateFields(obj sls_common.GenericHardware) error

func VerifyNetwork

func VerifyNetwork(nw sls_common.Network) error

Helper function to verify network is of a correct type and name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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