Skip to content

Commit

Permalink
Merged with dev branch
Browse files Browse the repository at this point in the history
  • Loading branch information
chauberahul1993 committed Jan 11, 2023
2 parents bf2ad40 + c33f3e7 commit b69f197
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 22 deletions.
261 changes: 242 additions & 19 deletions lib-dmtf/model/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,29 @@ type EventType string
// defined in the message registry with a value more applicable to the implementation.
type MessageSeverity string

//The subscription type for events.
// The authentication protocol for SNMPv3.
type SNMPAuthenticationProtocols string

// the SNMPv3 encryption protocol.
type SNMPEncryptionProtocols string

// The subscription type for events.
type SubscriptionType string

//DeliveryRetryPolicy - The subscription delivery retry policy for events, where the subscription type is RedfishEvent.
type DeliveryRetryPolicy string

// This property shall contain the types of programs that can log messages.
// If this property contains an empty array or is absent, all facilities
// shall be indicated. Facility values are described in the RFC5424.
type SyslogFacility string

// This property shall contain the lowest syslog severity level
// that will be forwarded. The service shall forward all messages
// equal to or greater than the value in this property. The value
// `All` shall indicate all severities.
type SyslogSeverity string

const (
// EventTypeAlert - "Alert": "A condition requires attention."
EventTypeAlert EventType = "Alert"
Expand Down Expand Up @@ -68,6 +85,39 @@ const (
// MessageSeverityWarning - "Warning": "A condition requires attention."
MessageSeverityWarning MessageSeverity = "Warning"

// authentication using SNMP community strings and the value of TrapCommunity.
SNMPAuthenticationProtocolsCommunityString SNMPAuthenticationProtocols = "CommunityString"

// authentication for SNMPv3 access conforms to the RFC7860-defined usmHMAC128SHA224AuthProtocol.
SNMPAuthenticationProtocolsHMAC128_SHA224 SNMPAuthenticationProtocols = "HMAC128_SHA224"

// authentication for SNMPv3 access conforms to the RFC7860-defined usmHMAC192SHA256AuthProtocol.
SNMPAuthenticationProtocolsHMAC192_SHA256 SNMPAuthenticationProtocols = "HMAC192_SHA256"

// authentication for SNMPv3 access conforms to the RFC7860-defined usmHMAC256SHA384AuthProtocol.
SNMPAuthenticationProtocolsHMAC256_SHA384 SNMPAuthenticationProtocols = "HMAC256_SHA384"

// authentication for SNMPv3 access conforms to the RFC7860-defined usmHMAC384SHA512AuthProtocol.
SNMPAuthenticationProtocolsHMAC384_SHA512 SNMPAuthenticationProtocols = "HMAC384_SHA512"

// authentication conforms to the RFC1321-defined HMAC-MD5-96 authentication protocol.
SNMPAuthenticationProtocolsHMAC_MD5 SNMPAuthenticationProtocols = "HMAC_MD5"

// authentication conforms to the RFC3414-defined HMAC-SHA-96 authentication protocol.
SNMPAuthenticationProtocolsHMAC_SHA96 SNMPAuthenticationProtocols = "HMAC_SHA96"

// authentication is not required.
SNMPAuthenticationProtocolsNone SNMPAuthenticationProtocols = "None"

// encryption conforms to the RFC3414-defined CBC-DES encryption protocol.
SNMPEncryptionProtocolsCBC_DES SNMPEncryptionProtocols = "CBC_DES"

// encryption conforms to the RFC3414-defined CFB128-AES-128 encryption protocol.
SNMPEncryptionProtocolsCFB128_AES128 SNMPEncryptionProtocols = "CFB128_AES128"

// there is no encryption.
SNMPEncryptionProtocolsNone SNMPEncryptionProtocols = "None"

// Subscription Types for events. Currently ODIM only support subscriptions
// of type RedFishTypeEvent.
// SubscriptionTypeRedFishEvent - The subscription follows the Redfish
Expand Down Expand Up @@ -114,6 +164,105 @@ const (
// DeliveryTerminateAfterRetries : The subscription is terminated after the
// maximum number of retries is reached.
DeliveryTerminateAfterRetries DeliveryRetryPolicy = "TerminateAfterRetries"

// Security/authentication messages.
SyslogFacilityAuth SyslogFacility = "Auth"

// Security/authentication messages.
SyslogFacilityAuthpriv SyslogFacility = "Authpriv"

//Log alert.
SyslogFacilityConsole SyslogFacility = "Console"

//Clock daemon.
SyslogFacilityCron SyslogFacility = "Cron"

//System daemons.
SyslogFacilityDaemon SyslogFacility = "Daemon"

//FTP daemon.
SyslogFacilityFTP SyslogFacility = "FTP"

//Kernel messages.
SyslogFacilityKern SyslogFacility = "Kern"

//Line printer subsystem.
SyslogFacilityLPR SyslogFacility = "LPR"

//Locally used facility 0.
SyslogFacilityLocal0 SyslogFacility = "Local0"

//Locally used facility 1.
SyslogFacilityLocal1 SyslogFacility = "Local1"

//Locally used facility 2.
SyslogFacilityLocal2 SyslogFacility = "Local2"

//Locally used facility 3.
SyslogFacilityLocal3 SyslogFacility = "Local3"

//Locally used facility 4.
SyslogFacilityLocal4 SyslogFacility = "Local4"

//Locally used facility 5.
SyslogFacilityLocal5 SyslogFacility = "Local5"

//Locally used facility 6.
SyslogFacilityLocal6 SyslogFacility = "Local6"

//Locally used facility 7.
SyslogFacilityLocal7 SyslogFacility = "Local7"

//Mail system.
SyslogFacilityMail SyslogFacility = "Mail"

//NTP subsystem.
SyslogFacilityNTP SyslogFacility = "NTP"

//Network news subsystem.
SyslogFacilityNews SyslogFacility = "News"

//Log audit.
SyslogFacilitySecurity SyslogFacility = "Security"

//Scheduling daemon.
SyslogFacilitySolarisCron SyslogFacility = "SolarisCron"

//Messages generated internally by syslogd.
SyslogFacilitySyslog SyslogFacility = "Syslog"

//UUCP subsystem.
SyslogFacilityUUCP SyslogFacility = "UUCP"

//User-level messages.
SyslogFacilityUser SyslogFacility = "User"

// A condition that should be corrected immediately, such as a corrupted system database.
SyslogSeverityAlert SyslogSeverity = "Alert"

// A message of any severity.
SyslogSeverityAll SyslogSeverity = "All"

// Hard device errors.
SyslogSeverityCritical SyslogSeverity = "Critical"

// Messages that contain information normally of use only when debugging a program.
SyslogSeverityDebug SyslogSeverity = "Debug"

// A panic condition.
SyslogSeverityEmergency SyslogSeverity = "Emergency"

// An Error.
SyslogSeverityError SyslogSeverity = "Error"

// Informational only.
SyslogSeverityInformational SyslogSeverity = "Informational"

// Conditions that are not error conditions, but that may require special handling.
SyslogSeverityNotice SyslogSeverity = "Notice"

// A Warning.
SyslogSeverityWarning SyslogSeverity = "Warning"
)

func (subscriptionType SubscriptionType) IsValidSubscriptionType() bool {
Expand Down Expand Up @@ -204,23 +353,97 @@ type EventRecord struct {
LogEntry *Link `json:"LogEntry,omitempty"`
}

// This Resource shall represent the target of an event subscription, including
// the event types and context to provide to the target in the Event payload.
// Refer to EventDestination.v1_11_2.json of the redfish spec for more details
// EventDestination represents the target of an event subscription,
// including the event types and context to provide to the target
// in the Event payload.
// Reference : EventDestination.v1_12_0.json
type EventDestination struct {
Context string `json:"Context"`
EventTypes []string `json:"EventTypes"`
EventFormatType string `json:"EventFormatType"`
ExcludeMessageIds []string `json:"ExcludeMessageIds,omitempty"`
ExcludeRegistryPrefixes []string `json:"ExcludeRegistryPrefixes,omitempty"`
DeliveryRetryPolicy DeliveryRetryPolicy `json:"DeliveryRetryPolicy"`
Destination string `json:"Destination"`
Id string `json:"id"`
MessageIds []string `json:"MessageIds"`
Name string `json:"Name"`
OriginResources []string `json:"OriginResources"`
Protocol string `json:"Protocol"`
ResourceTypes []string `json:"ResourceTypes"`
SubscriptionType SubscriptionType `json:"SubscriptionType"`
SubordinateResources bool `json:"SubordinateResources"`
ODataContext string `json:"@odata.context,omitempty"`
ODataEtag string `json:"@odata.etag,omitempty"`
ODataId string `json:"@odata.id"`
ODataType string `json:"@odata.type"`
Actions *Actions `json:"Actions,omitempty"`
Certificates *Link `json:"Certificates,omitempty"`
ClientCertificates *Link `json:"ClientCertificates,omitempty"`
Context string `json:"Context"`
DeliveryRetryPolicy DeliveryRetryPolicy `json:"DeliveryRetryPolicy,omitempty"`
Description string `json:"Description,omitempty"`
Destination string `json:"Destination"`
EventFormatType string `json:"EventFormatType,omitempty"`
EventTypes []string `json:"EventTypes,omitempty"`
ExcludeMessageIds []string `json:"ExcludeMessageIds,omitempty"`
ExcludeRegistryPrefixes []string `json:"ExcludeRegistryPrefixes,omitempty"`
HeartbeatIntervalMins int `json:"HeartbeatIntervalMinutes,omitempty"`
HttpHeaders []string `json:"HttpHeaders,omitempty"`
ID string `json:"Id"`
IncludeOriginOfCondition bool `json:"IncludeOriginOfCondition,omitempty"`
MessageIds []string `json:"MessageIds,omitempty"`
MetricReportDefinitions *Link `json:"MetricReportDefinitions,omitempty"`
MetricReportDefinitionsCount int `json:[email protected],omitempty`
Name string `json:"Name"`
OEMProtocol string `json:"OEMProtocol,omitempty"`
OEMSubscriptionType string `json:"OEMSubscriptionType"`
Oem interface{} `json:"Oem,omitempty"`
OriginResources []string `json:"OriginResources,omitempty"`
OriginResourcesCount int `json:[email protected],omitempty`
Protocol string `json:"Protocol"`
RegistryPrefixes []string `json:"RegistryPrefixes,omitempty"`
ResourceTypes []string `json:"ResourceTypes,omitempty"`
SNMP SNMPSettings `json:"SNMP,omitempty"`
SendHeartbeat bool `json:"SendHeartbeat,omitempty"`
Status Status `json:"Status,omitempty"`
SubordinateResources bool `json:"SubordinateResources,omitempty"`
SubscriptionType SubscriptionType `json:"SubscriptionType,omitempty"`
SyslogFilters SyslogFilter `json:"SyslogFilters,omitempty"`
VerifyCertificate bool `json:"VerifyCertificate,omitempty"`
}

// EventDestinationAction contain the available
// actions for this resource..
// Reference : EventDestination.v1_12_0.json
type EventDestinationAction struct {
ResumeSubscription *ResumeSubscription `json:"ResumeSubscription,omitempty"`
SuspendSubscription *SuspendSubscription `json:"SuspendSubscription,omitempty"`
Oem *OemActions `json:"OemActions,omitempty"`
}

// This action shall resume a suspended event subscription,
// which affects the subscription status. The service may deliver
// buffered events when the subscription is resumed.
// Reference : EventDestination.v1_12_0.json
type ResumeSubscription struct {
Target string `json:"target,omitempty"`
Title string `json:"title,omitempty"`
}

// This type shall contain the settings for an SNMP event destination.
// Reference : EventDestination.v1_12_0.json
type SNMPSettings struct {
AuthenticationKey string `json:"AuthenticationKey,omitempty"`
AuthenticationKeySet bool `json:"AuthenticationKeySet,omitempty"`
AuthenticationProtocol SNMPAuthenticationProtocols `json:"AuthenticationProtocol,omitempty"`
EncryptionKey string `json:"EncryptionKey,omitempty"`
EncryptionKeySet bool `json:"EncryptionKeySet,omitempty"`
EncryptionProtocol SNMPEncryptionProtocols `json:"EncryptionProtocol,omitempty"`
TrapCommunity string `json:"TrapCommunity,omitempty"`
}

// This action shall suspend an event subscription. No events shall be
// sent to the event destination until invocation of the ResumeSubscription
// action. The value of the State property within Status shall contain
// `Disabled` for a suspended subscription. The service may buffer
// events while the subscription is suspended.
// Reference : EventDestination.v1_12_0.json
type SuspendSubscription struct {
Target string `json:"target,omitempty"`
Title string `json:"title,omitempty"`
}

// A list of filters applied to syslog messages before sending
// to a remote syslog server. An empty list indicates all
// syslog messages are sent.
// Reference : EventDestination.v1_12_0.json
type SyslogFilter struct {
LogFacilities SyslogFacility `json:"LogFacilities,omitempty"`
LowestSeverity SyslogSeverity `json:"LowestSeverity,omitempty"`
}
8 changes: 7 additions & 1 deletion plugin-redfish/rfphandler/getResource.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
package rfphandler

import (
log "github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
"strings"

log "github.com/sirupsen/logrus"

pluginConfig "github.com/ODIM-Project/ODIM/plugin-redfish/config"
"github.com/ODIM-Project/ODIM/plugin-redfish/rfpmodel"
"github.com/ODIM-Project/ODIM/plugin-redfish/rfputilities"
Expand Down Expand Up @@ -106,6 +107,11 @@ func GetResource(ctx iris.Context) {

}
respData := string(body)
//Replace response body with smaller case of systems,bios to capital cases
if strings.Contains(uri, "Systems") {
respData = strings.Replace(string(respData), "systems", "Systems", -1)
respData = strings.Replace(string(respData), "bios", "Bios", -1)
}
//replacing the resposne with north bound translation URL
for key, value := range pluginConfig.Data.URLTranslation.NorthBoundURL {
respData = strings.Replace(respData, key, value, -1)
Expand Down
4 changes: 2 additions & 2 deletions svc-events/events/subscriptionCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func getAllSubscriptions() {
continue
}
subCache := sub.EventDestination
subCache.Id = sub.SubscriptionID
subscriptionsCache[subCache.Id] = *subCache
subCache.ID = sub.SubscriptionID
subscriptionsCache[subCache.ID] = *subCache
if len(sub.EventDestination.OriginResources) == 0 && sub.SubscriptionID != evcommon.DefaultSubscriptionID {
emptySubscriptionIdMap[sub.SubscriptionID] = true
} else {
Expand Down

0 comments on commit b69f197

Please sign in to comment.