Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the RedFish API emulation from the data manipulation part #18

Open
christian-pinto opened this issue Jun 29, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@christian-pinto
Copy link

In the current implementation of the OFMF we strongly rely on the RedFish emulator REST api even for manipulating data objects.
As an example, when aa a result of an event, we want to create an instance of a particular object we most of the times have to import the class defining the object and invoke the POST method for that class by also filling up the relevant fields of a mockup request.

Even if using the methods from api_emulator/utils.py, all the utils in there rely on the request object .

In the example below, the create_and_patch_object can be used to create a new object and patch the parent collection. However, the code verifies whether the request.data exists, where request is a global object coming from the restful API.

def create_and_patch_object (config, members, member_ids, path, collection_path):
# If input body data, then update properties
if request.data:
request_data = json.loads(request.data)
# Update the keys of payload in json file.
for key, value in request_data.items():
config[key] = value
res = create_object(config,members,member_ids,path)
if res != None:
return res
# update the collection json file with new added resource
update_collections_json(path=collection_path, link=config['@odata.id'])
return config

So let's say the OFMF receives an event. Events are delivered as a POST on the /EventListener URL path and as a result the request object is populated with the REST request for the event. If while handling such event one wants to create another object using the create_and_patch_object method, they would pass the config of the new object. The method however will pollute the content with data coming from the request object.

As a work-around at the moment we resort to modifying request.data with the configuration of the new object before invoking the above method.
We should instead have an interface to a data storage that allows manipulation of the objects independently from the RedFish REST API emulator.

@christian-pinto christian-pinto added the enhancement New feature or request label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant