evcommon

package
v0.0.0-...-81c02da Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package evcommon ...

Package evcommon ...

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSubscriptionID        = "0"
	SubscriptionChannelKey       = "__key*__:Subscription"
	DeviceSubscriptionChannelKey = "__key*__:DeviceSubscription"
	AggregateToHostChannelKey    = "__key*__:AggregateToHost"
	RedisNotifierType            = "notify-keyspace-events"
	RedisNotifierFilterKey       = "Kz"
)

global variables

View Source
var (
	//GetAllPluginsFunc is pointer function evmodel.GetAllPlugins
	GetAllPluginsFunc = evmodel.GetAllPlugins
	// ConfigFilePath holds the value of odim config file path
	ConfigFilePath string
)
View Source
var PluginStartUp = false

PluginStartUp is used to call plugin "Startup" only on plugin restart and not on every status check

Functions

func GenErrorResponse

func GenErrorResponse(errorMessage string, statusMessage string, httpStatusCode int32, msgArgs []interface{}, respPtr *response.RPC)

GenErrorResponse generates the error response in event service

func GenEventErrorResponse

func GenEventErrorResponse(errorMessage string, StatusMessage string, httpStatusCode int, respPtr *evresponse.EventResponse, argsParams []interface{})

GenEventErrorResponse generates the error response in event service

func GetEncryptedKey

func GetEncryptedKey(key []byte) ([]byte, error)

GetEncryptedKey is for mocking up of getting encrypted key

func GetPluginStatus

func GetPluginStatus(ctx context.Context, plugin *common.Plugin) bool

GetPluginStatus checks the status of given plugin in configured interval

func GetSearchKey

func GetSearchKey(key, index string) string

GetSearchKey will return search key with regular expression for filtering

func MockContactClient

func MockContactClient(ctx context.Context, url, method, token string, odataID string, body interface{}, credentials map[string]string) (*http.Response, error)

MockContactClient is for mocking up of contacting client

func MockContext

func MockContext() context.Context

MockContext creates a context for unit test

func MockCreateChildTask

func MockCreateChildTask(ctx context.Context, sessionID, taskid string) (string, error)

MockCreateChildTask is for mocking up of crete child task

func MockCreateTask

func MockCreateTask(ctx context.Context, sessionusername string) (string, error)

MockCreateTask is for mocking up of crete task

func MockDeleteDeviceSubscription

func MockDeleteDeviceSubscription(hostIP string) error

MockDeleteDeviceSubscription is for mocking up of delete device subscription

func MockDeleteEvtSubscription

func MockDeleteEvtSubscription(key string) error

MockDeleteEvtSubscription is for mocking up of delete event subscription

func MockDeleteUndeliveredEvents

func MockDeleteUndeliveredEvents(destination string) error

MockDeleteUndeliveredEvents is for mocking up of deleting undelivered events

func MockDeleteUndeliveredEventsFlag

func MockDeleteUndeliveredEventsFlag(destination string) error

MockDeleteUndeliveredEventsFlag is for mocking up of deleting undelivered events flag

func MockGetAggregateDatacData

func MockGetAggregateDatacData(aggregateID string) (evmodel.Aggregate, error)

MockGetAggregateDatacData is for mocking up of get aggregate data against the aggregate id

func MockGetAggregateHosts

func MockGetAggregateHosts(aggregateIP string) ([]string, error)

MockGetAggregateHosts is for mocking up of get all matching details from the given table

func MockGetAllFabrics

func MockGetAllFabrics() ([]string, error)

MockGetAllFabrics is for mocking up of get all fabric details

func MockGetAllKeysFromTable

func MockGetAllKeysFromTable(table string) ([]string, error)

MockGetAllKeysFromTable is for mocking up of get all keys from the given table

func MockGetAllMatchingDetails

func MockGetAllMatchingDetails(table, pattern string, dbtype common.DbType) ([]string, *errors.Error)

MockGetAllMatchingDetails is for mocking up of get all matching details from the given table

func MockGetAllSystems

func MockGetAllSystems() ([]string, error)

MockGetAllSystems is for mocking up of get all system info

func MockGetDeviceSubscriptions

func MockGetDeviceSubscriptions(hostIP string) (*common.DeviceSubscription, error)

MockGetDeviceSubscriptions is for mocking up of get device subscription

func MockGetEvtSubscriptions

func MockGetEvtSubscriptions(searchKey string) ([]evmodel.SubscriptionResource, error)

MockGetEvtSubscriptions is for mocking up of get event subscription

func MockGetFabricData

func MockGetFabricData(fabricID string) (evmodel.Fabric, error)

MockGetFabricData is for mocking up of get fabric data against the fabric id

func MockGetPluginData

func MockGetPluginData(pluginID string) (*common.Plugin, *errors.Error)

MockGetPluginData is for mocking up of get plugin data of particural plugin id

func MockGetSessionUserName

func MockGetSessionUserName(ctx context.Context, sessionToken string) (string, error)

MockGetSessionUserName is for mocking up of session user name

func MockGetSingleSystem

func MockGetSingleSystem(id string) (string, error)

MockGetSingleSystem is for mocking up of get system info

func MockGetTarget

func MockGetTarget(uuid string) (*common.Target, error)

MockGetTarget is for mocking up of getting target info

func MockGetUndeliveredEvents

func MockGetUndeliveredEvents(destination string) (string, error)

MockGetUndeliveredEvents is for mocking up of get undelivered events

func MockGetUndeliveredEventsFlag

func MockGetUndeliveredEventsFlag(destination string) (bool, error)

MockGetUndeliveredEventsFlag is for mocking up of getting undelivered events flag

func MockGetUndeliveredEventsKeyList

func MockGetUndeliveredEventsKeyList(table, pattern string, dbtype common.DbType, nextCursor int) ([]string, int, *errors.Error)

MockGetUndeliveredEventsKeyList is for mocking up of get all matching details from the given table

func MockIsAuthorized

func MockIsAuthorized(ctx context.Context, sessionToken string, privileges, oemPrivileges []string) (response.RPC, error)

MockIsAuthorized is for mocking up of authorization

func MockSaveAggregateSubscription

func MockSaveAggregateSubscription(aggregateID string, hostIP []string) error

MockSaveAggregateSubscription is for mocking up of get all matching details from the given table

func MockSaveDeviceSubscription

func MockSaveDeviceSubscription(common.DeviceSubscription) error

MockSaveDeviceSubscription is for mocking up of save undelivered events

func MockSaveEventSubscription

func MockSaveEventSubscription(evtSubscription evmodel.SubscriptionResource) error

MockSaveEventSubscription is for mocking up of save event subscription

func MockSaveUndeliveredEvents

func MockSaveUndeliveredEvents(key string, event []byte) error

MockSaveUndeliveredEvents is for mocking up of save undelivered events

func MockSetUndeliveredEventsFlag

func MockSetUndeliveredEventsFlag(destination string) error

MockSetUndeliveredEventsFlag is for mocking up of setting undelivered events flag

func MockUpdateDeviceSubscriptionLocation

func MockUpdateDeviceSubscriptionLocation(devSubscription common.DeviceSubscription) error

MockUpdateDeviceSubscriptionLocation is for mocking up of updating device subscription based on location

func MockUpdateEventSubscription

func MockUpdateEventSubscription(evtSubscription evmodel.SubscriptionResource) error

MockUpdateEventSubscription is for mocking up of update event subscription

func MockUpdateTask

func MockUpdateTask(context context.Context, task common.TaskData) error

MockUpdateTask is for mocking up of update task

func ProcessCtrlMsg

func ProcessCtrlMsg(ctx context.Context, data interface{}) bool

ProcessCtrlMsg is for processing the ODIM control message and to perform required action

func TrackConfigFileChanges

func TrackConfigFileChanges(ctx context.Context, errChan chan error)

TrackConfigFileChanges monitors the config changes using fsnotfiy

Types

type EmbTopic

type EmbTopic struct {
	TopicsList map[string]bool

	EMBConsume func(context.Context, string)
	// contains filtered or unexported fields
}

EmbTopic hold the list all consuming topics after

var EMBTopics EmbTopic

EMBTopics used to store the list of all topics

func (*EmbTopic) ConsumeTopic

func (e *EmbTopic) ConsumeTopic(ctx context.Context, topicName string)

ConsumeTopic check the existing topic list if it is not present then it will add topic name to list and consume that topic

type PluginContactRequest

type PluginContactRequest struct {
	URL             string
	HTTPMethodType  string
	ContactClient   func(string, string, string, string, interface{}, map[string]string) (*http.Response, error)
	PostBody        interface{}
	LoginCredential map[string]string
	Token           string
	Plugin          *common.Plugin
}

PluginContactRequest holds the details required to contact the plugin

type PluginToken

type PluginToken struct {
	Tokens map[string]string
	// contains filtered or unexported fields
}

PluginToken interface to hold the token

var Token PluginToken

Token variable hold the all the XAuthToken against the plguin ID

func (*PluginToken) GetToken

func (p *PluginToken) GetToken(pluginID string) string

GetToken to get the token from map

func (*PluginToken) StoreToken

func (p *PluginToken) StoreToken(plguinID, token string)

StoreToken to store the token ioto the map

type SavedSystems

type SavedSystems struct {
	ManagerAddress string
	Password       []byte
	UserName       string
	DeviceUUID     string
	PluginID       string
}

SavedSystems holds the resource details of the saved system

type StartUpInterface

type StartUpInterface struct {
	DecryptPassword                  func([]byte) ([]byte, error)
	EMBConsume                       func(context.Context, string)
	GetAllPlugins                    func() ([]common.Plugin, *errors.Error)
	GetAllSystems                    func() ([]string, error)
	GetSingleSystem                  func(string) (string, error)
	GetPluginData                    func(string) (*common.Plugin, *errors.Error)
	GetEvtSubscriptions              func(string) ([]evmodel.SubscriptionResource, error)
	GetDeviceSubscriptions           func(string) (*common.DeviceSubscription, error)
	UpdateDeviceSubscriptionLocation func(common.DeviceSubscription) error
}

StartUpInterface Holds the function pointer of external interface functions

func (*StartUpInterface) GetAllPluginStatus

func (st *StartUpInterface) GetAllPluginStatus(ctx context.Context)

GetAllPluginStatus ...

func (*StartUpInterface) SubscribePluginEMB

func (st *StartUpInterface) SubscribePluginEMB(ctx context.Context)

SubscribePluginEMB is for subscribing to plugin EMB

type StartUpMap

type StartUpMap struct {
	Location   string
	EventTypes []string
	Device     SavedSystems
}

StartUpMap holds required data for plugin startup

Jump to

Keyboard shortcuts

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