Documentation ¶
Overview ¶
Package common ...
Package common ...
Package common ...
Package common ...
Package common ...
Package common ...
Package common ...
Package common ...
Index ¶
- Constants
- Variables
- func CheckDBConnection() error
- func CreateJobQueue() (chan<- interface{}, <-chan interface{})
- func DecryptWithPrivateKey(ciphertext []byte) ([]byte, error)
- func EncryptWithPublicKey(password []byte) ([]byte, error)
- func GeneralError(statusCode int32, statusMsg, errMsg string, msgArgs []interface{}, ...) response.RPC
- func GetDBConnection(dbFlag DbType) (*persistencemgr.ConnPool, *errors.Error)
- func RequestParamsCaseValidator(rawRequestBody []byte, reqStruct interface{}) (string, error)
- func RunReadWorkers(jobChannel <-chan interface{}, jobProcess func(interface{}) bool, ...)
- func RunWriteWorkers(jobChannel chan<- interface{}, dataBatch []interface{}, workerCount int, ...)
- func SetResponseHeader(ctx iris.Context, params map[string]string)
- func SetUpMockConfig() error
- func TruncateDB(dbFlag DbType) *errors.Error
- func URIValidator(uri string) bool
- type DbType
- type EmbQueue
- type Event
- type EventMessageBus
- type Events
- type Hpe
- type MessageData
- type Oem
- type PluginResponseStatus
- type PluginStats
- type PluginStatus
- type StatusRequest
- type StatusResponse
- type TaskData
- type TaskUpdateInfo
Constants ¶
const ( // RoleAdmin defines admin role for all service to authorize RoleAdmin = "Administrator" // RoleMonitor defines monitor role for all service to authorize RoleMonitor = "Operator" // RoleClient defines client role for all service to authorize RoleClient = "ReadOnly" // PrivilegeLogin defines the privilege for login PrivilegeLogin = "Login" // PrivilegeConfigureManager defines the privilege for configuraton manager PrivilegeConfigureManager = "ConfigureManager" // PrivilegeConfigureUsers defines the privilege for user configuratons PrivilegeConfigureUsers = "ConfigureUsers" // PrivilegeConfigureSelf defines the privilege for self configuratons PrivilegeConfigureSelf = "ConfigureSelf" // PrivilegeConfigureComponents defines the privilege for component configuratons PrivilegeConfigureComponents = "ConfigureComponents" //Cancelled - This value shall represent that the operation was cancelled either through //a Delete on a Task Monitor or Task Resource or by an internal process. Cancelled = "Cancelled" //Cancelling - This value shall represent that the operation is in the process of being cancelled. Cancelling = "Cancelling" //Completed - This value shall represent that the operation is complete and //completed sucessfully or with warnings. Completed = "Completed" //Exception - This value shall represent that the operation is complete and completed with errors. Exception = "Exception" //Interrupted - This value shall represent that the operation has been interrupted but //is expected to restart and is therefore not complete. Interrupted = "Interrupted" //Killed - This value shall represent that the operation is complete because the task //was killed by an operator. Deprecated v1.2+. This value has been //deprecated and is being replaced by the value Cancelled which has more //determinate semantics. Killed = "Killed" //New - This value shall represent that this task is newly created but the operation //has not yet started. New = "New" //Pending - This value shall represent that the operation is pending some condition and //has not yet begun to execute. Pending = "Pending" //Running - This value shall represent that the operation is executing. Running = "Running" //Service - This value shall represent that the operation is now running as a service and //expected to continue operation until stopped or killed. Service = "Service" //Starting - This value shall represent that the operation is starting. Starting = "Starting" //Stopping - This value shall represent that the operation is stopping but is not yet complete. Stopping = "Stopping" //Suspended - This value shall represent that the operation has been suspended but is //expected to restart and is therefore not complete. Suspended = "Suspended" //Critical - A critical condition exists that requires immediate attention. Critical = "Critical" //OK - Normal. OK = "OK" //Warning - A condition exists that requires attention. Warning = "Warning" // ManagerTypeAuxiliaryController - A controller that provides management functions // for a particular subsystem or group of devices. ManagerTypeAuxiliaryController = "AuxiliaryController" // ManagerTypeBMC - A controller that provides management functions for a single computer system. ManagerTypeBMC = "BMC" // ManagerTypeEnclosureManager - A controller that provides management functions // for a chassis or group of devices or systems. ManagerTypeEnclosureManager = "EnclosureManager" // ManagerTypeManagementController - A controller that primarily monitors or manages the operation of a device or system. ManagerTypeManagementController = "ManagementController" // ManagerTypeRackManager - A controller that provides management functions for a whole or part of a rack. ManagerTypeRackManager = "RackManager" // ManagerTypeService - A software-based service that provides management functions. ManagerTypeService = "Service" )
Variables ¶
var ChassisResource = map[string]string{
"Power": "Power",
"Thermal": "Thermal",
"NetworkAdapters": "NetworkAdaptersCollection",
}
ChassisResource contains the Resource name and table name this map is basically to fetch the table name against the chassis resource name, so it will be usefull to store the resource data into the particular database table and also it will be usefull to retrives the chassis resource data
var ManagersResource = map[string]string{
"NetworkProtocol": "NetworkProtocol",
"EthernetInterfaces": "EthernetInterfacesCollection",
"HostInterfaces": "HostInterfacesCollection",
"VirtualMedia": "VirtualMediaCollection",
"LogServices": "LogServicesCollection",
}
ManagersResource contains the Resource name and table name this map is basically to fetch the table name against the manager resource name, so it will be usefull to store the resource data into the particular database table and also it will be usefull to retrives the manager resource data
var ResourceTypes = map[string]string{
"AccelerationFunction": "AccelerationFunction",
"AddressPool": "AddressPool",
"Assembly": "Assembly",
"Bios": "Bios",
"BootOption": "BootOptions",
"Chassis": "Chassis",
"ComputerSystem": "Systems",
"Drive": "Drive",
"Endpoint": "Endpoint",
"EthernetInterface": "EthernetInterfaces",
"Event": "Event",
"EventDestination": "EventDestination",
"EventService": "EventService",
"Fabric": "Fabric",
"HostInterface": "HostInterfaces",
"IPAddresses": "IPAddresses",
"Job": "Job",
"JobService": "JobService",
"LogEntry": "LogEntry",
"LogService": "LogServices",
"Manager": "Manager",
"ManagerAccount": "ManagerAccount",
"ManagerNetworkProtocol": "ManagerNetworkProtocol",
"Memory": "Memory",
"MemoryChunks": "MemoryChunks",
"MemoryDomain": "MemoryDomains",
"MemoryMetrics": "MemoryMetrics",
"Message": "Message",
"MessageRegistry": "MessageRegistry",
"MessageRegistryFile": "MessageRegistryFile",
"NetworkAdapter": "NetworkAdapters",
"NetworkDeviceFunction": "NetworkDeviceFunction",
"NetworkInterface": "NetworkInterfaces",
"NetworkPort": "NetworkPort",
"PCIeDevice": "PCIeDevices",
"PCIeFunction": "PCIeFunction",
"PCIeSlots": "PCIeSlots",
"PhysicalContext": "PhysicalContext",
"Port": "Port",
"Power": "Power",
"PrivilegeRegistry": "PrivilegeRegistry",
"Privileges": "Privileges",
"Processor": "Processors",
"ProcessorCollection": "ProcessorCollection",
"ProcessorMetrics": "ProcessorMetrics",
"Protocol": "Protocol",
"Redundancy": "Redundancy",
"Resource": "Resource",
"Role": "Role",
"SecureBoot": "SecureBoot",
"Sensor": "Sensor",
"SerialInterface": "SerialInterface",
"Session": "Session",
"Storage": "Storage",
"Switch": "Switch",
"Task": "Task",
"Thermal": "Thermal",
"VLanNetworkInterface": "VLanNetworkInterface",
"Volume": "Volume",
"Zone": "Zone",
}
ResourceTypes specifies the map of valid resource types that can be used for an event subscription
var SystemResource = map[string]string{
"Bios": "Bios",
"SecureBoot": "SecureBoot",
"Storage": "StorageCollection",
"BootOptions": "BootOptionsCollection",
"MemoryDomains": "MemoryDomainsCollection",
"NetworkInterfaces": "NetworkInterfacesCollection",
"Processors": "ProcessorsCollection",
"EthernetInterfaces": "EthernetInterfacesCollection",
"Memory": "MemoryCollection",
"VLANS": "VLANS",
"LogServices": "LogServicesCollection",
"Settings": "Bios",
}
SystemResource contains the Resource name and table name this map is basically to fetch the table name against the system resource name, so it will be usefull to store the resource data into the particular database table and also it will be usefull to retrives the system resource data
Functions ¶
func CheckDBConnection ¶
func CheckDBConnection() error
CheckDBConnection will check both inMemory and onDisk DB connections This function is expected to be called at each service startup
func CreateJobQueue ¶
func CreateJobQueue() (chan<- interface{}, <-chan interface{})
CreateJobQueue defines the queue which will act as an infinite buffer. We can make use of this when we are not sure about the capacity required for the creating a buffered channel.
The function will return two channels; the first one will act as an entry or input channel and the later will be an exit or output channel.
The in channel must be closed by the user, but the closing of the out channel is taken care by the function itself.
func DecryptWithPrivateKey ¶
DecryptWithPrivateKey is used to decrypt ciphered text to device password with the private key whose path is available in the config file
func EncryptWithPublicKey ¶
EncryptWithPublicKey is used to encrypt device password using odimra public key
func GeneralError ¶
func GeneralError(statusCode int32, statusMsg, errMsg string, msgArgs []interface{}, t *TaskUpdateInfo) response.RPC
GeneralError will create the error response and update task if required This function can be used only if the expected response have only one extended info object. Error code for the response will be GeneralError If there is no requirement of task updation pass a nil value for *TaskUpdateInfo
func GetDBConnection ¶
func GetDBConnection(dbFlag DbType) (*persistencemgr.ConnPool, *errors.Error)
GetDBConnection is for maintaining and supplying DB connection pool for InMemory and OnDisk DB's Takes dbFlag of type DbType/int32 dbFlag:
InMemory: returns In-Memory DB connection pool OnDsik: returns On-Disk DB connection pool
func RequestParamsCaseValidator ¶
RequestParamsCaseValidator function validates input json w.r.t the structure defined, returns all the invalid properties sent in an input
func RunReadWorkers ¶
func RunReadWorkers(jobChannel <-chan interface{}, jobProcess func(interface{}) bool, workerCount int)
RunReadWorkers will create a worker pool for doing a specific task which is passed to it as process after reading the data from the channel.
The function will three parameters: 1) jobChannel - an out channel of type interface on which the data is passed 2) process - a function which will do some logical tasks by taking data from jobChan 3) workerCount - number of workers required for doing the process
func RunWriteWorkers ¶
func RunWriteWorkers(jobChannel chan<- interface{}, dataBatch []interface{}, workerCount int, done chan bool)
RunWriteWorkers will create a worker pool for inserting data into a channel
The function will three parameters: 1) jobChannel - an in channel of type interface to which the data is passed 2) dataBatch - a slice of data which needed to be passed into the jobChannel 3) workerCount - number of workers required for doing the task 4) done - is a notification channel that indicates that job is done Please make sure all the data from the dataBatch has been wrote to the jobChannel before closing it, else it may cause data loss.
func SetResponseHeader ¶
SetResponseHeader will add the params to the response header
func SetUpMockConfig ¶
func SetUpMockConfig() error
SetUpMockConfig set ups a mock configuration for unit testing
func TruncateDB ¶
TruncateDB will clear DB. It will be useful for test cases Takes DbFlag of type DbType/int32 to choose Inmemory or OnDisk db to truncate dbFlag:
InMemory: Truncates InMemory DB OnDisk: Truncates OnDisk DB
Types ¶
type EmbQueue ¶
type EmbQueue struct { QueueName string `json:"EmbQueueName"` QueueDesc string `json:"EmbQueueDesc"` }
EmbQueue holds the information of Queue Name and Queue Description
type Event ¶
type Event struct { MemberID string `json:"MemberId,omitempty"` EventType string `json:"EventType"` EventGroupID int `json:"EventGroupId,omitempty"` EventID string `json:"EventId"` Severity string `json:"Severity"` EventTimestamp string `json:"EventTimestamp"` Message string `json:"Message"` MessageArgs []string `json:"MessageArgs,omitempty"` MessageID string `json:"MessageId"` Oem Oem `json:"Oem,omitempty"` OriginOfCondition string `json:"OriginOfCondition"` }
Event contains the details of the event subscribed from PMB
type EventMessageBus ¶
type EventMessageBus struct { EmbType string `json:"EmbType"` EmbQueue []EmbQueue `json:"EmbQueue"` }
EventMessageBus holds the information of EMB Broker type and EMBQueue information
type Hpe ¶
type Hpe struct { OdataType string `json:"@odata.type"` Resource string `json:"Resource"` Context string `json:"@odata.context"` }
Hpe struct in Event->Oem
type MessageData ¶
type MessageData struct { OdataType string `json:"@odata.type"` Name string `json:"Name"` Context string `json:"@odata.context"` Events []Event `json:"Events"` }
MessageData contains information of Events and message details including arguments it will be used to pass to gob encoding/decoding which will register the type. it will be send as byte stream on the wire to/from kafka
type PluginResponseStatus ¶
type PluginResponseStatus struct { Available string `json:"Available"` Uptime string `json:"Uptime"` TimeStamp string `json:"TimeStamp"` }
PluginResponseStatus hold status data of Plugin
type PluginStats ¶
type PluginStats struct { Resources string `json:"Resources"` Subscriptions string `json:"Subscriptions"` }
PluginStats holds the actual status details
type PluginStatus ¶
type PluginStatus struct { // Method - Method for communicating with Plugin Method string // Token - plugin session token Token string // RequestBody - holds the data for request body RequestBody StatusRequest // ResponseWaitTime - the resposne wait time in seconds ResponseWaitTime int // Count - the number of times the status check should happen Count int // RetryInterval the wait time in minutes before initiating the next request RetryInterval int // PluginIP PluginIP string //PluginPort PluginPort string //PluginUsername PluginUsername string //PluginUserPassword PluginUserPassword string //PluginPrefferedAuthType PluginPrefferedAuthType string //CACertificate to use while making HTTP queries CACertificate *[]byte }
PluginStatus holds the data required for continuously checking the plugin health
func (*PluginStatus) CheckStatus ¶
func (p *PluginStatus) CheckStatus() (bool, int, []string, error)
CheckStatus will check the for the status health of the plugin in a frequent interval The function will return the following bool: if true, plugin is alive int: number of tries on the plugin before concluding error: will contains the error details, if any happend during the tries queueList:will contains the list of queues to which events are published
type StatusRequest ¶
type StatusRequest struct { Comment string `json:"_comment"` Name string `json:"Name"` Version string `json:"Version"` }
StatusRequest is the plugin request for status check
type StatusResponse ¶
type StatusResponse struct { Comment string `json:"_comment"` Name string `json:"Name"` Version string `json:"Version"` Status *PluginResponseStatus `json:"Status"` EventMessageBus *EventMessageBus `json:"EventMessageBus"` }
StatusResponse is the general reponse for status check