Skip to content

Commit

Permalink
Changed to support paradise (Cray-HPE#13)
Browse files Browse the repository at this point in the history
Changed version to 1.6.0

Added exception for XD224 Paradise when creating a subscription

Paradise does not have the field 'EventTypesForSubscription'. This
changes the POST and PUT subscription code to not validate the event
type if the field is not present.
  • Loading branch information
shunr-hpe authored Aug 26, 2024
1 parent 097ab66 commit 3699a20
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.4
1.6.0
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Removed - for now removed features
Fixed - for any bug fixes
Security - in case of vulnerabilities
-->
## [1.6.0] - 2024-08-23

### Added

- Added support for XD224 Paradise. The mockup is not included.

## [1.5.3] - 2023-11-02

### Added
Expand Down
23 changes: 13 additions & 10 deletions src/api_emulator/redfish/event_service_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BSD 3-Clause License
#
# Copyright 2022-2023 Hewlett Packard Enterprise Development LP
# Copyright 2022-2024 Hewlett Packard Enterprise Development LP
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -59,7 +59,7 @@
s_config = {}
s_generator = None
members = {}
required = {'Destination', 'EventTypes'}
required = {'Destination'} # Fields required for POST subscription
eventTemplates = {}
id = 1

Expand Down Expand Up @@ -213,11 +213,13 @@ def post(self):
return simple_error_response('%s is required' % (field) , 400)
ident = '%d' % id

destination = raw_dict['Destination']
event_types = raw_dict['EventTypes']
for evType in event_types:
if evType not in e_config['EventTypesForSubscription']:
return 'Invalid EventType %s' % evType, 400
destination = raw_dict.get('Destination', '')
event_types = raw_dict.get('EventTypes', '')
if 'EventTypesForSubscription' in e_config: # XD224 Paradise does not have this field
for evType in event_types:
if evType not in e_config['EventTypesForSubscription']:
return 'Invalid EventType %s' % evType, 400

if 'Context' in raw_dict:
context = raw_dict['Context']
else:
Expand Down Expand Up @@ -305,9 +307,10 @@ def patch(self, ident):
return 'Field %s is not patchable' % field, 400
else:
if field == 'RegistryPrefixes' and value != []:
for evType in value:
if evType not in e_config['EventTypesForSubscription']:
return 'Invalid EventType %s' % evType, 400
if 'EventTypesForSubscription' in e_config: # XD224 Paradise does not have this field
for evType in value:
if evType not in e_config['EventTypesForSubscription']:
return 'Invalid EventType %s' % evType, 400
members[ident][field] = value
resp = success_response('PATCH request successful', 200)
except Exception:
Expand Down

0 comments on commit 3699a20

Please sign in to comment.